Bläddra i källkod

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

FANGLH 8 år sedan
förälder
incheckning
320937e3f2

+ 1 - 1
app_core/common/src/main/java/com/core/app/Constants.java

@@ -28,7 +28,7 @@ public class Constants {
             + "tf_name varchar(50),"
             + "tf_whichSys varchar(50),"
             + "tf_company varchar(50),"
-            + "tf_phone varchar(50),"
+            + "tf_phone varchar(50) ,"
             + "tf_email varchar(50),"
             + "tf_type integer,"
             + "tf_ownerId varchar(50),"

+ 8 - 5
app_modular/appcontact/src/main/java/com/uas/appcontact/db/ContactsDao.java

@@ -72,22 +72,25 @@ public class ContactsDao {
         String ownerId=MyApplication.getInstance().mLoginUser.getUserId();
         LogUtil.d("Test","master:"+master+" ownerId:"+ownerId);
         List<ContactsModel> models=new ArrayList<>();
-        Cursor cursor =db.rawQuery("select * from tbl_contacts a where id=" +
-                "(select min(id) from tbl_contacts where tf_phone=a.tf_phone and tf_ownerId=? ) and (tf_phone<> ? and tf_phone<> ?) " +
-                "   ", new String[]{ownerId,"未填写"," "});
+//        Cursor cursor =db.rawQuery("select * from tbl_contacts a where id=" +
+//                "(select min(id) from tbl_contacts where tf_phone=a.tf_phone and tf_ownerId=? ) and (tf_phone<> ? and tf_phone<> ?) " +
+//                "   ", new String[]{ownerId,"未填写"," "});
+
+        String sql="select * from tbl_contacts where tf_phone  in (select tf_phone from (select tf_phone,max(id) from tbl_contacts  where (tf_phone<> ? and tf_phone<> ?) group by tf_phone)) and tf_ownerId=?";
 //        Cursor cursor =db.rawQuery("select * from tbl_contacts a where id=" +
 //                "(select min(id) from tbl_contacts where tf_phone=a.tf_phone and tf_ownerId=? ) and (tf_phone<> ? and tf_phone<> ?) " +
 //                "  and (tf_whichSys=? or tf_whichSys=? ) ", new String[]{ownerId,"未填写"," ",master,""});
+        Cursor cursor =db.rawQuery(sql,new String[]{"未填写"," ",ownerId});
         while (cursor.moveToNext()) {
             ContactsModel model=new ContactsModel();
             model.setName(cursor.getString(cursor.getColumnIndex("tf_name")));
-            model.setCompany(cursor.getString(cursor.getColumnIndex("tf_company")));
             model.setWhichsys(cursor.getString(cursor.getColumnIndex("tf_whichSys")));
+            model.setCompany(cursor.getString(cursor.getColumnIndex("tf_company")));
             model.setPhone(cursor.getString(cursor.getColumnIndex("tf_phone")));
             model.setEmail(cursor.getString(cursor.getColumnIndex("tf_email")));
             model.setType(cursor.getInt(cursor.getColumnIndex("tf_type")));
-            model.setImid(cursor.getString(cursor.getColumnIndex("tf_imId")));
             model.setOwnerId(cursor.getString(cursor.getColumnIndex("tf_ownerId")));
+            model.setImid(cursor.getString(cursor.getColumnIndex("tf_imId")));
             models.add(model);
         }
         cursor.close();

+ 38 - 32
app_modular/appcontact/src/main/java/com/uas/appcontact/ui/activity/ContactsActivity.java

@@ -12,6 +12,7 @@ import android.os.Message;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.text.Editable;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.CheckBox;
@@ -331,7 +332,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 	 *
 	 * @param keyWork
 	 */
-	private void sreachKeyWork(final String keyWork) {
+	private synchronized void sreachKeyWork(final String keyWork) {
 		searchKey = keyWork;
 		LogUtil.i("allModels=" + allModels.size());
 		if (StringUtil.isEmail(keyWork)) {
@@ -340,7 +341,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 			models.addAll(allModels);
 			adapter.notifyDataSetChanged();
 		} else {
-			LogUtil.i("start for=" +System.currentTimeMillis());
+			LogUtil.i("start for=" + System.currentTimeMillis());
 			List<ContactsModel> keyWorkModels = new ArrayList<>();
 			for (ContactsModel e : allModels) {
 				if (includeKeyWork(e, searchKey)) {
@@ -356,7 +357,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 					}
 				}
 			}
-			LogUtil.i("end for=" +System.currentTimeMillis());
+			LogUtil.i("end for=" + System.currentTimeMillis());
 			updateAdapter(keyWorkModels);
 		}
 	}
@@ -379,7 +380,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 			} else {
 				this.models.clear();
 				this.models.addAll(models);
-				Collections.sort(this.models,getComparator());
+				Collections.sort(this.models, getComparator());
 				adapter.notifyDataSetChanged();
 				if (models.size() == 0) {
 					emptyLayout.showEmpty();
@@ -401,6 +402,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 		}
 		return false;
 	}
+
 	/**
 	 * 点击后
 	 *
@@ -598,7 +600,7 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 							if (adapter != null) {
 								models.clear();
 								models.addAll(lists);
-								Collections.sort(models,getComparator());
+								Collections.sort(models, getComparator());
 								adapter.notifyDataSetChanged();
 								if (adapter.getCount() == 0) emptyLayout.showEmpty();
 								mlist.onRefreshComplete();
@@ -958,34 +960,38 @@ public class ContactsActivity extends OABaseActivity implements ContactsAdapter.
 		public void handleMessage(Message msg) {
 			switch (msg.what) {
 				case 0x01:
-					try {
-						String result = msg.getData().getString("result");
-						String root = JSON.parseObject(result).getString("result");
-						JSONArray array = JSON.parseArray(root);
-						List<ContactsModel> xmodels = new ArrayList<>();
-						for (int i = 0; i < array.size(); i++) {
-							ContactsModel model = new ContactsModel();
-							model.setType(2);
-							model.setOwnerId(MyApplication.getInstance().mLoginUser.getUserId());
-							model.setImid(array.getJSONObject(i).getString("imid"));
-							model.setName(array.getJSONObject(i).getString("nickname"));
-							model.setPhone(array.getJSONObject(i).getString("telephone"));
-							xmodels.add(model);
-						}
-						if (!ListUtils.isEmpty(models)) {
-							models.clear();
-							models.addAll(xmodels);
-						} else {
-							models.addAll(xmodels);
-						}
-						if (adapter != null) {
-							adapter.notifyDataSetChanged();
-						}
-						if (adapter.getCount() == 0) {
-							emptyLayout.showEmpty();
-						}
-					} catch (Exception e) {
+					if (TextUtils.isEmpty(voiceSearchView.getText())) {
+						updateAdapter(allModels);
+					} else {
+						try {
+							String result = msg.getData().getString("result");
+							String root = JSON.parseObject(result).getString("result");
+							JSONArray array = JSON.parseArray(root);
+							List<ContactsModel> xmodels = new ArrayList<>();
+							for (int i = 0; i < array.size(); i++) {
+								ContactsModel model = new ContactsModel();
+								model.setType(2);
+								model.setOwnerId(MyApplication.getInstance().mLoginUser.getUserId());
+								model.setImid(array.getJSONObject(i).getString("imid"));
+								model.setName(array.getJSONObject(i).getString("nickname"));
+								model.setPhone(array.getJSONObject(i).getString("telephone"));
+								xmodels.add(model);
+							}
+							if (!ListUtils.isEmpty(models)) {
+								models.clear();
+								models.addAll(xmodels);
+							} else {
+								models.addAll(xmodels);
+							}
+							if (adapter != null) {
+								adapter.notifyDataSetChanged();
+							}
+							if (adapter.getCount() == 0) {
+								emptyLayout.showEmpty();
+							}
+						} catch (Exception e) {
 
+						}
 					}
 					break;
 			}