use of com.lingtuan.firefly.custom.contact.ContactItemComparator in project SmartMesh_Android by SmartMeshFoundation.
the class MainContactFragmentUI method deleteFriends.
/**
* Remove buddy
*/
private void deleteFriends(final String uid, final boolean isFriendOffline) {
if (isFriendOffline) {
FinalUserDataBase.getInstance().deleteFriendByUid(uid);
int i = 0;
for (UserBaseVo info : mFriendInfoList) {
if (uid.equals(info.getLocalId())) {
mFriendInfoList.remove(i);
break;
}
i++;
}
mContactList.clear();
for (UserBaseVo voT : mFriendInfoList) {
NewContactVO info = new NewContactVO();
info.setAge(voT.getAge());
info.setDistance(voT.getDistance());
info.setFriendLog(voT.getFriendLog());
info.setGender(voT.getGender());
info.setSightml(voT.getSightml());
info.setThumb(voT.getThumb());
info.setLocalId(voT.getLocalId());
info.setUsername(voT.getUserName());
info.setNote(voT.getNote());
info.setLogintime(voT.getLogintime());
info.setFullName(PinYin.getPinYin(voT.getShowName()));
info.setMid(voT.getMid());
info.setOffLine(voT.isOffLine());
mContactList.add(info);
}
mNewListView.setFastScrollEnabled(true);
Collections.sort(mContactList, new ContactItemComparator());
mNewContactListAdapter.updateList(mContactList);
contactNum.setText(getString(R.string.contact_num, mContactList.size()));
} else {
NetRequestImpl.getInstance().deleteFriends(uid, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
showToast(response.optString("msg"));
FinalUserDataBase.getInstance().deleteFriendByUid(uid);
int i = 0;
for (UserBaseVo info : mFriendInfoList) {
if (uid.equals(info.getLocalId())) {
mFriendInfoList.remove(i);
break;
}
i++;
}
mContactList.clear();
for (UserBaseVo voT : mFriendInfoList) {
NewContactVO info = new NewContactVO();
info.setAge(voT.getAge());
info.setDistance(voT.getDistance());
info.setFriendLog(voT.getFriendLog());
info.setGender(voT.getGender());
info.setSightml(voT.getSightml());
info.setThumb(voT.getThumb());
info.setLocalId(voT.getLocalId());
info.setUsername(voT.getUserName());
info.setNote(voT.getNote());
info.setLogintime(voT.getLogintime());
info.setFullName(PinYin.getPinYin(voT.getShowName()));
info.setMid(voT.getMid());
info.setOffLine(voT.isOffLine());
mContactList.add(info);
}
mNewListView.setFastScrollEnabled(true);
Collections.sort(mContactList, new ContactItemComparator());
mNewContactListAdapter.updateList(mContactList);
contactNum.setText(getString(R.string.contact_num, mContactList.size()));
}
@Override
public void error(int errorCode, String errorMsg) {
showToast(errorMsg);
}
});
}
}
Aggregations