Commit 64ec3d1a authored by Divyanshu Bhargava's avatar Divyanshu Bhargava

SaveInstance on screen rotation

parent c8fe544a
...@@ -17,8 +17,8 @@ object DateTimeHelper { ...@@ -17,8 +17,8 @@ object DateTimeHelper {
* @param long The [Long] * @param long The [Long]
* @return The [LocalDateTime] from a [Long]. * @return The [LocalDateTime] from a [Long].
*/ */
fun getLocalDateTime(long: Long): LocalDateTime { fun getLocalDateTime(long: Long?): LocalDateTime {
return LocalDateTime.ofInstant(Instant.ofEpochMilli(long), ZoneId.systemDefault()) return LocalDateTime.ofInstant(long?.let { Instant.ofEpochMilli(it) }, ZoneId.systemDefault())
} }
/** /**
......
...@@ -52,6 +52,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -52,6 +52,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
private var expanded = false private var expanded = false
private lateinit var googleApiClient: GoogleApiClient private lateinit var googleApiClient: GoogleApiClient
private val headerLayout by lazy { view_navigation.getHeaderView(0) } private val headerLayout by lazy { view_navigation.getHeaderView(0) }
private val CURRENT_STATE = "current_state"
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this) AndroidInjection.inject(this)
...@@ -268,4 +269,14 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -268,4 +269,14 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
} }
} }
} }
override fun onSaveInstanceState(outState: Bundle?) {
super.onSaveInstanceState(outState)
outState?.putBoolean(CURRENT_STATE,isFragmentAdded)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
super.onRestoreInstanceState(savedInstanceState)
isFragmentAdded = savedInstanceState?.getBoolean(CURRENT_STATE) ?: false
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment