mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 12:57:12 +01:00
Disable refreshing in SubscribedThingListingActivity in anonymous mode.
This commit is contained in:
parent
191023301d
commit
10cccb5b93
@ -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,6 +294,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadMultiReddits() {
|
private void loadMultiReddits() {
|
||||||
|
if (mAccessToken != null) {
|
||||||
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(ArrayList<MultiReddit> multiReddits) {
|
public void success(ArrayList<MultiReddit> multiReddits) {
|
||||||
@ -310,13 +312,20 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteMultiReddit(MultiReddit multiReddit) {
|
public void deleteMultiReddit(MultiReddit multiReddit) {
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
.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,
|
-> {
|
||||||
|
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() {
|
mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
@ -330,7 +339,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
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