Search in sources :

Example 11 with UserInfoVo

use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.

the class LoginUtil method registMethod.

/**
 * registration verification
 * @ param mPwd password
 * @ param mAgainPwd secondary password
 * @ param mName user name
 */
public void registMethod(String mPwd, String mAgainPwd, String mName, String locailid) {
    // Authentication codes are consistent
    if (!TextUtils.equals(mPwd, mAgainPwd)) {
        MyToast.showToast(mContext, mContext.getString(R.string.account_pwd_again_warning));
        return;
    }
    // Verify account password is in accordance with the specification
    if (!LoginUtil.getInstance().registCheck(mName, mPwd)) {
        return;
    }
    // Verify whether the user name already exists
    ArrayList<UserInfoVo> infoList = JsonUtil.readLocalInfo(mContext);
    for (int i = 0; i < infoList.size(); i++) {
        if (TextUtils.equals(mName, infoList.get(i).getUsername())) {
            MyToast.showToast(mContext, mContext.getString(R.string.notification_wallimp_repeat));
            return;
        }
    }
    LoadingDialog.show(mContext, "");
    // Store the registration information Convenient synchronization
    UserInfoVo userInfoVo = new UserInfoVo();
    userInfoVo.setUsername(mName);
    userInfoVo.setPassword(mPwd);
    userInfoVo.setLocalId(locailid);
    JsonUtil.writeLocalInfo(mContext, userInfoVo);
    // Login XMPP
    XmppUtils.loginXmppForNextApp(mContext);
    // Enter the app
    mContext.startActivity(new Intent(mContext, MainFragmentUI.class));
    Utils.openNewActivityAnim(mContext, true);
    LoadingDialog.close();
}
Also used : Intent(android.content.Intent) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo) MainFragmentUI(com.lingtuan.firefly.ui.MainFragmentUI)

Example 12 with UserInfoVo

use of com.lingtuan.firefly.vo.UserInfoVo 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)

Example 13 with UserInfoVo

use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.

the class LoginUtil method login.

/**
 * login authentication
 * @ param uName user name
 * @ param uPwd password
 * @ param showDialog whether to display the dialog
 */
public void login(final String uName, final String uPwd, final boolean showDialog) {
    this.aeskey = Utils.makeRandomKey(16);
    NetRequestImpl.getInstance().login(uName, uPwd, aeskey, new RequestListener() {

        @Override
        public void start() {
            if (showDialog) {
                LoadingDialog.show(mContext, "");
            }
        }

        @Override
        public void success(JSONObject response) {
            try {
                JSONObject object = response.optJSONObject("data");
                // Local encrypted token decrypted storage
                String token = object.optString("token");
                String mid = object.optString("mid");
                if (TextUtils.isEmpty(token)) {
                    return;
                }
                token = Aes.decode(aeskey, token);
                object.put("token", token);
                object.put("mid", mid);
                object.put("password", uPwd);
                MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_USERINFO, object.toString());
                UserInfoVo userInfoVo = new UserInfoVo().parse(object);
                JsonUtil.updateLocalInfo(mContext, userInfoVo);
                NextApplication.myInfo = new UserInfoVo().readMyUserInfo(mContext);
                XmppUtils.loginXmppForNextApp(mContext);
                getUserInfo(showDialog, mid, uPwd, token);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (showDialog) {
                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)

Example 14 with UserInfoVo

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

Example 15 with UserInfoVo

use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.

the class NextApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    /**
     * Initialize the folder
     */
    SDCardCtrl.initPath(this);
    XmppUtils.isLogining = false;
    mContext = this;
    try {
        myInfo = new UserInfoVo().readMyUserInfo(this);
        Resources res = getResources();
        Configuration config = new Configuration();
        config.setToDefaults();
        config.fontScale = 1;
        res.updateConfiguration(config, res.getDisplayMetrics());
    } catch (Exception e) {
        e.printStackTrace();
    }
    NetRequestUtils.getInstance().getServerTime(this);
    initImageLoaderConfig();
    /**
     *Initialize the expression
     */
    SmileyParser.init(this);
    mSmileyParser = SmileyParser.getInstance();
    /**
     *Initialization error log collection
     */
    CrashHandler crashHandler = CrashHandler.getInstance();
    crashHandler.init(getApplicationContext());
}
Also used : ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) Configuration(android.content.res.Configuration) CrashHandler(com.lingtuan.firefly.util.CrashHandler) Resources(android.content.res.Resources) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Aggregations

UserInfoVo (com.lingtuan.firefly.vo.UserInfoVo)16 JSONObject (org.json.JSONObject)8 JSONException (org.json.JSONException)6 JSONArray (org.json.JSONArray)5 Intent (android.content.Intent)4 RequestListener (com.lingtuan.firefly.listener.RequestListener)4 MainFragmentUI (com.lingtuan.firefly.ui.MainFragmentUI)2 SuppressLint (android.annotation.SuppressLint)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 NearByPeopleAdapter (com.lingtuan.firefly.adapter.NearByPeopleAdapter)1 CrashHandler (com.lingtuan.firefly.util.CrashHandler)1 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)1 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)1 ArrayList (java.util.ArrayList)1