diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index e9a841a..3fae6ef 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -33,21 +33,21 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/flatstack/android/utils/HomeAsUp.java b/app/src/main/java/com/flatstack/android/utils/HomeAsUp.java
deleted file mode 100644
index d45021c..0000000
--- a/app/src/main/java/com/flatstack/android/utils/HomeAsUp.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.flatstack.android.utils;
-
-import android.support.annotation.NonNull;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-
-/**
- * Created by adelnizamutdinov on 10/12/14
- */
-public class HomeAsUp {
- public static void enable(@NonNull AppCompatActivity activity) {
- final ActionBar bar = activity.getSupportActionBar();
- if (bar != null) {
- bar.setDisplayHomeAsUpEnabled(true);
- }
- }
-
- public static void disable(@NonNull AppCompatActivity activity) {
- final ActionBar bar = activity.getSupportActionBar();
- if (bar != null) {
- bar.setHomeButtonEnabled(false);
- bar.setDisplayHomeAsUpEnabled(false);
- }
- }
-}
diff --git a/app/src/main/java/com/flatstack/android/utils/storage/IStorage.java b/app/src/main/java/com/flatstack/android/utils/storage/IStorage.java
new file mode 100644
index 0000000..aa0bfcb
--- /dev/null
+++ b/app/src/main/java/com/flatstack/android/utils/storage/IStorage.java
@@ -0,0 +1,40 @@
+package com.flatstack.android.utils.storage;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * Created by ereminilya on 8/1/17.
+ */
+
+public interface IStorage {
+
+ @Nullable T get(@NonNull String key, @NonNull Type type);
+
+ void put(@NonNull String key, @NonNull T item);
+
+ void putString(@NonNull final String key, @NonNull String str);
+
+ @Nullable String getString(@NonNull String key);
+
+ void putLong(@NonNull String key, long number);
+
+ long getLong(@NonNull String key, long defaultValue);
+
+ void putInt(@NonNull String key, int number);
+
+ int getInt(@NonNull String key, int defaultValue);
+
+ void putBoolean(@NonNull String key, boolean value);
+
+ boolean getBoolean(@NonNull String key, boolean defaultValue);
+
+ void remove(@NonNull String key);
+
+ void putCollection(@NonNull String key, @NonNull List items);
+
+ @Nullable List getCollection(@NonNull String key, @NonNull Type type);
+}
diff --git a/app/src/main/java/com/flatstack/android/utils/storage/Storage.java b/app/src/main/java/com/flatstack/android/utils/storage/Storage.java
new file mode 100644
index 0000000..b395c3f
--- /dev/null
+++ b/app/src/main/java/com/flatstack/android/utils/storage/Storage.java
@@ -0,0 +1,83 @@
+package com.flatstack.android.utils.storage;
+
+import android.content.SharedPreferences;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.google.gson.Gson;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * Created by ereminilya on 8/1/17.
+ */
+
+public class Storage implements IStorage {
+
+ private final SharedPreferences sp;
+ private final Gson gson;
+
+ public Storage(SharedPreferences sp, Gson gson) {
+ this.sp = sp;
+ this.gson = gson;
+ }
+
+ @Override
+ @Nullable public T get(@NonNull String key, @NonNull Type type) {
+ String json = sp.getString(key, "");
+ if ("".equals(json)) return null;
+ else {
+ return gson.fromJson(json, type);
+ }
+ }
+
+ @Override public void put(@NonNull String key, @NonNull Object items) {
+ sp.edit().putString(key, gson.toJson(items)).apply();
+ }
+
+ @Override public void putString(@NonNull String key, @NonNull String str) {
+ sp.edit().putString(key, str).apply();
+ }
+
+ @Nullable @Override public String getString(@NonNull String key) {
+ return sp.getString(key, null);
+ }
+
+ @Override public void putLong(@NonNull String key, long number) {
+ sp.edit().putLong(key, number).apply();
+ }
+
+ @Override public long getLong(@NonNull String key, long defaultValue) {
+ return sp.getLong(key, defaultValue);
+ }
+
+ @Override public void putInt(@NonNull String key, int number) {
+ sp.edit().putInt(key, number).apply();
+ }
+
+ @Override public int getInt(@NonNull String key, int defaultValue) {
+ return sp.getInt(key, defaultValue);
+ }
+
+ @Override public void putBoolean(@NonNull String key, boolean value) {
+ sp.edit().putBoolean(key, value).apply();
+ }
+
+ @Override public boolean getBoolean(@NonNull String key, boolean defaultValue) {
+ return sp.getBoolean(key, defaultValue);
+ }
+
+ @Override public void remove(@NonNull String key) {
+ sp.edit().remove(key).apply();
+ }
+
+ public void putCollection(@NonNull String key, @NonNull List items) {
+ put(key, items);
+ }
+
+ @Override public List getCollection(@NonNull String key, @NonNull Type type) {
+ return get(key, type);
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/test/java/com/flatstack/android/utils/storage/RuntimeStorage.java b/app/src/test/java/com/flatstack/android/utils/storage/RuntimeStorage.java
new file mode 100644
index 0000000..ff25940
--- /dev/null
+++ b/app/src/test/java/com/flatstack/android/utils/storage/RuntimeStorage.java
@@ -0,0 +1,71 @@
+package com.flatstack.android.utils.storage;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RuntimeStorage implements IStorage {
+
+ private Map map = new HashMap<>();
+
+ @Override public void put(@NonNull String key, @NonNull T item) {
+ map.put(key, item);
+ }
+
+ @Nullable @Override
+ public T get(@NonNull String key, @NonNull Type clazz) {
+ return (T) map.get(key);
+ }
+
+ @Override public void putLong(@NonNull String key, long number) {
+ map.put(key, Long.valueOf(number));
+ }
+
+ @Override public long getLong(@NonNull String key, long defaultValue) {
+ Object o = map.get(key);
+ return o != null ? (long) o : defaultValue;
+ }
+
+ @Override public void putInt(@NonNull String key, int number) {
+ map.put(key, Integer.valueOf(number));
+ }
+
+ @Override public int getInt(@NonNull String key, int defaultValue) {
+ Object o = map.get(key);
+ return o != null ? (int) o : defaultValue;
+ }
+
+ @Override public void putBoolean(@NonNull String key, boolean value) {
+ map.put(key, Boolean.valueOf(value));
+ }
+
+ @Override public boolean getBoolean(@NonNull String key, boolean defaultValue) {
+ Object o = map.get(key);
+ return o != null ? (boolean) o : defaultValue;
+ }
+
+ @Override public void putString(@NonNull String key, @NonNull String str) {
+ map.put(key, str);
+ }
+
+ @Override public String getString(@NonNull String key) {
+ Object o = map.get(key);
+ return (o != null) ? (String) o : null;
+ }
+
+ @Override public void remove(@NonNull String key) {
+ map.remove(key);
+ }
+
+ @Override public void putCollection(@NonNull String key, @NonNull List items) {
+ map.put(key, items);
+ }
+
+ @Override public List getCollection(@NonNull String key, @NonNull Type type) {
+ return (List) map.get(key);
+ }
+}
\ No newline at end of file