forked from github/szkolny
[UI] Add snowfall to CounterActivity. Enable in February as well.
This commit is contained in:
parent
5f8016061d
commit
81d4801d27
@ -322,7 +322,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
|
|
||||||
// IT'S WINTER MY DUDES
|
// IT'S WINTER MY DUDES
|
||||||
val today = Date.getToday()
|
val today = Date.getToday()
|
||||||
if ((today.month % 11 == 1) && app.config.ui.snowfall) {
|
if ((today.month / 3 % 4 == 0) && app.config.ui.snowfall) {
|
||||||
b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false))
|
b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false))
|
||||||
} else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) {
|
} else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) {
|
||||||
val eggfall = layoutInflater.inflate(
|
val eggfall = layoutInflater.inflate(
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
package pl.szczodrzynski.edziennik.ui.home
|
package pl.szczodrzynski.edziennik.ui.home
|
||||||
|
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.jetradarmobile.snowfall.SnowfallView
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.utils.colorInt
|
import com.mikepenz.iconics.utils.colorInt
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
@ -20,6 +22,7 @@ import pl.szczodrzynski.edziennik.ext.startCoroutineTimer
|
|||||||
import pl.szczodrzynski.edziennik.ext.timeLeft
|
import pl.szczodrzynski.edziennik.ext.timeLeft
|
||||||
import pl.szczodrzynski.edziennik.ext.timeTill
|
import pl.szczodrzynski.edziennik.ext.timeTill
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.BellSyncTimeChooseDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.BellSyncTimeChooseDialog
|
||||||
|
import pl.szczodrzynski.edziennik.utils.BigNightUtil
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
@ -82,6 +85,27 @@ class CounterActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
counterJob = startCoroutineTimer(repeatMillis = 500) {
|
counterJob = startCoroutineTimer(repeatMillis = 500) {
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IT'S WINTER MY DUDES
|
||||||
|
val today = Date.getToday()
|
||||||
|
if ((today.month / 3 % 4 == 0) && app.config.ui.snowfall) {
|
||||||
|
b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false))
|
||||||
|
} else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) {
|
||||||
|
val eggfall = layoutInflater.inflate(
|
||||||
|
R.layout.eggfall,
|
||||||
|
b.rootFrame,
|
||||||
|
false
|
||||||
|
) as SnowfallView
|
||||||
|
eggfall.setSnowflakeBitmaps(listOf(
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg1),
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg2),
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg3),
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg4),
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg5),
|
||||||
|
BitmapFactory.decodeResource(resources, R.drawable.egg6)
|
||||||
|
))
|
||||||
|
b.rootFrame.addView(eggfall)
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
private fun update() {
|
private fun update() {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:tools="http://schemas.android.com/tools"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/rootFrame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -50,4 +53,4 @@
|
|||||||
android:textSize="48sp"
|
android:textSize="48sp"
|
||||||
tools:text="Zostało 2341 sekund" />
|
tools:text="Zostało 2341 sekund" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</FrameLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user