Update MxRx library from 0.7.0 to 1.0.1
This commit is contained in:
parent
99087019d2
commit
5da29e8063
|
@ -156,7 +156,7 @@ dependencies {
|
||||||
|
|
||||||
implementation("com.airbnb.android:epoxy:$epoxy_version")
|
implementation("com.airbnb.android:epoxy:$epoxy_version")
|
||||||
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
|
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
|
||||||
implementation 'com.airbnb.android:mvrx:0.7.0'
|
implementation 'com.airbnb.android:mvrx:1.0.1'
|
||||||
|
|
||||||
// Work
|
// Work
|
||||||
implementation "android.arch.work:work-runtime-ktx:1.0.0"
|
implementation "android.arch.work:work-runtime-ktx:1.0.0"
|
||||||
|
|
|
@ -27,6 +27,7 @@ import kotlinx.android.synthetic.main.view_state.view.*
|
||||||
class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||||
: FrameLayout(context, attrs, defStyle) {
|
: FrameLayout(context, attrs, defStyle) {
|
||||||
|
|
||||||
|
// TODO Use Async from MvRx?
|
||||||
sealed class State {
|
sealed class State {
|
||||||
object Content : State()
|
object Content : State()
|
||||||
object Loading : State()
|
object Loading : State()
|
||||||
|
|
|
@ -100,6 +100,7 @@ abstract class VectorBaseFragment : BaseMvRxFragment(), OnBackPressed {
|
||||||
|
|
||||||
override fun invalidate() {
|
override fun invalidate() {
|
||||||
//no-ops by default
|
//no-ops by default
|
||||||
|
// TODO Remove default implementation?
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun setArguments(args: Parcelable? = null) {
|
protected fun setArguments(args: Parcelable? = null) {
|
||||||
|
|
|
@ -19,21 +19,30 @@ import android.os.Bundle
|
||||||
import com.airbnb.mvrx.MvRxView
|
import com.airbnb.mvrx.MvRxView
|
||||||
import com.airbnb.mvrx.MvRxViewModelStore
|
import com.airbnb.mvrx.MvRxViewModelStore
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add MvRx capabilities to bottomsheetdialog (like BaseMvRxFragment)
|
* Add MvRx capabilities to bottomsheetdialog (like BaseMvRxFragment)
|
||||||
*/
|
*/
|
||||||
abstract class BaseMvRxBottomSheetDialog() : BottomSheetDialogFragment(), MvRxView {
|
abstract class BaseMvRxBottomSheetDialog : BottomSheetDialogFragment(), MvRxView {
|
||||||
|
|
||||||
override val mvrxViewModelStore by lazy { MvRxViewModelStore(viewModelStore) }
|
override val mvrxViewModelStore by lazy { MvRxViewModelStore(viewModelStore) }
|
||||||
|
private lateinit var mvrxPersistedViewId: String
|
||||||
|
|
||||||
|
final override val mvrxViewId: String by lazy { mvrxPersistedViewId }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
mvrxViewModelStore.restoreViewModels(this, savedInstanceState)
|
mvrxViewModelStore.restoreViewModels(this, savedInstanceState)
|
||||||
|
mvrxPersistedViewId = savedInstanceState?.getString(PERSISTED_VIEW_ID_KEY)
|
||||||
|
?: this::class.java.simpleName + "_" + UUID.randomUUID().toString()
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
mvrxViewModelStore.saveViewModels(outState)
|
mvrxViewModelStore.saveViewModels(outState)
|
||||||
|
outState.putString(PERSISTED_VIEW_ID_KEY, mvrxViewId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -43,3 +52,5 @@ abstract class BaseMvRxBottomSheetDialog() : BottomSheetDialogFragment(), MvRxVi
|
||||||
postInvalidate()
|
postInvalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val PERSISTED_VIEW_ID_KEY = "mvrx:bottomsheet_persisted_view_id"
|
Loading…
Reference in New Issue