|
|
@@ -1,18 +1,40 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.activity.message;
|
|
|
|
|
|
+import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+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.ui.erp.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
+import com.xzjmyk.pm.activity.util.DateFormatUtil;
|
|
|
import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* @desc:
|
|
|
* @author:Arison on 2016/11/1
|
|
|
@@ -24,55 +46,363 @@ public class ProcessMsgActivity extends BaseActivity implements View.OnClickList
|
|
|
@ViewInject(R.id.lv_process)
|
|
|
PullToRefreshListView mList;
|
|
|
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+
|
|
|
@ViewInject(R.id.tv_process_me)
|
|
|
private TextView tv_process_me;
|
|
|
@ViewInject(R.id.tv_process_already)
|
|
|
private TextView tv_process_already;
|
|
|
@ViewInject(R.id.tv_process_un)
|
|
|
private TextView tv_process_un;
|
|
|
+
|
|
|
+ @ViewInject(R.id.back)
|
|
|
+ private ImageView iv_back;
|
|
|
+
|
|
|
+ private ProcessAdapter mAdapter;
|
|
|
+ private JSONArray array=new JSONArray();
|
|
|
+
|
|
|
+ private int tab_type=1;
|
|
|
+ private int page=1;
|
|
|
+ private final int SUSSCESS_un=1;
|
|
|
+ private final int SUSSCESS_already=2;
|
|
|
+ private final int SUSSCESS_me=3;
|
|
|
+
|
|
|
|
|
|
|
|
|
+ private Handler mHandler=new Handler(){
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ String result=msg.getData().getString("result");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mList.onRefreshComplete();
|
|
|
+
|
|
|
+ switch (msg.what){
|
|
|
+ case SUSSCESS_un:
|
|
|
+ JSONArray itemArray= JSON.parseObject(result).getJSONArray("data");
|
|
|
+ if(page==1)array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ if (mAdapter==null){
|
|
|
+ mAdapter=new ProcessAdapter(ct,array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ }else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size()==0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SUSSCESS_already:
|
|
|
+ itemArray= JSON.parseObject(result).getJSONArray("data");
|
|
|
+ if(page==1)array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ if (mAdapter==null){
|
|
|
+ mAdapter=new ProcessAdapter(ct,array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ }else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size()==0){
|
|
|
+
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SUSSCESS_me:
|
|
|
+ itemArray= JSON.parseObject(result).getJSONArray("data");
|
|
|
+ if(page==1)array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ if (mAdapter==null){
|
|
|
+ mAdapter=new ProcessAdapter(ct,array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ }else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size()==0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ ToastMessage(result);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_process_msg);
|
|
|
ViewUtils.inject(this);
|
|
|
initView();
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initData() {
|
|
|
+ loadProcessToDo(page);
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mList.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.showLoading();
|
|
|
+
|
|
|
View view = LayoutInflater.from(ct).inflate(R.layout.process_header, null);
|
|
|
ActionBar bar = this.getSupportActionBar();
|
|
|
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
tv_process_already= (TextView) view.findViewById(R.id.tv_process_already);
|
|
|
tv_process_un= (TextView) view.findViewById(R.id.tv_process_un);
|
|
|
tv_process_me= (TextView) view.findViewById(R.id.tv_process_me);
|
|
|
+ iv_back= (ImageView) view.findViewById(R.id.back);
|
|
|
bar.setCustomView(view);
|
|
|
tv_process_already.setOnClickListener(this);
|
|
|
tv_process_me.setOnClickListener(this);
|
|
|
tv_process_un.setOnClickListener(this);
|
|
|
tv_process_un.setSelected(true);
|
|
|
- }
|
|
|
+ iv_back.setOnClickListener(this);
|
|
|
+ //mList.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ mList.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
+ @Override
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ page=1;
|
|
|
+ switch (tab_type){
|
|
|
+ case 1:
|
|
|
+ loadProcessToDo(page);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ page++;
|
|
|
+ switch (tab_type){
|
|
|
+ case 1:
|
|
|
+ loadProcessToDo(page);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ ProcessAdapter.ViewModel model= (ProcessAdapter.ViewModel) view.getTag();
|
|
|
+ String title="";
|
|
|
+ switch (tab_type){
|
|
|
+ case 1:
|
|
|
+ title="待审批";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ title="已审批";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ title="我发起的";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String url="jsps/mobile/jprocand.jsp?nodeId="+model.JP_NODEID;
|
|
|
+ CommonUtil.loadWebView(ct,url,title,CommonUtil.getSharedPreferences(ct,"erp_master"),null,null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()){
|
|
|
case R.id.tv_process_un:
|
|
|
+ page=1;
|
|
|
+ tab_type=1;
|
|
|
tv_process_un.setSelected(true);
|
|
|
tv_process_already.setSelected(false);
|
|
|
tv_process_me.setSelected(false);
|
|
|
+ loadProcessToDo(page);
|
|
|
break;
|
|
|
case R.id.tv_process_already:
|
|
|
+ page=1;
|
|
|
+ tab_type=2;
|
|
|
tv_process_un.setSelected(false);
|
|
|
tv_process_already.setSelected(true);
|
|
|
tv_process_me.setSelected(false);
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
break;
|
|
|
case R.id.tv_process_me:
|
|
|
+ page=1;
|
|
|
+ tab_type=3;
|
|
|
tv_process_un.setSelected(false);
|
|
|
tv_process_already.setSelected(false);
|
|
|
tv_process_me.setSelected(true);
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+ break;
|
|
|
+ case R.id.back:
|
|
|
+ onBackPressed();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void loadProcessToDo(int page){
|
|
|
+ progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/toDo.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ // count=10&page=1&limit=25
|
|
|
+ params.put("count","10");
|
|
|
+ params.put("page",page);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_un, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void loadProcesstoAlreadyDo(int page){
|
|
|
+ progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/alreadyDo.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("count","10");
|
|
|
+ params.put("page",page);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_already, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void loadProcessAlreadyLaunch(int page){
|
|
|
+ progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/alreadyLaunch.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("count","10");
|
|
|
+ params.put("page",page);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_me, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public class ProcessAdapter extends BaseAdapter{
|
|
|
+
|
|
|
+ private Context ct;
|
|
|
+ private LayoutInflater inflater;
|
|
|
+ private JSONArray jsonArray;
|
|
|
+
|
|
|
+ ProcessAdapter(Context ct,JSONArray array){
|
|
|
+ this.ct=ct;
|
|
|
+ this.jsonArray=array;
|
|
|
+ this.inflater=LayoutInflater.from(ct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return jsonArray==null?0:jsonArray.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ ViewModel model=null;
|
|
|
+ if(convertView==null){
|
|
|
+ convertView= inflater.inflate(R.layout.item_process_state,parent,false);
|
|
|
+ model=new ViewModel();
|
|
|
+ model.name= (TextView) convertView.findViewById(R.id.tv_name);
|
|
|
+ model.date= (TextView) convertView.findViewById(R.id.tv_date);
|
|
|
+ model.status= (TextView) convertView.findViewById(R.id.tv_status);
|
|
|
+ convertView.setTag(model);
|
|
|
+ }else{
|
|
|
+ model= (ViewModel) convertView.getTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (tab_type){
|
|
|
+ case 1:
|
|
|
+ //JP_LAUNCHERNAME
|
|
|
+ //JP_NAME
|
|
|
+ //JP_STATUS
|
|
|
+ //JP_LAUNCHTIME
|
|
|
+ String jp_launchername=jsonArray.getJSONObject(position).getString("JP_LAUNCHERNAME");
|
|
|
+ String jp_name=jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ String JP_NODEID=jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ if (!StringUtils.isEmpty(jp_name))jp_name=jp_name.replace("流程","");
|
|
|
+ long jp_launchtime=jsonArray.getJSONObject(position).getLong("JP_LAUNCHTIME");
|
|
|
+ String jp_status=jsonArray.getJSONObject(position).getString("JP_STATUS");
|
|
|
+
|
|
|
+ model.name.setText(jp_launchername+"的"+jp_name);
|
|
|
+ model.date.setText(DateFormatUtil.getStrDate4Date(new Date(jp_launchtime),"yyyy-MM-dd HH:mm"));
|
|
|
+ model.status.setText(jp_status);
|
|
|
+ model.JP_NODEID=JP_NODEID;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //JN_DEALMANNAME
|
|
|
+ //JP_NAME
|
|
|
+ //JN_DEALTIME
|
|
|
+ //JN_DEALRESULT
|
|
|
+ String jn_dealmanname=jsonArray.getJSONObject(position).getString("JN_DEALMANNAME");
|
|
|
+ jp_name=jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ JP_NODEID=jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ if (!StringUtils.isEmpty(jp_name))jp_name=jp_name.replace("流程","");
|
|
|
+ String jn_dealtime=jsonArray.getJSONObject(position).getString("JN_DEALTIME");
|
|
|
+ String jn_dealresult=jsonArray.getJSONObject(position).getString("JN_DEALRESULT");
|
|
|
+
|
|
|
+ model.name.setText(jn_dealmanname+"的"+jp_name);
|
|
|
+ model.date.setText(jn_dealtime);
|
|
|
+ model.status.setText(jn_dealresult);
|
|
|
+ model.JP_NODEID=JP_NODEID;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //JP_CODEVALUE
|
|
|
+ //JP_NODEDEALMANNAME
|
|
|
+ //JP_STATUS
|
|
|
+ //JP_LAUNCHTIME
|
|
|
+ //JP_NODEDEALMANNAME
|
|
|
+ long time=jsonArray.getJSONObject(position).getLong("JP_LAUNCHTIME");
|
|
|
+ String name=jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ String code=jsonArray.getJSONObject(position).getString("JP_CODEVALUE");
|
|
|
+ String status=jsonArray.getJSONObject(position).getString("JP_STATUS");
|
|
|
+ String nodename=jsonArray.getJSONObject(position).getString("JP_NODEDEALMANNAME");
|
|
|
+ JP_NODEID=jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ if (!StringUtils.isEmpty(status))
|
|
|
+ {
|
|
|
+ if (status.equals("待审批")){
|
|
|
+ status="等待"+nodename+"审批";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(name))name=name.substring(0,name.length()-2);
|
|
|
+ model.name.setText(name+"-"+code);
|
|
|
+ model.date.setText(DateFormatUtil.getStrDate4Date(new Date(time),"yyyy-MM-dd HH:mm"));
|
|
|
+ model.status.setText(status);
|
|
|
+ model.JP_NODEID=JP_NODEID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ class ViewModel{
|
|
|
+ TextView name;
|
|
|
+ TextView date;
|
|
|
+ TextView status;
|
|
|
+ String JP_NODEID;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|