mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +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);
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
|
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||||
|
|
||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
import ml.docilealligator.infinityforreddit.asynctasks.DeleteMultiredditInDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
|
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings;
|
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
@ -153,7 +154,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
setToolbarGoToTop(toolbar);
|
setToolbarGoToTop(toolbar);
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
||||||
@ -242,7 +243,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadSubscriptions(boolean forceLoad) {
|
public void loadSubscriptions(boolean forceLoad) {
|
||||||
if (!(!forceLoad && mInsertSuccess)) {
|
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
||||||
FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
|
FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
|
||||||
new ArrayList<>(), new ArrayList<>(),
|
new ArrayList<>(), new ArrayList<>(),
|
||||||
new ArrayList<>(),
|
new ArrayList<>(),
|
||||||
@ -293,22 +294,24 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadMultiReddits() {
|
private void loadMultiReddits() {
|
||||||
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
if (mAccessToken != null) {
|
||||||
@Override
|
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
||||||
public void success(ArrayList<MultiReddit> multiReddits) {
|
@Override
|
||||||
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> {
|
public void success(ArrayList<MultiReddit> multiReddits) {
|
||||||
mInsertMultiredditSuccess = true;
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> {
|
||||||
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
mInsertMultiredditSuccess = true;
|
||||||
});
|
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
mInsertMultiredditSuccess = false;
|
mInsertMultiredditSuccess = false;
|
||||||
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
||||||
Toast.makeText(SubscribedThingListingActivity.this, R.string.error_loading_multi_reddit_list, Toast.LENGTH_SHORT).show();
|
Toast.makeText(SubscribedThingListingActivity.this, R.string.error_loading_multi_reddit_list, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteMultiReddit(MultiReddit multiReddit) {
|
public void deleteMultiReddit(MultiReddit multiReddit) {
|
||||||
@ -316,21 +319,29 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
.setTitle(R.string.delete)
|
.setTitle(R.string.delete)
|
||||||
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
||||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||||
-> DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
-> {
|
||||||
mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
|
if (mAccessToken == null) {
|
||||||
@Override
|
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiReddit.getPath(),
|
||||||
public void success() {
|
() -> Toast.makeText(SubscribedThingListingActivity.this,
|
||||||
Toast.makeText(SubscribedThingListingActivity.this,
|
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
|
||||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
} else {
|
||||||
loadMultiReddits();
|
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
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
Toast.makeText(SubscribedThingListingActivity.this,
|
Toast.makeText(SubscribedThingListingActivity.this,
|
||||||
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
|
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}))
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
@ -109,11 +109,14 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
|
|||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
|
if (accessToken == null) {
|
||||||
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
|
}
|
||||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
|
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
|
||||||
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper,
|
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken);
|
||||||
getArguments().getString(EXTRA_ACCESS_TOKEN));
|
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
new FastScrollerBuilder(mRecyclerView).build();
|
new FastScrollerBuilder(mRecyclerView).build();
|
||||||
|
|
||||||
|
@ -112,6 +112,10 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
|
|||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
|
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
|
||||||
|
|
||||||
|
if (accessToken == null) {
|
||||||
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||||
|
@ -113,6 +113,10 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
|||||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
|
|
||||||
|
if (accessToken == null) {
|
||||||
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||||
|
@ -603,7 +603,7 @@
|
|||||||
<string name="settings_app_lock_title">App Lock</string>
|
<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_summary">Require authentication before using the app</string>
|
||||||
<string name="settings_app_lock_timeout_title">App Lock Timeout</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>
|
<string name="no_link_available">Cannot get the link</string>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:key="enable_fold_support"
|
app:key="enable_fold_support"
|
||||||
app:title="@string/settings_enable_fold_support" />
|
app:title="@string/settings_enable_fold_support_title" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
app:title="@string/post_layout_card" />
|
app:title="@string/post_layout_card" />
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:key="enable_fold_support"
|
app:key="enable_fold_support"
|
||||||
app:title="@string/settings_enable_fold_support" />
|
app:title="@string/settings_enable_fold_support_title" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/post_layout_card" />
|
android:title="@string/post_layout_card" />
|
||||||
|
Loading…
Reference in New Issue
Block a user