use of com.odysee.app.tasks.wallet.LoadSharedUserStateTask in project odysee-android by OdyseeTeam.
the class SignInActivity method loadSharedUserStateAndFinish.
private void loadSharedUserStateAndFinish() {
// load the shared user state after wallet sync is done
LoadSharedUserStateTask loadTask = new LoadSharedUserStateTask(SignInActivity.this, new LoadSharedUserStateTask.LoadSharedUserStateHandler() {
@Override
public void onSuccess(List<Subscription> subscriptions, List<Tag> followedTags, List<LbryUri> blockedChannels) {
Lbryio.subscriptions = new ArrayList<>(subscriptions);
Lbryio.blockedChannels = new ArrayList<>(blockedChannels);
finishSignInActivity();
}
@Override
public void onError(Exception error) {
// shouldn't happen, but if it does, finish anyway
finishSignInActivity();
}
}, Lbryio.AUTH_TOKEN);
loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.LoadSharedUserStateTask in project odysee-android by OdyseeTeam.
the class MainActivity method loadSharedUserState.
private void loadSharedUserState() {
// load wallet preferences
LoadSharedUserStateTask loadTask = new LoadSharedUserStateTask(MainActivity.this, new LoadSharedUserStateTask.LoadSharedUserStateHandler() {
@Override
public void onSuccess(List<Subscription> subscriptions, List<Tag> followedTags, List<LbryUri> blockedChannels) {
if (subscriptions != null && subscriptions.size() > 0) {
// reload subscriptions if wallet fragment is FollowingFragment
// openNavFragments.get
MergeSubscriptionsTask mergeTask = new MergeSubscriptionsTask(subscriptions, initialSubscriptionMergeDone(), MainActivity.this, new MergeSubscriptionsTask.MergeSubscriptionsHandler() {
@Override
public void onSuccess(List<Subscription> subscriptions, List<Subscription> diff) {
Lbryio.subscriptions = new ArrayList<>(subscriptions);
if (!diff.isEmpty()) {
saveSharedUserState();
}
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_INITIAL_SUBSCRIPTION_MERGE_DONE, true).apply();
Lbryio.cacheResolvedSubscriptions.clear();
FollowingFragment f = (FollowingFragment) getSupportFragmentManager().findFragmentByTag("FOLLOWING");
if (f != null) {
f.fetchLoadedSubscriptions(true);
}
}
@Override
public void onError(Exception error) {
Log.e(TAG, String.format("merge subscriptions failed: %s", error.getMessage()), error);
}
});
mergeTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if (followedTags != null && followedTags.size() > 0) {
List<Tag> previousTags = new ArrayList<>(Lbry.followedTags);
Lbry.followedTags = new ArrayList<>(followedTags);
AllContentFragment f = (AllContentFragment) getSupportFragmentManager().findFragmentByTag("HOME");
if (f != null) {
if (!f.isSingleTagView() && f.getCurrentContentScope() == ContentScopeDialogFragment.ITEM_TAGS && !previousTags.equals(followedTags)) {
f.fetchClaimSearchContent(true);
}
}
}
if (blockedChannels != null && !blockedChannels.isEmpty()) {
if (!initialBlockedListLoaded()) {
// first time the blocked list is loaded, so we attempt to merge the entries
List<LbryUri> newBlockedChannels = new ArrayList<>(Lbryio.blockedChannels);
for (LbryUri uri : blockedChannels) {
if (!newBlockedChannels.contains(uri)) {
newBlockedChannels.add(uri);
}
}
Lbryio.blockedChannels = new ArrayList<>(newBlockedChannels);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_INITIAL_BLOCKED_LIST_LOADED, true).apply();
} else {
// replace the blocked channels list entirely
Lbryio.blockedChannels = new ArrayList<>(blockedChannels);
}
}
if (!initialCollectionsLoaded()) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_INITIAL_COLLECTIONS_LOADED, true).apply();
}
}
@Override
public void onError(Exception error) {
Log.e(TAG, String.format("load shared user state failed: %s", error != null ? error.getMessage() : "no error message"), error);
}
}, Lbryio.AUTH_TOKEN);
loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations