// Path: lib/src/main/java/com/razerdp/github/lib/api/AppContext.java
// public class AppContext {
// 
//     private static final String TAG = "AppContext";
//     public static final Application sApplication;
//     private static final InnerLifecycleHandler INNER_LIFECYCLE_HANDLER;
// 
//     static {
//         Application app = null;
//         try {
//             app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null);
//             if (app == null)
//                 throw new IllegalStateException("Static initialization of Applications must be on main thread.");
//         } catch (final Exception e) {
//             Log.e(TAG, "Failed to get current application from AppGlobals." + e.getMessage());
//             try {
//                 app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null);
//             } catch (final Exception ex) {
//                 Log.e(TAG, "Failed to get current application from ActivityThread." + e.getMessage());
//             }
//         } finally {
//             sApplication = app;
//         }
//         INNER_LIFECYCLE_HANDLER = new InnerLifecycleHandler();
//         if (sApplication != null) {
//             sApplication.registerActivityLifecycleCallbacks(INNER_LIFECYCLE_HANDLER);
//         }
//     }
// 
//     public static boolean isAppVisable() {
//         return INNER_LIFECYCLE_HANDLER != null && INNER_LIFECYCLE_HANDLER.started > INNER_LIFECYCLE_HANDLER.stopped;
//     }
// 
//     public static boolean isAppBackground() {
//         return INNER_LIFECYCLE_HANDLER != null && INNER_LIFECYCLE_HANDLER.resumed <= INNER_LIFECYCLE_HANDLER.stopped;
//     }
// 
//     private static void checkAppContext() {
//         if (sApplication == null)
//             throw new IllegalStateException("app reference is null");
//     }
// 
//     public static Application getAppInstance() {
//         checkAppContext();
//         return sApplication;
//     }
// 
//     public static Context getAppContext() {
//         checkAppContext();
//         return sApplication.getApplicationContext();
//     }
// 
//     public static Resources getResources() {
//         checkAppContext();
//         return sApplication.getResources();
//     }
// 
//     public static boolean isMainThread() {
//         return Looper.getMainLooper().getThread() == Thread.currentThread();
//     }
// 
// 
//     @Nullable
//     public static FragmentActivity getTopActivity() {
//         return INNER_LIFECYCLE_HANDLER.mTopActivity == null ? null : INNER_LIFECYCLE_HANDLER.mTopActivity.get();
//     }
// 
//     private static class InnerLifecycleHandler implements Application.ActivityLifecycleCallbacks {
//         private int created;
//         private int resumed;
//         private int paused;
//         private int started;
//         private int stopped;
//         private WeakReference<FragmentActivity> mTopActivity;
// 
//         @Override
//         public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//             ++created;
// 
//         }
// 
//         @Override
//         public void onActivityStarted(Activity activity) {
//             ++started;
// 
//         }
// 
//         @Override
//         public void onActivityResumed(Activity activity) {
//             ++resumed;
//             if (mTopActivity != null) {
//                 mTopActivity.clear();
//             }
//             if (activity instanceof FragmentActivity) {
//                 mTopActivity = new WeakReference<>((FragmentActivity) activity);
//             }
//         }
// 
//         @Override
//         public void onActivityPaused(Activity activity) {
//             ++paused;
// 
//         }
// 
//         @Override
//         public void onActivityStopped(Activity activity) {
//             ++stopped;
// 
//         }
// 
//         @Override
//         public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// 
//         }
// 
//         @Override
//         public void onActivityDestroyed(Activity activity) {
// 
//         }
//     }
// 
// }


import android.content.Context;
import android.content.SharedPreferences;
import com.razerdp.github.lib.api.AppContext;
import java.util.Map;
package com.razerdp.github.lib.helper;





/**
 * Created by 大灯泡 on 2016/10/28.
 * <p>
 * preference单例
 */

public class SharePreferenceHelper {

    public static final String HAS_LOGIN = "haslogin";
    public static final String HOST_NAME = "hostName";
    public static final String HOST_AVATAR = "hostAvatar";
    public static final String HOST_NICK = "hostNick";
    public static final String HOST_ID = "hostId";
    public static final String HOST_COVER = "cover";
    public static final String CHECK_REGISTER = "check_register";
    public static final String APP_HAS_SCAN_IMG = "has_scan_img";
    public static final String APP_LAST_SCAN_IMG_TIME = "last_scan_image_time";


    private static final String PERFERENCE_NAME = "FriendCircleData";
    private static SharedPreferences sharedPreferences = AppContext.getAppContext().getSharedPreferences(PERFERENCE_NAME, Context.MODE_PRIVATE);

