Ejemplo n.º 1
0
 private void initOfflinePref() {
   User user = YftData.data().getMe();
   if (null != user && user.getShopId() > 0) {
     YftData.data()
         .setOffPref(
             getSharedPreferences(
                 getString(R.string.preference_offline) + user.getShopId(), Context.MODE_PRIVATE));
   }
 }
Ejemplo n.º 2
0
  @Override
  public void response(String result) {
    String rSign = "resultSign", rObj = "resultObj", rError = "errorMsg";
    try {
      JSONObject job = new JSONObject(result); // if null?
      if (job.has(rSign)) {
        if (job.getBoolean(rSign)) { // success

          if (job.has(rObj)) {
            String ro = job.getString(rObj);
            Log.i(TAG, ro + ";::resultObj");
            switch (requestStep) {
              case 1:
                new HttpRequestTask(this)
                    .execute(YftValues.getHTTPBodyString(RequestType.MEMBER_INFO, ro));
                requestStep = 2;
                break;
              case 2:
                // 保存user信息
                User user = new User();
                boolean iReturn = user.initWithJsonString(ro);
                if (!iReturn) Log.e(TAG, "user init failed!!");
                YftData.data().setMe(user); // 1029
                YftData.data().setMeCurrentUser();

                // 跳转
                enter(user.getMemberType() > 2);
                pref.edit()
                    .putString(getString(R.string.pref_username), username)
                    .commit(); // 成功则保存用户名
                initOfflinePref();
                requestStep = 0;
                //							TestDataTracker.settleDataString(RequestType.MEMBER_INFO.toString(),
                // result);//
                break;
              default:
                break;
            }
          }
        } else { // failed
          if (job.has(rError)) {
            JackUtils.showToast(this, job.getString(rError));
          }
          requestStep = 0;
        }
      }

    } catch (Exception e) {
      requestStep = 0;
      e.printStackTrace();
    }
  }
Ejemplo n.º 3
0
 private void goGuest() {
   enter(false);
   User guest = new User(); // 1113
   guest.setShopId(-1); // TODO
   YftData.data().setMe(guest);
 }