Search in sources :

Example 1 with Cal

use of run.wallet.common.Cal in project run-wallet-android by runplay.

the class TransferViewManager method populateViewHolder.

public static final void populateViewHolder(Context context, ViewHolder holder, Transfer transfer, boolean isAutoNudge, int adapterPosition, boolean filtered) {
    if (context != null) {
        String faddress = WalletTransfersCardAdapter.getFilterAddress();
        if (faddress != null && transfer.isCompleted()) {
            ((LinearLayout.LayoutParams) (holder.card).getLayoutParams()).setMarginStart(70);
            long value = 0;
            for (TransferTransaction t : transfer.getTransactions()) {
                if (faddress.equals(t.getAddress()))
                    value += t.getValue();
            }
            if (transfer.getTransactions().isEmpty()) {
            } else {
                IotaToText.IotaDisplayData fdata = IotaToText.getIotaDisplayData(value);
                holder.filtered.setVisibility(View.VISIBLE);
                holder.fBalance.setText((value > 0 ? "+" : "") + fdata.value);
                holder.fUnit.setText(fdata.unit);
                holder.fThird.setText(fdata.thirdDecimal);
                holder.fUnit.setTextColor(B.getColor(context, AppTheme.getPrimary()));
                if (value > 0) {
                    holder.fBalance.setTextColor(B.getColor(context, R.color.green));
                    holder.fThird.setTextColor(B.getColor(context, R.color.green));
                } else {
                    holder.fBalance.setTextColor(B.getColor(context, R.color.flatRed));
                    holder.fThird.setTextColor(B.getColor(context, R.color.flatRed));
                }
            }
        } else {
            holder.filtered.setVisibility(View.GONE);
        }
        IotaToText.IotaDisplayData data = IotaToText.getIotaDisplayData(transfer.getValue());
        holder.transfer = transfer;
        holder.balance.setText(data.value);
        holder.balanceThird.setText(data.thirdDecimal);
        holder.balanceUnit.setText(data.unit);
        holder.addressLabel.setText(transfer.getAddress());
        holder.messageLabel.setText(TextUtils.isEmpty(transfer.getMessage()) ? "" : formatMessage(context, transfer.getMessage()));
        holder.tagLabel.setText(transfer.getTag());
        holder.timeLabel.setText(Utils.timeStampToDate(transfer.getTimestamp()));
        holder.hashLabel.setText(transfer.getHash());
        holder.isCancelled = transfer.isMarkDoubleSpend();
        holder.isAddressDouble = transfer.isMarkDoubleAddress();
        holder.value = transfer.getValue();
        int persist = R.string.card_label_persistence_no;
        if (transfer.isCompleted())
            persist = R.string.card_label_persistence_yes;
        holder.persistenceLabel.setText(context.getString(persist));
        holder.isConfirmed = transfer.getPersistence() != null ? transfer.getPersistence() : false;
        holder.confirmCheck.setVisibility(View.GONE);
        holder.alternativeValueLabel.setText("");
        holder.timestatus.setVisibility(View.VISIBLE);
        holder.balance.setTextColor(B.getColor(context, R.color.grey));
        holder.balanceThird.setTextColor(B.getColor(context, R.color.grey));
        holder.balanceUnit.setTextColor(B.getColor(context, R.color.grey));
        holder.alternativeValueLabel.setTextColor(B.getColor(context, R.color.grey));
        holder.balance.setPaintFlags(0);
        if (transfer.getPersistence() != null && transfer.getPersistence().booleanValue()) {
            // holder.card.setCardBackgroundColor(B.getColor(context,R.color.cardview_light_background));
            holder.card.setAlpha(1F);
        } else {
            if ((System.currentTimeMillis() - 600000) > transfer.getTimestamp()) {
                holder.card.setAlpha(0.6F);
            } else {
                holder.card.setAlpha(0.8F);
            }
        // holder.card.setCardBackgroundColor(B.getColor(context,R.color.cardview_dark_background));
        }
        holder.mstoneCount.setVisibility(View.GONE);
        holder.getAlternativeValueTime.setText(Cal.friendlyReadDate(new Cal(transfer.getTimestamp())));
        holder.getAlternativeValueTime.setCompoundDrawables(null, null, null, null);
        if (transfer.getValue() == 0 && transfer.getTransactions().isEmpty()) {
            if (transfer.getTag().endsWith("NUDGE9")) {
                holder.alternativeValueLabel.setText(context.getString(R.string.info_nudge));
                holder.imgTran.setImageResource(R.drawable.nudge_orange);
            } else {
                holder.alternativeValueLabel.setText(context.getString(R.string.attached_address));
                holder.imgTran.setImageResource(R.drawable.tran_orange);
            }
        } else if (!transfer.isCompleted()) {
            if (isAutoNudge) {
                holder.imgTran.setImageResource(R.drawable.ic_replay_orange);
            } else {
                holder.imgTran.setImageResource(R.drawable.ic_replay_grey);
            }
            if (transfer.getValue() < 0) {
                holder.balance.setTextColor(B.getColor(context, R.color.flatRed));
                holder.balanceThird.setTextColor(B.getColor(context, R.color.flatRed));
                holder.balanceUnit.setTextColor(B.getColor(context, AppTheme.getPrimary()));
            } else if (transfer.isInternal()) {
                holder.alternativeValueLabel.setText(context.getString(R.string.card_label_internal));
                holder.imgTran.setImageResource(R.drawable.tran_green);
            }
            holder.confirmCheck.setText(transfer.getNudgeCount() + "");
            if (transfer.isMarkDoubleSpend()) {
                holder.imgTran.setImageResource(R.drawable.ic_replay_grey);
                holder.alternativeValueLabel.setText(context.getString(R.string.label_cancelled));
                holder.balance.setPaintFlags(holder.addressLabel.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else if (transfer.isMarkDoubleAddress()) {
                holder.imgTran.setImageResource(R.drawable.ic_replay_grey);
                holder.alternativeValueLabel.setText(context.getString(R.string.label_address_used));
                holder.balance.setPaintFlags(holder.addressLabel.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
                if (transfer.getValue() < 0) {
                    if (isAutoNudge || transfer.getNudgeCount() > 0) {
                        holder.confirmCheck.setVisibility(View.VISIBLE);
                        holder.confirmCheck.setBackgroundResource(R.drawable.ic_replay_orange_alpha);
                    }
                    holder.alternativeValueLabel.setText(context.getString(R.string.card_label_pending_out));
                } else {
                    if (isAutoNudge || transfer.getNudgeCount() > 0) {
                        holder.confirmCheck.setVisibility(View.VISIBLE);
                        holder.confirmCheck.setBackgroundResource(R.drawable.ic_replay_orange_alpha);
                    }
                    holder.alternativeValueLabel.setText(context.getString(R.string.card_label_pending_in));
                }
            }
        } else if (transfer.getValue() == 0) {
            holder.alternativeValueLabel.setText(context.getString(R.string.card_label_internal));
            holder.imgTran.setImageResource(R.drawable.tran_green);
            if (transfer.isCompleted()) {
                holder.confirmCheck.setBackgroundResource(R.drawable.check_green);
                holder.confirmCheck.setVisibility(View.VISIBLE);
            }
        } else if (transfer.getValue() > 0) {
            holder.confirmCheck.setVisibility(View.VISIBLE);
            holder.confirmCheck.setText("");
            holder.confirmCheck.setBackgroundResource(R.drawable.check_green);
            holder.alternativeValueLabel.setText(context.getString(R.string.card_label_persistence_yes));
            holder.getAlternativeValueTime.setCompoundDrawables(B.getDrawable(context, R.drawable.check_green), null, null, null);
            holder.imgTran.setImageResource(R.drawable.ic_iota_in);
            holder.balance.setTextColor(B.getColor(context, R.color.green));
            holder.balanceThird.setTextColor(B.getColor(context, R.color.green));
            holder.balanceUnit.setTextColor(B.getColor(context, AppTheme.getPrimary()));
        } else {
            holder.confirmCheck.setVisibility(View.VISIBLE);
            holder.confirmCheck.setText("");
            holder.confirmCheck.setBackgroundResource(R.drawable.check_green);
            holder.alternativeValueLabel.setText(context.getString(R.string.card_label_persistence_yes));
            holder.getAlternativeValueTime.setCompoundDrawables(B.getDrawable(context, R.drawable.check), null, null, null);
            holder.imgTran.setImageResource(R.drawable.ic_iota_out);
            holder.balance.setTextColor(B.getColor(context, R.color.flatRed));
            holder.balanceThird.setTextColor(B.getColor(context, R.color.flatRed));
            holder.balanceUnit.setTextColor(B.getColor(context, AppTheme.getPrimary()));
        }
        TransferViewManager.populateTransferTransactions(context, holder.transferTransactions, transfer.getTransactions(), false);
        if (!transfer.getOtherTransactions().isEmpty()) {
            holder.otherAddressView.setVisibility(View.VISIBLE);
            holder.otherAddressLayout.setVisibility(View.VISIBLE);
            TransferViewManager.populateTransferTransactions(context, holder.otherAddressLayout, transfer.getOtherTransactions(), true);
        } else {
            // holder.otherAddressLayout.removeAllViews();
            holder.otherAddressView.setVisibility(View.GONE);
        }
        if (adapterPosition < 0) {
        } else {
            holder.expandableLayout.setExpanded(expandState.get(adapterPosition));
            holder.expandableLayout.invalidate();
        }
    }
}
Also used : IotaToText(jota.utils.IotaToText) TransferTransaction(run.wallet.iota.model.TransferTransaction) Paint(android.graphics.Paint) Cal(run.wallet.common.Cal)

Example 2 with Cal

use of run.wallet.common.Cal in project run-wallet-android by runplay.

the class NodesListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(NodeViewHolder holder, int position) {
    int adapterPosition = holder.getAdapterPosition();
    Nodes.Node node = getItem(adapterPosition);
    // Log.e("NODESVIEW","pos: "+adapterPosition);
    if (node != null) {
        Nodes.Node currentnode = Store.getNode();
        NodeInfoResponse currentInfo = Store.getNodeInfo();
        holder.nodeAddress.setText(node.getName());
        holder.lastSyncStatus.setImageResource(R.drawable.node_off);
        holder.statusView.setImageResource(R.drawable.node_off);
        Cal cal = new Cal(node.lastused);
        holder.lastDate.setText(cal.friendlyReadDate());
        holder.itemBackground.setBackgroundColor(B.getColor(context, R.color.white));
        holder.lastSyncStatus.setImageResource(R.drawable.node_off);
        if (node.deadcount > 2) {
            holder.itemView.setBackgroundColor(B.getColor(context, R.color.grey));
            holder.lastDate.setText(R.string.menu_node_dead);
        } else {
            if (currentnode != null) {
                if (currentnode.ip.equals(node.ip)) {
                    holder.itemBackground.setBackgroundColor(B.getColor(context, R.color.flatGreen));
                    holder.statusView.setImageResource(R.drawable.node_live);
                    if (currentInfo != null && currentInfo.getSyncVal() > 1) {
                        holder.lastDate.setText(context.getString(R.string.messages_not_fully_synced_yet));
                    }
                }
            } else {
            // Log.e("CNODe","is null");
            }
        }
        holder.syncValue.setText(node.syncVal + "");
        if (node.syncVal == 0) {
            holder.lastSyncStatus.setImageResource(R.drawable.node_live);
        } else {
            holder.lastSyncStatus.setImageResource(R.drawable.node_tick_grey);
        }
        // holder.nodeName.setText(node.name);
        holder.nodePort.setText("" + node.port);
        holder.nodeProtocol.setText(node.protocol);
    }
}
Also used : NodeInfoResponse(run.wallet.iota.api.responses.NodeInfoResponse) Nodes(run.wallet.iota.model.Nodes) Cal(run.wallet.common.Cal)

Example 3 with Cal

use of run.wallet.common.Cal in project run-wallet-android by runplay.

the class AddNodesListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(NodeViewHolder holder, int position) {
    int adapterPosition = holder.getAdapterPosition();
    Nodes.Node node = getItem(adapterPosition);
    // Log.e("NODESVIEW","pos: "+adapterPosition);
    if (node != null) {
        if (node.ip.contains(".runplay.com") || node.ip.contains(".runpg.com")) {
            holder.nodeAddress.setText(Constants.DISPLAY_RUNIOTA_NODE_NAME + position + Constants.DISPLAY_RUNIOTA_NODE_NAME_END);
        } else {
            holder.nodeAddress.setText(node.ip);
        }
        holder.extras.setVisibility(View.GONE);
        Nodes.Node currentnode = Store.getNode();
        NodeInfoResponse currentInfo = Store.getNodeInfo();
        holder.lastSyncStatus.setImageResource(R.drawable.node_off);
        holder.statusView.setImageResource(R.drawable.node_off);
        Cal cal = new Cal(node.lastused);
        holder.lastDate.setText(cal.friendlyReadDate());
        holder.itemView.setBackgroundColor(B.getColor(context, R.color.white));
        holder.nodePort.setText("" + node.port);
        holder.nodeProtocol.setText(node.protocol);
    }
}
Also used : NodeInfoResponse(run.wallet.iota.api.responses.NodeInfoResponse) Nodes(run.wallet.iota.model.Nodes) Cal(run.wallet.common.Cal)

Aggregations

Cal (run.wallet.common.Cal)3 NodeInfoResponse (run.wallet.iota.api.responses.NodeInfoResponse)2 Nodes (run.wallet.iota.model.Nodes)2 Paint (android.graphics.Paint)1 IotaToText (jota.utils.IotaToText)1 TransferTransaction (run.wallet.iota.model.TransferTransaction)1