// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/Avatar.java
// public enum Avatar {
// 
//     ONE(R.drawable.avatar_1),
//     TWO(R.drawable.avatar_2),
//     THREE(R.drawable.avatar_3),
//     FOUR(R.drawable.avatar_4),
//     FIVE(R.drawable.avatar_5),
//     SIX(R.drawable.avatar_6),
//     SEVEN(R.drawable.avatar_7),
//     EIGHT(R.drawable.avatar_8),
//     NINE(R.drawable.avatar_9),
//     TEN(R.drawable.avatar_10),
//     ELEVEN(R.drawable.avatar_11),
//     TWELVE(R.drawable.avatar_12),
//     THIRTEEN(R.drawable.avatar_13),
//     FOURTEEN(R.drawable.avatar_14),
//     FIFTEEN(R.drawable.avatar_15),
//     SIXTEEN(R.drawable.avatar_16);
// 
//     private static final String TAG = "Avatar";
// 
//     private final int mResId;
// 
//     Avatar(@DrawableRes final int resId) {
//         mResId = resId;
//     }
// 
//     @DrawableRes
//     public int getDrawableId() {
//         return mResId;
//     }
// 
//     public String getNameForAccessibility() {
//         return TAG + " " + ordinal() + 1;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/User.java
// public class User implements Parcelable {
// 
//     public static final Creator<User> CREATOR = new Creator<User>() {
//         @Override
//         public User createFromParcel(Parcel in) {
//             return new User(in);
//         }
// 
//         @Override
//         public User[] newArray(int size) {
//             return new User[size];
//         }
//     };
//     private final String mPhone;
//     private final String mPass;
//     private final Avatar mAvatar;
// 
//     public User(String phone, String pass, Avatar avatar) {
//         mPhone = phone;
//         mPass = pass;
//         mAvatar = avatar;
//     }
// 
//     protected User(Parcel in) {
//         mPhone = in.readString();
//         mPass = in.readString();
//         mAvatar = Avatar.values()[in.readInt()];
//     }
// 
//     public String getPhone() {
//         return mPhone;
//     }
// 
//     public String getPass() {
//         return mPass;
//     }
// 
//     public Avatar getAvatar() {
//         return mAvatar;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(mPhone);
//         dest.writeString(mPass);
//         dest.writeInt(mAvatar.ordinal());
//     }
// 
//     @SuppressWarnings("RedundantIfStatement")
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         User user = (User) o;
// 
//         if (mAvatar != user.mAvatar) {
//             return false;
//         }
//         if (!mPhone.equals(user.mPhone)) {
//             return false;
//         }
//         if (!mPass.equals(user.mPass)) {
//             return false;
//         }
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = mPhone.hashCode();
//         result = 31 * result + mPass.hashCode();
//         result = 31 * result + mAvatar.hashCode();
//         return result;
//     }
// }


import android.content.Context;
import android.content.SharedPreferences;
import com.hufeiya.SignIn.model.Avatar;
import com.hufeiya.SignIn.model.User;
/*
 * Copyright 2015 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hufeiya.SignIn.helper;




/**
 * Easy storage and retrieval of preferences.
 */
public class PreferencesHelper {

    private static final String USER_PREFERENCES = "playerPreferences";
    private static final String PREFERENCE_PHONE = USER_PREFERENCES + ".phone";
    private static final String PREFERENCE_PASS = USER_PREFERENCES + ".pass";
    private static final String PREFERENCE_AVATAR = USER_PREFERENCES + ".avatar";

    private PreferencesHelper() {
        //no instancer
    }

    /**
     * Writes a {@link User} to preferences.
     *
     * @param context The Context which to obtain the SharedPreferences from.
     * @param user  The {@link User} to write.
     */
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/Avatar.java
// public enum Avatar {
// 
//     ONE(R.drawable.avatar_1),
//     TWO(R.drawable.avatar_2),
//     THREE(R.drawable.avatar_3),
//     FOUR(R.drawable.avatar_4),
//     FIVE(R.drawable.avatar_5),
//     SIX(R.drawable.avatar_6),
//     SEVEN(R.drawable.avatar_7),
//     EIGHT(R.drawable.avatar_8),
//     NINE(R.drawable.avatar_9),
//     TEN(R.drawable.avatar_10),
//     ELEVEN(R.drawable.avatar_11),
//     TWELVE(R.drawable.avatar_12),
//     THIRTEEN(R.drawable.avatar_13),
//     FOURTEEN(R.drawable.avatar_14),
//     FIFTEEN(R.drawable.avatar_15),
//     SIXTEEN(R.drawable.avatar_16);
// 
//     private static final String TAG = "Avatar";
// 
//     private final int mResId;
// 
//     Avatar(@DrawableRes final int resId) {
//         mResId = resId;
//     }
// 
//     @DrawableRes
//     public int getDrawableId() {
//         return mResId;
//     }
// 
//     public String getNameForAccessibility() {
//         return TAG + " " + ordinal() + 1;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/User.java
// public class User implements Parcelable {
// 
//     public static final Creator<User> CREATOR = new Creator<User>() {
//         @Override
//         public User createFromParcel(Parcel in) {
//             return new User(in);
//         }
// 
//         @Override
//         public User[] newArray(int size) {
//             return new User[size];
//         }
//     };
//     private final String mPhone;
//     private final String mPass;
//     private final Avatar mAvatar;
// 
//     public User(String phone, String pass, Avatar avatar) {
//         mPhone = phone;
//         mPass = pass;
//         mAvatar = avatar;
//     }
// 
//     protected User(Parcel in) {
//         mPhone = in.readString();
//         mPass = in.readString();
//         mAvatar = Avatar.values()[in.readInt()];
//     }
// 
//     public String getPhone() {
//         return mPhone;
//     }
// 
//     public String getPass() {
//         return mPass;
//     }
// 
//     public Avatar getAvatar() {
//         return mAvatar;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(mPhone);
//         dest.writeString(mPass);
//         dest.writeInt(mAvatar.ordinal());
//     }
// 
//     @SuppressWarnings("RedundantIfStatement")
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         User user = (User) o;
// 
//         if (mAvatar != user.mAvatar) {
//             return false;
//         }
//         if (!mPhone.equals(user.mPhone)) {
//             return false;
//         }
//         if (!mPass.equals(user.mPass)) {
//             return false;
//         }
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = mPhone.hashCode();
//         result = 31 * result + mPass.hashCode();
//         result = 31 * result + mAvatar.hashCode();
//         return result;
//     }
// }


// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/helper/PreferencesHelper.java
import android.content.Context;
import android.content.SharedPreferences;
import com.hufeiya.SignIn.model.Avatar;
import com.hufeiya.SignIn.model.User;

/*
 * Copyright 2015 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hufeiya.SignIn.helper;




/**
 * Easy storage and retrieval of preferences.
 */
public class PreferencesHelper {

    private static final String USER_PREFERENCES = "playerPreferences";
    private static final String PREFERENCE_PHONE = USER_PREFERENCES + ".phone";
    private static final String PREFERENCE_PASS = USER_PREFERENCES + ".pass";
    private static final String PREFERENCE_AVATAR = USER_PREFERENCES + ".avatar";

    private PreferencesHelper() {
        //no instancer
    }

    /**
     * Writes a {@link User} to preferences.
     *
     * @param context The Context which to obtain the SharedPreferences from.
     * @param user  The {@link User} to write.
     */
    public static void writeToPreferences(Context context, User user) {