-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WilliamKwokX
committed
Sep 13, 2023
1 parent
3abe582
commit 94c8fa4
Showing
44 changed files
with
147 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
api/src/main/java/pers/shawxingkwok/mvb/android/convertParcelableArrayIfNeeded.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package pers.shawxingkwok.mvb.android | ||
|
||
import android.os.Parcelable | ||
import java.util.* | ||
import kotlin.reflect.KClass | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
@PublishedApi | ||
internal fun <T> T.convertParcelableArrayIfNeeded(parcelableComponent: KClass<out Parcelable>?): T = | ||
if (this is Array<*> && javaClass.componentType == Parcelable::class.java) { | ||
requireNotNull(parcelableComponent){ | ||
"The parcelable component misses." | ||
} | ||
val newArrClass = java.lang.reflect.Array.newInstance(parcelableComponent.java, size).javaClass as Class<out Array<*>> | ||
Arrays.copyOf(this, size, newArrClass) as T | ||
} | ||
else | ||
this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab
Binary file not shown.
Binary file modified
BIN
+10 KB
(190%)
...uild/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab
Binary file not shown.
Binary file modified
BIN
+12 Bytes
(110%)
.../kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...ild/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab
Binary file not shown.
Binary file modified
BIN
+373 Bytes
(130%)
.../compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...ild/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab
Binary file not shown.
Binary file modified
BIN
+6.45 KB
(190%)
.../compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab
Binary file not shown.
Binary file modified
BIN
+5.33 KB
(180%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab
Binary file not shown.
Binary file modified
BIN
+5.8 KB
(190%)
...kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab
Binary file not shown.
Binary file modified
BIN
+227 Bytes
(130%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab
Binary file not shown.
Binary file modified
BIN
+151 Bytes
(130%)
.../build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
8 | ||
12 | ||
0 |
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab
Binary file not shown.
Binary file modified
BIN
+24 Bytes
(120%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len
Binary file not shown.
Binary file modified
BIN
+373 Bytes
(150%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab
Binary file not shown.
Binary file modified
BIN
+14.1 KB
(200%)
demo/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
demo/build/kotlin/compileDebugKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file modified
BIN
+276 Bytes
(110%)
demo/build/kotlin/compileDebugKotlin/local-state/build-history.bin
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
demo/src/androidTest/java/pers/shawxingkwok/androidutil/view/ParcelableComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@file:Suppress("unused") | ||
|
||
package pers.shawxingkwok.androidutil.view | ||
|
||
import android.os.Parcelable | ||
import android.util.SparseArray | ||
import androidx.fragment.app.Fragment | ||
import kotlinx.parcelize.Parcelize | ||
import pers.shawxingkwok.mvb.android.save | ||
|
||
internal class ParcelableComponent { | ||
internal class MyFragment : Fragment() { | ||
@Parcelize | ||
data class User(val id: Long, val name: String): Parcelable | ||
|
||
/** | ||
* Pass `KClass<out Parcelable>` (`User::class` in this case) when ultimately | ||
* saved as `List<out Parcelable>`/`SparseArray<out Parcelable>`. | ||
* | ||
* 'ultimately' means saved types change with `transform`. | ||
*/ | ||
val userList by save(User::class) { mutableListOf<User>() } | ||
val userSparseArr by save(User::class) { SparseArray<User>() } | ||
|
||
/** | ||
* `User::class` could be automatically recognized in cases below. | ||
*/ | ||
var user: User by save() | ||
var userArr by save { emptyArray<User>() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
demo/src/androidTest/java/pers/shawxingkwok/androidutil/view/SaveWithParcelableComponents.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.