|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.tianrun.sipcall.db;
|
2
|
2
|
|
|
3
|
+import android.util.Log;
|
3
|
4
|
import android.widget.ImageView;
|
4
|
5
|
import android.widget.TextView;
|
5
|
6
|
|
|
@@ -18,12 +19,16 @@ public class DBUser {
|
18
|
19
|
public String name = "";
|
19
|
20
|
public String phone = "";
|
20
|
21
|
public String status = "";
|
|
22
|
+ public int groupOrder = 0;
|
|
23
|
+ public int priority = 0;
|
21
|
24
|
public boolean isManager = true;
|
22
|
25
|
public boolean isAddFlag = false;
|
23
|
26
|
|
24
|
27
|
public boolean isMute = false;
|
25
|
28
|
public boolean isVMute = false;
|
26
|
29
|
public boolean isLayout = false;
|
|
30
|
+ public boolean isEmpty = false;
|
|
31
|
+ private static final String TAG = "DBUser";
|
27
|
32
|
|
28
|
33
|
public DBUser(String name, String phone, String status) {
|
29
|
34
|
this.name = name;
|
|
@@ -31,21 +36,34 @@ public class DBUser {
|
31
|
36
|
this.status = status;
|
32
|
37
|
}
|
33
|
38
|
|
|
39
|
+ public DBUser () {
|
|
40
|
+ }
|
|
41
|
+
|
34
|
42
|
public DBUser(JSONObject d) {
|
35
|
|
- this.name = d.getString("name");
|
36
|
|
- this.phone = d.getString("extn");
|
37
|
|
- this.status = d.getString("sip_state");
|
38
|
|
- status = status == null ? "" : status;
|
39
|
|
- String weight = d.getString("weight");
|
40
|
|
- if (weight != null) {
|
41
|
|
- this.isManager = weight.equals("1") ? true : false;
|
42
|
|
- } else {
|
43
|
|
- this.isManager = false;
|
|
43
|
+ try {
|
|
44
|
+ this.name = d.getString("name");
|
|
45
|
+ this.phone = d.getString("extn");
|
|
46
|
+ this.status = d.getString("sip_state");
|
|
47
|
+ status = status == null ? "" : status;
|
|
48
|
+ String weight = d.getString("weight");
|
|
49
|
+ if (weight != null) {
|
|
50
|
+ this.isManager = weight.equals("1") ? true : false;
|
|
51
|
+ } else {
|
|
52
|
+ this.isManager = false;
|
|
53
|
+ }
|
|
54
|
+ String ifMute = d.getString("ifMute");
|
|
55
|
+ this.isMute = ifMute != null ? ifMute.equals("true") : false;
|
|
56
|
+ String ifVMute = d.getString("ifVMute");
|
|
57
|
+ this.isVMute = ifVMute != null ? ifVMute.equals("true") : false;
|
|
58
|
+
|
|
59
|
+ String _groupOrder = d.getString("group_order");
|
|
60
|
+ this.groupOrder = _groupOrder != null ? Integer.parseInt(_groupOrder) : 0;
|
|
61
|
+ String _priority = d.getString("priority");
|
|
62
|
+ this.priority = _priority != null ? Integer.parseInt(_priority) : 0;
|
|
63
|
+ isEmpty = false;
|
|
64
|
+ } catch (Exception e){
|
|
65
|
+ Log.i(TAG, "onRequestComplete: " + e);
|
44
|
66
|
}
|
45
|
|
- String ifMute = d.getString("ifMute");
|
46
|
|
- this.isMute = ifMute != null ? ifMute.equals("true") : false;
|
47
|
|
- String ifVMute = d.getString("ifVMute");
|
48
|
|
- this.isVMute = ifVMute != null ? ifVMute.equals("true") : false;
|
49
|
67
|
}
|
50
|
68
|
|
51
|
69
|
public boolean isBusy() {
|
|
@@ -63,8 +81,23 @@ public class DBUser {
|
63
|
81
|
public static void onGetUsers(JSONArray array) {
|
64
|
82
|
allUser.clear();
|
65
|
83
|
DBUser u;
|
|
84
|
+ int cellSize = 5;
|
|
85
|
+ int oldGroupOrder = -1;
|
66
|
86
|
for (Object o : array) {
|
67
|
87
|
u = new DBUser((JSONObject) o);
|
|
88
|
+ if(oldGroupOrder >= 0 && oldGroupOrder != u.groupOrder) {
|
|
89
|
+ //需要分组
|
|
90
|
+ int yushu = allUser.size() % cellSize;
|
|
91
|
+ if(yushu > 0){
|
|
92
|
+ yushu = cellSize - yushu;
|
|
93
|
+ for (int i=0;i<yushu;i++){
|
|
94
|
+ DBUser _u = new DBUser();
|
|
95
|
+ _u.isEmpty = true;
|
|
96
|
+ allUser.add(_u);
|
|
97
|
+ }
|
|
98
|
+ }
|
|
99
|
+ }
|
|
100
|
+ oldGroupOrder = u.groupOrder;
|
68
|
101
|
allUser.add(u);
|
69
|
102
|
mapUsers.put(u.phone, u);
|
70
|
103
|
if (mySelf != null && u.phone.equals(mySelf.phone)) {
|