Search in sources :

Example 16 with RequestListener

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);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) Intent(android.content.Intent)

Example 17 with RequestListener

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();
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Example 18 with RequestListener

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();
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) SuppressLint(android.annotation.SuppressLint)

Example 19 with RequestListener

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);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject)

Example 20 with RequestListener

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);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Aggregations

RequestListener (com.lingtuan.firefly.listener.RequestListener)32 JSONObject (org.json.JSONObject)32 SuppressLint (android.annotation.SuppressLint)7 Intent (android.content.Intent)6 JSONArray (org.json.JSONArray)5 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)4 UserInfoVo (com.lingtuan.firefly.vo.UserInfoVo)4 JSONException (org.json.JSONException)4 TokenVo (com.lingtuan.firefly.wallet.vo.TokenVo)3 Handler (android.os.Handler)2 RegistUI (com.lingtuan.firefly.login.RegistUI)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Bundle (android.os.Bundle)1 NewContactVO (com.lingtuan.firefly.contact.vo.NewContactVO)1 ContactItemComparator (com.lingtuan.firefly.custom.contact.ContactItemComparator)1 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)1