use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class TokenListUI method loadTokenList.
/**
* get token list
*/
private void loadTokenList() {
boolean isFirstGet = MySharedPrefs.readBoolean(TokenListUI.this, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_FIRST_GET_TOKEN_LIST);
ArrayList<TokenVo> tokenList = FinalUserDataBase.getInstance().getTokenListAll(address);
if (!isFirstGet && tokenList != null && tokenList.size() > 0) {
tokenListAdapter.resetSource(tokenList);
swipeLayout.setRefreshing(false);
} else {
NetRequestImpl.getInstance().getTokenList(address, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
source.clear();
JSONArray array = response.optJSONArray("data");
if (array != null) {
for (int i = 0; i < array.length(); i++) {
TokenVo tokenVo = new TokenVo().parse(array.optJSONObject(i));
source.add(tokenVo);
}
}
FinalUserDataBase.getInstance().beginTransaction();
for (int i = 0; i < source.size(); i++) {
FinalUserDataBase.getInstance().updateTokenList(source.get(i), address, true);
}
FinalUserDataBase.getInstance().endTransactionSuccessful();
MySharedPrefs.writeBoolean(TokenListUI.this, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_FIRST_GET_TOKEN_LIST, false);
tokenListAdapter.resetSource(source);
swipeLayout.setRefreshing(false);
checkListEmpty();
}
@Override
public void error(int errorCode, String errorMsg) {
swipeLayout.setRefreshing(false);
showToast(errorMsg);
checkListEmpty();
}
});
}
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class ContactSearchNickUI method searchNick.
private synchronized void searchNick(final String text) {
friendList.clear();
NetRequestImpl.getInstance().friendSearch(text, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
String data = response.optString("data");
boolean flag = TextUtils.equals("[]", data);
JSONArray jsonArray = response.optJSONArray("data");
if (jsonArray != null && !flag) {
int count = jsonArray.length();
for (int i = 0; i < count; i++) {
UserInfoVo uInfo = new UserInfoVo().parse(jsonArray.optJSONObject(i));
if (uInfo != null) {
friendList.add(uInfo);
}
}
mAdapter.updateList(friendList);
checkListEmpty(false);
} else {
checkListEmpty(true);
}
swipeLayout.setRefreshing(false);
}
@Override
public void error(int errorCode, String errorMsg) {
swipeLayout.setRefreshing(false);
showToast(errorMsg);
checkListEmpty(true);
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupListUI method createDiscussionGroups.
/**
* Create a group chat
* @param touids members id
*/
private void createDiscussionGroups(String touids, final List<UserBaseVo> member) {
NetRequestImpl.getInstance().createDiscussionGroups(touids, new RequestListener() {
@Override
public void start() {
showProgressDialog();
}
@Override
public void success(JSONObject response) {
showToast(response.optString("msg"));
dismissProgressDialog();
Utils.gotoGroupChat(DiscussGroupListUI.this, false, null, response.optString("cid"), member);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
swipeLayout.setRefreshing(true);
loadGroupList();
}
}, 500);
}
@Override
public void error(int errorCode, String errorMsg) {
dismissProgressDialog();
showToast(errorMsg);
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupMemberListUI method removeMember.
public void removeMember(final int arg2) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
mProgressDialog = LoadingDialog.showDialog(this, null, null);
mProgressDialog.setCancelable(false);
NetRequestImpl.getInstance().removeDiscussMember(data.get(arg2).getLocalId(), cid, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
showToast(response.optString("msg"));
UserBaseVo user = data.get(arg2);
data.remove(user);
showdata.remove(user);
removeMemberChatMsg(user.getShowName());
mAdapter.notifyDataSetChanged();
}
@Override
public void error(int errorCode, String errorMsg) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
showToast(errorMsg);
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupMemberListUI method addMembersRequest.
private void addMembersRequest(final ArrayList<UserBaseVo> continueList) {
if (continueList.size() <= 0) {
return;
}
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
mProgressDialog = LoadingDialog.showDialog(this, null, null);
mProgressDialog.setCancelable(false);
StringBuffer touids = new StringBuffer();
final StringBuffer tonames = new StringBuffer();
for (int i = 0; i < continueList.size(); i++) {
if (i == continueList.size() - 1) {
touids.append(continueList.get(i).getLocalId());
tonames.append(continueList.get(i).getShowName());
} else {
touids.append(continueList.get(i).getLocalId() + ",");
tonames.append(continueList.get(i).getShowName() + ",");
}
}
NetRequestImpl.getInstance().addDiscussMembers(touids.toString(), cid, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
showToast(response.optString("msg"));
for (int m = 0; m < continueList.size(); m++) {
if (isAdmin) {
data.add(continueList.get(m));
showdata.add(showdata.size() - 2, continueList.get(m));
} else {
data.add(continueList.get(m));
showdata.add(showdata.size() - 1, continueList.get(m));
}
}
inviteOthersChatMsg(tonames.toString());
mAdapter.notifyDataSetChanged();
}
@Override
public void error(int errorCode, String errorMsg) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
showToast(errorMsg);
}
});
}
Aggregations