mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Changing ost layout in AccountSavedThingActivity is available.
This commit is contained in:
parent
eff385ccd6
commit
2fbc4d02c8
@ -34,6 +34,7 @@ import butterknife.BindView;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
@ -47,7 +48,8 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
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 NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
private static final String ACCESS_TOKEN_STATE = "ATS";
|
private static final String ACCESS_TOKEN_STATE = "ATS";
|
||||||
@ -75,6 +77,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private SlidrInterface mSlidrInterface;
|
private SlidrInterface mSlidrInterface;
|
||||||
@ -84,6 +89,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
|
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -122,6 +128,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
|
|
||||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||||
|
|
||||||
|
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
||||||
@ -252,6 +260,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_change_post_layout_account_saved_thing_activity:
|
||||||
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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 class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
private PostFragment postFragment;
|
private PostFragment postFragment;
|
||||||
private CommentsListingFragment commentsListingFragment;
|
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() {
|
public void goBackToTop() {
|
||||||
if (viewPager.getCurrentItem() == 0) {
|
if (viewPager.getCurrentItem() == 0) {
|
||||||
postFragment.goBackToTop();
|
postFragment.goBackToTop();
|
||||||
|
@ -13,4 +13,10 @@
|
|||||||
android:orderInCategory="2"
|
android:orderInCategory="2"
|
||||||
android:title="@string/action_start_lazy_mode"
|
android:title="@string/action_start_lazy_mode"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_change_post_layout_account_saved_thing_activity"
|
||||||
|
android:orderInCategory="3"
|
||||||
|
android:title="@string/action_change_post_layout"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user