all
This commit is contained in:
62
app/src/main/java/com/tianrun/sipcall/db/DBUser.java
Normal file
62
app/src/main/java/com/tianrun/sipcall/db/DBUser.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.tianrun.sipcall.db;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DBUser {
|
||||
public static List<DBUser> allUser = new ArrayList<>();
|
||||
public static HashMap<String, DBUser> mapUsers = new HashMap<>();
|
||||
public static DBUser mySelf;
|
||||
public String name = "";
|
||||
public String phone = "";
|
||||
public String status = "";
|
||||
public boolean isManager = false;
|
||||
public boolean isAddFlag = false;
|
||||
|
||||
public DBUser(String name, String phone, String status) {
|
||||
this.name = name;
|
||||
this.phone = phone;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public DBUser(JSONObject d) {
|
||||
this.name = d.getString("name");
|
||||
this.phone = d.getString("extn");
|
||||
this.status = d.getString("sip_state");
|
||||
this.isManager = d.getString("weight").equals("1");
|
||||
}
|
||||
|
||||
public boolean isBusy() {
|
||||
return status.equals("busy");
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return status.equals("true");
|
||||
}
|
||||
|
||||
public boolean isOffline() {
|
||||
return status.equals("false");
|
||||
}
|
||||
|
||||
public static void onGetUsers(JSONArray array) {
|
||||
allUser.clear();
|
||||
DBUser u;
|
||||
for (Object o : array) {
|
||||
u = new DBUser((JSONObject) o);
|
||||
allUser.add(u);
|
||||
mapUsers.put(u.phone, u);
|
||||
if (mySelf != null && u.phone == mySelf.phone) {
|
||||
mySelf = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DBUser getUser(String phoneNo) {
|
||||
return mapUsers.get(phoneNo);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user