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

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

Loading…
Cancel
Save