Search in sources :

Example 1 with TransVo

use of com.lingtuan.firefly.wallet.vo.TransVo in project SmartMesh_Android by SmartMeshFoundation.

the class FinalUserDataBase method getTransList.

/**
 * Add trans list
 */
public List<TransVo> getTransList(int type, String address) {
    if (!address.startsWith("0x")) {
        address = "0x" + address;
    }
    String sql = "select * from " + TableField.TABLE_TRANS + " where " + TableField.FIELD_RESERVED_DATA1 + "=? and (" + TableField.FIELD_RESERVED_DATA5 + "=? or " + TableField.FIELD_RESERVED_DATA6 + "=? )" + " order by " + TableField.FIELD_CHAT_MSGTIME + " desc ";
    Cursor cursor = db.rawQuery(sql, new String[] { String.valueOf(type), address, address });
    List<TransVo> list = new ArrayList<>();
    while (cursor.moveToNext()) {
        TransVo vo = new TransVo();
        vo.setTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
        vo.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
        vo.setValue(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
        vo.setFee(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)));
        vo.setTx(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA4)));
        vo.setFromAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
        vo.setToAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)));
        vo.setTxBlockNumber(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)));
        vo.setTxurl(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
        vo.setNoticeType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
        vo.setState(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA10)) + 1);
        if (// send
        vo.getNoticeType() == 0) {
            if (TextUtils.equals(address, vo.getToAddress()) && !TextUtils.equals(address, vo.getFromAddress())) {
                continue;
            }
        } else {
            // rec
            if (TextUtils.equals(address, vo.getFromAddress()) && !TextUtils.equals(address, vo.getToAddress())) {
                continue;
            }
        }
        list.add(vo);
    }
    cursor.close();
    getTransTempList(list, type, address);
    return list;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) TransVo(com.lingtuan.firefly.wallet.vo.TransVo)

Example 2 with TransVo

use of com.lingtuan.firefly.wallet.vo.TransVo in project SmartMesh_Android by SmartMeshFoundation.

the class FinalUserDataBase method getTransTempList.

/**
 * Add trans list
 */
public void getTransTempList(List<TransVo> transVoList, int type, String address) {
    String sql = "select * from " + TableField.TABLE_TRANS_TEMP + " where " + TableField.FIELD_RESERVED_DATA1 + "=? and (" + TableField.FIELD_RESERVED_DATA5 + "=? or " + TableField.FIELD_RESERVED_DATA6 + "=? )" + " order by " + TableField.FIELD_CHAT_MSGTIME + " asc ";
    Cursor cursor = db.rawQuery(sql, new String[] { String.valueOf(type), address, address });
    while (cursor.moveToNext()) {
        TransVo vo = new TransVo();
        vo.setTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
        vo.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
        vo.setValue(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
        vo.setFee(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)));
        vo.setTx(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA4)));
        vo.setFromAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
        vo.setToAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)));
        vo.setTxBlockNumber(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)));
        vo.setTxurl(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
        vo.setNoticeType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
        vo.setState(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA10)) + 1);
        if (// send
        vo.getNoticeType() == 0) {
            if (TextUtils.equals(address, vo.getToAddress()) && !TextUtils.equals(address, vo.getFromAddress())) {
                continue;
            }
        } else {
            // rec
            if (TextUtils.equals(address, vo.getFromAddress()) && !TextUtils.equals(address, vo.getToAddress())) {
                continue;
            }
        }
        boolean isFound = false;
        for (int i = 0; i < transVoList.size(); i++) {
            String tx = transVoList.get(i).getTx();
            if (TextUtils.equals(tx, vo.getTx())) {
                FinalUserDataBase.getInstance().deleteTransTemp(vo.getTx());
                isFound = true;
                break;
            }
        }
        if (!isFound) {
            transVoList.add(0, vo);
        }
    }
    cursor.close();
}
Also used : Cursor(android.database.Cursor) TransVo(com.lingtuan.firefly.wallet.vo.TransVo)

Example 3 with TransVo

use of com.lingtuan.firefly.wallet.vo.TransVo in project SmartMesh_Android by SmartMeshFoundation.

the class MsgTransListUI method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Intent intent = new Intent(MsgTransListUI.this, TransactionDetailActivity.class);
    ChatMsg chatmsg = mList.get(position);
    TransVo transVo = new TransVo();
    transVo.setTime(chatmsg.getCreateTime());
    transVo.setType(Integer.parseInt(chatmsg.getMode()));
    transVo.setTxBlockNumber(Integer.parseInt(chatmsg.getTxBlockNumber()));
    transVo.setFee(chatmsg.getFee());
    transVo.setValue(chatmsg.getMoney());
    transVo.setTxurl(chatmsg.getShareUrl());
    transVo.setTx(chatmsg.getNumber());
    transVo.setFromAddress(chatmsg.getFromAddress());
    transVo.setToAddress(chatmsg.getToAddress());
    transVo.setState(chatmsg.getInviteType() + 1);
    transVo.setNoticeType(chatmsg.getNoticeType());
    intent.putExtra("transVo", transVo);
    startActivity(intent);
}
Also used : Intent(android.content.Intent) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) TransVo(com.lingtuan.firefly.wallet.vo.TransVo)

Example 4 with TransVo

use of com.lingtuan.firefly.wallet.vo.TransVo in project SmartMesh_Android by SmartMeshFoundation.

the class TransAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(context, R.layout.wallet_trans_item, null);
        holder.address = (TextView) convertView.findViewById(R.id.address);
        holder.time = (TextView) convertView.findViewById(R.id.time);
        holder.value = (TextView) convertView.findViewById(R.id.value);
        holder.transFailed = (TextView) convertView.findViewById(R.id.transFailed);
        holder.transIcon = (ImageView) convertView.findViewById(R.id.transIcon);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    TransVo transVo = transVos.get(position);
    if (transVo.getNoticeType() == 0) {
        holder.address.setText(transVo.getToAddress());
        holder.transIcon.setImageResource(R.drawable.icon_transfer_out);
        holder.value.setTextColor(context.getResources().getColor(R.color.colorRed));
        if (transVo.getType() == 0) {
            // eth
            holder.value.setText("-" + context.getString(R.string.eth_er, transVo.getValue()));
        } else if (transVo.getType() == 1) {
            // smt
            holder.value.setText("-" + context.getString(R.string.smt_er, transVo.getValue()));
        } else if (transVo.getType() == 2) {
            holder.value.setText("-" + context.getString(R.string.mesh_er, transVo.getValue()));
        }
    } else {
        holder.address.setText(transVo.getFromAddress());
        holder.transIcon.setImageResource(R.drawable.icon_transfer_in);
        holder.value.setTextColor(context.getResources().getColor(R.color.yellow_wallet));
        if (transVo.getType() == 0) {
            // eth
            holder.value.setText("+" + context.getString(R.string.eth_er, transVo.getValue()));
        } else if (transVo.getType() == 1) {
            // smt
            holder.value.setText("+" + context.getString(R.string.smt_er, transVo.getValue()));
        } else if (transVo.getType() == 2) {
            holder.value.setText("+" + context.getString(R.string.mesh_er, transVo.getValue()));
        }
    }
    holder.transFailed.setTextColor(context.getResources().getColor(R.color.colorRed));
    if (transVo.getState() == 2) {
        holder.transFailed.setVisibility(View.VISIBLE);
    } else if (transVo.getState() == -1) {
        holder.transFailed.setVisibility(View.VISIBLE);
        holder.transFailed.setText(context.getString(R.string.wallet_trans_detail_type_0));
    } else if (transVo.getState() == 0) {
        holder.transFailed.setVisibility(View.VISIBLE);
        holder.transFailed.setTextColor(context.getResources().getColor(R.color.yellow_wallet));
        if (transVo.getBlockNumber() - transVo.getTxBlockNumber() < 0) {
            holder.transFailed.setText(context.getString(R.string.wallet_trans_detail_type_1, 1));
        } else {
            holder.transFailed.setText(context.getString(R.string.wallet_trans_detail_type_1, transVo.getBlockNumber() - transVo.getTxBlockNumber() + 1));
        }
    } else {
        holder.transFailed.setVisibility(View.INVISIBLE);
    }
    holder.time.setText(Utils.formatTransTime(transVo.getTime()));
    return convertView;
}
Also used : TransVo(com.lingtuan.firefly.wallet.vo.TransVo)

Aggregations

TransVo (com.lingtuan.firefly.wallet.vo.TransVo)4 Cursor (android.database.Cursor)2 Intent (android.content.Intent)1 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)1 ArrayList (java.util.ArrayList)1