Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-library into develop
  • Loading branch information
Merseyside committed Dec 17, 2021
2 parents 138b0d8 + cd3cc46 commit 897e05d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.merseyside.merseyLib.archy.core.presentation.model.BaseViewModel
import com.merseyside.merseyLib.archy.core.presentation.model.StateViewModel
import com.merseyside.merseyLib.archy.core.presentation.model.StateViewModel.Companion.INSTANCE_STATE_KEY
import com.merseyside.merseyLib.utils.core.SavedState
import com.merseyside.utils.ext.getSerialize
import com.merseyside.utils.ext.putSerialize
import com.merseyside.utils.reflection.ReflectionUtils
import com.merseyside.utils.requestPermissions
Expand Down Expand Up @@ -109,6 +110,22 @@ abstract class BaseVMFragment<B : ViewDataBinding, M : BaseViewModel>
}
}

override fun onViewStateRestored(savedInstanceState: Bundle?) {
val savedState = SavedState().apply {
savedInstanceState?.getSerialize(
INSTANCE_STATE_KEY, MapSerializer(String.serializer(), String.serializer())
)?.let {
addAll(
it
)
}
}
if (viewModel is StateViewModel) {
(viewModel as StateViewModel).onRestoreState(savedState)
}
super.onViewStateRestored(savedInstanceState)
}

override fun updateLanguage(context: Context) {
super.updateLanguage(context)
//viewModel.updateLanguage(context)
Expand Down Expand Up @@ -160,3 +177,4 @@ abstract class BaseVMFragment<B : ViewDataBinding, M : BaseViewModel>
).kotlin as KClass<M>
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ abstract class BaseViewModel protected constructor() : ViewModel() {
val isInProgress: LiveData<Boolean> = mutProgress

protected var progress: Boolean
get() { return mutProgress.value }
set(value) { mutProgress.value = value }
get() {
return mutProgress.value
}
set(value) {
mutProgress.value = value
}

private val mutProgressText = MutableSingleEvent<String?>(null)
val progressText: LiveData<String?> = mutProgressText
Expand All @@ -32,6 +36,9 @@ abstract class BaseViewModel protected constructor() : ViewModel() {
private val mutGrantPermissionLiveEvent = MutableSingleEvent<Pair<Array<String>, Int>?>(null)
val grantPermissionLiveEvent: LiveData<Pair<Array<String>, Int>?> = mutGrantPermissionLiveEvent

private val mutQueryRestoreEvent = MutableSingleEvent<String?>(null)
val queryRestoreEvent: LiveData<String?> = mutQueryRestoreEvent

data class TextMessage(
val isError: Boolean = false,
var msg: String = "",
Expand Down Expand Up @@ -182,7 +189,11 @@ abstract class BaseViewModel protected constructor() : ViewModel() {
)
}

open fun onBack() : Boolean {
fun restoreQuery(query: String) {
mutQueryRestoreEvent.value = query
}

open fun onBack(): Boolean {
return true
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencyResolutionManagement {

val androidLibs by creating {
from("$group:catalog-version-android:$catalogVersions")
version("merseyLib", "1.7.1")
version("merseyLib", "1.7.4")
}

val common by creating {
Expand Down

0 comments on commit 897e05d

Please sign in to comment.