|
@@ -1,7 +1,8 @@
|
|
|
package com.xzjmyk.pm.activity.ui.message;
|
|
package com.xzjmyk.pm.activity.ui.message;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
-import android.util.Log;
|
|
|
|
|
|
|
+import android.os.Handler;
|
|
|
|
|
+import android.os.Message;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -9,26 +10,59 @@ import android.widget.AdapterView;
|
|
|
import android.widget.BaseAdapter;
|
|
import android.widget.BaseAdapter;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
|
|
+import android.widget.ListView;
|
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
|
|
+import com.xzjmyk.pm.activity.bean.message.SortSubsrciprion;
|
|
|
import com.xzjmyk.pm.activity.bean.message.SubscriptionMessage;
|
|
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.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
|
|
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONException;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SubscriptionActivity extends BaseActivity {
|
|
public class SubscriptionActivity extends BaseActivity {
|
|
|
- private static final int TAG_BIG = 1;
|
|
|
|
|
|
|
+ private String baseUrl = "http://218.17.158.219:8090/ERP//";
|
|
|
private PullToRefreshListView listView;
|
|
private PullToRefreshListView listView;
|
|
|
private ArrayList<SubscriptionMessage> SubscriptionMessages;
|
|
private ArrayList<SubscriptionMessage> SubscriptionMessages;
|
|
|
private SubscriptionAdapter adapter;
|
|
private SubscriptionAdapter adapter;
|
|
|
private SubscriptionActivity activity = this;
|
|
private SubscriptionActivity activity = this;
|
|
|
|
|
+ private ArrayList<SortSubsrciprion> sortSubsrciprions;
|
|
|
|
|
+ private Handler handler = new Handler() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
|
|
+ if (msg.what == 2) {
|
|
|
|
|
+ String message = (String) msg.getData().get("result");
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject object = new JSONObject(message);
|
|
|
|
|
+ JSONArray array = object.getJSONArray("data");
|
|
|
|
|
+ SubscriptionMessages = (ArrayList<SubscriptionMessage>) JSON.parseArray(array.toString(), SubscriptionMessage.class);
|
|
|
|
|
+ setData();
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if (Constants.APP_SOCKETIMEOUTEXCEPTION == msg.what) {
|
|
|
|
|
+ //错误信息
|
|
|
|
|
+ String message = (String) msg.getData().get("result");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
@Override//设置右划退出
|
|
@Override//设置右划退出
|
|
|
public void setTouch(boolean b) {
|
|
public void setTouch(boolean b) {
|
|
@@ -39,58 +73,87 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_subscription);
|
|
setContentView(R.layout.activity_subscription);
|
|
|
- initView();
|
|
|
|
|
- init2();//初始化数据
|
|
|
|
|
- }
|
|
|
|
|
- private void init() {
|
|
|
|
|
- //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);
|
|
|
|
|
|
|
+ listView = (PullToRefreshListView) findViewById(R.id.listview);
|
|
|
|
|
+ listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
|
|
+ cancelData();
|
|
|
|
|
+ initData();
|
|
|
}
|
|
}
|
|
|
- message.setBeans(beans);
|
|
|
|
|
- SubscriptionMessages.add(message);
|
|
|
|
|
- }
|
|
|
|
|
- long i = SubscriptionDao.getInstance().addMessage(SubscriptionMessages);
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ initData();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ private void cancelData() {
|
|
|
|
|
+ if (sortSubsrciprions != null) {
|
|
|
|
|
+ SubscriptionMessages.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (SubscriptionMessages != null) {
|
|
|
|
|
+ SubscriptionMessages.clear();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void init2() {
|
|
|
|
|
- SubscriptionMessages = SubscriptionDao.getInstance().findAll();
|
|
|
|
|
- Log.i("gong", SubscriptionMessages.size() + "");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void setData() {
|
|
|
|
|
+
|
|
|
|
|
+ if (SubscriptionMessages == null || SubscriptionMessages.size() <= 0) return;
|
|
|
|
|
+ saveDataToDB();
|
|
|
|
|
+ sortSubsrciprions = new ArrayList<>();
|
|
|
|
|
+ SortSubsrciprion sortSubsrciprion = null;
|
|
|
|
|
+ for (int i = 0; i < SubscriptionMessages.size(); i++) {
|
|
|
|
|
+ sortSubsrciprion = new SortSubsrciprion();
|
|
|
|
|
+ sortSubsrciprion.num_id = SubscriptionMessages.get(i).getNUM_ID_();
|
|
|
|
|
+ sortSubsrciprion.beans = new ArrayList<>();
|
|
|
|
|
+ sortSubsrciprion.beans.add(SubscriptionMessages.get(i));
|
|
|
|
|
+ if (sortSubsrciprions.size() > 0) {
|
|
|
|
|
+ for (int j = 0; j < sortSubsrciprions.size(); j++) {
|
|
|
|
|
+ if (sortSubsrciprion.num_id == sortSubsrciprions.get(j).num_id) {//如果相同
|
|
|
|
|
+ sortSubsrciprions.get(j).beans.add(SubscriptionMessages.get(i));
|
|
|
|
|
+ break;
|
|
|
|
|
+ } else if (j == (sortSubsrciprions.size() - 1)) {//如果到最后一个都不相同
|
|
|
|
|
+ sortSubsrciprions.add(sortSubsrciprion);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sortSubsrciprions.add(sortSubsrciprion);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ adapter = new SubscriptionAdapter();
|
|
|
listView.setAdapter(adapter);
|
|
listView.setAdapter(adapter);
|
|
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
|
|
+ if (listView.isRefreshing()) {
|
|
|
|
|
+ listView.setRefreshing(false);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void initView() {
|
|
|
|
|
- listView = (PullToRefreshListView) findViewById(R.id.listview);
|
|
|
|
|
- adapter = new SubscriptionAdapter();
|
|
|
|
|
|
|
+ private void saveDataToDB() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public void initData() {
|
|
|
|
|
+ String url = baseUrl + "common/desktop/subs/getSubs.action";
|
|
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("count", 2);
|
|
|
|
|
+ param.put("condition", "where to_char(createdate_,'yyyymmdd')='20160612'");
|
|
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(this, "sessionId"));
|
|
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(this, "sessionId"));
|
|
|
|
|
+ ViewUtil.httpSendRequest(this, url, param, handler, headers, 2, null, null, "get");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//外层list
|
|
//外层list
|
|
|
class SubscriptionAdapter extends BaseAdapter {
|
|
class SubscriptionAdapter extends BaseAdapter {
|
|
|
@Override
|
|
@Override
|
|
|
public int getCount() {
|
|
public int getCount() {
|
|
|
- return SubscriptionMessages.size();
|
|
|
|
|
|
|
+ return sortSubsrciprions.size();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Object getItem(int position) {
|
|
public Object getItem(int position) {
|
|
|
- return SubscriptionMessages.get(position);
|
|
|
|
|
|
|
+ return sortSubsrciprions.get(position);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -107,18 +170,22 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
viewholder = new Viewholder();
|
|
viewholder = new Viewholder();
|
|
|
viewholder.tvTime = (TextView) contextView.findViewById(R.id.tvTime);
|
|
viewholder.tvTime = (TextView) contextView.findViewById(R.id.tvTime);
|
|
|
viewholder.listview = (MyListView) contextView.findViewById(R.id.listview);
|
|
viewholder.listview = (MyListView) contextView.findViewById(R.id.listview);
|
|
|
- viewholder.adapter = new ListAdapter(SubscriptionMessages.get(position).getBeans());
|
|
|
|
|
|
|
+ viewholder.adapter = new ListAdapter(sortSubsrciprions.get(position).beans);
|
|
|
contextView.setTag(viewholder);
|
|
contextView.setTag(viewholder);
|
|
|
} else {
|
|
} else {
|
|
|
viewholder = (Viewholder) contextView.getTag();
|
|
viewholder = (Viewholder) contextView.getTag();
|
|
|
}
|
|
}
|
|
|
- viewholder.tvTime.setText(SubscriptionMessages.get(position).getData_());
|
|
|
|
|
viewholder.listview.setAdapter(viewholder.adapter);
|
|
viewholder.listview.setAdapter(viewholder.adapter);
|
|
|
viewholder.listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
viewholder.listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- //TODO 点击跳到web页面
|
|
|
|
|
- ViewUtil.WebLinks(activity, "http://blog.csdn.net/androidzhaoxiaogang/article/details/8797539", "测试");
|
|
|
|
|
|
|
+ SubscriptionMessage bean = sortSubsrciprions.get(position).beans.get(i);
|
|
|
|
|
+ String url = "http://218.17.158.219:8090/ERP//jsps/mobile/charts.jsp?" + "numId=" + bean.getNUM_ID_() +
|
|
|
|
|
+ "&mainId=" + bean.getINSTANCE_ID_() + "&insId=" + bean.getID_() +
|
|
|
|
|
+ "&title=" + bean.getSON_TITLE_();
|
|
|
|
|
+ ViewUtil.WebLinks(activity, url, "订阅");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
return contextView;
|
|
return contextView;
|
|
@@ -135,10 +202,9 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
|
|
|
|
|
//内层list
|
|
//内层list
|
|
|
class ListAdapter extends BaseAdapter {
|
|
class ListAdapter extends BaseAdapter {
|
|
|
|
|
+ private ArrayList<SubscriptionMessage> beans;
|
|
|
|
|
|
|
|
- private ArrayList<SubscriptionMessage.SubscriptionBean> beans; //当天消息列表
|
|
|
|
|
-
|
|
|
|
|
- private ListAdapter(ArrayList<SubscriptionMessage.SubscriptionBean> beans) {
|
|
|
|
|
|
|
+ private ListAdapter(ArrayList<SubscriptionMessage> beans) {
|
|
|
this.beans = beans;
|
|
this.beans = beans;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -174,14 +240,14 @@ public class SubscriptionActivity extends BaseActivity {
|
|
|
} else {
|
|
} else {
|
|
|
holder = (VieweHolder) contextView.getTag();
|
|
holder = (VieweHolder) contextView.getTag();
|
|
|
}
|
|
}
|
|
|
- if (getItemViewType(i) == TAG_BIG) {
|
|
|
|
|
|
|
+ if (i == 0) {
|
|
|
holder.ll.setVisibility(View.GONE);
|
|
holder.ll.setVisibility(View.GONE);
|
|
|
holder.rl.setVisibility(View.VISIBLE);
|
|
holder.rl.setVisibility(View.VISIBLE);
|
|
|
- holder.big_tv.setText(beans.get(i).getSubTitle());
|
|
|
|
|
|
|
+ holder.big_tv.setText(beans.get(i).getTITLE_());
|
|
|
} else {
|
|
} else {
|
|
|
holder.ll.setVisibility(View.VISIBLE);
|
|
holder.ll.setVisibility(View.VISIBLE);
|
|
|
holder.rl.setVisibility(View.GONE);
|
|
holder.rl.setVisibility(View.GONE);
|
|
|
- holder.small_tv.setText(beans.get(i).getSubTitle());
|
|
|
|
|
|
|
+ holder.small_tv.setText(beans.get(i).getTITLE_());
|
|
|
}
|
|
}
|
|
|
return contextView;
|
|
return contextView;
|
|
|
}
|
|
}
|