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.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
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.post.PostPagingSource;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
|
||||||
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
@ -98,6 +100,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
public SubredditViewModel mSubredditViewModel;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String name;
|
private String name;
|
||||||
@ -105,6 +108,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
private int postType;
|
private int postType;
|
||||||
private PostFragment mFragment;
|
private PostFragment mFragment;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
|
private boolean isNsfwSubreddit = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -276,6 +280,15 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
} else {
|
} else {
|
||||||
String subredditNamePrefixed = "r/" + name;
|
String subredditNamePrefixed = "r/" + name;
|
||||||
getSupportActionBar().setTitle(subredditNamePrefixed);
|
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;
|
break;
|
||||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||||
@ -484,4 +497,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
public void contentScrollDown() {
|
public void contentScrollDown() {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNsfwSubreddit() {
|
||||||
|
return isNsfwSubreddit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,10 +354,10 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
|
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();
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
|
||||||
params.bottomMargin = systemBar.bottom;
|
params.bottomMargin = navigationBars.bottom;
|
||||||
params.rightMargin = systemBar.right;
|
params.rightMargin = navigationBars.right;
|
||||||
return WindowInsetsCompat.CONSUMED;
|
return WindowInsetsCompat.CONSUMED;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1723,6 +1723,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
public boolean getIsNsfwSubreddit() {
|
public boolean getIsNsfwSubreddit() {
|
||||||
if (activity instanceof ViewSubredditDetailActivity) {
|
if (activity instanceof ViewSubredditDetailActivity) {
|
||||||
return ((ViewSubredditDetailActivity) activity).isNsfwSubreddit();
|
return ((ViewSubredditDetailActivity) activity).isNsfwSubreddit();
|
||||||
|
} else if (activity instanceof FilteredPostsActivity) {
|
||||||
|
return ((FilteredPostsActivity) activity).isNsfwSubreddit();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user