Skip to content

Instantly share code, notes, and snippets.

View vegeta2102's full-sized avatar
🙋‍♂️
頑張るぞ!

vegeta2102

🙋‍♂️
頑張るぞ!
View GitHub Profile
override suspend fun startCountDown(count: Int) {
// 10 seconds for count down
// 100 is a finer number that makes progress run smoother than normal
val countTime = count * 100
repeat(countTime) {
// In case of 10 seconds count down
// The timer will display as 10 -> 9 -> 8 -> 7 -> 6 -> 5 -> 4 -> 3 -> 2 -> 1 -> 0
// So it must plus 1
val displaySeconds = countTime.minus(it).div(100).plus(1)
class ProgressBarViewModel @ViewModelInject constructor(
private val progressBarRepository: ProgressBarRepository
) : ViewModel() {
// Display seconds
val countDown: LiveData<String> = progressBarRepository.data.map {
it.time.toString()
}.asLiveData().distinctUntilChanged()
// Progress state of circle bar
interface ProgressBarRepository {
val data: Flow<Int>
suspend fun startCountDown(count: Int)
}
class ProgressBarRepositoryImpl @Inject constructor() : ProgressBarRepository {
private val _data: MutableStateFlow<Int?> = MutableStateFlow(null)
override val data: Flow<Int>
get() = _data.filterNotNull()
@AndroidEntryPoint
class NextScreenFragment : Fragment(R.layout.fragment_next_screen) {
private val navigation: NavController by lazy {
findNavController()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
observeViewModel()
@AndroidEntryPoint
class MediumFragment : Fragment(R.layout.fragment_medium) {
private val navigation: NavController by lazy {
findNavController()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
observeNavigationCallBack()
private val modeChangeListener =
Preference.OnPreferenceChangeListener { preference, newValue ->
Log.i("newValue", newValue.toString())
newValue as? String
when (newValue) {
getString(R.string.pf_light_on) -> {
updateTheme(AppCompatDelegate.MODE_NIGHT_YES)
}
getString(R.string.pf_light_off) -> {
updateTheme(AppCompatDelegate.MODE_NIGHT_NO)
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference
android:defaultValue="@string/pf_dark_auto"
android:dialogTitle="@string/pf_dark_dialog"
android:entries="@array/light_theme"
android:entryValues="@array/light_theme_value"
app:key="@string/pf_key_light"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="light_theme">
<item>@string/light_mode_auto</item>
<item>@string/light_mode_on</item>
<item>@string/light_mode_off</item>
</string-array>
<string-array name="light_theme_value">
<item>@string/pf_dark_auto</item>
<item>@string/pf_light_on</item>
@vegeta2102
vegeta2102 / gist:766542d17bcdcc9d909f85c866cda7b9
Created April 16, 2020 10:14 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: