aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java4
4 files changed, 24 insertions, 3 deletions
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 8c3148ac..670729c0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -1682,8 +1682,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED
|| postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_DOWNVOTED
|| postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HIDDEN
- || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SAVED
- || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_GILDED) {
+ || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SAVED) {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
index d3bfb2d3..f4641ac6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
@@ -168,6 +168,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption4 = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, 3);
mainActivityFAB = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0);
+ mainActivityOption1 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption1);
+ mainActivityOption2 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption2);
+ mainActivityOption3 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption3);
+ mainActivityOption4 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption4);
+
mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount));
mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]);
mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]);
@@ -285,6 +290,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption4 = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, 3);
otherActivitiesFAB = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0);
+ otherActivitiesOption1 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption1);
+ otherActivitiesOption2 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption2);
+ otherActivitiesOption3 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption3);
+ otherActivitiesOption4 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption4);
+
otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount));
otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]);
otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
index 6d971102..fb8a5df7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
@@ -10,7 +10,6 @@ import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -226,6 +225,9 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab1CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home));
tab1CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
+ if (accountName != null) {
+ tab1CurrentPostType = Utils.fixIndexOutOfBounds(typeValues, tab1CurrentPostType);
+ }
tab1CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]);
tab1TitleSummaryTextView.setText(tab1CurrentTitle);
@@ -315,6 +317,9 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab2CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular));
tab2CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
+ if (accountName != null) {
+ tab2CurrentPostType = Utils.fixIndexOutOfBounds(typeValues, tab2CurrentPostType);
+ }
tab2CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]);
tab2TitleSummaryTextView.setText(tab2CurrentTitle);
@@ -401,6 +406,9 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab3CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all));
tab3CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
+ if (accountName == null) {
+ tab3CurrentPostType = Utils.fixIndexOutOfBounds(typeValues, tab3CurrentPostType);
+ }
tab3CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]);
tab3TitleSummaryTextView.setText(tab3CurrentTitle);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
index 8504b621..67925743 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -482,4 +482,8 @@ public final class Utils {
((TextView) rootView).setTypeface(typeface);
}
}
+
+ public static <T> int fixIndexOutOfBounds(T[] array, int index) {
+ return index >= array.length ? array.length - 1 : index;
+ }
}