@@ -0,0 +1,3187 @@
+package ir.asparsa.hobbytaste.core.manager;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0Aimport android.support.annotation.NonNull;%0Aimport android.support.annotation.Nullable;%0Aimport junit.framework.Assert;%0A%0Aimport javax.inject.Inject;%0Aimport javax.inject.Singleton;%0Aimport java.util.Map;%0A%0A/**%0A * @author hadi%0A * @since 12/2/2016 AD%0A */%0A@Singleton%0Apublic class PreferenceManager %7B%0A%0A    public static final String PREFERENCES_KEY_AUTHENTICATION = %22PREFERENCES_KEY_AUTHENTICATION%22;%0A%0A    private static final String SHARED_PREFERENCES_NAME = PreferenceManager.class.getPackage().getName();%0A    private SharedPreferences mSharedPreferences;%0A%0A    private final Object committerSync = new Object();%0A%0A    @Inject%0A    public PreferenceManager(Context context) %7B%0A        mSharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);%0A    %7D%0A%0A    public void put(@NonNull Map%3CString, Object%3E entries) %7B%0A        synchronized (committerSync) %7B%0A            SharedPreferences.Editor editor = mSharedPreferences.edit();%0A            for (String key : entries.keySet()) %7B%0A                Object value = entries.get(key);%0A                if (value instanceof String) %7B%0A                    editor.putString(key, (String) value);%0A                %7D else if (value instanceof Integer) %7B%0A                    editor.putInt(key, (Integer) value);%0A                %7D else if (value instanceof Long) %7B%0A                    editor.putLong(key, (Long) value);%0A                %7D else if (value instanceof Boolean) %7B%0A                    editor.putBoolean(key, (Boolean) value);%0A                %7D else if (value instanceof Float) %7B%0A                    editor.putFloat(key, (Float) value);%0A                %7D else %7B%0A                    Assert.fail(%22Try to save invalid value to shared preferences: %22 + value + %22, %22 + value.getClass());%0A                %7D%0A            %7D%0A            editor.apply();%0A        %7D%0A    %7D%0A%0A    public void put(@NonNull String key, String value) %7B%0A        synchronized (committerSync) %7B%0A            SharedPreferences.Editor editor = mSharedPreferences.edit();%0A            editor.putString(key, value);%0A            editor.apply();%0A        %7D%0A    %7D%0A%0A    public String get(@NonNull String key, @Nullable String defaultValue) %7B%0A        synchronized (committerSync) %7B%0A            return mSharedPreferences.getString(key, defaultValue);%0A        %7D%0A    %7D%0A%0A    public Integer get(@NonNull String key, @NonNull Integer defaultValue) %7B%0A        synchronized (committerSync) %7B%0A            return mSharedPreferences.getInt(key, defaultValue);%0A        %7D%0A    %7D%0A%0A    public Long get(@NonNull String key, @NonNull Long defaultValue) %7B%0A        synchronized (committerSync) %7B%0A            return mSharedPreferences.getLong(key, defaultValue);%0A        %7D%0A    %7D%0A%0A    public Boolean get(@NonNull String key, @NonNull Boolean defaultValue) %7B%0A        synchronized (committerSync) %7B%0A            return mSharedPreferences.getBoolean(key, defaultValue);%0A        %7D%0A    %7D%0A%0A    public Float get(@NonNull String key, @NonNull Float defaultValue) %7B%0A        synchronized (committerSync) %7B%0A            return mSharedPreferences.getFloat(key, defaultValue);%0A        %7D%0A    %7D%0A%7D%0A

Implement PreferenceManager