예제 #1
0
 private void initData() {
   // 删除以前记录的cookie信息
   File cookieFile = new File(LocalPath.intance().cacheBasePath + "co");
   if (cookieFile.exists()) {
     cookieFile.delete();
   }
   RequestTask.setmCookieStore(null);
   String eMail = mUser.getPhone();
   String pwd = mUser.getPassword();
   auto = mUser.isRemember();
   auto = (auto == null) ? false : auto;
   if (auto) {
     mEmailText.setText(eMail);
     mPwdText.setText(pwd);
     requestLogin(eMail, pwd, auto);
   } else {
     SPUtils.clearAllInfo(this);
     Log.i(TAG, "clearAllInfos");
     mPwdText.setText("");
     if (!isManual) {
       FramMainActivity_.intent(mContext).start();
       finish();
     }
   }
   mAutoCheck.setChecked(auto);
 }
예제 #2
0
 @AfterViews
 void crateData() {
   this.titleButton.setText("用户登录");
   this.titleButton.setVisibility(View.VISIBLE);
   this.rightButton.setVisibility(View.INVISIBLE);
   this.backButton.setVisibility(View.VISIBLE);
   this.backButton.setText("返回");
   this.backButton.setTextColor(Color.WHITE);
   SpannableString span = new SpannableString(this.registerButton.getText());
   ForegroundColorSpan fgcs = new ForegroundColorSpan(getResources().getColor(R.color.second_red));
   span.setSpan(fgcs, span.length() - 2, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   this.registerButton.setText(span);
   mAutoCheck.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           auto = !auto;
           mAutoCheck.setChecked(auto);
         }
       });
   mUser = User.lastLoginUser(mContext);
   if (mUser == null) {
     mUser = new User();
     mUser.setUserName("");
     mUser.setPassword("");
   } else {
   }
   initUI();
   initData();
 }
예제 #3
0
  @UiThread
  void requestLogin(final String eMail, final String pwd, Boolean auto) {
    mLoadingLayout.setVisibility(View.VISIBLE);
    mUser.setUserName(eMail);
    mUser.setPassword(pwd);
    mUser.setRemember(auto);
    mUser.login(
        new LoginListener() {
          @Override
          public void success(final User user) {
            new SerializerJSON(
                    new SerializeListener() {
                      @Override
                      public String onSerialize() {
                        ObjectMapper om = new ObjectMapper();
                        try {
                          return om.writeValueAsString(user);
                        } catch (JsonProcessingException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                        return null;
                      }

                      @Override
                      public void onComplete(String serializeResult) {
                        if (serializeResult != null) {
                          PreferenceManager.getDefaultSharedPreferences(mContext)
                              .edit()
                              .putString("user", serializeResult)
                              .commit();
                          saveInfoToSp(serializeResult);
                        }
                      }
                    })
                .execute();
            mLoadingLayout.setVisibility(View.GONE);
            com.yoopoon.home.ui.home.FramMainActivity_.intent(mContext).start();
            finish();
          }

          @Override
          public void faild(String msg) {
            mLoadingLayout.setVisibility(View.GONE);
            if (isManual) showError(msg);
            else {
              com.yoopoon.home.ui.home.FramMainActivity_.intent(mContext).start();
              finish();
            }
          }
        });
  }
예제 #4
0
 /**
  * 将后台传递过来的json数据以xml的格式保存至sp中 @Title: saveInfoToSp @Description: TODO
  *
  * @param serializeResult json数据
  */
 public void saveInfoToSp(String serializeResult) {
   SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
   Editor editor = sp.edit();
   try {
     JSONObject obj = new JSONObject(serializeResult);
     String userName = obj.getString("userName");
     String phone = obj.getString("phone");
     String password = obj.getString("password");
     String userId = String.valueOf(obj.getInt("id"));
     boolean remember = User.lastLoginUser(this).remember;
     boolean isBroker = obj.getBoolean("broker");
     editor.putString("userName", userName);
     editor.putString("phone", phone);
     editor.putString("password", password);
     editor.putString("userId", userId);
     editor.putBoolean("isBroker", isBroker);
     editor.putBoolean("remember", remember);
     editor.commit();
     sendLoginSuccessBroadcast();
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }