Search in sources :

Example 1 with RequestListener

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

Example 2 with RequestListener

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

Example 3 with RequestListener

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

Example 4 with RequestListener

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

Example 5 with RequestListener

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

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