Browse Source

Merge branch 'developer' of https://gitlab.com/Arisono/SkWeiChat-Baidu into developer

Bitliker 9 years ago
parent
commit
32be0ce85f

+ 1 - 2
WeiChat/src/main/AndroidManifest.xml

@@ -206,8 +206,7 @@
         <activity android:name=".ui.erp.activity.NewsTwoActivity" />
         <activity android:name=".ui.erp.activity.NoticesActivity" />
         <activity android:name=".ui.erp.activity.InformActivity" />
-        <activity android:name=".ui.erp.activity.TaskActivity"
-            android:label="待办工作"/>
+        <activity android:name=".ui.erp.activity.TaskActivity" />
         <activity android:name=".ui.erp.activity.ScheduleActivity" />
         <activity android:name=".ui.erp.activity.SubscribeDetailActivity" />
         <!-- Contacts 模块 -->

+ 263 - 20
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/TaskActivity.java

@@ -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);
     }

+ 2 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/me/FeedbackActivity.java

@@ -468,7 +468,8 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
 
 
     private void getCode() {
-        String url = Constants.getAppBaseUrl(ct) + "common/getCodeString.action";
+//        String url = Constants.getAppBaseUrl(ct) + "common/getCodeString.action";
+        String url =" http://218.18.115.198:8888/ERP/common/getCodeString.action";
         Map<String, Object> params = new HashMap<>();
         params.put("caller", "Commentsback_mobile");
         params.put("type", 2);

+ 8 - 4
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/message/ProcessB2BActivity.java

@@ -86,6 +86,10 @@ public class ProcessB2BActivity extends BaseActivity implements View.OnClickList
     private final int SUSSCESS_me = 3;
     private int exceptionCount=0;//
 
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+    }
 
     private Handler mHandler = new Handler() {
         @Override
@@ -299,7 +303,7 @@ public class ProcessB2BActivity extends BaseActivity implements View.OnClickList
                                     .putExtra("deal_id", deal_id)
                                     .putExtra("detail_id",detail_id)
                                     .putExtra("deal_type", 1)
-                                    ,0x322); //T 你根据这个0x322 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
+                                    ,0x322); //TODO 你根据这个0x322 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据,resultcode == 0x41701
                         }else {
                             startActivityForResult(new Intent(ProcessB2BActivity.this, FormDetailActivity.class)
                                     .putExtra("fromwhere", "examine_and_approve")
@@ -307,7 +311,7 @@ public class ProcessB2BActivity extends BaseActivity implements View.OnClickList
                                     .putExtra("deal_id", deal_id)
                                     .putExtra("detail_id",detail_id)
                                     .putExtra("deal_type",1)
-                                    ,0x321); // 你根据这个0x321 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
+                                    ,0x321); // TODO 你根据这个0x321 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
                         }
 
                         
@@ -323,7 +327,7 @@ public class ProcessB2BActivity extends BaseActivity implements View.OnClickList
                                     .putExtra("deal_id", deal_id)
                                     .putExtra("detail_id",detail_id)
                                     .putExtra("deal_type", 2)
-                                    ,0x322); // 你根据这个0x322 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
+                                    ,0x322); // TODO 你根据这个0x322 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
                         }else {
                             startActivityForResult(new Intent(ProcessB2BActivity.this, FormDetailActivity.class)
                                     .putExtra("fromwhere", "examine_and_approve")
@@ -331,7 +335,7 @@ public class ProcessB2BActivity extends BaseActivity implements View.OnClickList
                                     .putExtra("deal_id", deal_id)
                                     .putExtra("detail_id",detail_id)
                                     .putExtra("deal_type", 2)
-                                    ,0x321); // 你根据这个0x321 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
+                                    ,0x321); // TODO 你根据这个0x321 我的详情界面审批操作返回后这里改变列表数据状态,或者remove该条单据
                         }
                         break;
                     case 3:

+ 1 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/PlatWDdetailyActivity.java

