mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 21:57:11 +00:00
Improve seasonal shop sorting
This commit is contained in:
parent
413c3bbc7b
commit
99dd93344d
2 changed files with 14 additions and 7 deletions
|
|
@ -39,8 +39,10 @@
|
|||
android:src="@drawable/shop_header_sparkle" />
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="3dp"
|
||||
android:visibility="gone"
|
||||
android:background="#EA8C31" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -83,17 +85,13 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_arrow_drop_down_10dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
android:src="@drawable/ic_arrow_drop_down_10dp" />
|
||||
</LinearLayout>
|
||||
<Spinner
|
||||
android:id="@+id/class_selection_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="10dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="bottom"
|
||||
tools:visibility="gone" />
|
||||
android:visibility="invisible" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ open class ShopFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>()
|
|||
Shop.SEASONAL_SHOP -> {
|
||||
newShop.categories.sortWith(
|
||||
compareBy<ShopCategory> { it.items.firstOrNull()?.currency != "gold" }
|
||||
.thenByDescending { it.items.firstOrNull()?.availableUntil }
|
||||
.thenByDescending { if (it.identifier == "quests") 10000 else findReleaseYear(it.items.firstOrNull()?.key ?: "") }
|
||||
.thenBy { it.items.firstOrNull()?.locked },
|
||||
)
|
||||
}
|
||||
|
|
@ -394,6 +394,15 @@ open class ShopFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>()
|
|||
}
|
||||
}
|
||||
|
||||
private fun findReleaseYear(key: String): Int {
|
||||
val result = key.filter { it.isDigit() }
|
||||
return if (result.isEmpty()) {
|
||||
2014
|
||||
} else {
|
||||
result.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatTimeTravelersShop(shop: Shop): Shop {
|
||||
val newCategories = mutableListOf<ShopCategory>()
|
||||
for (category in shop.categories) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue