Skip to content

Commit a6ffdbe

Browse files
committed
patch 4
1 parent 31019dd commit a6ffdbe

4 files changed

Lines changed: 35 additions & 22 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
minSdk 23
1313
targetSdk 34
1414
versionCode 10
15-
versionName "0.8.1-reborn-neko11-compatibility"
15+
versionName "0.8.2-reborn-neko11-compatibility"
1616

1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
}
@@ -31,6 +31,7 @@ android {
3131
kotlinOptions {
3232
jvmTarget = '17'
3333
}
34+
setBuildToolsVersion('35.0.0 rc1')
3435
}
3536

3637
dependencies {

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Copyright (C) 2016 The Android Open Source Project
6565
<!-- FileProvider for sending pictures -->
6666
<provider
6767
android:name="androidx.core.content.FileProvider"
68-
android:authorities="com.android.egg.fileprovider"
68+
android:authorities="ru.dimon6018.neko11.fileprovider"
6969
android:grantUriPermissions="true"
7070
android:exported="false">
7171
<meta-data

app/src/main/java/ru/dimon6018/neko11/NekoLand.kt

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,25 @@ import androidx.recyclerview.widget.GridLayoutManager
4949
import androidx.recyclerview.widget.RecyclerView
5050
import com.google.android.material.dialog.MaterialAlertDialogBuilder
5151
import kotlinx.coroutines.CoroutineScope
52+
import kotlinx.coroutines.Deferred
5253
import kotlinx.coroutines.Dispatchers
54+
import kotlinx.coroutines.async
5355
import kotlinx.coroutines.cancel
5456
import kotlinx.coroutines.launch
57+
import kotlinx.coroutines.runBlocking
5558
import ru.dimon6018.neko11.NekoService.Companion.setupNotificationChannels
5659
import java.io.File
5760
import java.io.FileOutputStream
5861
import java.io.IOException
5962
import java.io.OutputStream
6063

6164

65+
6266
class NekoLand : AppCompatActivity(), PrefState.PrefsListener {
6367
private var mPrefs: PrefState? = null
6468
private var mAdapter: CatAdapter? = null
6569
private var mPendingShareCat: Cat? = null
70+
private var numCats = 0
6671

6772

6873
override fun onCreate(savedInstanceState: Bundle?) {
@@ -156,26 +161,33 @@ class NekoLand : AppCompatActivity(), PrefState.PrefsListener {
156161
}
157162

158163
private fun updateCats(): Int {
159-
val cats: Array<Cat?>
160-
if (CAT_GEN) {
161-
cats = arrayOfNulls(50)
162-
for (i in cats.indices) {
163-
cats[i] = Cat.create(this)
164-
}
165-
} else {
166-
val hsv = FloatArray(3)
167-
val list = mPrefs!!.cats
168-
list.sortedWith { cat, cat2 ->
169-
Color.colorToHSV(cat.bodyColor, hsv)
170-
val bodyH1 = hsv[0]
171-
Color.colorToHSV(cat2.bodyColor, hsv)
172-
val bodyH2 = hsv[0]
173-
bodyH1.compareTo(bodyH2)
164+
val catsUpdate: Deferred<Int> = CoroutineScope(Dispatchers.IO).async {
165+
val cats: Array<Cat?>
166+
if (CAT_GEN) {
167+
cats = arrayOfNulls(50)
168+
for (i in cats.indices) {
169+
cats[i] = Cat.create(this@NekoLand)
170+
}
171+
} else {
172+
val hsv = FloatArray(3)
173+
val list = mPrefs!!.cats
174+
list.sortedWith { cat, cat2 ->
175+
Color.colorToHSV(cat.bodyColor, hsv)
176+
val bodyH1 = hsv[0]
177+
Color.colorToHSV(cat2.bodyColor, hsv)
178+
val bodyH2 = hsv[0]
179+
bodyH1.compareTo(bodyH2)
180+
}
181+
cats = list.toTypedArray<Cat?>()
174182
}
175-
cats = list.toTypedArray<Cat?>()
183+
mAdapter!!.setCats(cats)
184+
185+
return@async cats.size
186+
}
187+
runBlocking {
188+
numCats = catsUpdate.await()
176189
}
177-
mAdapter!!.setCats(cats)
178-
return cats.size
190+
return numCats
179191
}
180192

181193
private fun onCatClick(cat: Cat?) {
@@ -336,7 +348,7 @@ class NekoLand : AppCompatActivity(), PrefState.PrefsListener {
336348
val uri: Uri =
337349
FileProvider.getUriForFile(
338350
this@NekoLand,
339-
"com.android.egg.fileprovider",
351+
"ru.dimon6018.neko11.fileprovider",
340352
png
341353
)
342354
Log.v("Neko", "cat uri: $uri")

app/src/main/java/ru/dimon6018/neko11/PrefState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PrefState(private val mContext: Context) : OnSharedPreferenceChangeListene
3232
mPrefs.edit().remove(CAT_KEY_PREFIX + cat.seed).apply()
3333
}
3434

35-
val cats: List<Cat>
35+
val cats: MutableList<Cat>
3636
get() {
3737
val cats = ArrayList<Cat>()
3838
val map = mPrefs.all

0 commit comments

Comments
 (0)