diff options
8 files changed, 60 insertions, 38 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java index a0b9acbb..344f00dd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java @@ -131,7 +131,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act mSwipeRefreshLayout.setEnabled(false); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-"); - + bindView(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index 22b1a469..850ada27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -44,6 +44,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; +import ml.docilealligator.infinityforreddit.asynctasks.DeleteMultiredditInDatabase; import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit; import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; @@ -153,7 +154,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti setToolbarGoToTop(toolbar); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); - mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); + mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-"); if (savedInstanceState != null) { mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE); @@ -242,7 +243,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } public void loadSubscriptions(boolean forceLoad) { - if (!(!forceLoad && mInsertSuccess)) { + if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) { FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), @@ -293,22 +294,24 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } private void loadMultiReddits() { - FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() { - @Override - public void success(ArrayList<MultiReddit> multiReddits) { - InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> { - mInsertMultiredditSuccess = true; - sectionsPagerAdapter.stopMultiRedditRefreshProgressbar(); - }); - } + if (mAccessToken != null) { + FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() { + @Override + public void success(ArrayList<MultiReddit> multiReddits) { + InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> { + mInsertMultiredditSuccess = true; + sectionsPagerAdapter.stopMultiRedditRefreshProgressbar(); + }); + } - @Override - public void failed() { - mInsertMultiredditSuccess = false; - sectionsPagerAdapter.stopMultiRedditRefreshProgressbar(); - Toast.makeText(SubscribedThingListingActivity.this, R.string.error_loading_multi_reddit_list, Toast.LENGTH_SHORT).show(); - } - }); + @Override + public void failed() { + mInsertMultiredditSuccess = false; + sectionsPagerAdapter.stopMultiRedditRefreshProgressbar(); + Toast.makeText(SubscribedThingListingActivity.this, R.string.error_loading_multi_reddit_list, Toast.LENGTH_SHORT).show(); + } + }); + } } public void deleteMultiReddit(MultiReddit multiReddit) { @@ -316,21 +319,29 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti .setTitle(R.string.delete) .setMessage(R.string.delete_multi_reddit_dialog_message) .setPositiveButton(R.string.delete, (dialogInterface, i) - -> DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() { - @Override - public void success() { - Toast.makeText(SubscribedThingListingActivity.this, - R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); - loadMultiReddits(); - } - - @Override - public void failed() { - Toast.makeText(SubscribedThingListingActivity.this, - R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); - } - })) + -> { + if (mAccessToken == null) { + DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiReddit.getPath(), + () -> Toast.makeText(SubscribedThingListingActivity.this, + R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show()); + } else { + DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() { + @Override + public void success() { + Toast.makeText(SubscribedThingListingActivity.this, + R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); + loadMultiReddits(); + } + + @Override + public void failed() { + Toast.makeText(SubscribedThingListingActivity.this, + R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); + } + }); + } + }) .setNegativeButton(R.string.cancel, null) .show(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java index 1fda28d4..b3413209 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java @@ -109,11 +109,14 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo mGlide = Glide.with(this); + String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); + if (accessToken == null) { + mSwipeRefreshLayout.setEnabled(false); + } mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity); mRecyclerView.setLayoutManager(mLinearLayoutManager); FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity, - mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, - getArguments().getString(EXTRA_ACCESS_TOKEN)); + mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken); mRecyclerView.setAdapter(adapter); new FastScrollerBuilder(mRecyclerView).build(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java index 0f80d47a..c6ff0b85 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java @@ -112,6 +112,10 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false); + if (accessToken == null) { + mSwipeRefreshLayout.setEnabled(false); + } + mGlide = Glide.with(this); mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java index 61333955..26425941 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java @@ -113,6 +113,10 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); + if (accessToken == null) { + mSwipeRefreshLayout.setEnabled(false); + } + mGlide = Glide.with(this); mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 425f0d74..c791b2dd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -603,7 +603,7 @@ <string name="settings_app_lock_title">App Lock</string> <string name="settings_app_lock_summary">Require authentication before using the app</string> <string name="settings_app_lock_timeout_title">App Lock Timeout</string> - <string name="settings_enable_fold_support">Enable folding phone support</string> + <string name="settings_enable_fold_support_title">Enable folding phone support</string> <string name="no_link_available">Cannot get the link</string> diff --git a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml index db9e1e4e..14b56c16 100644 --- a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml @@ -8,7 +8,7 @@ <SwitchPreference app:defaultValue="false" app:key="enable_fold_support" - app:title="@string/settings_enable_fold_support" /> + app:title="@string/settings_enable_fold_support_title" /> <PreferenceCategory app:title="@string/post_layout_card" /> diff --git a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml index 5785b189..6287bfbb 100644 --- a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml @@ -10,7 +10,7 @@ <SwitchPreference app:defaultValue="false" app:key="enable_fold_support" - app:title="@string/settings_enable_fold_support" /> + app:title="@string/settings_enable_fold_support_title" /> <PreferenceCategory android:title="@string/post_layout_card" /> |