-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed all direct public live data mutablity access from all view mo…
…dels
- Loading branch information
Showing
28 changed files
with
463 additions
and
292 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
26 changes: 23 additions & 3 deletions
26
chooloolib/src/main/java/com/chooloo/www/chooloolib/ui/base/BaseViewState.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 |
---|---|---|
@@ -1,14 +1,34 @@ | ||
package com.chooloo.www.chooloolib.ui.base | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.lifecycle.ViewModel | ||
import com.chooloo.www.chooloolib.util.DataLiveEvent | ||
import com.chooloo.www.chooloolib.util.LiveEvent | ||
import com.chooloo.www.chooloolib.util.MutableDataLiveEvent | ||
import com.chooloo.www.chooloolib.util.MutableLiveEvent | ||
|
||
open class BaseViewState : ViewModel() { | ||
val finishEvent = LiveEvent() | ||
val errorEvent = DataLiveEvent<Int>() | ||
val messageEvent = DataLiveEvent<Int>() | ||
protected val _finishEvent = MutableLiveEvent() | ||
protected val _errorEvent = MutableDataLiveEvent<Int>() | ||
protected val _messageEvent = MutableDataLiveEvent<Int>() | ||
|
||
val finishEvent = _finishEvent as LiveEvent | ||
val errorEvent = _errorEvent as DataLiveEvent<Int> | ||
val messageEvent = _messageEvent as DataLiveEvent<Int> | ||
|
||
|
||
open fun attach() {} | ||
open fun detach() {} | ||
|
||
fun onFinish() { | ||
_finishEvent.call() | ||
} | ||
|
||
fun onError(@StringRes errMessageRes: Int) { | ||
_errorEvent.call(errMessageRes) | ||
} | ||
|
||
fun onMessage(@StringRes messageRes: Int) { | ||
_messageEvent.call(messageRes) | ||
} | ||
} |
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
10 changes: 8 additions & 2 deletions
10
chooloolib/src/main/java/com/chooloo/www/chooloolib/ui/base/menu/BaseMenuViewState.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
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
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
Oops, something went wrong.