diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-12-22 16:12:41 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-12-22 16:12:41 +0000 |
commit | e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a (patch) | |
tree | bb066b27ab31750bdb45defbcb4bfcf0adafad0b | |
parent | efa960013ac2cbf3909e8f8867a1b9e2dd2791f2 (diff) | |
download | infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar.gz infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar.bz2 infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar.lz infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar.xz infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.tar.zst infinity-for-reddit-e4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a.zip |
Initialize views in CustomizePostFilterActivity.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java | 40 | ||||
-rw-r--r-- | app/src/main/res/values/arrays.xml | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java index 8fef2ae8..61f7c57d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java @@ -37,7 +37,9 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class CustomizePostFilterActivity extends BaseActivity { + public static final String EXTRA_POST_FILTER = "EPF"; public static final String RETURN_EXTRA_POST_FILTER = "REPF"; + private static final String POST_FILTER_STATE = "PFS"; @BindView(R.id.coordinator_layout_customize_post_filter_activity) CoordinatorLayout coordinatorLayout; @@ -150,6 +152,7 @@ public class CustomizePostFilterActivity extends BaseActivity { SharedPreferences mSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private PostFilter postFilter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -207,6 +210,37 @@ public class CustomizePostFilterActivity extends BaseActivity { onlySpoilerLinearLayout.setOnClickListener(view -> { onlySpoilerSwitch.performClick(); }); + + if (savedInstanceState != null) { + postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE); + } else { + postFilter = getIntent().getParcelableExtra(EXTRA_POST_FILTER); + if (postFilter == null) { + postFilter = new PostFilter(); + } + bindView(); + } + } + + private void bindView() { + postTypeTextCheckBox.setChecked(postFilter.containsTextType); + postTypeLinkCheckBox.setChecked(postFilter.containsLinkType); + postTypeImageCheckBox.setChecked(postFilter.containsImageType); + postTypeGifCheckBox.setChecked(postFilter.containsGifType); + postTypeVideoCheckBox.setChecked(postFilter.containsVideoType); + postTypeGalleryCheckBox.setChecked(postFilter.containsGalleryType); + titleExcludesStringsTextInputEditText.setText(postFilter.postTitleExcludesStrings); + titleExcludesRegexTextInputEditText.setText(postFilter.postTitleExcludesRegex); + excludesSubredditsTextInputEditText.setText(postFilter.excludesSubreddits); + excludesUsersTextInputEditText.setText(postFilter.excludesUsers); + excludesFlairsTextInputEditText.setText(postFilter.excludesFlairs); + containsFlairsTextInputEditText.setText(postFilter.containsFlairs); + minVoteTextInputEditText.setText(Integer.toString(postFilter.minVote)); + maxVoteTextInputEditText.setText(Integer.toString(postFilter.maxVote)); + minCommentsTextInputEditText.setText(Integer.toString(postFilter.minComments)); + maxCommentsTextInputEditText.setText(Integer.toString(postFilter.maxComments)); + minAwardsTextInputEditText.setText(Integer.toString(postFilter.minAwards)); + maxAwardsTextInputEditText.setText(Integer.toString(postFilter.maxAwards)); } @Override @@ -314,4 +348,10 @@ public class CustomizePostFilterActivity extends BaseActivity { } return false; } + + @Override + protected void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putParcelable(POST_FILTER_STATE, postFilter); + } }
\ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index d643be2c..58de5faf 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -261,6 +261,7 @@ <item>Go to User</item> <item>Random</item> <item>Hide Read Posts</item> + <item>Filter Posts</item> </string-array> <string-array name="settings_swipe_action_threshold"> |