use of com.odysee.app.utils.LbryUri 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);
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class ClaimListAdapter method filterBlockedChannels.
public void filterBlockedChannels(List<LbryUri> blockedChannels) {
if (blockedChannels.size() == 0) {
return;
}
List<String> blockedChannelClaimIds = new ArrayList<>();
for (LbryUri uri : blockedChannels) {
blockedChannelClaimIds.add(uri.getClaimId());
}
for (Claim claim : items) {
if (claim.getSigningChannel() != null && blockedChannelClaimIds.contains(claim.getSigningChannel().getClaimId())) {
int position = items.indexOf(claim);
items.remove(claim);
notifyItemRemoved(position);
}
}
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class DatabaseHelper method getBlockedChannels.
public static List<LbryUri> getBlockedChannels(SQLiteDatabase db) {
List<LbryUri> blockedChannels = new ArrayList<>();
Cursor cursor = null;
try {
cursor = db.rawQuery(SQL_GET_BLOCKED_CHANNELS, null);
while (cursor.moveToNext()) {
LbryUri uri = LbryUri.tryParse(String.format("lbry://%s:%s", cursor.getString(1), cursor.getString(0)));
if (uri != null) {
blockedChannels.add(uri);
}
}
} finally {
Helper.closeCursor(cursor);
}
return blockedChannels;
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class TransactionListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(TransactionListAdapter.ViewHolder vh, int position) {
Transaction item = items.get(position);
vh.descView.setText(item.getDescriptionStringId());
vh.amountView.setText(TX_LIST_AMOUNT_FORMAT.format(item.getValue().doubleValue()));
vh.claimView.setText(item.getClaim());
vh.feeView.setText(context.getString(R.string.tx_list_fee, TX_LIST_AMOUNT_FORMAT.format(item.getFee().doubleValue())));
vh.txidLinkView.setText(item.getTxid().substring(0, 7));
vh.dateView.setVisibility(item.getConfirmations() > 0 ? View.VISIBLE : View.GONE);
vh.dateView.setText(item.getConfirmations() > 0 ? TX_LIST_DATE_FORMAT.format(item.getTxDate()) : null);
vh.pendingView.setVisibility(item.getConfirmations() == 0 ? View.VISIBLE : View.GONE);
vh.infoFeeContainer.setVisibility(!Helper.isNullOrEmpty(item.getClaim()) || Math.abs(item.getFee().doubleValue()) > 0 ? View.VISIBLE : View.GONE);
vh.claimView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LbryUri claimUrl = item.getClaimUrl();
if (claimUrl != null && listener != null) {
listener.onClaimUrlClicked(claimUrl);
}
}
});
vh.txidLinkView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (context != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("%s/%s", Helper.EXPLORER_TX_PREFIX, item.getTxid())));
context.startActivity(intent);
}
}
});
vh.itemView.setOnClickListener(view -> {
if (listener != null) {
listener.onTransactionClicked(item);
}
});
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class InvitesFragment method updateInviteLink.
private void updateInviteLink(Claim claim) {
LbryUri canonical = LbryUri.tryParse(claim.getCanonicalUrl());
String link = String.format(INVITE_LINK_FORMAT, canonical != null ? String.format("@%s", canonical.getChannelName()) : claim.getName(), canonical != null ? canonical.getChannelClaimId() : claim.getClaimId());
textInviteLink.setText(link);
}
Aggregations