Added fail safes

pull/215/head
M66B 7 months ago
parent 4458b24fad
commit d992fe9788

@ -123,7 +123,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override @Override
public void onBackStackChanged() { public void onBackStackChanged() {
try {
appbar.setExpanded(true); appbar.setExpanded(true);
} catch (Throwable ex) {
Log.e(ex);
}
} }
}); });
} }
@ -137,15 +141,20 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override @Override
public void onOffsetChanged(AppBarLayout appBarLayout, int i) { public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
try {
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
mlp.topMargin = abh + i; mlp.topMargin = abh + i;
view.setLayoutParams(mlp); view.setLayoutParams(mlp);
} catch (Throwable ex) {
Log.e(ex);
}
} }
}); });
FragmentDialogTheme.setBackground(this, holder, this instanceof ActivityCompose); FragmentDialogTheme.setBackground(this, holder, this instanceof ActivityCompose);
ViewCompat.setOnApplyWindowInsetsListener(holder, (v, windowInsets) -> { ViewCompat.setOnApplyWindowInsetsListener(holder, (v, windowInsets) -> {
try {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
@ -154,6 +163,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
mlp.rightMargin = insets.right; mlp.rightMargin = insets.right;
mlp.bottomMargin = insets.bottom; mlp.bottomMargin = insets.bottom;
v.setLayoutParams(mlp); v.setLayoutParams(mlp);
} catch (Throwable ex) {
Log.e(ex);
}
return WindowInsetsCompat.CONSUMED; return WindowInsetsCompat.CONSUMED;
}); });
@ -167,6 +179,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
public WindowInsetsCompat onProgress( public WindowInsetsCompat onProgress(
@NonNull WindowInsetsCompat windowInsets, @NonNull WindowInsetsCompat windowInsets,
@NonNull List<WindowInsetsAnimationCompat> runningAnimations) { @NonNull List<WindowInsetsAnimationCompat> runningAnimations) {
try {
// https://developer.android.com/develop/ui/views/layout/sw-keyboard // https://developer.android.com/develop/ui/views/layout/sw-keyboard
for (WindowInsetsAnimationCompat animation : runningAnimations) for (WindowInsetsAnimationCompat animation : runningAnimations)
if ((animation.getTypeMask() & WindowInsetsCompat.Type.ime()) != 0) { if ((animation.getTypeMask() & WindowInsetsCompat.Type.ime()) != 0) {
@ -176,6 +189,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
holder.setPaddingRelative(0, 0, 0, pad < 0 ? 0 : pad); holder.setPaddingRelative(0, 0, 0, pad < 0 ? 0 : pad);
break; break;
} }
} catch (Throwable ex) {
Log.e(ex);
}
return windowInsets; return windowInsets;
} }

Loading…
Cancel
Save