use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class ContactAddAdapter method requestAgree.
/**
* Agree to add buddy
*/
private void requestAgree(final Holder h, final ChatMsg msg) {
if (msg.isOffLineMsg()) {
if (listener != null) {
boolean successed = listener.addFriendConfim(msg.getUserId());
if (successed) {
FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
UserBaseVo vo = new UserBaseVo();
vo.setFriendLog(1);
vo.setThumb(msg.getUserImage());
vo.setLocalId(msg.getUserId());
vo.setUsername(msg.getUsername());
vo.setGender(msg.getGender() + "");
vo.setOffLine(true);
FinalUserDataBase.getInstance().saveFriendUserBase(vo);
msg.setAgree(true);
notifyDataSetChanged();
} else {
h.agreeBtn.setEnabled(true);
if (Utils.isConnectNet(mContext)) {
NetRequestImpl.getInstance().addFriendAgree(msg.getUserId(), new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
try {
MyToast.showToast(mContext, response.optString("msg"));
FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
msg.setAgree(true);
Constants.isRefresh = true;
notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void error(int errorCode, String errorMsg) {
try {
if (1211122 == errorCode) {
FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
msg.setAgree(true);
} else {
MyToast.showToast(mContext, errorMsg);
}
} catch (Exception e) {
e.printStackTrace();
}
notifyDataSetChanged();
}
});
}
}
}
} else {
NetRequestImpl.getInstance().addFriendAgree(msg.getUserId(), new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
try {
MyToast.showToast(mContext, response.optString("msg"));
FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
msg.setAgree(true);
Constants.isRefresh = true;
notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void error(int errorCode, String errorMsg) {
try {
if (1211121 == errorCode) {
FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
msg.setAgree(true);
} else {
MyToast.showToast(mContext, errorMsg);
}
} catch (Exception e) {
e.printStackTrace();
}
notifyDataSetChanged();
}
});
}
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class MainMessageFragmentUI method createDiscussionGroups.
/**
* create a group chat
* @ param touids member id
* @ param member group members
*/
private void createDiscussionGroups(String touids, final List<UserBaseVo> member) {
showDialog();
NetRequestImpl.getInstance().createDiscussionGroups(touids, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
showToast(response.optString("msg"));
dismissDialog();
Utils.gotoGroupChat(getActivity(), false, null, response.optString("cid"), member);
}
@Override
public void error(int errorCode, String errorMsg) {
dismissDialog();
showToast(errorMsg);
}
});
}
Aggregations