Browse Source

mm

master
chenbin 3 years ago
parent
commit
a90f8bf59c
1 changed files with 46 additions and 13 deletions
  1. 46
    13
      app/src/main/java/com/tianrun/sipcall/db/DBUser.java

+ 46
- 13
app/src/main/java/com/tianrun/sipcall/db/DBUser.java View File

1
 package com.tianrun.sipcall.db;
1
 package com.tianrun.sipcall.db;
2
 
2
 
3
+import android.util.Log;
3
 import android.widget.ImageView;
4
 import android.widget.ImageView;
4
 import android.widget.TextView;
5
 import android.widget.TextView;
5
 
6
 
18
     public String name = "";
19
     public String name = "";
19
     public String phone = "";
20
     public String phone = "";
20
     public String status = "";
21
     public String status = "";
22
+    public int groupOrder = 0;
23
+    public int priority = 0;
21
     public boolean isManager = true;
24
     public boolean isManager = true;
22
     public boolean isAddFlag = false;
25
     public boolean isAddFlag = false;
23
 
26
 
24
     public boolean isMute = false;
27
     public boolean isMute = false;
25
     public boolean isVMute = false;
28
     public boolean isVMute = false;
26
     public boolean isLayout = false;
29
     public boolean isLayout = false;
30
+    public boolean isEmpty = false;
31
+    private static final String TAG = "DBUser";
27
 
32
 
28
     public DBUser(String name, String phone, String status) {
33
     public DBUser(String name, String phone, String status) {
29
         this.name = name;
34
         this.name = name;
31
         this.status = status;
36
         this.status = status;
32
     }
37
     }
33
 
38
 
39
+    public DBUser () {
40
+    }
41
+
34
     public DBUser(JSONObject d) {
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
     public boolean isBusy() {
69
     public boolean isBusy() {
63
     public static void onGetUsers(JSONArray array) {
81
     public static void onGetUsers(JSONArray array) {
64
         allUser.clear();
82
         allUser.clear();
65
         DBUser u;
83
         DBUser u;
84
+        int cellSize = 5;
85
+        int oldGroupOrder = -1;
66
         for (Object o : array) {
86
         for (Object o : array) {
67
             u = new DBUser((JSONObject) o);
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
             allUser.add(u);
101
             allUser.add(u);
69
             mapUsers.put(u.phone, u);
102
             mapUsers.put(u.phone, u);
70
             if (mySelf != null && u.phone.equals(mySelf.phone)) {
103
             if (mySelf != null && u.phone.equals(mySelf.phone)) {

Loading…
Cancel
Save