use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class MainContactFragmentUI method uploadOfflineFriends.
/**
* Synchronous no net friends
*/
private void uploadOfflineFriends() {
if (!Utils.isConnectNet(getActivity())) {
return;
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < mFriendInfoList.size(); i++) {
if (mFriendInfoList.get(i).isOffLine()) {
builder.append(mFriendInfoList.get(i).getLocalId()).append(",");
}
}
if (builder.length() > 0) {
builder.deleteCharAt(builder.length() - 1);
NetRequestImpl.getInstance().addOfflineFriend(builder.toString(), new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
loadFriends();
}
@Override
public void error(int errorCode, String errorMsg) {
}
});
}
}
use of com.lingtuan.firefly.listener.RequestListener 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);
}
});
}
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class BindMobileCodeUI method verifyMail.
/**
* Validation email
*/
private void verifyMail() {
String code = codeEt.getText().toString().trim();
if (TextUtils.isEmpty(code)) {
showToast(getString(R.string.code_number_not_empty));
return;
}
NetRequestImpl.getInstance().verifyMail(code, email, new RequestListener() {
@Override
public void start() {
LoadingDialog.show(BindMobileCodeUI.this, "");
}
@Override
public void success(JSONObject response) {
if (type == 1) {
// Binding email
bindEmailMethod();
} else {
// Email retrieve password
Intent intent = new Intent(BindMobileCodeUI.this, RegistUI.class);
intent.putExtra("number", email);
intent.putExtra("type", type);
startActivity(intent);
Utils.openNewActivityAnim(BindMobileCodeUI.this, false);
}
}
@Override
public void error(int errorCode, String errorMsg) {
LoadingDialog.close();
showToast(errorMsg);
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class WalletStorage method addAddressToServer.
/**
* add address to server
* @param mapdb wallet list
*/
private void addAddressToServer(ArrayList<StorableWallet> mapdb) {
if (mapdb == null || mapdb.size() <= 0) {
return;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mapdb.size(); i++) {
String address = mapdb.get(i).getPublicKey();
if (!address.startsWith("0x")) {
address = "0x" + address;
}
sb.append(address).append(",");
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
NetRequestImpl.getInstance().addAddress(sb.toString(), new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
}
@Override
public void error(int errorCode, String errorMsg) {
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class MyProfileUI method updateInfoMethod.
/**
* Modify the personal information
*/
private void updateInfoMethod() {
LoadingDialog.show(MyProfileUI.this, getString(R.string.info_edit_dialog));
final String username = userName.getText().toString();
final String sightml = addSign.getText().toString();
final String birthcity = addRegion.getText().toString();
if (imgPath != null) {
Bundle bundle = new Bundle();
bundle.putSerializable("imgPath", imgPath);
bundle.putString("username", username);
bundle.putString("sightml", sightml);
bundle.putString("gender", gender);
bundle.putString("birthcity", birthcity);
Utils.intentServiceAction(MyProfileUI.this, LoadDataService.ACTION_FILE_UPLOAD_IMAGE, bundle);
} else {
try {
NetRequestImpl.getInstance().editUserInfo(null, username, sightml, gender, birthcity, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
LoadingDialog.close();
NextApplication.myInfo.updateJsonUserInfo(username, sightml, gender, birthcity, MyProfileUI.this);
NextApplication.myInfo.setUsername(username);
NextApplication.myInfo.setSightml(sightml);
NextApplication.myInfo.setGender(gender);
NextApplication.myInfo.setAddress(birthcity);
finish();
}
@Override
public void error(int errorCode, String errorMsg) {
LoadingDialog.close();
showToast(errorMsg);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations