private static final StringKEY_CNY = WConstant.CURRENCY_CNY +"_" WConstant.CURRENCY_ISSUE;
private static final StringKEY_SWT = WConstant.CURRENCY_SWT +"_" +"";
case "offernew":
mTvType.setText(getResources().getString(R.string.tv_offernew));
String getsCur =mTransactions.getGets().getCurrency() +"_" +mTransactions.getGets().getIssuer();
String paysCur =mTransactions.getPays().getCurrency() +"_" +mTransactions.getPays().getIssuer();
String getsAmount ="0";
String paysAmount ="0";
if (mTransactions.getEffects() !=null) {
mEffects =mTransactions.getEffects();
for (int i =mEffects.size() -1; i >=0; i--) {
JSONObject effect =mEffects.getJSONObject(i);
pays = effect.getJSONObject("paid");
gets = effect.getJSONObject("got");
String effectType = effect.getString("effect");
Log.i("effectTYpe",effectType);
if (!TextUtils.equals(effectType,"offer_cancelled") &&
!TextUtils.equals(effectType,"offer_created")) {
if (pays !=null && gets !=null) {
Log.i("pays",pays.toJSONString());
Log.i("gets",gets.toJSONString());
String currency = pays.getString("currency") +"_" + pays.getString("issuer");
String paysCount = pays.getString("value");
if (TextUtils.equals(currency, paysCur)) {
paysAmount = CaclUtil.add(paysAmount, paysCount);
}
Log.i("payAmount",paysAmount);
currency = gets.getString("currency") +"_" + gets.getString("issuer");
String getsCount = gets.getString("value");
if (TextUtils.equals(currency, getsCur)) {
getsAmount = CaclUtil.add(getsAmount, getsCount);
}
Log.i("getAmount",getsAmount);
}else {
Log.i("effectTYpe11111",effectType);
mEffects.remove(i);
}
}
}
if (mEffects !=null &&mEffects.size() >0) {
mRecyclerView.setVisibility(View.VISIBLE);
}
Log.i("getAmount",getsAmount);
// 成交
if (!TextUtils.isEmpty(getsAmount) && CaclUtil.compare(getsAmount,"0") !=0 &&
!TextUtils.isEmpty(paysAmount) && CaclUtil.compare(paysAmount,"0") !=0) {
mLayoutTurnoverAmount.setVisibility(View.VISIBLE);
mTvTurnoverContent.setText(formatHtml(CaclUtil.formatAmount(paysAmount,SCALE), paysCur, CaclUtil.formatAmount(getsAmount,SCALE), getsCur));
// 成交价格
String price;
String token;
if (TextUtils.equals(KEY_CNY, getsCur)) {
price = amountRatio(getsAmount, paysAmount);
token = WConstant.CURRENCY_CNT;
}else if (TextUtils.equals(KEY_CNY, paysCur)) {
price = amountRatio(paysAmount, getsAmount);
token = WConstant.CURRENCY_CNT;
}else if (TextUtils.equals(KEY_SWT, getsCur)) {
price = amountRatio(getsAmount, paysAmount);
token = WConstant.CURRENCY_SWTC;
}else {
price = amountRatio(paysAmount, getsAmount);
token = paysCur.split("_")[0];
}
if (!TextUtils.equals("0", price)) {
mLayoutTurnoverValue.setVisibility(View.VISIBLE);
mTvTurnoverValue.setText(CaclUtil.formatAmount(price,6));
mTvTurnoverValueToken.setText(token);
}
}
// 委托
String getsValue =mTransactions.getGets().getValue();
String paysValue =mTransactions.getPays().getValue();
mLayoutEntrustAmount.setVisibility(View.VISIBLE);
mTvEntrustContent.setText(formatHtml(CaclUtil.formatAmount(paysValue,SCALE), paysCur, CaclUtil.formatAmount(getsValue,SCALE), getsCur));
// 委托价格
String price;
String token;
if (TextUtils.equals(KEY_CNY, getsCur)) {
price = amountRatio(getsValue, paysValue);
token = WConstant.CURRENCY_CNT;
}else if (TextUtils.equals(KEY_CNY, paysCur)) {
price = amountRatio(paysValue, getsValue);
token = WConstant.CURRENCY_CNT;
}else if (TextUtils.equals(KEY_SWT, getsCur)) {
price = amountRatio(getsValue, paysValue);
token = WConstant.CURRENCY_SWTC;
}else {
price = amountRatio(paysValue, getsValue);
token = paysCur.split("_")[0];
}
if (!TextUtils.equals("0", price)) {
mLayoutValue.setVisibility(View.VISIBLE);
mTvValue.setText(CaclUtil.formatAmount(price,6));
mTvValueToken.setText(token);
}
mFrom = currentAddr;
mTvFrom.setText(mFrom);
}
网友评论