Simplification

master
M66B 1 week ago
parent 30da5ecb3a
commit de97def0ee

@ -104,7 +104,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
} }
@Override @Override
public void setContentView(View view) { public void setContentView(@NonNull View view) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean hide_toolbar = prefs.getBoolean("hide_toolbar", !BuildConfig.PLAY_STORE_RELEASE); boolean hide_toolbar = prefs.getBoolean("hide_toolbar", !BuildConfig.PLAY_STORE_RELEASE);
boolean edge_to_edge = prefs.getBoolean("edge_to_edge", false); boolean edge_to_edge = prefs.getBoolean("edge_to_edge", false);
@ -192,7 +192,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
View cf = view.findViewById(R.id.content_frame); View cf = view.findViewById(R.id.content_frame);
View content = (cf == null ? view : cf); View content = (cf == null ? view : cf);
int cpad = (content == null ? 0 : content.getPaddingBottom()); int cpad = content.getPaddingBottom();
ViewCompat.setOnApplyWindowInsetsListener(holder, (v, windowInsets) -> { ViewCompat.setOnApplyWindowInsetsListener(holder, (v, windowInsets) -> {
try { try {
@ -212,7 +212,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
changed = true; changed = true;
mlp.rightMargin = insets.right; mlp.rightMargin = insets.right;
} }
if (!edge_to_edge || content == null) if (!edge_to_edge)
if (mlp.bottomMargin != insets.bottom) { if (mlp.bottomMargin != insets.bottom) {
changed = true; changed = true;
mlp.bottomMargin = insets.bottom; mlp.bottomMargin = insets.bottom;
@ -232,7 +232,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
} }
if (edge_to_edge) { if (edge_to_edge) {
if (content != null) {
Insets nav = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()); Insets nav = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
int pad = Math.max(0, cpad + (nav.bottom - nav.top)); int pad = Math.max(0, cpad + (nav.bottom - nav.top));
Snackbar.SnackbarLayout sl = Helper.findSnackbarLayout(content.getRootView()); Snackbar.SnackbarLayout sl = Helper.findSnackbarLayout(content.getRootView());
@ -248,8 +247,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
content.getPaddingStart(), content.getPaddingTop(), content.getPaddingStart(), content.getPaddingTop(),
content.getPaddingEnd(), pad); content.getPaddingEnd(), pad);
} }
}
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }

Loading…
Cancel
Save