Exemple #1
0
 @Override
 public void onErrorResponse(VolleyError error) {
   doingLogin = false;
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.remove(sp, KEY_USERKEY);
   if (onCompleteLoginListener != null) onCompleteLoginListener.onCompleteLogin(false);
 }
Exemple #2
0
 private void saveUserToSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.put(sp, KEY_ID, user.id);
   PrefUtil.put(sp, KEY_USERNAME, user.name);
   PrefUtil.put(sp, KEY_EMAIL, user.email);
   PrefUtil.put(sp, KEY_POINT, user.point);
 }
Exemple #3
0
 private void readUserFromSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   user.id = PrefUtil.getString(sp, KEY_ID);
   user.name = PrefUtil.getString(sp, KEY_USERNAME);
   user.email = PrefUtil.getString(sp, KEY_EMAIL);
   user.point = PrefUtil.getInt(sp, KEY_POINT);
 }
Exemple #4
0
        @Override
        public void onResponse(ResponseLogin response) {
          doingLogin = false;

          if (response.getIs_success() == 1) {
            login();
            userKey = response.getUkey();
            saveUserKeyToSharedPreference();
          } else {
            logout();
            SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
            PrefUtil.remove(sp, KEY_USERKEY);
          }

          if (onCompleteLoginListener != null)
            onCompleteLoginListener.onCompleteLogin(response.getIs_success() == 1);
        }
Exemple #5
0
 public void saveReadNotice(String readNoticeId) {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.put(sp, KEY_READ_NOTICE, readNoticeId);
 }
Exemple #6
0
 public String getReadNotice() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   return PrefUtil.getString(sp, KEY_READ_NOTICE);
 }
Exemple #7
0
 public void logout() {
   this.login = false;
   PrefUtil.clear(PrefUtil.getPref(context, MYPREFS));
 }
Exemple #8
0
 private void savePointToSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.put(sp, KEY_POINT, this.user.point);
 }
Exemple #9
0
 private void saveLoginToSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.put(sp, KEY_LOGIN, this.login);
 }
Exemple #10
0
 private void readLoginFromSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   this.login = PrefUtil.getBoolean(sp, KEY_LOGIN);
 }
Exemple #11
0
 private void saveUserKeyToSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   PrefUtil.put(sp, KEY_USERKEY, this.userKey);
 }
Exemple #12
0
 private void readUserKeyFromSharedPreference() {
   SharedPreferences sp = PrefUtil.getPref(context, MYPREFS);
   this.userKey = PrefUtil.getString(sp, KEY_USERKEY);
 }