Refactoring

pull/215/head
M66B 3 months ago
parent 93e192a309
commit 0703bb232d

@ -169,7 +169,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
v.setLayoutParams(mlp); v.setLayoutParams(mlp);
if (edge_to_edge) if (edge_to_edge)
for (View child : getInsetViews(v)) { for (View child : Helper.getViewsWithTag(v, "inset")) {
mlp = (ViewGroup.MarginLayoutParams) child.getLayoutParams(); mlp = (ViewGroup.MarginLayoutParams) child.getLayoutParams();
mlp.bottomMargin = insets.bottom; mlp.bottomMargin = insets.bottom;
child.setLayoutParams(mlp); child.setLayoutParams(mlp);
@ -226,18 +226,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
setContentView(view); setContentView(view);
} }
private static List<View> getInsetViews(View view) {
List<View> result = new ArrayList<>();
if (view != null && "inset".equals(view.getTag()))
result.add(view);
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int i = 0; i <= group.getChildCount(); i++)
result.addAll(getInsetViews(group.getChildAt(i)));
}
return result;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
EntityLog.log(this, "Activity create " + this.getClass().getName() + EntityLog.log(this, "Activity create " + this.getClass().getName() +

@ -935,6 +935,18 @@ public class Helper {
return context.getResources().getDimensionPixelSize(resid); return context.getResources().getDimensionPixelSize(resid);
} }
static @NonNull List<View> getViewsWithTag(@NonNull View view, @NonNull String tag) {
List<View> result = new ArrayList<>();
if (view != null && tag.equals(view.getTag()))
result.add(view);
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int i = 0; i <= group.getChildCount(); i++)
result.addAll(getViewsWithTag(group.getChildAt(i), tag));
}
return result;
}
static ObjectAnimator getFabAnimator(View fab, LifecycleOwner owner) { static ObjectAnimator getFabAnimator(View fab, LifecycleOwner owner) {
ObjectAnimator.AnimatorUpdateListener listener = new ObjectAnimator.AnimatorUpdateListener() { ObjectAnimator.AnimatorUpdateListener listener = new ObjectAnimator.AnimatorUpdateListener() {
@Override @Override

Loading…
Cancel
Save