    static {
        sharedPreferences = AppContext.getAppContext().getSharedPreferences(PERFERENCE_NAME, Context.MODE_PRIVATE);
    }

// Path: lib/src/main/java/com/razerdp/github/lib/api/AppContext.java
// public class AppContext {
// 
//     private static final String TAG = "AppContext";
//     public static final Application sApplication;
//     private static final InnerLifecycleHandler INNER_LIFECYCLE_HANDLER;
// 
//     static {
//         Application app = null;
//         try {
//             app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null);
//             if (app == null)
//                 throw new IllegalStateException("Static initialization of Applications must be on main thread.");
//         } catch (final Exception e) {
//             Log.e(TAG, "Failed to get current application from AppGlobals." + e.getMessage());
//             try {
//                 app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null);
//             } catch (final Exception ex) {
//                 Log.e(TAG, "Failed to get current application from ActivityThread." + e.getMessage());
//             }
//         } finally {
//             sApplication = app;
//         }
//         INNER_LIFECYCLE_HANDLER = new InnerLifecycleHandler();
//         if (sApplication != null) {
//             sApplication.registerActivityLifecycleCallbacks(INNER_LIFECYCLE_HANDLER);
//         }
//     }
// 
//     public static boolean isAppVisable() {
//         return INNER_LIFECYCLE_HANDLER != null && INNER_LIFECYCLE_HANDLER.started > INNER_LIFECYCLE_HANDLER.stopped;
//     }
// 
//     public static boolean isAppBackground() {
//         return INNER_LIFECYCLE_HANDLER != null && INNER_LIFECYCLE_HANDLER.resumed <= INNER_LIFECYCLE_HANDLER.stopped;
//     }
// 
//     private static void checkAppContext() {
//         if (sApplication == null)
//             throw new IllegalStateException("app reference is null");
//     }
// 
//     public static Application getAppInstance() {
//         checkAppContext();
//         return sApplication;
//     }
// 
//     public static Context getAppContext() {
//         checkAppContext();
//         return sApplication.getApplicationContext();
//     }
// 
//     public static Resources getResources() {
//         checkAppContext();
//         return sApplication.getResources();
//     }
// 
//     public static boolean isMainThread() {
//         return Looper.getMainLooper().getThread() == Thread.currentThread();
//     }
// 
// 
//     @Nullable
//     public static FragmentActivity getTopActivity() {
//         return INNER_LIFECYCLE_HANDLER.mTopActivity == null ? null : INNER_LIFECYCLE_HANDLER.mTopActivity.get();
//     }
// 
//     private static class InnerLifecycleHandler implements Application.ActivityLifecycleCallbacks {
//         private int created;
//         private int resumed;
//         private int paused;
//         private int started;
//         private int stopped;
//         private WeakReference<FragmentActivity> mTopActivity;
// 
//         @Override
//         public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//             ++created;
// 
//         }
// 
//         @Override
//         public void onActivityStarted(Activity activity) {
//             ++started;
// 
//         }
// 
//         @Override
//         public void onActivityResumed(Activity activity) {
//             ++resumed;
//             if (mTopActivity != null) {
//                 mTopActivity.clear();
//             }
//             if (activity instanceof FragmentActivity) {
//                 mTopActivity = new WeakReference<>((FragmentActivity) activity);
//             }
//         }
// 
//         @Override
//         public void onActivityPaused(Activity activity) {
//             ++paused;
// 
//         }
// 
//         @Override
//         public void onActivityStopped(Activity activity) {
//             ++stopped;
// 
//         }
// 
//         @Override
//         public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// 
//         }
// 
//         @Override
//         public void onActivityDestroyed(Activity activity) {
// 
//         }
//     }
// 
// }


// Path: lib/src/main/java/com/razerdp/github/lib/helper/SharePreferenceHelper.java
import android.content.Context;
import android.content.SharedPreferences;
import com.razerdp.github.lib.api.AppContext;
import java.util.Map;

package com.razerdp.github.lib.helper;





/**
 * Created by 大灯泡 on 2016/10/28.
 * <p>
 * preference单例
 */

public class SharePreferenceHelper {

    public static final String HAS_LOGIN = "haslogin";
    public static final String HOST_NAME = "hostName";
    public static final String HOST_AVATAR = "hostAvatar";
    public static final String HOST_NICK = "hostNick";
    public static final String HOST_ID = "hostId";
    public static final String HOST_COVER = "cover";
    public static final String CHECK_REGISTER = "check_register";
    public static final String APP_HAS_SCAN_IMG = "has_scan_img";
    public static final String APP_LAST_SCAN_IMG_TIME = "last_scan_image_time";


    private static final String PERFERENCE_NAME = "FriendCircleData";
    private static SharedPreferences sharedPreferences = AppContext.getAppContext().getSharedPreferences(PERFERENCE_NAME, Context.MODE_PRIVATE);

    static {
        sharedPreferences = AppContext.getAppContext().getSharedPreferences(PERFERENCE_NAME, Context.MODE_PRIVATE);
    }

    public static String getString(String key, String defaultValue) {