use of net.tsz.afinal.FinalDb in project wechat by motianhuo.
the class SplashActivity method initData.
private void initData() {
GloableParams.UserInfos = new ArrayList<User>();
GloableParams.Users = new HashMap<String, User>();
GloableParams.ListGroupInfos = new ArrayList<GroupInfo>();
GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
FinalDb db = FinalDb.create(this, Constants.DB_NAME, false);
GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
GloableParams.UserInfos = db.findAll(User.class);
}
use of net.tsz.afinal.FinalDb in project wechat by motianhuo.
the class Fragment_Friends method initData.
private void initData() {
if (GloableParams.UserInfos != null) {
lvContact.setAdapter(new ContactAdapter(getActivity(), GloableParams.UserInfos));
} else {
FinalDb db = FinalDb.create(getActivity(), Constants.DB_NAME, false);
GloableParams.UserInfos = db.findAllByWhere(User.class, "type='N'");
lvContact.setAdapter(new ContactAdapter(getActivity(), GloableParams.UserInfos));
for (User user : GloableParams.UserInfos) {
GloableParams.Users.put(user.getTelephone(), user);
}
// Intent intent = new Intent(getActivity(), UpdateService.class);
// getActivity().startService(intent);
}
}
use of net.tsz.afinal.FinalDb in project wechat by motianhuo.
the class AddGroupChatActivity method creatNewGroup.
private void creatNewGroup(final List<String> members) {
// TODO 请求服务器创建群组,服务端实现接口
new Thread(new Runnable() {
@Override
public void run() {
// 调用sdk创建群组方法
try {
final String[] strmembers = new String[members.size()];
for (int i = 0; i < members.size(); i++) {
User user = GloableParams.Users.get(members.get(i));
if (user != null) {
if (i < 3) {
if (i == 0)
groupName = user.getUserName();
else
groupName += "、" + user.getUserName();
} else if (i == 4) {
groupName += "...";
}
strmembers[i] = user.getTelephone();
if (i == 0) {
manber = user.getTelephone();
} else {
manber += "、" + user.getTelephone();
}
}
}
final EMGroup group = EMGroupManager.getInstance().createPublicGroup(groupName, "", strmembers, true);
runOnUiThread(new Runnable() {
public void run() {
if (group != null) {
// TODO 保存本地数据库
GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
GroupInfo info = new GroupInfo();
info.setGroup_id(group.getGroupId());
info.setGroup_name(groupName);
info.setMembers(manber);
String owner_id = Utils.getValue(AddGroupChatActivity.this, Constants.User_ID);
info.setOwner_id(owner_id);
GloableParams.GroupInfos.put(group.getGroupId(), info);
FinalDb db = FinalDb.create(AddGroupChatActivity.this, Constants.DB_NAME, false);
db.save(info);
addServieGroup(group.getGroupId(), groupName, manber, // 保存服务器
owner_id);
}
}
});
} catch (final EaseMobException e) {
runOnUiThread(new Runnable() {
public void run() {
Utils.showLongToast(AddGroupChatActivity.this, "创建失败");
getLoadingDialog("正在创建群聊...").dismiss();
}
});
}
}
}).start();
}
use of net.tsz.afinal.FinalDb in project wechat by motianhuo.
the class UserUtils method initUserInfo.
public static void initUserInfo(final Context context, final String telphone, final ImageView img_avar, final TextView txt_name) {
NetClient netClient = new NetClient(context);
RequestParams params = new RequestParams();
params.put("telphone", telphone);
netClient.post(Constants.getUserInfoURL, params, new BaseJsonRes() {
@Override
public void onMySuccess(String data) {
User user = JSON.parseObject(data, User.class);
if (user != null) {
if (user.getUserName() != null) {
txt_name.setText(user.getUserName());
}
if (user.getHeadUrl() != null) {
NetClient.getIconBitmap(img_avar, user.getHeadUrl());
}
FinalDb db = FinalDb.create(context, Constants.DB_NAME, false);
if (db.findById(user.getId(), User.class) != null)
db.deleteById(User.class, user.getId());
db.save(user);
GloableParams.UserInfos.add(user);
GloableParams.Users.put(user.getTelephone(), user);
}
}
@Override
public void onMyFailure() {
}
});
}
Aggregations