Parcelable: Support SortedSet, NavigableSet, SortedMap, NavigableMap
This commit is contained in:
+4
@@ -82,6 +82,8 @@ interface ParcelSerializer {
|
|||||||
|| className == ArrayList::class.java.canonicalName
|
|| className == ArrayList::class.java.canonicalName
|
||||||
|| className == LinkedList::class.java.canonicalName
|
|| className == LinkedList::class.java.canonicalName
|
||||||
|| className == Set::class.java.canonicalName
|
|| className == Set::class.java.canonicalName
|
||||||
|
|| className == SortedSet::class.java.canonicalName
|
||||||
|
|| className == NavigableSet::class.java.canonicalName
|
||||||
|| className == HashSet::class.java.canonicalName
|
|| className == HashSet::class.java.canonicalName
|
||||||
|| className == LinkedHashSet::class.java.canonicalName
|
|| className == LinkedHashSet::class.java.canonicalName
|
||||||
|| className == TreeSet::class.java.canonicalName
|
|| className == TreeSet::class.java.canonicalName
|
||||||
@@ -93,6 +95,8 @@ interface ParcelSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
className == Map::class.java.canonicalName
|
className == Map::class.java.canonicalName
|
||||||
|
|| className == SortedMap::class.java.canonicalName
|
||||||
|
|| className == NavigableMap::class.java.canonicalName
|
||||||
|| className == HashMap::class.java.canonicalName
|
|| className == HashMap::class.java.canonicalName
|
||||||
|| className == LinkedHashMap::class.java.canonicalName
|
|| className == LinkedHashMap::class.java.canonicalName
|
||||||
|| className == TreeMap::class.java.canonicalName
|
|| className == TreeMap::class.java.canonicalName
|
||||||
|
|||||||
+4
@@ -204,7 +204,11 @@ abstract internal class AbstractCollectionParcelSerializer(
|
|||||||
protected val collectionType: Type = Type.getObjectType(when (asmType.internalName) {
|
protected val collectionType: Type = Type.getObjectType(when (asmType.internalName) {
|
||||||
"java/util/List" -> "java/util/ArrayList"
|
"java/util/List" -> "java/util/ArrayList"
|
||||||
"java/util/Set" -> "java/util/LinkedHashSet"
|
"java/util/Set" -> "java/util/LinkedHashSet"
|
||||||
|
"java/util/SortedSet" -> "java/util/TreeSet"
|
||||||
|
"java/util/NavigableSet" -> "java/util/TreeSet"
|
||||||
"java/util/Map" -> "java/util/LinkedHashMap"
|
"java/util/Map" -> "java/util/LinkedHashMap"
|
||||||
|
"java/util/SortedMap" -> "java/util/TreeMap"
|
||||||
|
"java/util/NavigableMap" -> "java/util/TreeMap"
|
||||||
else -> asmType.internalName
|
else -> asmType.internalName
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -19,7 +19,9 @@ data class Test(
|
|||||||
val f: MutableSet<String>,
|
val f: MutableSet<String>,
|
||||||
val g: TreeSet<String>,
|
val g: TreeSet<String>,
|
||||||
val h: HashSet<String>,
|
val h: HashSet<String>,
|
||||||
val i: LinkedHashSet<String>
|
val i: LinkedHashSet<String>,
|
||||||
|
val j: NavigableSet<String>,
|
||||||
|
val k: SortedSet<String>
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
fun box() = parcelTest { parcel ->
|
fun box() = parcelTest { parcel ->
|
||||||
@@ -32,7 +34,9 @@ fun box() = parcelTest { parcel ->
|
|||||||
f = mutableSetOf("F"),
|
f = mutableSetOf("F"),
|
||||||
g = TreeSet<String>().apply { this += "G" },
|
g = TreeSet<String>().apply { this += "G" },
|
||||||
h = HashSet<String>().apply { this += "H" },
|
h = HashSet<String>().apply { this += "H" },
|
||||||
i = LinkedHashSet<String>().apply { this += "I" }
|
i = LinkedHashSet<String>().apply { this += "I" },
|
||||||
|
j = TreeSet<String>().apply { this += "J" },
|
||||||
|
k = TreeSet<String>().apply { this += "K" }
|
||||||
)
|
)
|
||||||
|
|
||||||
first.writeToParcel(parcel, 0)
|
first.writeToParcel(parcel, 0)
|
||||||
@@ -45,4 +49,6 @@ fun box() = parcelTest { parcel ->
|
|||||||
assert(first == first2)
|
assert(first == first2)
|
||||||
assert((first.d as LinkedList<*>).size == 1)
|
assert((first.d as LinkedList<*>).size == 1)
|
||||||
assert((first2.h as HashSet<*>).size == 1)
|
assert((first2.h as HashSet<*>).size == 1)
|
||||||
|
assert(first2.j is NavigableSet<*>)
|
||||||
|
assert(first2.k is SortedSet<*>)
|
||||||
}
|
}
|
||||||
+8
-2
@@ -15,7 +15,9 @@ data class Test(
|
|||||||
val b: MutableMap<String, String>,
|
val b: MutableMap<String, String>,
|
||||||
val c: HashMap<String, String>,
|
val c: HashMap<String, String>,
|
||||||
val d: LinkedHashMap<String, String>,
|
val d: LinkedHashMap<String, String>,
|
||||||
val e: TreeMap<String, String>
|
val e: TreeMap<String, String>,
|
||||||
|
val f: SortedMap<String, String>,
|
||||||
|
val g: NavigableMap<String, String>
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
fun box() = parcelTest { parcel ->
|
fun box() = parcelTest { parcel ->
|
||||||
@@ -24,7 +26,9 @@ fun box() = parcelTest { parcel ->
|
|||||||
b = mutableMapOf("A" to "B"),
|
b = mutableMapOf("A" to "B"),
|
||||||
c = HashMap<String, String>().apply { put("A", "B") },
|
c = HashMap<String, String>().apply { put("A", "B") },
|
||||||
d = LinkedHashMap<String, String>().apply { put("A", "B") },
|
d = LinkedHashMap<String, String>().apply { put("A", "B") },
|
||||||
e = TreeMap<String, String>().apply { put("A", "B") }
|
e = TreeMap<String, String>().apply { put("A", "B") },
|
||||||
|
f = TreeMap<String, String>().apply { put("A", "B") },
|
||||||
|
g = TreeMap<String, String>().apply { put("A", "B") }
|
||||||
)
|
)
|
||||||
|
|
||||||
first.writeToParcel(parcel, 0)
|
first.writeToParcel(parcel, 0)
|
||||||
@@ -37,4 +41,6 @@ fun box() = parcelTest { parcel ->
|
|||||||
assert(first == first2)
|
assert(first == first2)
|
||||||
assert((first.c as HashMap<*, *>).size == 1)
|
assert((first.c as HashMap<*, *>).size == 1)
|
||||||
assert((first2.e as TreeMap<*, *>).size == 1)
|
assert((first2.e as TreeMap<*, *>).size == 1)
|
||||||
|
assert(first2.f is SortedMap<*, *>)
|
||||||
|
assert(first2.g is NavigableMap<*, *>)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user