예제 #1
0
 private void applyToken(String token) {
   HashMap<String, String> map = new HashMap();
   JSONObject json = new JSONObject();
   try {
     json.put("token", token);
     json.put("type", "android");
     json.put("version", Utils.getAppVersionCode() + "");
   } catch (JSONException e) {
     e.printStackTrace();
   }
   map.put("token", json.toString());
   RequestManager.getInstance().setHeader(map);
   Utils.Log("setToken:" + json.toString());
 }
예제 #2
0
 /**
  * 绑定手机
  *
  * @param
  * @param code
  */
 public void boundTel(
     String oldTel,
     String newTel,
     String oldPassword,
     String newPassword,
     String code,
     StatusCallback callback) {
   RequestMap params = new RequestMap();
   params.put("oldTel", oldTel);
   params.put("newTel", newTel);
   params.put("oldPassword", Utils.MD5(oldPassword.getBytes()));
   params.put("newPassword", Utils.MD5(newPassword.getBytes()));
   params.put("code", code);
   RequestManager.getInstance().post(API.URL.BindTel, params, callback);
 }
예제 #3
0
 /**
  * 修改密码
  *
  * @param tel
  * @param password
  * @param verify
  * @param callback
  */
 public void modifyPassword(String tel, String password, String verify, StatusCallback callback) {
   RequestMap params = new RequestMap();
   params.put("tel", tel);
   params.put("newP", Utils.MD5(password.getBytes()));
   params.put("code", verify);
   RequestManager.getInstance().post(API.URL.ModifyPassword, params, callback);
 }
예제 #4
0
 public void setUserAccountData(UserAccountData userAccountData) {
   isUser = true;
   this.userAccountData = userAccountData;
   saveAccount();
   applyToken(userAccountData.getTokenApp());
   userAccountDataBehaviorSubject.onNext(userAccountData);
   Utils.Log("f**k");
 }
예제 #5
0
  public void saveAccount() {
    if (isUser) {
      Utils.writeObjectToFile(
          userAccountData, FileManager.getInstance().getChild(FileManager.Dir.Object, ACCOUNTFILE));
    } else {

    }
  }
예제 #6
0
 public void userRegister(
     String name, String tel, String password, String verify, StatusCallback callback) {
   RequestMap params = new RequestMap();
   params.put("name", name);
   params.put("tel", tel);
   params.put("pass", Utils.MD5(password.getBytes()));
   params.put("code", verify);
   RequestManager.getInstance().post(API.URL.Register, params, callback);
 }
예제 #7
0
  @Override
  protected void onAppCreate(Context ctx) {
    super.onAppCreate(ctx);
    Activity a = new Activity();
    Window.Callback callback = a;
    View.OnCreateContextMenuListener menuListener = a;
    ComponentCallbacks2 componentCallbacks = a;

    userAccountData =
        (UserAccountData)
            Utils.readObjectFromFile(
                FileManager.getInstance().getChild(FileManager.Dir.Object, ACCOUNTFILE));
    if (userAccountData != null) {
      applyToken(userAccountData.getTokenApp());
    } else {
      applyToken("");
    }
    updateAccountData();
  }
예제 #8
0
  public void userLogin(String tel, String password, StatusCallback callback) {
    RequestMap params = new RequestMap();
    params.put("tel", tel);
    params.put("pass", Utils.MD5(password.getBytes()));
    RequestManager.getInstance()
        .post(
            API.URL.Login,
            params,
            callback.add(
                new DataCallback<UserAccountData>() {
                  @Override
                  public void success(String info, UserAccountData data) {
                    setUserAccountData(data);
                  }

                  @Override
                  public void error(String errorInfo) {}
                }));
  }