|
@@ -12,14 +12,16 @@ import android.widget.TextView;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.liaobo.im.R;
|
|
|
-import com.liaobo.im.bean.redpacket.RedListItemRecive;
|
|
|
-import com.liaobo.im.bean.redpacket.RedListItemSend;
|
|
|
+import com.liaobo.im.bean.redpacket.RedPacketReceviceBean;
|
|
|
+import com.liaobo.im.bean.redpacket.RedPacketSendBean;
|
|
|
import com.liaobo.im.db.InternationalizationHelper;
|
|
|
import com.liaobo.im.ui.base.BaseActivity;
|
|
|
import com.liaobo.im.ui.smarttab.SmartTabLayout;
|
|
|
import com.liaobo.im.xuan.xuanhttplibrary.okhttp.HttpUtils;
|
|
|
+import com.liaobo.im.xuan.xuanhttplibrary.okhttp.callback.BaseCallback;
|
|
|
import com.liaobo.im.xuan.xuanhttplibrary.okhttp.callback.ListCallback;
|
|
|
import com.liaobo.im.xuan.xuanhttplibrary.okhttp.result.ArrayResult;
|
|
|
+import com.liaobo.im.xuan.xuanhttplibrary.okhttp.result.ObjectResult;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -47,8 +49,8 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
private PullToRefreshListView pullToRefreshListViewRedrecive;
|
|
|
private PullToRefreshListView pullToRefreshListViewRedsend;
|
|
|
// 数据集合
|
|
|
- private List<RedListItemSend> sendRedList;
|
|
|
- private List<RedListItemRecive> reciveRedList;
|
|
|
+ private RedPacketSendBean redSendBean;
|
|
|
+ private RedPacketReceviceBean mRedPacketReceviceBean;
|
|
|
// 表示发出的还是接受的红包list 0代表收到 1代表发出
|
|
|
private int adapterType;
|
|
|
// 两个listview数据加载的页数
|
|
@@ -80,8 +82,8 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
mTitleList = new ArrayList<String>();
|
|
|
views = new ArrayList<View>();
|
|
|
|
|
|
- sendRedList = new ArrayList<RedListItemSend>();
|
|
|
- reciveRedList = new ArrayList<RedListItemRecive>();
|
|
|
+ redSendBean = new RedPacketSendBean();
|
|
|
+ mRedPacketReceviceBean = new RedPacketReceviceBean();
|
|
|
// mTitleList.add("收到的红包");
|
|
|
// mTitleList.add("发出的红包");
|
|
|
mTitleList.add(InternationalizationHelper.getString("PACKETS_RECEIVED"));
|
|
@@ -148,16 +150,21 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
params.put("access_token", coreManager.getSelfStatus().accessToken);
|
|
|
params.put("pageIndex", pageIndexSend + "");
|
|
|
params.put("pageSize", 25 + "");
|
|
|
+ params.put("secret","");
|
|
|
|
|
|
HttpUtils.get().url(coreManager.getConfig().SEND_REDPACKET_LIST_GET)
|
|
|
.params(params)
|
|
|
.build()
|
|
|
- .execute(new ListCallback<RedListItemSend>(RedListItemSend.class) {
|
|
|
+ .execute(new BaseCallback<RedPacketSendBean>(RedPacketSendBean.class) {
|
|
|
+
|
|
|
@Override
|
|
|
- public void onResponse(ArrayResult<RedListItemSend> result) {
|
|
|
- if (result.getData().size() > 0) {
|
|
|
- for (RedListItemSend redListItemSend : result.getData()) {
|
|
|
- sendRedList.add(redListItemSend);
|
|
|
+ public void onResponse(ObjectResult<RedPacketSendBean> result) {
|
|
|
+ if (result!=null && result.getData()!=null && result.getData().getList()!=null && result.getData().getList().size() > 0) {
|
|
|
+ if (redSendBean.getList()==null){
|
|
|
+ redSendBean.setList(new ArrayList<>());
|
|
|
+ }
|
|
|
+ for (RedPacketSendBean.RedSendRedItemEntry item : result.getData().getList()) {
|
|
|
+ redSendBean.getList().add(item);
|
|
|
}
|
|
|
redListItemAdapter.notifyDataSetChanged();
|
|
|
pageIndexSend++;
|
|
@@ -167,6 +174,7 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
|
|
|
@Override
|
|
|
public void onError(Call call, Exception e) {
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -180,12 +188,17 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
HttpUtils.get().url(coreManager.getConfig().RECIVE_REDPACKET_LIST_GET)
|
|
|
.params(params)
|
|
|
.build()
|
|
|
- .execute(new ListCallback<RedListItemRecive>(RedListItemRecive.class) {
|
|
|
+ .execute(new BaseCallback<RedPacketReceviceBean>(RedPacketReceviceBean.class) {
|
|
|
+
|
|
|
@Override
|
|
|
- public void onResponse(ArrayResult<RedListItemRecive> result) {
|
|
|
- if (result.getData().size() > 0) {
|
|
|
- for (RedListItemRecive redListItemRecive : result.getData()) {
|
|
|
- reciveRedList.add(redListItemRecive);
|
|
|
+ public void onResponse(ObjectResult<RedPacketReceviceBean> result) {
|
|
|
+
|
|
|
+ if (mRedPacketReceviceBean.getList()==null){
|
|
|
+ mRedPacketReceviceBean.setList(new ArrayList<>());
|
|
|
+ }
|
|
|
+ if (result!=null && result.getData()!=null&& result.getData().getList()!=null && result.getData().getList().size() > 0) {
|
|
|
+ for (RedPacketReceviceBean.RedPacketReceviceItemEntity itemEntity : result.getData().getList()) {
|
|
|
+ mRedPacketReceviceBean.getList().add(itemEntity);
|
|
|
}
|
|
|
redListItemAdapter.notifyDataSetChanged();
|
|
|
getPageIndexRecive++;
|
|
@@ -261,9 +274,11 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
public int getCount() {
|
|
|
|
|
|
if (adapterType == 0) {
|
|
|
- return reciveRedList.size();
|
|
|
+ if (mRedPacketReceviceBean.getList()==null) return 0;
|
|
|
+ return mRedPacketReceviceBean.getList().size();
|
|
|
} else {
|
|
|
- return sendRedList.size();
|
|
|
+ if (redSendBean.getList()==null) return 0;
|
|
|
+ return redSendBean.getList().size();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -294,14 +309,14 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
}
|
|
|
|
|
|
if (adapterType == 0) {
|
|
|
- long lcc_time = Long.valueOf(reciveRedList.get(position).getTime());
|
|
|
+ long lcc_time = mRedPacketReceviceBean.getList().get(position).getTime();
|
|
|
String StrTime = sdf.format(new Date(lcc_time * 1000L));
|
|
|
- redViewHolder.userNameTv.setText(reciveRedList.get(position).getSendName());
|
|
|
+ redViewHolder.userNameTv.setText(mRedPacketReceviceBean.getList().get(position).getSendName());
|
|
|
redViewHolder.timeTv.setText(StrTime);
|
|
|
- redViewHolder.moneyTv.setText(df.format(reciveRedList.get(position).getMoney()) + InternationalizationHelper.getString("YUAN"));
|
|
|
+ redViewHolder.moneyTv.setText(df.format(mRedPacketReceviceBean.getList().get(position).getMoney()) + InternationalizationHelper.getString("YUAN"));
|
|
|
} else if (adapterType == 1) {
|
|
|
|
|
|
- switch (sendRedList.get(position).getType()) {
|
|
|
+ switch (redSendBean.getList().get(position).getType()) {
|
|
|
case 1: {
|
|
|
// redViewHolder.userNameTv.setText("普通红包");
|
|
|
redViewHolder.userNameTv.setText(InternationalizationHelper.getString("JX_UsualGift"));
|
|
@@ -320,10 +335,10 @@ public class RedListActivity extends BaseActivity implements View.OnClickListene
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- long lcc_time = Long.valueOf(sendRedList.get(position).getSendTime());
|
|
|
+ long lcc_time = (long) redSendBean.getList().get(position).getSendTime();
|
|
|
String StrTime = sdf.format(new Date(lcc_time * 1000L));
|
|
|
redViewHolder.timeTv.setText(StrTime);
|
|
|
- redViewHolder.moneyTv.setText(df.format(sendRedList.get(position).getMoney()) + InternationalizationHelper.getString("YUAN"));
|
|
|
+ redViewHolder.moneyTv.setText(df.format(redSendBean.getList().get(position).getMoney()) + InternationalizationHelper.getString("YUAN"));
|
|
|
}
|
|
|
return convertView;
|
|
|
}
|