|
|
@@ -1,6 +1,7 @@
|
|
|
package com.xzjmyk.pm.activity.ui.message;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -13,7 +14,8 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
-import com.xzjmyk.pm.activity.bean.message.SubscriptionBean;
|
|
|
+import com.xzjmyk.pm.activity.bean.message.SubscriptionMessage;
|
|
|
+import com.xzjmyk.pm.activity.db.dao.SubscriptionDao;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
@@ -25,7 +27,7 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
private static final int TAG_BIG = 1;
|
|
|
private static final int TAG_SUB = 2;
|
|
|
private PullToRefreshListView listView;
|
|
|
- private ArrayList<SubscriptionBean> SubscriptionBeans;
|
|
|
+ private ArrayList<SubscriptionMessage> SubscriptionMessages;
|
|
|
private SubscriptionAdapter adapter;
|
|
|
private SubscriptionActivity activity = this;
|
|
|
|
|
|
@@ -39,31 +41,40 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_subscription);
|
|
|
initView();
|
|
|
- init();//初始化数据
|
|
|
+ init2();//初始化数据
|
|
|
}
|
|
|
-
|
|
|
private void init() {
|
|
|
- SubscriptionBean bean = null;
|
|
|
- SubscriptionBeans = new ArrayList<>();
|
|
|
- ArrayList<SubscriptionBean.SubscriptionMessage> messages = null;
|
|
|
- for (int i = 0; i < 5; ) {
|
|
|
- bean = new SubscriptionBean();
|
|
|
- bean.setSize(5);
|
|
|
- bean.setTime("2012-11-0" + (++i));
|
|
|
- messages = new ArrayList<>();
|
|
|
- for (int j = 0; j < 6; j++) {
|
|
|
- SubscriptionBean.SubscriptionMessage message = bean.getSubscriptionMessage();
|
|
|
- message.setImgUrl("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1642940013,2147239593&fm=111&gp=0.jpg");
|
|
|
- message.setSub("这个一个测试信息:" + "其中j==" + j + "\ni==" + i);
|
|
|
- message.setTag(j == 0 ? 1 : 2);
|
|
|
- message.setUrl("ss");
|
|
|
- messages.add(message);
|
|
|
+ //TODO 测试保存
|
|
|
+ SubscriptionMessages = new ArrayList<>();
|
|
|
+ SubscriptionMessage message = null;
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ message = new SubscriptionMessage();
|
|
|
+ message.setId_(i);
|
|
|
+ message.setData_("2016-10-0" + i);
|
|
|
+ message.setTitle_("这是标题" + i);
|
|
|
+ message.setSon_title_("这是副标题" + i);
|
|
|
+ message.setStatus(1);
|
|
|
+ message.setNum_id(101);
|
|
|
+ message.setInstance_id(101);
|
|
|
+ message.setCreatedate_("201120100");
|
|
|
+ ArrayList<SubscriptionMessage.SubscriptionBean> beans = new ArrayList<>();
|
|
|
+ for (int j = 0; j < 5; j++) {
|
|
|
+ SubscriptionMessage.SubscriptionBean bean = message.getNewBean();
|
|
|
+ bean.setId(j);
|
|
|
+ bean.setImageUrl("http://img0.bdstatic.com/img/image/shouye/xiaoxiao/%E5%8A%A8%E7%89%A9527.jpg");
|
|
|
+ bean.setSubTitle("设个是一个标题,关于内容的标题,是一个简介,第三行会议省略号形式出现" + j);
|
|
|
}
|
|
|
- bean.setSubscriptionMessages(messages);
|
|
|
- SubscriptionBeans.add(bean);
|
|
|
+ message.setBeans(beans);
|
|
|
+ SubscriptionMessages.add(message);
|
|
|
}
|
|
|
- listView.getRefreshableView().setAdapter(adapter);
|
|
|
+ long i = SubscriptionDao.getInstance().addMessage(SubscriptionMessages);
|
|
|
+ Log.i("gongpengming", "i=" + i);
|
|
|
+ }
|
|
|
|
|
|
+ private void init2() {
|
|
|
+ SubscriptionMessages = SubscriptionDao.getInstance().findAll();
|
|
|
+ Log.i("gong", SubscriptionMessages.size() + "");
|
|
|
+ listView.setAdapter(adapter);
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
@@ -71,17 +82,16 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
adapter = new SubscriptionAdapter();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//外层list
|
|
|
class SubscriptionAdapter extends BaseAdapter {
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return SubscriptionBeans.size();
|
|
|
+ return SubscriptionMessages.size();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object getItem(int position) {
|
|
|
- return SubscriptionBeans.get(position);
|
|
|
+ return SubscriptionMessages.get(position);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -98,18 +108,16 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
viewholder = new Viewholder();
|
|
|
viewholder.tvTime = (TextView) contextView.findViewById(R.id.tvTime);
|
|
|
viewholder.listview = (MyListView) contextView.findViewById(R.id.listview);
|
|
|
- viewholder.adapter = new ListAdapter(SubscriptionBeans.get(position).getSubscriptionMessages());
|
|
|
+ viewholder.adapter = new ListAdapter(SubscriptionMessages.get(position).getBeans());
|
|
|
contextView.setTag(viewholder);
|
|
|
} else {
|
|
|
viewholder = (Viewholder) contextView.getTag();
|
|
|
}
|
|
|
- viewholder.tvTime.setText(SubscriptionBeans.get(position).getTime());
|
|
|
+ viewholder.tvTime.setText(SubscriptionMessages.get(position).getData_());
|
|
|
viewholder.listview.setAdapter(viewholder.adapter);
|
|
|
- viewholder.listview.setTag(SubscriptionBeans.get(position));
|
|
|
viewholder.listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- SubscriptionBean.SubscriptionMessage bean = SubscriptionBeans.get(position).getSubscriptionMessages().get(i);
|
|
|
//TODO 点击跳到web页面
|
|
|
ViewUtil.WebLinks(activity, "http://blog.csdn.net/androidzhaoxiaogang/article/details/8797539", "测试");
|
|
|
}
|
|
|
@@ -129,20 +137,20 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
//内层list
|
|
|
class ListAdapter extends BaseAdapter {
|
|
|
|
|
|
- private ArrayList<SubscriptionBean.SubscriptionMessage> SubscriptionMessages; //当天消息列表
|
|
|
+ private ArrayList<SubscriptionMessage.SubscriptionBean> beans; //当天消息列表
|
|
|
|
|
|
- private ListAdapter(ArrayList<SubscriptionBean.SubscriptionMessage> SubscriptionMessages) {
|
|
|
- this.SubscriptionMessages = SubscriptionMessages;
|
|
|
+ private ListAdapter(ArrayList<SubscriptionMessage.SubscriptionBean> beans) {
|
|
|
+ this.beans = beans;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return SubscriptionMessages.size();
|
|
|
+ return beans.size();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object getItem(int position) {
|
|
|
- return SubscriptionMessages.get(position);
|
|
|
+ return beans.get(position);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -150,10 +158,6 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
return position;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public int getItemViewType(int position) {
|
|
|
- return SubscriptionMessages.get(position).getTag();
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public View getView(int i, View contextView, ViewGroup viewGroup) {
|
|
|
@@ -174,11 +178,11 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
if (getItemViewType(i) == TAG_BIG) {
|
|
|
holder.ll.setVisibility(View.GONE);
|
|
|
holder.rl.setVisibility(View.VISIBLE);
|
|
|
- holder.big_tv.setText(SubscriptionMessages.get(i).getSub());
|
|
|
+ holder.big_tv.setText(beans.get(i).getSubTitle());
|
|
|
} else {
|
|
|
holder.ll.setVisibility(View.VISIBLE);
|
|
|
holder.rl.setVisibility(View.GONE);
|
|
|
- holder.small_tv.setText(SubscriptionMessages.get(i).getSub());
|
|
|
+ holder.small_tv.setText(beans.get(i).getSubTitle());
|
|
|
}
|
|
|
return contextView;
|
|
|
}
|