// Path: app/src/main/java/com/ge/protein/data/ProteinAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class ProteinAdapterFactory implements TypeAdapterFactory {
// 
//     public static TypeAdapterFactory create() {
//         return new AutoValueGson_ProteinAdapterFactory();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/data/model/AccessToken.java
// @AutoValue
// public abstract class AccessToken {
// 
//     public abstract String access_token();
// 
//     public abstract String token_type();
// 
//     public abstract String scope();
// 
//     public static TypeAdapter<AccessToken> typeAdapter(Gson gson) {
//         return new AutoValue_AccessToken.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String name();
// 
//     public abstract String username();
// 
//     public abstract String html_url();
// 
//     public abstract String avatar_url();
// 
//     public abstract String bio();
// 
//     @Nullable
//     public abstract String location();
// 
//     public abstract Links links();
// 
//     public abstract long buckets_count();
// 
//     public abstract long comments_received_count();
// 
//     public abstract long followers_count();
// 
//     public abstract long followings_count();
// 
//     public abstract long likes_count();
// 
//     public abstract long likes_received_count();
// 
//     public abstract long projects_count();
// 
//     public abstract long rebounds_received_count();
// 
//     public abstract long shots_count();
// 
//     public abstract long teams_count();
// 
//     public abstract boolean can_upload_shot();
// 
//     public abstract String type();
// 
//     public abstract boolean pro();
// 
//     public abstract String buckets_url();
// 
//     public abstract String followers_url();
// 
//     public abstract String following_url();
// 
//     public abstract String likes_url();
// 
//     public abstract String shots_url();
// 
//     @Nullable
//     public abstract String teams_url();
// 
//     public abstract String created_at();
// 
//     public abstract String updated_at();
// 
//     public static TypeAdapter<User> typeAdapter(Gson gson) {
//         return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
//     }
// }


import com.ge.protein.data.ProteinAdapterFactory;
import com.ge.protein.data.model.AccessToken;
import com.ge.protein.data.model.User;
import com.google.gson.GsonBuilder;
/*
 * Copyright 2017 Jiaheng Ge
 *
 * 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.ge.protein.util;


public class AccountManager {

    private static AccountManager accountManager = new AccountManager();
    private AccessToken accessToken;
    private User me;

    private AccountManager() {
    }

    public static AccountManager getInstance() {
        return accountManager;
    }

    public AccessToken getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(AccessToken accessToken) {
        this.accessToken = accessToken;
    }

    public void setAccessToken(String token) {
        accessToken = new GsonBuilder()
                .registerTypeAdapterFactory(ProteinAdapterFactory.create())
                .create()
                .fromJson(token, AccessToken.class);
    }

    public boolean isLogin() {
        return accessToken != null;
    }

// Path: app/src/main/java/com/ge/protein/data/ProteinAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class ProteinAdapterFactory implements TypeAdapterFactory {
// 
//     public static TypeAdapterFactory create() {
//         return new AutoValueGson_ProteinAdapterFactory();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/data/model/AccessToken.java
// @AutoValue
// public abstract class AccessToken {
// 
//     public abstract String access_token();
// 
//     public abstract String token_type();
// 
//     public abstract String scope();
// 
//     public static TypeAdapter<AccessToken> typeAdapter(Gson gson) {
//         return new AutoValue_AccessToken.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String name();
// 
//     public abstract String username();
// 
//     public abstract String html_url();
// 
//     public abstract String avatar_url();
// 
//     public abstract String bio();
// 
//     @Nullable
//     public abstract String location();
// 
//     public abstract Links links();
// 
//     public abstract long buckets_count();
// 
//     public abstract long comments_received_count();
// 
//     public abstract long followers_count();
// 
//     public abstract long followings_count();
// 
//     public abstract long likes_count();
// 
//     public abstract long likes_received_count();
// 
//     public abstract long projects_count();
// 
//     public abstract long rebounds_received_count();
// 
//     public abstract long shots_count();
// 
//     public abstract long teams_count();
// 
//     public abstract boolean can_upload_shot();
// 
//     public abstract String type();
// 
//     public abstract boolean pro();
// 
//     public abstract String buckets_url();
// 
//     public abstract String followers_url();
// 
//     public abstract String following_url();
// 
//     public abstract String likes_url();
// 
//     public abstract String shots_url();
// 
//     @Nullable
//     public abstract String teams_url();
// 
//     public abstract String created_at();
// 
//     public abstract String updated_at();
// 
//     public static TypeAdapter<User> typeAdapter(Gson gson) {
//         return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
//     }
// }


// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
import com.ge.protein.data.ProteinAdapterFactory;
import com.ge.protein.data.model.AccessToken;
import com.ge.protein.data.model.User;
import com.google.gson.GsonBuilder;

/*
 * Copyright 2017 Jiaheng Ge
 *
 * 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.ge.protein.util;


public class AccountManager {

    private static AccountManager accountManager = new AccountManager();
    private AccessToken accessToken;
    private User me;

    private AccountManager() {
    }

    public static AccountManager getInstance() {
        return accountManager;
    }

    public AccessToken getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(AccessToken accessToken) {
        this.accessToken = accessToken;
    }

    public void setAccessToken(String token) {
        accessToken = new GsonBuilder()
                .registerTypeAdapterFactory(ProteinAdapterFactory.create())
                .create()
                .fromJson(token, AccessToken.class);
    }

    public boolean isLogin() {
        return accessToken != null;
    }

    public User getMe() {