use of com.odysee.app.model.WalletDetailItem in project odysee-android by OdyseeTeam.
the class WalletFragment method onWalletBalanceUpdated.
public void onWalletBalanceUpdated(WalletBalance walletBalance) {
if (walletBalance == null) {
return;
}
double totalBalance = walletBalance.getTotal().doubleValue();
double spendableBalance = walletBalance.getAvailable().doubleValue();
double supportingBalance = walletBalance.getClaims().doubleValue() + walletBalance.getTips().doubleValue() + walletBalance.getSupports().doubleValue();
double usdBalance = totalBalance * Lbryio.LBCUSDRate;
double tipsBalance = walletBalance.getTips().doubleValue();
if (detailRows == null)
detailRows = new ArrayList<>(3);
if (detailAdapter == null) {
detailAdapter = new WalletDetailAdapter(getContext(), detailRows);
detailListView.setAdapter(detailAdapter);
}
Activity activity = (Activity) getContext();
boolean tipsBeenUnlocked;
if (activity instanceof MainActivity)
tipsBeenUnlocked = ((MainActivity) activity).isUnlockingTips();
else
tipsBeenUnlocked = false;
WalletDetailItem earnedBalance = new WalletDetailItem(getResources().getString(R.string.earned_from_others), getResources().getString(R.string.unlock_to_spend), Helper.SIMPLE_CURRENCY_FORMAT.format(tipsBalance), tipsBalance != 0, tipsBeenUnlocked);
WalletDetailItem initialPublishes = new WalletDetailItem(getResources().getString(R.string.on_initial_publishes), getResources().getString(R.string.delete_or_edit_past_content), Helper.SIMPLE_CURRENCY_FORMAT.format(walletBalance.getClaims().doubleValue()), false, false);
WalletDetailItem supportingContent = new WalletDetailItem(getResources().getString(R.string.supporting_content), getResources().getString(R.string.delete_supports_to_spend), Helper.SIMPLE_CURRENCY_FORMAT.format(walletBalance.getSupports().doubleValue()), false, false);
if (detailRows.size() == 0) {
detailRows.add(0, earnedBalance);
detailRows.add(1, initialPublishes);
detailRows.add(2, supportingContent);
} else {
if (!detailRows.get(0).detailAmount.equals(earnedBalance.detailAmount) || detailRows.get(0).isInProgress != earnedBalance.isInProgress || detailRows.get(0).isUnlockable != earnedBalance.isUnlockable) {
detailRows.set(0, earnedBalance);
}
if (!detailRows.get(1).detailAmount.equals(initialPublishes.detailAmount)) {
detailRows.set(1, initialPublishes);
}
if (!detailRows.get(2).detailAmount.equals(supportingContent.detailAmount)) {
detailRows.set(2, supportingContent);
}
}
detailListView.setAdapter(detailAdapter);
String formattedTotalBalance = Helper.REDUCED_LBC_CURRENCY_FORMAT.format(totalBalance);
String formattedSpendableBalance = Helper.SIMPLE_CURRENCY_FORMAT.format(spendableBalance);
String formattedSupportingBalance = Helper.SIMPLE_CURRENCY_FORMAT.format(supportingBalance);
Helper.setViewText(walletTotalBalanceView, totalBalance > 0 && formattedTotalBalance.equals("0") ? Helper.FULL_LBC_CURRENCY_FORMAT.format(totalBalance) : formattedTotalBalance);
Helper.setViewText(walletSpendableBalanceView, spendableBalance > 0 && formattedSpendableBalance.equals("0") ? Helper.FULL_LBC_CURRENCY_FORMAT.format(spendableBalance) : formattedSpendableBalance);
Helper.setViewText(walletSupportingBalanceView, supportingBalance > 0 && formattedSupportingBalance.equals("0") ? Helper.FULL_LBC_CURRENCY_FORMAT.format(supportingBalance) : formattedSupportingBalance);
Helper.setViewText(textWalletInlineBalance, Helper.shortCurrencyFormat(spendableBalance));
if (Lbryio.LBCUSDRate > 0) {
// only update display usd values if the rate is loaded
Helper.setViewText(textWalletBalanceUSD, String.format("≈$%s", Helper.SIMPLE_CURRENCY_FORMAT.format(usdBalance)));
}
textWalletBalanceDesc.setText(spendableBalance == totalBalance ? getResources().getString(R.string.your_total_balance) : getResources().getString(R.string.all_of_this_is_yours));
fetchRecentTransactions(true);
checkRewardsDriver();
}
use of com.odysee.app.model.WalletDetailItem in project odysee-android by OdyseeTeam.
the class WalletDetailAdapter method getView.
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.list_item_boosting_balance, viewGroup, false);
CreditsBalanceView balanceView = view.findViewById(R.id.wallet_supporting_balance);
TextView detailTextView = view.findViewById(R.id.detail);
TextView detailExplanationTextView = view.findViewById(R.id.detail_explanation);
WalletDetailItem item = (WalletDetailItem) getItem(i);
detailTextView.setText(item.detail);
detailExplanationTextView.setText(item.detailDesc);
Helper.setViewText(balanceView, item.detailAmount);
ProgressBar progressUnlockTips = view.findViewById(R.id.wallet_unlock_tips_progress);
progressUnlockTips.setVisibility(item.isInProgress ? View.VISIBLE : View.GONE);
ImageButton buttonLock = view.findViewById(R.id.lock_button);
buttonLock.setVisibility((item.isUnlockable && !item.isInProgress) ? View.VISIBLE : View.GONE);
if (item.isUnlockable) {
buttonLock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getContext() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()).setTitle(R.string.unlock_tips).setMessage(R.string.confirm_unlock_tips).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
unlockTips(view);
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
}
});
}
}
return view;
}
Aggregations