mirror of
https://codeberg.org/timelimit/opentimelimit-android.git
synced 2025-10-05 19:42:25 +02:00
Eventually fix some rare crashes
This commit is contained in:
parent
ae9f6b1a08
commit
da0f0ea332
4 changed files with 41 additions and 6 deletions
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Open TimeLimit Copyright <C> 2019 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.timelimit.android.ui.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ViewFlipper
|
||||
|
||||
// based on https://stackoverflow.com/a/8208874
|
||||
// this should fix some rare crashes at Android 4.4
|
||||
class SafeViewFlipper: ViewFlipper {
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
try {
|
||||
super.onDetachedFromWindow()
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
stopFlipping()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<ViewFlipper
|
||||
<io.timelimit.android.ui.view.SafeViewFlipper
|
||||
android:id="@+id/flipper"
|
||||
android:measureAllChildren="false"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -111,6 +111,6 @@
|
|||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</ViewFlipper>
|
||||
</io.timelimit.android.ui.view.SafeViewFlipper>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<data></data>
|
||||
|
||||
<ViewFlipper
|
||||
<io.timelimit.android.ui.view.SafeViewFlipper
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/flipper"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -101,5 +101,5 @@
|
|||
<include layout="@layout/circular_progress_indicator" />
|
||||
|
||||
<include android:id="@+id/missing_auth_view" layout="@layout/fragment_add_user_missing_authentication" />
|
||||
</ViewFlipper>
|
||||
</io.timelimit.android.ui.view.SafeViewFlipper>
|
||||
</layout>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ViewFlipper
|
||||
<io.timelimit.android.ui.view.SafeViewFlipper
|
||||
android:measureAllChildren="false"
|
||||
android:id="@+id/switcher"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -27,5 +27,5 @@
|
|||
<include android:id="@+id/enter_password"
|
||||
layout="@layout/new_login_fragment_password" />
|
||||
|
||||
</ViewFlipper>
|
||||
</io.timelimit.android.ui.view.SafeViewFlipper>
|
||||
</layout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue