From e8f2ce3090eb4a710755efcc16121182e9c0db8f Mon Sep 17 00:00:00 2001 From: Aditya Kshirsagar Date: Thu, 27 Feb 2025 23:06:17 -0600 Subject: [PATCH] fixed point shop raffle stuff --- app/build.gradle | 4 ++-- .../android/view/home/CountdownManager.kt | 8 +++---- .../android/view/shop/ShopFragment.kt | 23 +++++++++++++------ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 361d63c7..1da26825 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,8 +24,8 @@ android { applicationId "org.hackillinois.android" minSdkVersion 23 targetSdkVersion 34 - versionCode 68 - versionName "2025.1.3" + versionCode 69 + versionName "2025.1.4" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/hackillinois/android/view/home/CountdownManager.kt b/app/src/main/java/org/hackillinois/android/view/home/CountdownManager.kt index df61029b..5a3b89d4 100644 --- a/app/src/main/java/org/hackillinois/android/view/home/CountdownManager.kt +++ b/app/src/main/java/org/hackillinois/android/view/home/CountdownManager.kt @@ -7,10 +7,10 @@ import java.util.* class CountdownManager(val listener: CountDownListener) { - // 02-28-2025 : 14:30 + // 02-28-2025 : 18:00 private val eventStartTime: Calendar = Calendar.getInstance().apply { timeZone = TimeZone.getTimeZone("America/Chicago") - timeInMillis = 1740774600000 // 1708723800000 + timeInMillis = 1740774600000 } // 02-28-2025 : 18:00 @@ -19,10 +19,10 @@ class CountdownManager(val listener: CountDownListener) { timeInMillis = 1740787200000 } - // 03-02-2025 11:30 + // 03-02-2025 7:00 private val hackingEndTime: Calendar = Calendar.getInstance().apply { timeZone = TimeZone.getTimeZone("America/Chicago") - timeInMillis = 1740936600000 + timeInMillis = 1740920400000 } private var times = listOf(eventStartTime, hackingStartTime, hackingEndTime) diff --git a/app/src/main/java/org/hackillinois/android/view/shop/ShopFragment.kt b/app/src/main/java/org/hackillinois/android/view/shop/ShopFragment.kt index 5c44f991..f39c1377 100644 --- a/app/src/main/java/org/hackillinois/android/view/shop/ShopFragment.kt +++ b/app/src/main/java/org/hackillinois/android/view/shop/ShopFragment.kt @@ -160,15 +160,14 @@ class ShopFragment : Fragment(), ShopAdapter.OnBuyItemListener { // Called in onCreateView within shopLiveData.observe private fun updateShopItems(newShop: List) { - // Split shop items into categories merchItems = newShop.filter { !it.isRaffle }.sortedBy { it.quantity == 0 } raffleItems = newShop.filter { it.isRaffle }.sortedBy { it.quantity == 0 } - // **Update only the RecyclerView items** + // Update only the RecyclerView items: skip the first two fixed items for both tabs val recyclerViewItems = if (showingMerch) { if (merchItems.size > 2) merchItems.subList(2, merchItems.size) else listOf() } else { - raffleItems + if (raffleItems.size > 2) raffleItems.subList(2, raffleItems.size) else listOf() } // Update adapter @@ -336,16 +335,26 @@ class ShopFragment : Fragment(), ShopAdapter.OnBuyItemListener { } private fun buyFirstItem() { - if (merchItems.isNotEmpty()) { - val firstItem = merchItems[0] + val sortedItems = if (showingMerch) { + merchItems.sortedBy { it.quantity == 0 } + } else { + raffleItems.sortedBy { it.quantity == 0 } + } + if (sortedItems.isNotEmpty()) { + val firstItem = sortedItems[0] Log.d("ShopFragment", "Buying: ${firstItem.name}") onBuyItem(firstItem) } } private fun buySecondItem() { - if (merchItems.size >= 2) { - val secondItem = merchItems[1] + val sortedItems = if (showingMerch) { + merchItems.sortedBy { it.quantity == 0 } + } else { + raffleItems.sortedBy { it.quantity == 0 } + } + if (sortedItems.size >= 2) { + val secondItem = sortedItems[1] Log.d("ShopFragment", "Buying: ${secondItem.name}") onBuyItem(secondItem) }