aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-05-04 05:06:27 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-05-04 05:06:27 +0000
commit304fa86400d473a514f18f4f0334ef1cbe26d8eb (patch)
treeae53f5679cefaec2044a26807f7aa45077a1606b /app/src
parentb0f2e89c7b8ebe3eab4d440f4fdd62750d8517f9 (diff)
downloadinfinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar.gz
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar.bz2
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar.lz
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar.xz
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.tar.zst
infinity-for-reddit-304fa86400d473a514f18f4f0334ef1cbe26d8eb.zip
Fix https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1301
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java2
3 files changed, 22 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index 8f93faa9..1305733b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -52,6 +53,7 @@ import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
+import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
@@ -98,6 +100,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
+ public SubredditViewModel mSubredditViewModel;
private String mAccessToken;
private String mAccountName;
private String name;
@@ -105,6 +108,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
private int postType;
private PostFragment mFragment;
private Menu mMenu;
+ private boolean isNsfwSubreddit = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -276,6 +280,15 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
} else {
String subredditNamePrefixed = "r/" + name;
getSupportActionBar().setTitle(subredditNamePrefixed);
+
+ mSubredditViewModel = new ViewModelProvider(this,
+ new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, name))
+ .get(SubredditViewModel.class);
+ mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
+ if (subredditData != null) {
+ isNsfwSubreddit = subredditData.isNSFW();
+ }
+ });
}
break;
case PostPagingSource.TYPE_MULTI_REDDIT:
@@ -484,4 +497,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
public void contentScrollDown() {
fab.hide();
}
+
+ public boolean isNsfwSubreddit() {
+ return isNsfwSubreddit;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
index ed8a6cd8..59cb5fd4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -354,10 +354,10 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
- Insets systemBar = insets.getInsets(WindowInsetsCompat.Type.systemBars());
+ Insets navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
- params.bottomMargin = systemBar.bottom;
- params.rightMargin = systemBar.right;
+ params.bottomMargin = navigationBars.bottom;
+ params.rightMargin = navigationBars.right;
return WindowInsetsCompat.CONSUMED;
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 766eadf1..06eef725 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -1723,6 +1723,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
public boolean getIsNsfwSubreddit() {
if (activity instanceof ViewSubredditDetailActivity) {
return ((ViewSubredditDetailActivity) activity).isNsfwSubreddit();
+ } else if (activity instanceof FilteredPostsActivity) {
+ return ((FilteredPostsActivity) activity).isNsfwSubreddit();
} else {
return false;
}