Commit d0d732b 1 parent 50ce437 commit d0d732b Copy full SHA for d0d732b
File tree 1 file changed +5
-7
lines changed
app/src/main/java/com/infomaniak/mail/utils
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -165,26 +165,24 @@ object UiUtils {
165
165
fun dividerDrawable (context : Context ) = AppCompatResources .getDrawable(context, R .drawable.divider)
166
166
167
167
fun saveFocusWhenNavigatingBack (getLayout : () -> ViewGroup , lifecycle : Lifecycle ) {
168
+
168
169
val lifecycleObserver = object : DefaultLifecycleObserver {
170
+
169
171
@IdRes
170
172
private var lastFocusViewId: Int? = null
171
173
172
174
override fun onStart (owner : LifecycleOwner ) {
173
175
super .onStart(owner)
174
- lastFocusViewId?.let { viewId ->
175
- getLayout().findViewById<View >(viewId).requestFocus()
176
- }
176
+ lastFocusViewId?.let { viewId -> getLayout().findViewById<View >(viewId).requestFocus() }
177
177
}
178
178
179
179
override fun onStop (owner : LifecycleOwner ) {
180
- getLayout().focusedChild?.let {
181
- lastFocusViewId = it.id
182
- }
180
+ getLayout().focusedChild?.let { lastFocusViewId = it.id }
183
181
super .onStop(owner)
184
182
}
185
183
186
184
override fun onDestroy (owner : LifecycleOwner ) {
187
- lifecycle.removeObserver(this )
185
+ lifecycle.removeObserver(observer = this )
188
186
super .onDestroy(owner)
189
187
}
190
188
}
You can’t perform that action at this time.
0 commit comments