use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class BindMobileUI method sendSmsc.
/**
* Verify the signature for text messages
*/
private void sendSmsc() {
this.aeskey = Utils.makeRandomKey(16);
final String phoneNumber = "+" + mCountryCode.getCode() + " " + phoneEt.getText().toString().trim();
NetRequestImpl.getInstance().sendSmsc(aeskey, type == 0 ? 0 : 1, phoneNumber, new RequestListener() {
@Override
public void start() {
LoadingDialog.show(BindMobileUI.this, "");
}
@Override
public void success(JSONObject response) {
LoadingDialog.close();
showToast(response.optString("msg"));
Intent intent = new Intent(BindMobileUI.this, BindMobileCodeUI.class);
intent.putExtra("phonemubmer", phoneNumber);
intent.putExtra("type", type);
startActivity(intent);
Utils.openNewActivityAnim(BindMobileUI.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 BlackListUI method loadBlackList.
/**
* Load the data
*/
private void loadBlackList(int page) {
if (isLoadingData) {
return;
}
isLoadingData = true;
oldPage = page;
NetRequestImpl.getInstance().getBlackList(page, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
currentPage = oldPage;
if (currentPage == 1) {
source.clear();
}
JSONArray jsonArray = response.optJSONArray("data");
if (jsonArray != null) {
int count = jsonArray.length();
for (int i = 0; i < count; i++) {
UserInfoVo uInfo = new UserInfoVo().parse(jsonArray.optJSONObject(i));
source.add(uInfo);
}
blackAdapter.resetSource(source);
} else {
showToast(getString(R.string.black_list_empty));
}
isLoadingData = false;
swipeLayout.setRefreshing(false);
if (jsonArray != null && jsonArray.length() >= 10) {
blackLv.resetFooterState(true);
} else {
blackLv.resetFooterState(false);
}
checkListEmpty();
}
@Override
public void error(int errorCode, String errorMsg) {
isLoadingData = false;
swipeLayout.setRefreshing(false);
showToast(errorMsg);
checkListEmpty();
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class SubmitFeedBackUI method feedBackMethod.
/**
* 意见反馈方法
*/
private void feedBackMethod(String message, int type) {
String email = emailEt.getText().toString();
if (TextUtils.isEmpty(email)) {
showToast(getString(R.string.email_empty));
return;
}
if (!isEmail(email)) {
showToast(getString(R.string.email_is_error));
return;
}
NetRequestImpl.getInstance().feedBack(message, email, type, new RequestListener() {
@Override
public void start() {
LoadingDialog.show(SubmitFeedBackUI.this, "");
}
@Override
public void success(JSONObject response) {
LoadingDialog.close();
showToast(getString(R.string.submit_success));
finish();
}
@Override
public void error(int errorCode, String errorMsg) {
LoadingDialog.close();
showToast(getString(R.string.submit_faile));
finish();
}
});
}
use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.
the class FriendAddUI method addFriend.
private void addFriend() {
String content = contentEt.getText().toString().trim();
String note = addNoteEt.getText().toString().trim();
NetRequestImpl.getInstance().addFriend(localId, note, content, new RequestListener() {
@Override
public void start() {
LoadingDialog.show(FriendAddUI.this, "");
}
@Override
public void success(JSONObject response) {
LoadingDialog.close();
showToast(response.optString("msg"));
finish();
}
@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 LoginUtil method register.
/**
* registered
* @ param uName user name
* @ param uPwd password
*/
public void register(final String uName, final String uPwd, final String mid, final String localid, final TextView uploadRegisterInfo) {
this.aeskey = Utils.makeRandomKey(16);
NetRequestImpl.getInstance().register(uName, uPwd, mid, localid, aeskey, new RequestListener() {
@Override
public void start() {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.show(mContext, "");
}
}
@Override
public void success(JSONObject response) {
String token = response.optString("token");
if (TextUtils.isEmpty(token)) {
return;
}
token = Aes.decode(aeskey, token);
try {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.close();
}
JSONObject info = new JSONObject();
info.put("username", uName);
info.put("password", uPwd);
if (!TextUtils.isEmpty(mid)) {
info.put("mid", mid);
}
info.put("localid", localid);
info.put("token", token);
MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_USERINFO, info.toString());
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUsername(uName);
userInfoVo.setPassword(uPwd);
if (!TextUtils.isEmpty(mid)) {
userInfoVo.setMid(mid);
}
userInfoVo.setLocalId(localid);
userInfoVo.setToken(token);
JsonUtil.updateLocalInfo(mContext, userInfoVo);
NextApplication.myInfo = new UserInfoVo().readMyUserInfo(mContext);
if (uploadRegisterInfo != null) {
uploadRegisterInfo.setVisibility(View.GONE);
}
// Login XMPP
XmppUtils.loginXmppForNextApp(mContext);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void error(int errorCode, String errorMsg) {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.close();
}
MyToast.showToast(mContext, errorMsg);
}
});
}
Aggregations