mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 10:58:23 +01:00
This commit is contained in:
parent
b0f2e89c7b
commit
304fa86400
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user