-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ViewModel in a lifecycle component that can help share necessary live data among Activities.
- Loading branch information
1 parent
63fd86b
commit 305bf2b
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/osfans/trime/ui/main/MainViewModel.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,23 @@ | ||
package com.osfans.trime.ui.main | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
|
||
class MainViewModel : ViewModel() { | ||
|
||
val toolbarTitle = MutableLiveData<String>() | ||
|
||
val topOptionsMenu = MutableLiveData<Boolean>() | ||
|
||
fun setToolbarTitle(title: String) { | ||
toolbarTitle.value = title | ||
} | ||
|
||
fun enableTopOptionsMenu() { | ||
topOptionsMenu.value = true | ||
} | ||
|
||
fun disableTopOptionsMenu() { | ||
topOptionsMenu.value = false | ||
} | ||
} |