|
|
@@ -0,0 +1,167 @@
|
|
|
+package com.xzjmyk.pm.activity.ui.message;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+
|
|
|
+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.ui.base.BaseActivity;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+
|
|
|
+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 SubscriptionAdapter adapter;
|
|
|
+ private SubscriptionActivity activity = this;
|
|
|
+
|
|
|
+ @Override//设置右划退出
|
|
|
+ public void setTouch(boolean b) {
|
|
|
+ super.setTouch(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_subscription);
|
|
|
+ initView();
|
|
|
+ init();//初始化数据
|
|
|
+ }
|
|
|
+
|
|
|
+ private void init() {
|
|
|
+ //TODO SubscriptionBeans获取数据 。。。。
|
|
|
+ SubscriptionBean bean = null;
|
|
|
+ SubscriptionBeans = new ArrayList<>();
|
|
|
+ ArrayList<SubscriptionBean.SubscriptionMessage> messages = null;
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ 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((int) (Math.random() * 2));
|
|
|
+ message.setUrl("ss");
|
|
|
+ messages.add(message);
|
|
|
+ }
|
|
|
+ bean.setSubscriptionMessages(messages);
|
|
|
+ SubscriptionBeans.add(bean);
|
|
|
+ }
|
|
|
+ listView.getRefreshableView().setAdapter(adapter);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
+ listView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
|
|
|
+ adapter = new SubscriptionAdapter();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //外层list
|
|
|
+ class SubscriptionAdapter extends BaseAdapter {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return SubscriptionBeans.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return SubscriptionBeans.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View contextView, ViewGroup viewGroup) {
|
|
|
+ ListView listview = null;
|
|
|
+ if (contextView == null) {
|
|
|
+ contextView = LayoutInflater.from(activity).inflate(R.layout.subscription, null);
|
|
|
+ listview = (ListView) contextView.findViewById(R.id.listview);
|
|
|
+ contextView.setTag(listview);
|
|
|
+ } else {
|
|
|
+ listview = (ListView) contextView.getTag();
|
|
|
+ }
|
|
|
+ listview.setAdapter(new ListAdapter(SubscriptionBeans.get(position).getSubscriptionMessages()));
|
|
|
+ return contextView;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //内层list
|
|
|
+ class ListAdapter extends BaseAdapter {
|
|
|
+
|
|
|
+ private ArrayList<SubscriptionBean.SubscriptionMessage> SubscriptionMessages; //当天消息列表
|
|
|
+
|
|
|
+ private ListAdapter(ArrayList<SubscriptionBean.SubscriptionMessage> SubscriptionMessages) {
|
|
|
+ this.SubscriptionMessages = SubscriptionMessages;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return SubscriptionMessages.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return SubscriptionMessages.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemViewType(int position) {
|
|
|
+ return SubscriptionMessages.get(position).getTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int i, View contextView, ViewGroup viewGroup) {
|
|
|
+ VieweHolder holder = null;
|
|
|
+ if (contextView == null) {
|
|
|
+ holder = new VieweHolder();
|
|
|
+ contextView = LayoutInflater.from(activity).inflate(R.layout.bigimage_subscription, null);
|
|
|
+ holder.ll = (LinearLayout) contextView.findViewById(R.id.small_ll);
|
|
|
+ holder.rl = (RelativeLayout) contextView.findViewById(R.id.big_rl);
|
|
|
+ contextView.setTag(holder);
|
|
|
+ } else {
|
|
|
+ holder = (VieweHolder) contextView.getTag();
|
|
|
+ }
|
|
|
+ if (getItemViewType(i) == TAG_BIG) {
|
|
|
+ holder.ll.setVisibility(View.GONE);
|
|
|
+ holder.rl.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ holder.ll.setVisibility(View.VISIBLE);
|
|
|
+ holder.rl.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ return contextView;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ class VieweHolder {
|
|
|
+ LinearLayout ll;
|
|
|
+ RelativeLayout rl;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|