aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java64
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java87
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java38
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java59
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java43
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java61
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java60
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java37
-rw-r--r--app/src/main/res/menu/account_posts_activity.xml8
-rw-r--r--app/src/main/res/menu/account_saved_thing_activity.xml8
-rw-r--r--app/src/main/res/menu/filtered_posts_activity.xml8
-rw-r--r--app/src/main/res/menu/main_activity.xml6
-rw-r--r--app/src/main/res/menu/post_fragment.xml8
-rw-r--r--app/src/main/res/menu/view_multi_reddit_detail_activity.xml12
-rw-r--r--app/src/main/res/menu/view_subreddit_detail_activity.xml18
-rw-r--r--app/src/main/res/menu/view_user_detail_activity.xml20
16 files changed, 83 insertions, 454 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
index 2f569409..2bd6a247 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
@@ -46,7 +46,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
static final String EXTRA_USER_WHERE = "EUW";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String FRAGMENT_OUT_STATE = "FOS";
@BindView(R.id.coordinator_layout_account_posts_activity)
@@ -68,13 +67,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private boolean isInLazyMode = false;
private String mAccessToken;
private String mAccountName;
private String mUserWhere;
private Fragment mFragment;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
@@ -129,16 +125,12 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
-
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
} else {
@@ -188,54 +180,23 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.account_posts_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_refresh_account_posts_activity:
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_account_posts_activity).setTitle(R.string.action_start_lazy_mode);
- }
- if (mFragment != null) {
- ((PostFragment) mFragment).refresh();
- }
- return true;
- case R.id.action_lazy_mode_account_posts_activity:
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
- if (isInLazyMode) {
- ((FragmentCommunicator) mFragment).stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
- case R.id.action_change_post_layout_account_posts_activity:
- postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
- return true;
- case android.R.id.home:
- finish();
- return true;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_refresh_account_posts_activity) {
+ if (mFragment != null) {
+ ((PostFragment) mFragment).refresh();
+ }
+ return true;
+ } else if (itemId == R.id.action_change_post_layout_account_posts_activity) {
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
+ } else if (itemId == android.R.id.home) {
+ finish();
+ return true;
}
return false;
}
@@ -244,7 +205,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
index a006ac26..bbdb74f0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
@@ -38,7 +38,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
-import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
@@ -58,8 +57,6 @@ import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, MarkPostAsReadInterface {
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
-
@BindView(R.id.coordinator_layout_account_saved_thing_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity)
@@ -93,11 +90,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private SlidrInterface mSlidrInterface;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private String mAccessToken;
private String mAccountName;
- private boolean isInLazyMode = false;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
@@ -141,8 +135,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
fragmentManager = getSupportFragmentManager();
@@ -150,9 +142,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
- if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
- }
initializeViewPager();
}
@@ -216,67 +205,26 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.account_saved_thing_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_refresh_account_saved_thing_activity:
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity).setTitle(R.string.action_start_lazy_mode);
- }
- sectionsPagerAdapter.refresh();
- return true;
- case R.id.action_lazy_mode_account_saved_thing_activity:
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
- case R.id.action_change_post_layout_account_saved_thing_activity:
- postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
- return true;
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_refresh_account_saved_thing_activity) {
+ sectionsPagerAdapter.refresh();
+ return true;
+ } else if (itemId == R.id.action_change_post_layout_account_saved_thing_activity) {
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
}
return false;
}
@Override
- protected void onSaveInstanceState(@NonNull Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
- }
-
- @Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
@@ -382,21 +330,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeNSFW(boolean nsfw) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
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 c9c43953..7d9ef895 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -68,7 +68,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
public static final String EXTRA_POST_TYPE = "EPT";
public static final String EXTRA_USER_WHERE = "EUW";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String FRAGMENT_OUT_STATE = "FOS";
private static final int CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE = 1000;
@@ -97,7 +96,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private boolean isInLazyMode = false;
private String mAccessToken;
private String mAccountName;
private String name;
@@ -105,7 +103,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
private int postType;
private PostFragment mFragment;
private Menu mMenu;
- private AppBarLayout.LayoutParams params;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -155,8 +152,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
name = getIntent().getStringExtra(EXTRA_NAME);
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
int filter = getIntent().getIntExtra(EXTRA_FILTER, -1000);
@@ -231,7 +226,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mFragment = (PostFragment) getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit();
bindView(postFilter, false);
@@ -342,17 +336,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
getMenuInflater().inflate(R.menu.filtered_posts_activity, menu);
applyMenuItemTheme(menu);
mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
if (userWhere != null && !PostPagingSource.USER_WHERE_SUBMITTED.equals(userWhere)) {
mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false);
}
@@ -408,30 +391,10 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
}
return true;
} else if (itemId == R.id.action_refresh_filtered_thing_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (mFragment != null) {
((FragmentCommunicator) mFragment).refresh();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_filtered_thing_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity);
- if (isInLazyMode) {
- ((FragmentCommunicator) mFragment).stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_filtered_post_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -454,7 +417,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 47a62003..5afa6f17 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -140,7 +140,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private static final String FETCH_USER_INFO_STATE = "FUIS";
private static final String FETCH_SUBSCRIPTIONS_STATE = "FSS";
private static final String DRAWER_ON_ACCOUNT_SWITCH_STATE = "DOASS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
@@ -222,7 +221,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Executor mExecutor;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
- private AppBarLayout.LayoutParams params;
private NavigationDrawerRecyclerViewAdapter adapter;
private Call<String> subredditAutocompleteCall;
private String mAccessToken;
@@ -232,8 +230,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private boolean mDrawerOnAccountSwitch = false;
private String mMessageFullname;
private String mNewAccountName;
- private Menu mMenu;
- private boolean isInLazyMode = false;
private boolean showBottomAppBar;
private boolean mConfirmToExit;
private boolean mLockBottomAppBar;
@@ -315,8 +311,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
toggle.syncState();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
@@ -331,7 +325,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
@@ -1086,19 +1079,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
-
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@@ -1122,30 +1102,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
changeSortType();
return true;
} else if (itemId == R.id.action_refresh_main_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_main_activity).setTitle(R.string.action_start_lazy_mode);
- }
sectionsPagerAdapter.refresh();
mFetchUserInfoSuccess = false;
loadUserData();
return true;
- } else if (itemId == R.id.action_lazy_mode_main_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
- if (isInLazyMode) {
- sectionsPagerAdapter.stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (sectionsPagerAdapter.startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_main_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -1187,7 +1147,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
outState.putString(ACCOUNT_NAME_STATE, mAccountName);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
@@ -1806,24 +1765,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
}
- boolean startLazyMode() {
- PostFragment currentFragment = getCurrentFragment();
- if (currentFragment != null) {
- return currentFragment.startLazyMode();
- }
-
- return false;
- }
-
- void stopLazyMode() {
- for (int i = 0; i < getItemCount(); i++) {
- Fragment fragment = fragmentManager.findFragmentByTag("f" + i);
- if (fragment instanceof PostFragment && ((PostFragment) fragment).isInLazyMode()) {
- ((PostFragment) fragment).stopLazyMode();
- }
- }
- }
-
int getCurrentPostType() {
PostFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
index 2b2cd198..012742d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -62,7 +62,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public static final String EXTRA_MULTIREDDIT_PATH = "EMP";
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
@BindView(R.id.coordinator_layout_view_multi_reddit_detail_activity)
CoordinatorLayout coordinatorLayout;
@@ -99,10 +98,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private String mAccessToken;
private String mAccountName;
private String multiPath;
- private boolean isInLazyMode = false;
private Fragment mFragment;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private SortTypeBottomSheetFragment sortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@@ -163,8 +159,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
-
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();
} else {
@@ -179,8 +173,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
-
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
}
private void initializeFragment() {
@@ -198,17 +190,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_multi_reddit_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@@ -226,33 +207,10 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_multi_reddit_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (mFragment instanceof FragmentCommunicator) {
((FragmentCommunicator) mFragment).refresh();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_view_multi_reddit_detail_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- ((FragmentCommunicator) mFragment).stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_multi_reddit_detail_activity) {
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
@@ -302,7 +260,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE_KEY, mFragment);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index c6695f41..727a35fe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -135,7 +135,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private static final String FETCH_SUBREDDIT_INFO_STATE = "FSIS";
private static final String CURRENT_ONLINE_SUBSCRIBERS_STATE = "COSS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
private static final int ADD_TO_MULTIREDDIT_REQUEST_CODE = 1;
@@ -228,15 +227,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int mNCurrentOnlineSubscribers = 0;
private boolean isNsfwSubreddit = false;
private boolean subscriptionReady = false;
- private boolean isInLazyMode = false;
private boolean showToast = false;
private boolean showBottomAppBar;
private boolean lockBottomAppBar;
private String mMessageFullname;
private String mNewAccountName;
private RequestManager glide;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private int expandedTabTextColor;
private int expandedTabBackgroundColor;
private int expandedTabIndicatorColor;
@@ -359,7 +355,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
} else {
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
@@ -372,8 +367,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fetchSubredditData();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
String title = "r/" + subredditName;
subredditNameTextView.setText(title);
@@ -1091,18 +1084,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@@ -1121,38 +1102,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_subreddit_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.refresh();
mFetchSubredditInfoSuccess = false;
fetchSubredditData();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_view_subreddit_detail_activity) {
- if (sectionsPagerAdapter != null) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_subreddit_detail_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -1231,7 +1186,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
super.onSaveInstanceState(outState);
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
}
@@ -1637,21 +1591,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeSortType(SortType sortType) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 5d748bef..e1b5314c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -131,7 +131,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
public static final int ADD_TO_MULTIREDDIT_REQUEST_CODE = 400;
private static final String FETCH_USER_INFO_STATE = "FSIS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
@@ -211,8 +210,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private RequestManager glide;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@@ -222,7 +219,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String username;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
- private boolean isInLazyMode = false;
private int expandedTabTextColor;
private int expandedTabBackgroundColor;
private int expandedTabIndicatorColor;
@@ -271,7 +267,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
} else {
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
}
@@ -280,8 +275,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fetchUserInfo();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
Resources resources = getResources();
adjustToolbar(toolbar);
@@ -923,19 +916,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@@ -955,34 +935,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_user_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
sectionsPagerAdapter.refresh();
mFetchUserInfoSuccess = false;
fetchUserInfo();
return true;
- } else if (itemId == R.id.action_lazy_mode_view_user_detail_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) {
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
@@ -1100,7 +1056,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
}
@@ -1528,21 +1483,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeSortType(SortType sortType) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
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 cd066a1f..a1c76724 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -18,10 +18,12 @@ import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -211,12 +213,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private AppCompatActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
private StaggeredGridLayoutManager mStaggeredGridLayoutManager;
+ private MenuItem lazyModeItem;
private long postFragmentId;
private int postType;
private boolean isInLazyMode = false;
private boolean isLazyModePaused = false;
private boolean hasPost = false;
- private boolean isShown = false;
private boolean savePostFeedScrolledPosition;
private boolean rememberMutingOptionInPostFeed;
private Boolean masterMutingOption;
@@ -259,7 +261,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void onResume() {
super.onResume();
- isShown = true;
if (mAdapter != null) {
mAdapter.setCanStartActivity(true);
}
@@ -306,6 +307,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
unbinder = ButterKnife.bind(this, rootView);
+ setHasOptionsMenu(true);
+
EventBus.getDefault().register(this);
applyTheme();
@@ -1275,6 +1278,31 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
view -> mAdapter.retry())));
}
+ @Override
+ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
+ inflater.inflate(R.menu.post_fragment, menu);
+ lazyModeItem = menu.findItem(R.id.action_lazy_mode_post_fragment);
+
+ if (isInLazyMode) {
+ lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
+ } else {
+ lazyModeItem.setTitle(R.string.action_start_lazy_mode);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ if (item.getItemId() == R.id.action_lazy_mode_post_fragment) {
+ if (isInLazyMode) {
+ stopLazyMode();
+ } else {
+ startLazyMode();
+ }
+ return true;
+ }
+ return false;
+ }
+
private void noPostFound() {
hasPost = false;
if (isInLazyMode) {
@@ -1434,6 +1462,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
}
+ lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
+
if (mAdapter != null && mAdapter.isAutoplay()) {
mAdapter.setAutoplay(false);
refreshAdapter();
@@ -1453,6 +1483,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void stopLazyMode() {
+ lazyModeItem.setTitle(R.string.action_start_lazy_mode);
if (mAdapter != null) {
String autoplayString = mSharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON) ||
diff --git a/app/src/main/res/menu/account_posts_activity.xml b/app/src/main/res/menu/account_posts_activity.xml
index 96174315..2d8e6578 100644
--- a/app/src/main/res/menu/account_posts_activity.xml
+++ b/app/src/main/res/menu/account_posts_activity.xml
@@ -8,14 +8,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_account_posts_activity"
- android:orderInCategory="2"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_account_posts_activity"
- android:orderInCategory="3"
+ android:orderInCategory="2"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/account_saved_thing_activity.xml b/app/src/main/res/menu/account_saved_thing_activity.xml
index 483c27a3..4efb3689 100644
--- a/app/src/main/res/menu/account_saved_thing_activity.xml
+++ b/app/src/main/res/menu/account_saved_thing_activity.xml
@@ -9,14 +9,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_account_saved_thing_activity"
- android:orderInCategory="2"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_account_saved_thing_activity"
- android:orderInCategory="3"
+ android:orderInCategory="2"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/menu/filtered_posts_activity.xml b/app/src/main/res/menu/filtered_posts_activity.xml
index 6e826b5a..d4414d5b 100644
--- a/app/src/main/res/menu/filtered_posts_activity.xml
+++ b/app/src/main/res/menu/filtered_posts_activity.xml
@@ -16,14 +16,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_filtered_thing_activity"
- android:orderInCategory="3"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_filtered_post_activity"
- android:orderInCategory="4"
+ android:orderInCategory="3"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/main_activity.xml b/app/src/main/res/menu/main_activity.xml
index f4e275bc..c043a812 100644
--- a/app/src/main/res/menu/main_activity.xml
+++ b/app/src/main/res/menu/main_activity.xml
@@ -25,12 +25,6 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_main_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_main_activity"
android:orderInCategory="5"
android:title="@string/action_change_post_layout"
diff --git a/app/src/main/res/menu/post_fragment.xml b/app/src/main/res/menu/post_fragment.xml
new file mode 100644
index 00000000..d29054d3
--- /dev/null
+++ b/app/src/main/res/menu/post_fragment.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/action_lazy_mode_post_fragment"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_multi_reddit_detail_activity.xml b/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
index c214a6d3..aabbdc96 100644
--- a/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
@@ -23,26 +23,20 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_multi_reddit_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_multi_reddit_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_edit_view_multi_reddit_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_edit_multi_reddit"
app:showAsAction="never" />
<item
android:id="@+id/action_delete_view_multi_reddit_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_delete_multi_reddit"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml
index cb92de44..b72aa93f 100644
--- a/app/src/main/res/menu/view_subreddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml
@@ -24,44 +24,38 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_subreddit_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_subreddit_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_select_user_flair_view_subreddit_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_select_user_flair"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_multireddit_view_subreddit_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_add_to_multireddit"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_post_filter_view_subreddit_detail_activity"
- android:orderInCategory="8"
+ android:orderInCategory="7"
android:title="@string/action_add_to_post_filter"
app:showAsAction="never" />
<item
android:id="@+id/action_share_view_subreddit_detail_activity"
- android:orderInCategory="9"
+ android:orderInCategory="8"
android:title="@string/action_share"
app:showAsAction="never" />
<item
android:id="@+id/action_go_to_wiki_activity"
- android:orderInCategory="10"
+ android:orderInCategory="9"
android:title="@string/action_go_to_wiki"
app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml
index 8d89ff08..437c6e23 100644
--- a/app/src/main/res/menu/view_user_detail_activity.xml
+++ b/app/src/main/res/menu/view_user_detail_activity.xml
@@ -21,48 +21,42 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_user_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_user_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_send_private_message_view_user_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_send_private_message"
app:showAsAction="never" />
<item
android:id="@+id/action_share_view_user_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_share"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_multireddit_view_user_detail_activity"
- android:orderInCategory="8"
+ android:orderInCategory="7"
android:title="@string/action_add_to_multireddit"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_post_filter_view_user_detail_activity"
- android:orderInCategory="9"
+ android:orderInCategory="8"
android:title="@string/action_add_to_post_filter"
app:showAsAction="never" />
<item
android:id="@+id/action_report_view_user_detail_activity"
- android:orderInCategory="10"
+ android:orderInCategory="9"
android:title="@string/action_report" />
<item
android:id="@+id/action_block_user_view_user_detail_activity"
- android:orderInCategory="11"
+ android:orderInCategory="10"
android:title="@string/action_block_user" />
</menu>