diff --git a/app/build.gradle b/app/build.gradle
index 22946e7..fa8513c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -110,9 +110,9 @@ dependencies {
implementation project(":imageloading")
implementation project(":imageloading-glide")
- implementation "com.arthurivanets.mvvm:mvvm-core:1.4.1"
- implementation "com.arthurivanets.mvvm:mvvm-navigation:1.4.1"
- implementation "com.arthurivanets.mvvm:mvvm-navigation-dagger:1.4.1"
+ implementation "com.arthurivanets.mvvm:mvvm-core:1.5.0"
+ implementation "com.arthurivanets.mvvm:mvvm-navigation:1.5.0"
+ implementation "com.arthurivanets.mvvm:mvvm-navigation-dagger:1.5.0"
testImplementation unitTestingDependencies
androidTestImplementation instrumentationTestingDependencies
diff --git a/common/constants.gradle b/common/constants.gradle
index 4782c1a..66a3ec4 100644
--- a/common/constants.gradle
+++ b/common/constants.gradle
@@ -54,8 +54,8 @@ project.ext {
releaseRepoName = "maven"
releaseUserOrg = "arthurlabs"
releaseGroupId = "com.arthurivanets.mvvm"
- releaseVersion = "1.4.1"
- releaseVersionCode = 8
+ releaseVersion = "1.5.0"
+ releaseVersionCode = 9
releaseWebsite = "https://github.com/arthur3486/android-mvvm"
releaseLicense = ["Apache-2.0"]
diff --git a/domain/src/test/java/com/arthurivanets/sample/domain/ExampleUnitTest.java b/domain/src/test/java/com/arthurivanets/sample/domain/ExampleUnitTest.java
deleted file mode 100644
index 29fd1e4..0000000
--- a/domain/src/test/java/com/arthurivanets/sample/domain/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.arthurivanets.sample.domain;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmActivity.kt b/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmActivity.kt
index 55ccc75..df50c27 100644
--- a/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmActivity.kt
+++ b/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmActivity.kt
@@ -85,6 +85,7 @@ abstract class MvvmActivity(
postInit()
performDataBinding()
subscribeViewStateObservers()
+ onBind()
}
@@ -177,17 +178,21 @@ abstract class MvvmActivity(
protected abstract fun createViewModel() : VM
- /**
- * Executes the pending Data Binding operations.
- */
- @CallSuper
- protected open fun performDataBinding() {
+ private fun performDataBinding() {
if(isDataBindingEnabled) {
viewDataBinding?.executePendingBindings()
} else {
- Log.e(this::class.java.canonicalName, "The DataBinding is disabled for this Activity.")
+ Log.i(this::class.java.canonicalName, "The DataBinding is disabled for this Activity.")
}
}
+
+
+ /**
+ * Override this lifecycle method if you need to perform the manual view-state specific binding.
+ */
+ protected open fun onBind() {
+ // to be overridden.
+ }
@CallSuper
@@ -283,9 +288,18 @@ abstract class MvvmActivity(
final override fun onDestroy() {
disposeViewStateSubscriptions()
+ onUnbind()
onRecycle()
super.onDestroy()
}
+
+
+ /**
+ * Override this method if you need to manually unbind the previously bound view-state specific observers.
+ */
+ protected open fun onUnbind() {
+ // to be overridden.
+ }
/**
diff --git a/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmFragment.kt b/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmFragment.kt
index a482386..a17a449 100644
--- a/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmFragment.kt
+++ b/mvvm/src/main/java/com/arthurivanets/mvvm/MvvmFragment.kt
@@ -158,6 +158,7 @@ abstract class MvvmFragment(
performDataBinding()
subscribeViewStateObservers()
+ onBind()
// performing the state restoring only in cases when the view was created for the first time
// (otherwise there's no need to restore the state, as the current view already holds the most recent state)
@@ -232,19 +233,23 @@ abstract class MvvmFragment(
}
- /**
- * Executes the pending Data Binding operations.
- */
- @CallSuper
- protected open fun performDataBinding() {
+ private fun performDataBinding() {
if(isDataBindingEnabled) {
viewDataBinding?.executePendingBindings()
} else {
- Log.e(this::class.java.canonicalName, "The DataBinding is disabled for this Fragment.")
+ Log.i(this::class.java.canonicalName, "The DataBinding is disabled for this Fragment.")
}
}
+ /**
+ * Override this lifecycle method if you need to perform the manual view-state specific binding.
+ */
+ protected open fun onBind() {
+ // to be overridden.
+ }
+
+
/**
* Looks up the [View] for the specified viewId within the current view hierarchy.
*
@@ -449,6 +454,15 @@ abstract class MvvmFragment(
super.onDestroyView()
disposeViewStateSubscriptions()
+ onUnbind()
+ }
+
+
+ /**
+ * Override this method if you need to manually unbind the previously bound view-state specific observers.
+ */
+ protected open fun onUnbind() {
+ // to be overridden.
}