|
|
@@ -9,6 +9,9 @@ import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Looper;
|
|
|
import android.os.Message;
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
@@ -19,6 +22,7 @@ import android.view.WindowManager;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.AdapterView.OnItemClickListener;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
@@ -29,8 +33,15 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
+import com.iflytek.cloud.speech.RecognizerResult;
|
|
|
+import com.iflytek.cloud.speech.SpeechError;
|
|
|
+import com.iflytek.cloud.ui.RecognizerDialogListener;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
+import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
+import com.xzjmyk.pm.activity.MyApplication;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.JsonParser;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.VoiceToWord;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.adapter.NewSchedultAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.entity.AllProcess;
|
|
|
@@ -40,9 +51,12 @@ import com.xzjmyk.pm.activity.ui.erp.util.Blowfish;
|
|
|
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.FlexJsonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.ui.platform.task.TaskAddErpActivity;
|
|
|
+import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -50,6 +64,8 @@ import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @注释:任务书
|
|
|
@@ -57,7 +73,7 @@ import java.util.Map;
|
|
|
*/
|
|
|
|
|
|
@SuppressWarnings({"unused", "deprecation"})
|
|
|
-public class TaskActivity extends BaseActivity {
|
|
|
+public class TaskActivity extends BaseActivity implements OnClickListener,RecognizerDialogListener{
|
|
|
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
private Context context;
|
|
|
@@ -65,9 +81,26 @@ public class TaskActivity extends BaseActivity {
|
|
|
// private SchedultAdapter adapter;
|
|
|
private NewSchedultAdapter adapter;
|
|
|
private List<AllProcess> allList = new ArrayList<AllProcess>();
|
|
|
+ private List<AllProcess> waitList = new ArrayList<>();
|
|
|
+ private List<AllProcess> doneList = new ArrayList<>();
|
|
|
+ private List<AllProcess> isendList = new ArrayList<>();
|
|
|
+ private List<AllProcess> real_List = new ArrayList<>();
|
|
|
+ private String login_Name = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");;
|
|
|
private HttpClient hClient;
|
|
|
private String task_url = "jsps/mobile/task.jsp?caller=ResourceAssignment!Bill%26id=";
|
|
|
-
|
|
|
+ @ViewInject(R.id.isend_tv)
|
|
|
+ private TextView isend_tv;
|
|
|
+ @ViewInject(R.id.wait_tv)
|
|
|
+ private TextView wait_tv;
|
|
|
+ @ViewInject(R.id.done_tv)
|
|
|
+ private TextView done_tv;
|
|
|
+ @ViewInject(R.id.back)
|
|
|
+ private ImageView iv_back;
|
|
|
+ private int tab_type = 1;
|
|
|
+ @ViewInject(R.id.edt_search)
|
|
|
+ private ClearEditText edt_search;
|
|
|
+ @ViewInject(R.id.voice_search_iv)
|
|
|
+ private ImageView voice_search_iv;
|
|
|
private Handler handler = new Handler() {
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
|
public void handleMessage(Message msg) {
|
|
|
@@ -88,10 +121,11 @@ public class TaskActivity extends BaseActivity {
|
|
|
listview_main.onRefreshComplete();
|
|
|
}
|
|
|
if (msg.what == 2) {
|
|
|
+ progressDialog.dismiss();
|
|
|
String result = msg.getData().getString("result");
|
|
|
JSONObject dataroot = JSON.parseObject(result);
|
|
|
JSONArray data = dataroot.getJSONArray("data");
|
|
|
- allList.clear();
|
|
|
+ if (!ListUtils.isEmpty(allList)) allList.clear();
|
|
|
if (data != null) {
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
AllProcess process = new AllProcess();
|
|
|
@@ -115,14 +149,16 @@ public class TaskActivity extends BaseActivity {
|
|
|
process.setEndTime(item.getString("ra_enddate"));
|
|
|
allList.add(process);
|
|
|
}
|
|
|
- adapter = new NewSchedultAdapter(TaskActivity.this, allList);
|
|
|
- listview_main.setAdapter(adapter);
|
|
|
- if (adapter.getCount() != 0) {
|
|
|
- sendHomeBroadcast(adapter.getCount());
|
|
|
- } else {
|
|
|
- mEmptyLayout.showEmpty();
|
|
|
- }
|
|
|
- listview_main.onRefreshComplete();
|
|
|
+
|
|
|
+ doClassifyAllList(allList); // TODO 分类
|
|
|
+// adapter = new NewSchedultAdapter(TaskActivity.this, allList);
|
|
|
+// listview_main.setAdapter(adapter);
|
|
|
+// if (adapter.getCount() != 0) {
|
|
|
+// sendHomeBroadcast(adapter.getCount());
|
|
|
+// } else {
|
|
|
+// mEmptyLayout.showEmpty();
|
|
|
+// }
|
|
|
+// listview_main.onRefreshComplete();
|
|
|
} else {
|
|
|
mEmptyLayout.showEmpty();
|
|
|
adapter = new NewSchedultAdapter(context, allList);
|
|
|
@@ -149,6 +185,7 @@ public class TaskActivity extends BaseActivity {
|
|
|
listview_main.onRefreshComplete();
|
|
|
ViewUtil.AutoLoginErp(TaskActivity.this);
|
|
|
Log.i("login", "自动登录");
|
|
|
+ progressDialog.dismiss();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
@@ -157,6 +194,67 @@ public class TaskActivity extends BaseActivity {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ private void doClassifyAllList(List<AllProcess> allList) {
|
|
|
+ if (ListUtils.isEmpty(allList)) return;;
|
|
|
+ if (!ListUtils.isEmpty(waitList)) waitList.clear();
|
|
|
+ if (!ListUtils.isEmpty(doneList)) doneList.clear();
|
|
|
+ if (!ListUtils.isEmpty(isendList)) isendList.clear();
|
|
|
+ for (int i = 0; i < allList.size(); i++) {
|
|
|
+ // 待处理
|
|
|
+ if ((!login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "进行中".equals(allList.get(i).getStatus()) )||
|
|
|
+ (login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "待确认".equals(allList.get(i).getStatus()))){
|
|
|
+
|
|
|
+ waitList.add(allList.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ //已处理
|
|
|
+ if ((!login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "已完成".equals(allList.get(i).getStatus()) )||
|
|
|
+ (!login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "待确认".equals(allList.get(i).getStatus()))){
|
|
|
+ doneList.add(allList.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ //我发起的
|
|
|
+ if ((login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "进行中".equals(allList.get(i).getStatus()) )||
|
|
|
+ (login_Name.equals(allList.get(i).getRecorder()) &&
|
|
|
+ "已完成".equals(allList.get(i).getStatus()))){
|
|
|
+ isendList.add(allList.get(i));
|
|
|
+ }
|
|
|
+ if (i == allList.size() -1){
|
|
|
+ if (tab_type == 1){
|
|
|
+ if (ListUtils.isEmpty(waitList)) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, waitList);
|
|
|
+ real_List = waitList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tab_type == 2){
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, doneList);
|
|
|
+ real_List = doneList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tab_type == 3){
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, isendList);
|
|
|
+ real_List = isendList;
|
|
|
+ }
|
|
|
+ listview_main.setAdapter(adapter);
|
|
|
+ if (adapter.getCount() != 0) {
|
|
|
+ sendHomeBroadcast(adapter.getCount());
|
|
|
+ } else {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ listview_main.onRefreshComplete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -170,10 +268,12 @@ public class TaskActivity extends BaseActivity {
|
|
|
mEmptyLayout.setShowEmptyButton(false);
|
|
|
mEmptyLayout.setShowErrorButton(false);
|
|
|
mEmptyLayout.setShowLoadingButton(false);
|
|
|
- mEmptyLayout.showLoading();
|
|
|
//加载网络数据
|
|
|
new Thread(new getallprocess_run()).start();
|
|
|
- sendResquestForServer("START", 2);
|
|
|
+// sendResquestForServer("START", 2);
|
|
|
+ initHeaderView();// 头布局显示
|
|
|
+ sendResquestForServerAll(2); // update TODO :出息进来请求所有任务数据
|
|
|
+ initSearchEvent();
|
|
|
/**注释:监听 */
|
|
|
listview_main.setOnItemClickListener(new OnItemClickListener() {
|
|
|
@Override
|
|
|
@@ -241,15 +341,141 @@ public class TaskActivity extends BaseActivity {
|
|
|
listview_main.setOnRefreshListener(new OnRefreshListener<ListView>() {
|
|
|
@Override
|
|
|
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
- refreshing();
|
|
|
+// refreshing();
|
|
|
+
|
|
|
+ listview_main.getLoadingLayoutProxy().setPullLabel("下拉刷新");
|
|
|
+ sendResquestForServerAll(2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initSearchEvent() {
|
|
|
+ edt_search.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ LogUtil.prinlnLongMsg("real_List", real_List + "");
|
|
|
+ String strChche = editable.toString().replace(" ", "");//去除空格
|
|
|
+ strChche = strChche.replace(" ", " ");//去除空格
|
|
|
+ List<AllProcess> chche = new ArrayList<>();
|
|
|
+ if (StringUtils.isEmpty(strChche)) return;
|
|
|
+
|
|
|
+ if (ListUtils.isEmpty(real_List)) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < real_List.size(); i++) {
|
|
|
+ boolean b = getResult(real_List.get(i).getRecorder() + real_List.get(i).getDealpersoncode()
|
|
|
+ + real_List.get(i).getStatus() + real_List.get(i).getTaskname()
|
|
|
+ + real_List.get(i).getEndTime() + real_List.get(i).getDatetime(), strChche.trim());
|
|
|
+
|
|
|
+ if (b){
|
|
|
+ chche.add(real_List.get(i));
|
|
|
+ }
|
|
|
+ if (i == real_List.size() - 1){
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, chche);
|
|
|
+ listview_main.setAdapter(adapter);
|
|
|
+ if (adapter.getCount() != 0) {
|
|
|
+ sendHomeBroadcast(adapter.getCount());
|
|
|
+ } else {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ listview_main.onRefreshComplete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.v("chche",chche+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(strChche)){
|
|
|
+ listview_main.getRefreshableView().setAdapter(adapter);
|
|
|
+ }else {
|
|
|
+ adapter.notifyDataSetInvalidated();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ //正则
|
|
|
+ private static boolean getResult(String text, String str) {
|
|
|
+ Pattern p = Pattern.compile(str);
|
|
|
+ Matcher m = p.matcher(text);
|
|
|
+ return m.find();
|
|
|
+ }
|
|
|
+ private void initHeaderView() {
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.task_header, null);
|
|
|
+ ActionBar bar = this.getSupportActionBar();
|
|
|
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
+ wait_tv = (TextView) view.findViewById(R.id.wait_tv);
|
|
|
+ done_tv = (TextView) view.findViewById(R.id.done_tv);
|
|
|
+ isend_tv = (TextView) view.findViewById(R.id.isend_tv);
|
|
|
+ iv_back = (ImageView) view.findViewById(R.id.back);
|
|
|
+ bar.setCustomView(view);
|
|
|
+ isend_tv.setOnClickListener(this);
|
|
|
+ done_tv.setOnClickListener(this);
|
|
|
+ wait_tv.setOnClickListener(this);
|
|
|
+ wait_tv.setSelected(true);
|
|
|
+ iv_back.setOnClickListener(this);
|
|
|
+ voice_search_iv.setOnClickListener(this);
|
|
|
+ tab_type = 1;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()){
|
|
|
+ case R.id.wait_tv:
|
|
|
+ tab_type = 1;
|
|
|
+ wait_tv.setSelected(true);
|
|
|
+ done_tv.setSelected(false);
|
|
|
+ isend_tv.setSelected(false);
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, waitList);
|
|
|
+ real_List = waitList;
|
|
|
+ break;
|
|
|
+ case R.id.done_tv:
|
|
|
+ tab_type = 2;
|
|
|
+ wait_tv.setSelected(false);
|
|
|
+ done_tv.setSelected(true);
|
|
|
+ isend_tv.setSelected(false);
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, doneList);
|
|
|
+ real_List = doneList;
|
|
|
+ break;
|
|
|
+ case R.id.isend_tv:
|
|
|
+ tab_type = 3;
|
|
|
+ wait_tv.setSelected(false);
|
|
|
+ done_tv.setSelected(false);
|
|
|
+ isend_tv.setSelected(true);
|
|
|
+ adapter = new NewSchedultAdapter(TaskActivity.this, isendList);
|
|
|
+ real_List = isendList;
|
|
|
+ break;
|
|
|
+ case R.id.voice_search_iv:
|
|
|
+ final VoiceToWord voice = new VoiceToWord(TaskActivity.this,"534e3fe2");
|
|
|
+ voice.setRecognizerDialogListener(this); //自己调用自己
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ break;
|
|
|
+ case R.id.back:
|
|
|
+ onBackPressed();
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
+ listview_main.setAdapter(adapter);
|
|
|
+ if (adapter.getCount() != 0) {
|
|
|
+ sendHomeBroadcast(adapter.getCount());
|
|
|
+ } else {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ listview_main.onRefreshComplete();
|
|
|
+ }
|
|
|
@Override
|
|
|
protected void onResume() {
|
|
|
super.onResume();
|
|
|
- getEmNameForServer();//网络请求
|
|
|
+// getEmNameForServer();//网络请求
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -350,6 +576,18 @@ public class TaskActivity extends BaseActivity {
|
|
|
sendBroadcast(intent_update);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
+ String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
+ edt_search.setText(edt_search.getText().toString() + CommonUtil.getPlaintext(text));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SpeechError speechError) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @author LiuJie
|
|
|
* 线程
|
|
|
@@ -394,7 +632,7 @@ public class TaskActivity extends BaseActivity {
|
|
|
String d = null;
|
|
|
String t = null;
|
|
|
if (password != null) {
|
|
|
- d = "" + new Date().getTime();
|
|
|
+ d = new Date().getTime() + "";
|
|
|
Blowfish blowfish = new Blowfish("00" + d);
|
|
|
t = blowfish.encryptString(password);
|
|
|
}
|
|
|
@@ -554,6 +792,7 @@ public class TaskActivity extends BaseActivity {
|
|
|
* @注释: 带条件的调转
|
|
|
*/
|
|
|
public void sendResquestForServerAll(int handlerWhat) {
|
|
|
+ progressDialog.show();
|
|
|
String url = Constants.getAppBaseUrl(context) + "common/datalist/data.action";
|
|
|
Map<String, Object> mparams = new HashMap<String, Object>();
|
|
|
mparams.put("sessionId", CommonUtil.getSharedPreferences(context, "sessionId"));
|
|
|
@@ -607,15 +846,19 @@ public class TaskActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- getMenuInflater().inflate(R.menu.menu_state, menu);
|
|
|
+// getMenuInflater().inflate(R.menu.menu_state, menu);
|
|
|
+ getMenuInflater().inflate(R.menu.menu_add_icon, menu);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
- if (item.getItemId() == R.id.reset) {
|
|
|
- View view = getWindow().findViewById(item.getItemId());
|
|
|
- showWindow(view);
|
|
|
+// if (item.getItemId() == R.id.reset) {
|
|
|
+// View view = getWindow().findViewById(item.getItemId());
|
|
|
+// showWindow(view);
|
|
|
+// }
|
|
|
+ if (item.getItemId() == R.id.add_item) {
|
|
|
+ startActivityForResult(new Intent(context, TaskAddErpActivity.class), 0x17);
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|