aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-02 01:52:19 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-02 01:52:19 +0000
commit2fbc4d02c863bad0426eece6fb7bcc02dc8ac193 (patch)
tree9b33bd8f7513b1290da0366043f3a35630eaac70 /app/src/main/java
parenteff385ccd61caea2e272e378d572ca53b67a1e67 (diff)
downloadinfinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar.gz
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar.bz2
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar.lz
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar.xz
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.tar.zst
infinity-for-reddit-2fbc4d02c863bad0426eece6fb7bcc02dc8ac193.zip
Changing ost layout in AccountSavedThingActivity is available.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
index 36a61624..1641c449 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
@@ -34,6 +34,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
@@ -47,7 +48,8 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
-public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface {
+public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
+ PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS";
@@ -75,6 +77,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("post_layout")
+ SharedPreferences mPostLayoutSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
private SectionsPagerAdapter sectionsPagerAdapter;
private SlidrInterface mSlidrInterface;
@@ -84,6 +89,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
private String mAccessToken;
private String mAccountName;
private boolean isInLazyMode = false;
+ private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -122,6 +128,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
+ postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
+
if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@@ -252,6 +260,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
return true;
+ case R.id.action_change_post_layout_account_saved_thing_activity:
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
}
return false;
}
@@ -300,6 +311,14 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
+ @Override
+ public void postLayoutSelected(int postLayout) {
+ if (sectionsPagerAdapter != null) {
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
+ sectionsPagerAdapter.changePostLayout(postLayout);
+ }
+ }
+
private class SectionsPagerAdapter extends FragmentPagerAdapter {
private PostFragment postFragment;
private CommentsListingFragment commentsListingFragment;
@@ -409,6 +428,13 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
+ public void changePostLayout(int postLayout) {
+ if (postFragment != null) {
+ ((FragmentCommunicator) postFragment).changePostLayout(postLayout);
+ }
+ }
+
+
public void goBackToTop() {
if (viewPager.getCurrentItem() == 0) {
postFragment.goBackToTop();