aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-01-04 07:17:02 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-01-04 07:17:02 +0000
commit9589ec5192cdb4988e9bc780f91f4a69e8f6a864 (patch)
treee9dac1d9296aa0ebf4ef22108aeefa44f08667b4 /app/src
parent9830db0303928f0a873da0d6c59616e22912b15d (diff)
downloadinfinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar.gz
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar.bz2
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar.lz
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar.xz
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.tar.zst
infinity-for-reddit-9589ec5192cdb4988e9bc780f91f4a69e8f6a864.zip
Fix options in Post History not hidden in anonymous mode. Fix memory leak in ViewSubredditDetailActivity related to bottom sheet fragmnets.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java37
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java2
2 files changed, 20 insertions, 19 deletions
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 1316dfc1..a45b4a57 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -209,11 +209,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private RequestManager glide;
private Menu mMenu;
private AppBarLayout.LayoutParams params;
- private PostTypeBottomSheetFragment postTypeBottomSheetFragment;
- private SortTypeBottomSheetFragment sortTypeBottomSheetFragment;
- private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
- private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
- private FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment;
private int expandedTabTextColor;
private int expandedTabBackgroundColor;
private int expandedTabIndicatorColor;
@@ -354,17 +349,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fetchSubredditData();
- postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
-
- sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
- Bundle bottomSheetBundle = new Bundle();
- bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
- sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
-
- sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
- postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
- fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
-
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
String title = "r/" + subredditName;
@@ -734,10 +718,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: {
- sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
+ displaySortTypeBottomSheetFragment();
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: {
+ PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break;
}
@@ -767,11 +752,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
break;
default:
+ PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break;
}
});
fab.setOnLongClickListener(view -> {
+ FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccessToken == null);
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
@@ -885,6 +872,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
+ private void displaySortTypeBottomSheetFragment() {
+ SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
+ Bundle bottomSheetBundle = new Bundle();
+ bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
+ sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
+ sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
@@ -911,7 +906,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
finish();
return true;
case R.id.action_sort_view_subreddit_detail_activity:
- sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
+ displaySortTypeBottomSheetFragment();
return true;
case R.id.action_search_view_subreddit_detail_activity:
Intent intent = new Intent(this, SearchActivity.class);
@@ -952,6 +947,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
return true;
case R.id.action_change_post_layout_view_subreddit_detail_activity:
+ PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
case R.id.action_select_user_flair_view_subreddit_detail_activity:
@@ -1018,6 +1014,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
public void sortTypeSelected(String sortType) {
+ SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
sortTimeBottomSheetFragment.setArguments(bundle);
@@ -1115,6 +1112,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public void fabOptionSelected(int option) {
switch (option) {
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SUBMIT_POST:
+ PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_REFRESH:
@@ -1123,9 +1121,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_SORT_TYPE:
- sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
+ displaySortTypeBottomSheetFragment();
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT:
+ PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
index 0c12aed9..647e03af 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
@@ -71,6 +71,8 @@ public class PostHistoryFragment extends Fragment {
infoTextView.setText(R.string.only_for_logged_in_user);
markPostsAsReadLinearLayout.setVisibility(View.GONE);
markPostsAsReadAfterVotingLinearLayout.setVisibility(View.GONE);
+ markPostsAsReadOnScrollLinearLayout.setVisibility(View.GONE);
+ hideReadPostsAutomaticallyLinearLayout.setVisibility(View.GONE);
return rootView;
}