|
|
@@ -7,6 +7,9 @@ import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
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;
|
|
|
@@ -15,6 +18,7 @@ import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
@@ -24,9 +28,15 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
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.bean.Friend;
|
|
|
import com.xzjmyk.pm.activity.db.dao.FriendDao;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
@@ -37,8 +47,12 @@ import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
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.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.util.DateFormatUtil;
|
|
|
+import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
import com.xzjmyk.pm.activity.wxapi.ApiConfig;
|
|
|
import com.xzjmyk.pm.activity.wxapi.ApiUtils;
|
|
|
|
|
|
@@ -48,8 +62,10 @@ 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;
|
|
|
|
|
|
-public class TaskB2BActivity extends BaseActivity {
|
|
|
+public class TaskB2BActivity extends BaseActivity implements RecognizerDialogListener,View.OnClickListener{
|
|
|
|
|
|
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
@@ -58,7 +74,24 @@ public class TaskB2BActivity 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(), "b2b_emname");;
|
|
|
+ private int tab_type = 1;
|
|
|
+ @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;
|
|
|
+ @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) {
|
|
|
@@ -133,7 +166,59 @@ public class TaskB2BActivity 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){
|
|
|
+ adapter = new NewSchedultAdapter(TaskB2BActivity.this, waitList);
|
|
|
+ real_List = waitList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tab_type == 2){
|
|
|
+ adapter = new NewSchedultAdapter(TaskB2BActivity.this, doneList);
|
|
|
+ real_List = doneList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tab_type == 3){
|
|
|
+ adapter = new NewSchedultAdapter(TaskB2BActivity.this, isendList);
|
|
|
+ real_List = isendList;
|
|
|
+ }
|
|
|
+ listview_main.setAdapter(adapter);
|
|
|
+ if (adapter.getCount() != 0) {
|
|
|
+ sendHomeBroadcast(adapter.getCount());
|
|
|
+ } else {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ listview_main.onRefreshComplete();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -230,11 +315,70 @@ public class TaskB2BActivity extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
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(TaskB2BActivity.this, chche);
|
|
|
+ listview_main.onRefreshComplete();
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //正则
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -419,15 +563,19 @@ public class TaskB2BActivity 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, TaskAddB2BActivity.class), 0x17);
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
@@ -438,4 +586,61 @@ public class TaskB2BActivity extends BaseActivity {
|
|
|
refreshing();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @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(TaskB2BActivity.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(TaskB2BActivity.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(TaskB2BActivity.this, isendList);
|
|
|
+ real_List = isendList;
|
|
|
+ break;
|
|
|
+ case R.id.voice_search_iv:
|
|
|
+ final VoiceToWord voice = new VoiceToWord(TaskB2BActivity.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
|
|
|
+ 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) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|