-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #524 from HackIllinois/leah/home-2024
Home Page 2024
- Loading branch information
Showing
20 changed files
with
289 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
app/src/main/java/org/hackillinois/android/view/home/EventProgressManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.hackillinois.android.view.home | ||
|
||
import android.os.CountDownTimer | ||
import org.hackillinois.android.R | ||
import org.hackillinois.android.common.isBeforeNow | ||
import org.hackillinois.android.common.timeUntilMs | ||
import java.util.* | ||
|
||
class EventProgressManager(val listener: CountDownListener) { | ||
|
||
// CORRECT TIMES ARE NOT SET YET | ||
// 02-23-2024 15:30:00 | ||
private val checkInTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708723800000 | ||
} | ||
|
||
// 02-23-2024 16:00:00 | ||
private val scavengerHuntTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708725600000 | ||
} | ||
|
||
// 02-23-2024 18:00:00 | ||
private val openingCeremonyTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708732800000 | ||
} | ||
|
||
// 02-23-2024 19:00:00 | ||
private val hackingTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708736400000 | ||
} | ||
|
||
// 02-25-2024 11:00:00 | ||
private val projectShowcaseTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708880400000 | ||
} | ||
|
||
// 02-25-2024 15:00:00 | ||
private val closingCeremonyTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708894800000 | ||
} | ||
|
||
// 02-25-2024 16:00:00 | ||
private val afterHackathonTime: Calendar = Calendar.getInstance().apply { | ||
timeZone = TimeZone.getTimeZone("America/Chicago") | ||
timeInMillis = 1708898400000 | ||
} | ||
|
||
private var times = listOf(checkInTime, scavengerHuntTime, openingCeremonyTime, hackingTime, projectShowcaseTime, closingCeremonyTime, afterHackathonTime) | ||
private var backgrounds = listOf(R.drawable.home_bg_start, R.drawable.home_check_in_bg, R.drawable.home_scavenger_hunt_bg, R.drawable.home_opening_bg, R.drawable.home_hacking_bg, R.drawable.home_project_showcase_bg, R.drawable.home_closing_bg, R.drawable.home_final_bg) | ||
private var timer: CountDownTimer? = null | ||
private var state = 0 | ||
|
||
private val refreshRateMs = 500L | ||
|
||
fun start() { | ||
// find current state of the event progress | ||
while (state < times.size && times[state].isBeforeNow()) { | ||
state++ | ||
} | ||
startTimer() | ||
} | ||
|
||
private fun startTimer() { | ||
// if past the last event, don't start another timer | ||
if (state >= times.size) { | ||
listener.updateBackground(backgrounds[backgrounds.size - 1]) | ||
return | ||
} | ||
|
||
// else set the current title and start timer until next timestamp | ||
listener.updateBackground(backgrounds[state]) | ||
val millisTillTimerFinishes = times[state].timeUntilMs() | ||
|
||
timer = object : CountDownTimer(millisTillTimerFinishes, refreshRateMs) { | ||
override fun onTick(millisUntilFinished: Long) { | ||
// do nothing | ||
} | ||
|
||
override fun onFinish() { | ||
state++ | ||
startTimer() | ||
} | ||
}.start() | ||
} | ||
|
||
fun onPause() { | ||
timer?.cancel() | ||
timer = null | ||
} | ||
|
||
fun onResume() { | ||
if (timer == null) { | ||
start() | ||
} | ||
} | ||
|
||
interface CountDownListener { | ||
fun updateBackground(newBackgroundResource: Int) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape android:shape="rectangle" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/tangerine" /> | ||
<corners android:radius="8dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape android:shape="rectangle" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/sweetCitrus" /> | ||
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp"/> | ||
</shape> |
Oops, something went wrong.