mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Disable refreshing in SubscribedThingListingActivity in anonymous mode.
This commit is contained in:
parent
191023301d
commit
10cccb5b93
@ -131,7 +131,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||
|
||||
|
||||
bindView();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
-> {
|
||||
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();
|
||||
}
|
||||
}))
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(SubscribedThingListingActivity.this,
|
||||
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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" />
|
||||
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user