diff --git a/build.gradle b/build.gradle
index 7653fa4..501d988 100755
--- a/build.gradle
+++ b/build.gradle
@@ -1,11 +1,8 @@
buildscript {
ext.kotlin_version = '1.7.0'
repositories {
- jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ mavenCentral()
+ google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4' // Gradle
@@ -21,11 +18,8 @@ plugins {
allprojects {
repositories {
- jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ mavenCentral()
+ google()
}
tasks.withType(Javadoc) {
diff --git a/demo/build.gradle b/demo/build.gradle
index a25bdfb..7bed00a 100755
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 29
+ compileSdkVersion 31
defaultConfig {
applicationId "dev.aspirasoft.apis.tiled.demo"
minSdkVersion 15
- targetSdkVersion 29
+ targetSdkVersion 31
versionCode 1
versionName "1.0.0"
}
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
index f7511ac..08e8fed 100755
--- a/demo/src/main/AndroidManifest.xml
+++ b/demo/src/main/AndroidManifest.xml
@@ -12,12 +12,14 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tiles/src/main/java/dev/aspirasoft/apis/tiled/TiledView.kt b/tiles/src/main/java/dev/aspirasoft/apis/tiled/TiledView.kt
index c33b55c..52e72de 100755
--- a/tiles/src/main/java/dev/aspirasoft/apis/tiled/TiledView.kt
+++ b/tiles/src/main/java/dev/aspirasoft/apis/tiled/TiledView.kt
@@ -32,7 +32,8 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
private val lookupTable: HashMap = HashMap()
- private lateinit var tileMap: TileMap
+ lateinit var map: TileMap
+ private set
var pixelWidth: Double = 0.0
var pixelHeight: Double = 0.0
@@ -114,7 +115,7 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
}
val tileSize = calculateTileSize(rowCount, columnCount)
- this.tileMap = TileMap(columnCount, rowCount, tileSize.first, tileSize.second)
+ this.map = TileMap(columnCount, rowCount, tileSize.first, tileSize.second)
val grid = LinearLayout(context)
grid.layoutParams = LayoutParams(
@@ -127,7 +128,7 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
val row = LinearLayout(context)
row.layoutParams = LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
- this.tileMap.tileHeight.roundToInt()
+ this.map.tileHeight.roundToInt()
)
row.orientation = HORIZONTAL
@@ -136,12 +137,12 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
val tileImage = ImageView(context)
tileImage.scaleType = ImageView.ScaleType.FIT_XY
tileImage.layoutParams = ViewGroup.LayoutParams(
- ceil(this.tileMap.tileWidth).roundToInt(),
- ceil(this.tileMap.tileHeight).roundToInt(),
+ ceil(this.map.tileWidth).roundToInt(),
+ ceil(this.map.tileHeight).roundToInt(),
)
row.addView(tileImage)
- this.tileMap[c, r] = id
+ this.map[c, r] = id
lookupTable[id]?.let { tileImage.setImageResource(it) }
tileImage.setOnClickListener {
@@ -173,7 +174,7 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
@UiThread
@Throws(IllegalArgumentException::class, IndexOutOfBoundsException::class)
operator fun set(c: Int, r: Int, id: String) {
- this.tileMap[c, r] = id
+ this.map[c, r] = id
val tileImage = getViewAt(c, r)
val resId = lookupTable[id]
@@ -191,21 +192,21 @@ class TiledView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
*/
@Throws(IndexOutOfBoundsException::class)
operator fun get(c: Int, r: Int): String {
- return tileMap[c, r]
+ return map[c, r]
}
/**
* Column in which horizontal position [x] (in pixels) lies.
*/
fun getColumn(x: Double): Int {
- return (x / tileMap.tileWidth).toInt()
+ return (x / map.tileWidth).toInt()
}
/**
* Row in which vertical position [y] (in pixels) lies.
*/
fun getRow(y: Double): Int {
- return (y / tileMap.tileHeight).toInt()
+ return (y / map.tileHeight).toInt()
}
private fun calculateTileSize(rowCount: Int, columnCount: Int): Pair {
diff --git a/tiles/src/test/java/dev/aspirasoft/apis/tiled/TileMapTest.kt b/tiles/src/test/java/dev/aspirasoft/apis/tiled/TileMapTest.kt
index 8e864a7..93a8a9a 100644
--- a/tiles/src/test/java/dev/aspirasoft/apis/tiled/TileMapTest.kt
+++ b/tiles/src/test/java/dev/aspirasoft/apis/tiled/TileMapTest.kt
@@ -9,15 +9,15 @@ internal class TileMapTest {
private val tilemap = TileMap(3, 3, 35.0, 25.0)
init {
- tilemap[0, 0] = 'a'
- tilemap[0, 1] = 'b'
- tilemap[0, 2] = 'c'
- tilemap[1, 0] = 'd'
- tilemap[1, 1] = 'e'
- tilemap[1, 2] = 'f'
- tilemap[2, 0] = 'g'
- tilemap[2, 1] = 'h'
- tilemap[2, 2] = 'i'
+ tilemap[0, 0] = "a"
+ tilemap[0, 1] = "b"
+ tilemap[0, 2] = "c"
+ tilemap[1, 0] = "d"
+ tilemap[1, 1] = "e"
+ tilemap[1, 2] = "f"
+ tilemap[2, 0] = "g"
+ tilemap[2, 1] = "h"
+ tilemap[2, 2] = "i"
}
@Test
@@ -32,15 +32,15 @@ internal class TileMapTest {
@Test
fun testTileMapData() {
- assertEquals('a', tilemap[0, 0])
- assertEquals('b', tilemap[0, 1])
- assertEquals('c', tilemap[0, 2])
- assertEquals('d', tilemap[1, 0])
- assertEquals('e', tilemap[1, 1])
- assertEquals('f', tilemap[1, 2])
- assertEquals('g', tilemap[2, 0])
- assertEquals('h', tilemap[2, 1])
- assertEquals('i', tilemap[2, 2])
+ assertEquals("a", tilemap[0, 0])
+ assertEquals("b", tilemap[0, 1])
+ assertEquals("c", tilemap[0, 2])
+ assertEquals("d", tilemap[1, 0])
+ assertEquals("e", tilemap[1, 1])
+ assertEquals("f", tilemap[1, 2])
+ assertEquals("g", tilemap[2, 0])
+ assertEquals("h", tilemap[2, 1])
+ assertEquals("i", tilemap[2, 2])
assertThrows(IndexOutOfBoundsException::class.java) { tilemap[-1, 0] }
assertThrows(IndexOutOfBoundsException::class.java) { tilemap[0, -1] }