Sticker: sort by title

main
Alibek Omarov 5 years ago
parent ac2dba316e
commit 962b6728dd
  1. 10
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt
  2. 7
      app/src/main/java/com/keylesspalace/tusky/entity/Sticker.kt

@ -426,7 +426,7 @@ class ComposeViewModel
super.onCleared() super.onCleared()
} }
fun getStickers() { private fun getStickers() {
if(!tryFetchStickers) if(!tryFetchStickers)
return return
@ -435,6 +435,7 @@ class ComposeViewModel
haveStickers.postValue(true) haveStickers.postValue(true)
val singles = mutableListOf<Single<Response<StickerPack>>>() val singles = mutableListOf<Single<Response<StickerPack>>>()
for(entry in stickers) { for(entry in stickers) {
val url = entry.value.removePrefix("/").removeSuffix("/") + "/pack.json"; val url = entry.value.removePrefix("/").removeSuffix("/") + "/pack.json";
singles += api.getStickerPack(url) singles += api.getStickerPack(url)
@ -450,8 +451,11 @@ class ComposeViewModel
Log.d(TAG, "Failed to get sticker pack.json", it) Log.d(TAG, "Failed to get sticker pack.json", it)
emptyList() emptyList()
}.subscribe() { pack -> }.subscribe() { pack ->
if(pack.isNotEmpty()) if(pack.isNotEmpty()) {
this.stickers.postValue(pack.toTypedArray()) val array = pack.toTypedArray()
array.sort()
this.stickers.postValue(array)
}
}.autoDispose() }.autoDispose()
} }
}, { }, {

@ -18,10 +18,13 @@ package com.keylesspalace.tusky.entity
import android.os.Parcelable import android.os.Parcelable
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
@Parcelize
data class StickerPack( data class StickerPack(
val title: String, val title: String,
val tabIcon: String, val tabIcon: String,
val stickers: List<String>, val stickers: List<String>,
var internal_url: String = "" var internal_url: String = ""
) : Parcelable ) : Comparable<StickerPack> {
override fun compareTo(pack: StickerPack) : Int {
return title.compareTo(pack.title)
}
}

Loading…
Cancel
Save