ViewCompat.setOnApplyWindowInsetsListener in SelectedSubredditsAndUsersActivity.

This commit is contained in:
Docile-Alligator
2025-06-16 21:56:55 -04:00
parent 3250fe7c45
commit a3f6025445
2 changed files with 44 additions and 0 deletions

View File

@ -6,9 +6,14 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
@ -27,6 +32,7 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.databinding.ActivitySelectedSubredditsBinding;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface {
@ -66,6 +72,43 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
Slidr.attach(this);
}
if (isImmersiveInterface()) {
if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.appbarLayoutSelectedSubredditsAndUsersActivity);
}
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
Insets allInsets = insets.getInsets(
WindowInsetsCompat.Type.systemBars()
| WindowInsetsCompat.Type.displayCutout()
);
setMargins(binding.toolbarSelectedSubredditsAndUsersActivity,
allInsets.left,
allInsets.top,
allInsets.right,
BaseActivity.IGNORE_MARGIN);
binding.recyclerViewSelectedSubredditsAndUsersActivity.setPadding(
allInsets.left,
0,
allInsets.right,
allInsets.bottom);
setMargins(binding.fabSelectedSubredditsAndUsersActivity,
BaseActivity.IGNORE_MARGIN,
BaseActivity.IGNORE_MARGIN,
(int) Utils.convertDpToPixel(16, SelectedSubredditsAndUsersActivity.this) + allInsets.right,
(int) Utils.convertDpToPixel(16, SelectedSubredditsAndUsersActivity.this) + allInsets.bottom);
return WindowInsetsCompat.CONSUMED;
}
});
}
setSupportActionBar(binding.toolbarSelectedSubredditsAndUsersActivity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(binding.toolbarSelectedSubredditsAndUsersActivity);

View File

@ -36,6 +36,7 @@
android:id="@+id/recycler_view_selected_subreddits_and_users_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton