Search in sources :

Example 1 with UserInfoVo

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

the class NearByPeopleUI method initData.

@Override
protected void initData() {
    swipeLayout.setColorScheme(R.color.app_title_bg);
    setTitle(getString(R.string.near_by_people_title));
    String filter = MySharedPrefs.readString(this, MySharedPrefs.FILE_USER, MySharedPrefs.NEARY_PEOPLE_FILTER);
    if (!TextUtils.isEmpty(filter)) {
        // int index=Integer.parseInt(filter);
        // imgFilter.setText(sexFilter[index]);
        CURRENT_FILTER = filter;
    }
    // else{
    // imgFilter.setText(sexFilter[0]);
    // }
    imgFilter.setVisibility(View.VISIBLE);
    source = new ArrayList<UserInfoVo>();
    String response = Utils.readFromFile("discover-people_nearby.json");
    if (!TextUtils.isEmpty(response)) {
        try {
            JSONObject json = new JSONObject(response);
            JSONArray array = json.optJSONArray("data");
            parseJson(array);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    mRequestUtils = NetRequestUtils.getInstance();
    adapter = new NearByPeopleAdapter(this, source);
    nearLv.setAdapter(adapter);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            swipeLayout.setRefreshing(true);
            loadNearByList(1, CURRENT_FILTER);
        }
    }, 500);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) Handler(android.os.Handler) NearByPeopleAdapter(com.lingtuan.firefly.adapter.NearByPeopleAdapter) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Example 2 with UserInfoVo

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

the class NearByPeopleUI method parseJson.

/*parse json*/
private void parseJson(JSONArray jsonArray) {
    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);
        }
    }
}
Also used : SuppressLint(android.annotation.SuppressLint) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Example 3 with UserInfoVo

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

the class RadarViewGroup method setDatas.

/**
 * Set up the data
 *
 * @param mDatas
 */
public void setDatas(ArrayList<WifiPeopleVO> mDatas) {
    this.mDatas = mDatas;
    dataLength = mDatas.size();
    float min = Float.MAX_VALUE;
    float max = Float.MIN_VALUE;
    // Find the maximum distance, the minimum corresponding minItemPosition
    for (int j = 0; j < dataLength; j++) {
        UserInfoVo item = mDatas.get(j);
        if (Float.parseFloat(item.getDistance()) < min) {
            min = Float.parseFloat(item.getDistance());
            minItemPosition = j;
        }
        if (Float.parseFloat(item.getDistance()) > max) {
            max = Float.parseFloat(item.getDistance());
        }
        scanAngleList.put(j, 0f);
    }
    // According to the data source information dynamically add CircleView
    for (int i = 0; i < dataLength; i++) {
        CircleView circleView = new CircleView(getContext());
        circleView.setPortraitIcon(mDatas.get(i).getThumb(), mDatas.get(i).getUsername());
        if (minItemPosition == i) {
            minShowChild = circleView;
        }
        addView(circleView);
    }
}
Also used : UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Example 4 with UserInfoVo

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

the class JsonUtil method writeLocalInfo.

/**
 * Save the local login information
 * @param userInfoVo The user information
 */
public static void writeLocalInfo(Context mContext, UserInfoVo userInfoVo) {
    String localInfo = MySharedPrefs.readString(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOCAL_USERINFO);
    try {
        JSONArray array;
        if (!TextUtils.isEmpty(localInfo)) {
            array = new JSONArray(localInfo);
        } else {
            array = new JSONArray();
        }
        if (array.length() > 0) {
            for (int i = 0; i < array.length(); i++) {
                if (TextUtils.equals(userInfoVo.getLocalId(), array.optString(i))) {
                    return;
                }
            }
        }
        array.put(array.length(), userInfoVo.getLocalId());
        MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOCAL_USERINFO, array.toString());
        JSONObject jsonObject = new JSONObject();
        JSONObject data = new JSONObject();
        data.put(JsonConstans.Token, userInfoVo.getToken());
        data.put(JsonConstans.Mid, userInfoVo.getMid());
        data.put(JsonConstans.Password, userInfoVo.getPassword());
        data.put(JsonConstans.Username, userInfoVo.getUserName());
        data.put(JsonConstans.Localid, userInfoVo.getLocalId());
        jsonObject.put(userInfoVo.getLocalId(), data);
        MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, userInfoVo.getLocalId(), jsonObject.toString());
        MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_USERINFO, data.toString());
        NextApplication.myInfo = new UserInfoVo().readMyUserInfo(mContext);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Example 5 with UserInfoVo

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

the class LoginUI method onClick.

@Override
public void onClick(View v) {
    super.onClick(v);
    switch(v.getId()) {
        case R.id.login:
            String mName = userName.getText().toString();
            String mPwd = password.getText().toString();
            String tempName;
            String tempPwd;
            String mid = "";
            MySharedPrefs.write(this, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_NAME, mName);
            if (loginUtil.checkUser(mName, mPwd)) {
                if (Utils.isConnectNet(LoginUI.this)) {
                    ArrayList<UserInfoVo> infoList = JsonUtil.readLocalInfo(LoginUI.this);
                    // has username but not password
                    boolean isFoundName = false;
                    // username and password is right
                    boolean isFound = false;
                    for (int i = 0; i < infoList.size(); i++) {
                        // Whether the local user id
                        try {
                            tempName = infoList.get(i).getUsername();
                            if (TextUtils.equals(mName, tempName)) {
                                isFoundName = true;
                                tempPwd = infoList.get(i).getPassword();
                                mid = infoList.get(i).getMid();
                                if (TextUtils.equals(mPwd, tempPwd)) {
                                    isFound = true;
                                    break;
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (isFound) {
                        // username and password is right
                        if (TextUtils.isEmpty(mid)) {
                            LoginUtil.getInstance().intoMainUI(LoginUI.this, mName, mPwd);
                        } else {
                            loginUtil.login(mid, mPwd, true);
                        }
                    } else if (isFoundName) {
                        // only has username
                        if (TextUtils.isEmpty(mid)) {
                            showToast(getString(R.string.login_pwd_error));
                        } else {
                            loginUtil.login(mid, mPwd, true);
                        }
                    } else {
                        // no all
                        loginUtil.login(mName, mPwd, true);
                    }
                } else {
                    LoginUtil.getInstance().intoMainUI(LoginUI.this, mName, mPwd);
                }
            } else {
                showToast(getString(R.string.login_pwd_error));
            }
            break;
        case R.id.clearUserName:
            userName.setText("");
            break;
        case R.id.regist:
            startActivity(new Intent(LoginUI.this, RegistUI.class));
            Utils.openNewActivityAnim(LoginUI.this, false);
            break;
        case R.id.forgotPassword:
            Intent intent = new Intent(LoginUI.this, ForgotPwdUI.class);
            startActivity(intent);
            Utils.openNewActivityAnim(LoginUI.this, false);
            break;
        case R.id.isShowPass:
            isShowPassWorld = !isShowPassWorld;
            if (isShowPassWorld) {
                /* Set the EditText content is visible */
                password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                isShowPass.setImageResource(R.drawable.eye_open);
            } else {
                /* The content of the EditText set as hidden*/
                password.setTransformationMethod(PasswordTransformationMethod.getInstance());
                isShowPass.setImageResource(R.drawable.eye_close);
            }
            break;
    }
}
Also used : Intent(android.content.Intent) 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