@@ -595,6 +595,7 @@ private int agree_type = 0;
                         String agree_or_disagree_result = msg.getData().getString("result");
                         LogUtil.prinlnLongMsg("agree_or_disagree_result", agree_or_disagree_result);
                         Toast.makeText(getApplicationContext(),"操作成功",Toast.LENGTH_LONG).show();
+                        setResult(0x41701);
                         finish();
                     }
                     break;

+ 19 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/adapter/NewSchedultAdapter.java

@@ -24,6 +24,25 @@ import java.util.List;
 public class NewSchedultAdapter extends BaseAdapter {
     public List<AllProcess> fList;
     public List<AllProcess> flistNew;
+    public List<AllProcess> real_List;
+    public String search_content;
+    public String getSearch_content() {
+        return search_content;
+    }
+
+    public void setSearch_content(String search_content) {
+        this.search_content = search_content;
+    }
+
+
+    public List<AllProcess> getReal_List() {
+        return real_List;
+    }
+
+    public void setReal_List(List<AllProcess> real_List) {
+        this.real_List = real_List;
+    }
+
     private Context context;
 
     public NewSchedultAdapter() {

+ 1 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/platform/pageforms/FormDetailActivity.java

@@ -774,6 +774,7 @@ public class FormDetailActivity extends BaseActivity {
                         String agree_or_disagree_result = msg.getData().getString("result");
                         LogUtil.prinlnLongMsg("agree_or_disagree_result", agree_or_disagree_result);
                         Toast.makeText(getApplicationContext(),"操作成功",Toast.LENGTH_LONG).show();
+                        setResult(0x41701);
                         finish();
                     }
                     break;

+ 244 - 12
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/platform/task/TaskB2BActivity.java

@@ -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,12 +74,30 @@ 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) {
             try {
                 if (msg.what == 2) {
+                    progressDialog.dismiss();
                     String result = msg.getData().getString("result");
                     JSONObject dataroot = JSON.parseObject(result);
                     JSONArray data = dataroot.getJSONArray("listdata");
@@ -102,14 +136,15 @@ public class TaskB2BActivity extends BaseActivity {
                             process.setEndTime(item.getString("enddate"));
                             allList.add(process);
                         }
-                        adapter = new NewSchedultAdapter(TaskB2BActivity.this, allList);
+                        doClassifyAllList(allList); // TODO 分类
+         /*               adapter = new NewSchedultAdapter(TaskB2BActivity.this, allList);
                         listview_main.setAdapter(adapter);
                         if (adapter.getCount() != 0) {
                             sendHomeBroadcast(adapter.getCount());
                         } else {
                             mEmptyLayout.showEmpty();
                         }
-                        listview_main.onRefreshComplete();
+                        listview_main.onRefreshComplete();*/
                     } else {
                         mEmptyLayout.showEmpty();
                         adapter = new NewSchedultAdapter(context, allList);
@@ -131,6 +166,62 @@ 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
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -147,10 +238,12 @@ public class TaskB2BActivity extends BaseActivity {
         mEmptyLayout.setShowEmptyButton(false);
         mEmptyLayout.setShowErrorButton(false);
         mEmptyLayout.setShowLoadingButton(false);
-        mEmptyLayout.showLoading();
+//        mEmptyLayout.showLoading();
        
-        sendResquestForServer("进行中", 2);
-      
+//        sendResquestForServer("进行中", 2);
+        sendResquestForServer("", 2); // update TODO :出息进来请求所有任务数据
+        initHeaderView();//  头布局显示
+        initSearchEvent();
         listview_main.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view,
@@ -221,7 +314,84 @@ 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.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;
+    }
 
 
     private void refreshing() {
@@ -387,6 +557,7 @@ public class TaskB2BActivity extends BaseActivity {
      * @注释:状态码
      */
     public void sendResquestForServer(String status, int handlerWhat) {
+        progressDialog.show();
         String url = ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().task_list;
         Map<String, Object> params = new HashMap<String, Object>();
         String statu="进行中";
@@ -405,15 +576,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);
     }
@@ -424,4 +599,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) {
+
+    }
 }

+ 82 - 0
WeiChat/src/main/res/layout/task_header.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/top"
+    android:layout_width="match_parent"
+    android:background="@color/antionbarcolor"
+    android:layout_height="?attr/actionBarSize">
+    <ImageView
+        android:id="@+id/back"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:padding="10dp"
+        android:src="@drawable/back" />
+    <LinearLayout
+        android:id="@+id/ll_top_state"
+        android:layout_width="match_parent"
+        android:layout_centerInParent="true"
+        android:layout_marginLeft="60dp"
+        android:layout_marginRight="60dp"
+        android:layout_marginBottom="13dp"
+        android:layout_marginTop="13dp"
+        android:layout_height="40dp"
+        android:padding="1dp"
+        android:background="@drawable/shape_process_linear"
+        android:orientation="horizontal"
+        android:weightSum="3">
+
+        <TextView
+            android:id="@+id/wait_tv"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center_vertical"
+            android:gravity="center"
+            android:background="@drawable/shape_process_item"
+            android:layout_weight="1"
+            android:text="待处理"
+            android:textColor="@color/selector_schedule_text"
+            />
+
+        <TextView
+            android:id="@+id/done_tv"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center_vertical"
+            android:layout_weight="1"
+            android:background="@drawable/shape_process_item"
+            android:textColor="@color/selector_schedule_text"
+            android:gravity="center"
+            android:text="已处理"
+             />
+
+        <TextView
+            android:id="@+id/isend_tv"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center_vertical"
+            android:layout_weight="1"
+            android:background="@drawable/shape_process_item"
+            android:textColor="@color/selector_schedule_text"
+            android:gravity="center"
+            android:text="我发起的"
+             />
+
+    </LinearLayout>
+    
+
+    <!--<TextView-->
+        <!--android:id="@+id/title"-->
+        <!--android:layout_width="wrap_content"-->
+        <!--android:layout_height="wrap_content"-->
+        <!--android:layout_centerInParent="true"-->
+        <!--android:drawableRight="@drawable/down"-->
+        <!--android:textColor="@color/white"-->
+        <!--android:textSize="@dimen/text_main" />-->
+
+  <!--  <ImageView
+        android:id="@+id/seting"
+        android:layout_width="40dp"
+        android:layout_height="match_parent"
+        android:layout_alignParentRight="true"
+        android:padding="8dp"
+        android:src="@drawable/setting" />-->
+</RelativeLayout>

+ 39 - 3
WeiChat/src/main/res/layout/task_listview.xml

@@ -1,9 +1,45 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@drawable/bg_main">
+    android:background="@drawable/bg_main"
+    android:orientation="vertical">
 
+    <RelativeLayout
+        android:background="@drawable/bg_bar"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:orientation="horizontal"
+        android:paddingBottom="5dp"
+        android:paddingLeft="15dp"
+        android:paddingRight="15dp"
+        android:paddingTop="5dp">
+
+        <com.xzjmyk.pm.activity.view.ClearEditText
+            android:id="@+id/edt_search"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:layout_centerHorizontal="true"
+            android:background="@drawable/search_input"
+            android:drawableLeft="@drawable/search"
+            android:drawableRight="@drawable/search_clear"
+            android:hint="@string/search"
+            android:textColor="@color/dark_grey"
+            android:textColorHint="@color/grey"
+            android:textSize="15sp" />
+
+        <ImageView
+            android:id="@+id/voice_search_iv"
+            android:background="@drawable/btn_yuyin_nor"
+            android:visibility="visible"
+            android:layout_marginRight="25dp"
+            android:layout_alignParentRight="true"
+            android:layout_alignRight="@+id/search_edit"
+            android:layout_width="20dp"
+            android:layout_height="20dp"
+            android:layout_marginTop="8dp"
+            />
+    </RelativeLayout>
     <com.handmark.pulltorefresh.library.PullToRefreshListView
         android:id="@+id/listview_schedult"
         android:layout_width="match_parent"
@@ -15,4 +51,4 @@
         android:scrollingCache="false"
         android:listSelector="#00000000"
         android:scrollbars="none"></com.handmark.pulltorefresh.library.PullToRefreshListView>
-</RelativeLayout>
+</LinearLayout>