diff options
Diffstat (limited to 'app/src/main/java')
4 files changed, 194 insertions, 45 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java index 943dbf2d..d5ae4f84 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java @@ -46,7 +46,7 @@ import retrofit2.Retrofit; public class MultiredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface { - static final String EXTRA_RETURN_MULTIREDDIT = "ERM"; + public static final String EXTRA_RETURN_MULTIREDDIT = "ERM"; private static final String INSERT_SUBSCRIBED_MULTIREDDIT_STATE = "ISSS"; private static final String FRAGMENT_OUT_STATE = "FOS"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index eab43461..6daffcce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -58,19 +58,19 @@ import retrofit2.Retrofit; public class SearchActivity extends BaseActivity { - static final String EXTRA_QUERY = "EQ"; - static final String EXTRA_SUBREDDIT_NAME = "ESN"; - static final String EXTRA_SUBREDDIT_IS_USER = "ESIU"; - static final String EXTRA_SEARCH_ONLY_SUBREDDITS = "ESOS"; - static final String EXTRA_SEARCH_ONLY_USERS = "ESOU"; - static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; - static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIU"; - static final String RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES = "RESSN"; - static final String RETURN_EXTRA_SELECTED_USERNAMES = "RESU"; - static final String EXTRA_RETURN_USER_NAME = "ERUN"; - static final String EXTRA_RETURN_USER_ICON_URL = "ERUIU"; - static final String EXTRA_IS_MULTI_SELECTION = "EIMS"; - static final int SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE = 101; + public static final String EXTRA_QUERY = "EQ"; + public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + public static final String EXTRA_SUBREDDIT_IS_USER = "ESIU"; + public static final String EXTRA_SEARCH_ONLY_SUBREDDITS = "ESOS"; + public static final String EXTRA_SEARCH_ONLY_USERS = "ESOU"; + public static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; + public static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIU"; + public static final String RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES = "RESSN"; + public static final String RETURN_EXTRA_SELECTED_USERNAMES = "RESU"; + public static final String EXTRA_RETURN_USER_NAME = "ERUN"; + public static final String EXTRA_RETURN_USER_ICON_URL = "ERUIU"; + public static final String EXTRA_IS_MULTI_SELECTION = "EIMS"; + public static final int SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE = 101; private static final String SUBREDDIT_NAME_STATE = "SNS"; private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java index e1458042..3db45c00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java @@ -49,10 +49,10 @@ import retrofit2.Retrofit; public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface { - static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS"; - static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; - static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL"; - static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU"; + public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS"; + public static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; + public static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL"; + public static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU"; private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 0; private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS"; 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 18327e8c..dddbda85 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.settings; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.LayoutInflater; @@ -9,10 +10,13 @@ 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; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.fragment.app.Fragment; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -25,6 +29,10 @@ import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.activities.MultiredditSelectionActivity; +import ml.docilealligator.infinityforreddit.activities.SearchActivity; +import ml.docilealligator.infinityforreddit.activities.SubredditSelectionActivity; +import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class CustomizeMainPageTabsFragment extends Fragment { @@ -53,12 +61,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { LinearLayout tab1TypeLinearLayout; @BindView(R.id.tab_1_type_summary_text_view_customize_main_page_tabs_fragment) TextView tab1TypeSummaryTextView; - @BindView(R.id.tab_1_name_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab1NameLinearLayout; + @BindView(R.id.tab_1_name_constraint_layout_customize_main_page_tabs_fragment) + ConstraintLayout tab1NameConstraintLayout; @BindView(R.id.tab_1_name_title_text_view_customize_main_page_tabs_fragment) TextView tab1NameTitleTextView; @BindView(R.id.tab_1_name_summary_text_view_customize_main_page_tabs_fragment) TextView tab1NameSummaryTextView; + @BindView(R.id.tab_1_name_add_image_view_customize_main_page_tabs_fragment) + ImageView tab1AddImageView; @BindView(R.id.divider_2_customize_main_page_tabs_fragment) View divider2; @BindView(R.id.tab_2_group_summary_customize_main_page_tabs_fragment) @@ -71,12 +81,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { LinearLayout tab2TypeLinearLayout; @BindView(R.id.tab_2_type_summary_text_view_customize_main_page_tabs_fragment) TextView tab2TypeSummaryTextView; - @BindView(R.id.tab_2_name_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab2NameLinearLayout; + @BindView(R.id.tab_2_name_constraint_layout_customize_main_page_tabs_fragment) + ConstraintLayout tab2NameConstraintLayout; @BindView(R.id.tab_2_name_title_text_view_customize_main_page_tabs_fragment) TextView tab2NameTitleTextView; @BindView(R.id.tab_2_name_summary_text_view_customize_main_page_tabs_fragment) TextView tab2NameSummaryTextView; + @BindView(R.id.tab_2_name_add_image_view_customize_main_page_tabs_fragment) + ImageView tab2AddImageView; @BindView(R.id.divider_3_customize_main_page_tabs_fragment) View divider3; @BindView(R.id.tab_3_group_summary_customize_main_page_tabs_fragment) @@ -89,12 +101,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { LinearLayout tab3TypeLinearLayout; @BindView(R.id.tab_3_type_summary_text_view_customize_main_page_tabs_fragment) TextView tab3TypeSummaryTextView; - @BindView(R.id.tab_3_name_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab3NameLinearLayout; + @BindView(R.id.tab_3_name_constraint_layout_customize_main_page_tabs_fragment) + ConstraintLayout tab3NameConstraintLayout; @BindView(R.id.tab_3_name_title_text_view_customize_main_page_tabs_fragment) TextView tab3NameTitleTextView; @BindView(R.id.tab_3_name_summary_text_view_customize_main_page_tabs_fragment) TextView tab3NameSummaryTextView; + @BindView(R.id.tab_3_name_add_image_view_customize_main_page_tabs_fragment) + ImageView tab3AddImageView; @BindView(R.id.divider_4_customize_main_page_tabs_fragment) View divider4; @BindView(R.id.more_tabs_group_summary_customize_main_page_tabs_fragment) @@ -121,6 +135,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { @Named("main_activity_tabs") SharedPreferences mainActivityTabsSharedPreferences; private Activity activity; + private String accountName; private int tabCount; private String tab1CurrentTitle; private int tab1CurrentPostType; @@ -146,7 +161,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { ButterKnife.bind(this, rootView); - String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); + accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); String[] typeValues; if (accountName == null) { @@ -180,7 +195,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]); tab1TitleSummaryTextView.setText(tab1CurrentTitle); tab1NameSummaryTextView.setText(tab1CurrentName); - applyTab1NameView(tab1NameLinearLayout, tab1NameTitleTextView, tab1CurrentPostType); + applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, tab1CurrentPostType); View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_text, null); EditText editText = dialogView.findViewById(R.id.edit_text_edit_text_dialog); @@ -223,14 +238,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab1CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply(); tab1TypeSummaryTextView.setText(typeValues[i]); - applyTab1NameView(tab1NameLinearLayout, tab1NameTitleTextView, i); + applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab1NameLinearLayout.setOnClickListener(view -> { + tab1NameConstraintLayout.setOnClickListener(view -> { int titleId; switch (tab1CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -275,13 +290,15 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); + tab1AddImageView.setOnClickListener(view -> selectName(0)); + 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); tab2CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]); tab2TitleSummaryTextView.setText(tab2CurrentTitle); tab2NameSummaryTextView.setText(tab2CurrentName); - applyTab2NameView(tab2NameLinearLayout, tab2NameTitleTextView, tab2CurrentPostType); + applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, tab2CurrentPostType); tab2TitleLinearLayout.setOnClickListener(view -> { editText.setHint(R.string.settings_tab_title); @@ -321,14 +338,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab2CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply(); tab2TypeSummaryTextView.setText(typeValues[i]); - applyTab2NameView(tab2NameLinearLayout, tab2NameTitleTextView, i); + applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab2NameLinearLayout.setOnClickListener(view -> { + tab2NameConstraintLayout.setOnClickListener(view -> { int titleId; switch (tab2CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -373,13 +390,15 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); + tab2AddImageView.setOnClickListener(view -> selectName(1)); + 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); tab3CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]); tab3TitleSummaryTextView.setText(tab3CurrentTitle); tab3NameSummaryTextView.setText(tab3CurrentName); - applyTab3NameView(tab3NameLinearLayout, tab3NameTitleTextView, tab3CurrentPostType); + applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, tab3CurrentPostType); tab3TitleLinearLayout.setOnClickListener(view -> { editText.setHint(R.string.settings_tab_title); @@ -419,14 +438,14 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab3CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply(); tab3TypeSummaryTextView.setText(typeValues[i]); - applyTab3NameView(tab3NameLinearLayout, tab3NameTitleTextView, i); + applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab3NameLinearLayout.setOnClickListener(view -> { + tab3NameConstraintLayout.setOnClickListener(view -> { int titleId; switch (tab3CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -471,6 +490,8 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); + tab3AddImageView.setOnClickListener(view -> selectName(2)); + showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false)); showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply()); showMultiredditsLinearLayout.setOnClickListener(view -> { @@ -498,26 +519,26 @@ public class CustomizeMainPageTabsFragment extends Fragment { return rootView; } - private void applyTab1NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + private void applyTab1NameView(ConstraintLayout constraintLayout, TextView titleTextView, int postType) { switch (postType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_subreddit_name); break; case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_multi_reddit_name); break; case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_username); break; default: - linearLayout.setVisibility(View.GONE); + constraintLayout.setVisibility(View.GONE); } } - private void applyTab2NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + private void applyTab2NameView(ConstraintLayout linearLayout, TextView titleTextView, int postType) { switch (postType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: linearLayout.setVisibility(View.VISIBLE); @@ -536,22 +557,150 @@ public class CustomizeMainPageTabsFragment extends Fragment { } } - private void applyTab3NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + private void applyTab3NameView(ConstraintLayout constraintLayout, TextView titleTextView, int postType) { switch (postType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_subreddit_name); break; case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_multi_reddit_name); break; case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: - linearLayout.setVisibility(View.VISIBLE); + constraintLayout.setVisibility(View.VISIBLE); titleTextView.setText(R.string.settings_tab_username); break; default: - linearLayout.setVisibility(View.GONE); + constraintLayout.setVisibility(View.GONE); + } + } + + private void selectName(int tab) { + switch (tab) { + case 0: + switch (tab1CurrentPostType) { + case 3: { + Intent intent = new Intent(activity, SubredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 4: { + Intent intent = new Intent(activity, MultiredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 5: { + Intent intent = new Intent(activity, SearchActivity.class); + intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_USERS, true); + startActivityForResult(intent, tab); + break; + } + } + break; + case 1: + switch (tab2CurrentPostType) { + case 3: { + Intent intent = new Intent(activity, SubredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 4: { + Intent intent = new Intent(activity, MultiredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 5: { + Intent intent = new Intent(activity, SearchActivity.class); + intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_USERS, true); + startActivityForResult(intent, tab); + break; + } + } + break; + case 2: + switch (tab3CurrentPostType) { + case 3: { + Intent intent = new Intent(activity, SubredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 4: { + Intent intent = new Intent(activity, MultiredditSelectionActivity.class); + startActivityForResult(intent, tab); + break; + } + case 5: { + Intent intent = new Intent(activity, SearchActivity.class); + intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_USERS, true); + startActivityForResult(intent, tab); + break; + } + } + break; + } + } + + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode == Activity.RESULT_OK && data != null) { + switch (requestCode) { + case 0: + if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { + tab1CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); + tab1NameSummaryTextView.setText(tab1CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); + } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { + MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); + if (multireddit != null) { + tab1CurrentName = multireddit.getPath(); + tab1NameSummaryTextView.setText(tab1CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); + } + } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { + tab1CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab1NameSummaryTextView.setText(tab1CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); + } + break; + case 1: + if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { + tab2CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); + tab2NameSummaryTextView.setText(tab2CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); + } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { + MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); + if (multireddit != null) { + tab2CurrentName = multireddit.getPath(); + tab2NameSummaryTextView.setText(tab2CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); + } + } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { + tab2CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab2NameSummaryTextView.setText(tab2CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); + } + break; + case 2: + if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { + tab3CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); + tab3NameSummaryTextView.setText(tab3CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); + } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { + MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); + if (multireddit != null) { + tab3CurrentName = multireddit.getPath(); + tab3NameSummaryTextView.setText(tab3CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); + } + } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { + tab3CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab3NameSummaryTextView.setText(tab3CurrentName); + mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); + } + break; + } } } |