From 14de918a79943e4961b09fa01ed320c6cad41f2e Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 28 六月 2023 17:14:51 +0800
Subject: [PATCH] Revert "Revert "Merge branch 'hxb' into wjc""

---
 HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 154 insertions(+), 0 deletions(-)

diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java
new file mode 100644
index 0000000..f5b8810
--- /dev/null
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java
@@ -0,0 +1,154 @@
+package com.hdl.sdk.link.common.utils;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import androidx.annotation.NonNull;
+
+
+import com.hdl.sdk.link.HDLLinkLocalSdk;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by Tong on 2021/9/28.
+ */
+public class SPUtils {
+    private static final String APP_PREFERENCES_KEY = "profile";
+    private static SharedPreferences PREFERENCES =
+            HDLLinkLocalSdk.getInstance().getContext().getApplicationContext().getSharedPreferences(APP_PREFERENCES_KEY, Context.MODE_PRIVATE);
+
+    private static SharedPreferences getAppPreference() {
+        if (PREFERENCES == null) {
+            PREFERENCES = HDLLinkLocalSdk.getInstance().getContext().getApplicationContext().getSharedPreferences(APP_PREFERENCES_KEY, Context.MODE_PRIVATE);
+        }
+        return PREFERENCES;
+    }
+
+
+    //======閫氱敤瀛樺偍========
+    public static void put(@NonNull final String key, final String value) {
+        getAppPreference().edit().putString(key, value).apply();
+    }
+
+
+    public static String getString(@NonNull final String key) {
+        return getString(key, "");
+    }
+
+
+    public static String getString(@NonNull final String key, final String defaultValue) {
+        return getAppPreference().getString(key, defaultValue);
+    }
+
+
+    public static void put(@NonNull final String key, final int value) {
+        put(key, value, false);
+    }
+
+
+    public static void put(@NonNull final String key, final int value, final boolean isCommit) {
+        getAppPreference().edit().putInt(key, value).apply();
+    }
+
+
+    public static int getInt(@NonNull final String key) {
+        return getInt(key, -1);
+    }
+
+
+    public static int getInt(@NonNull final String key, final int defaultValue) {
+        return getAppPreference().getInt(key, defaultValue);
+    }
+
+
+    public static void put(@NonNull final String key, final long value) {
+        getAppPreference().edit().putLong(key, value).apply();
+    }
+
+
+    public static long getLong(@NonNull final String key) {
+        return getLong(key, -1L);
+    }
+
+
+    public static long getLong(@NonNull final String key, final long defaultValue) {
+        return getAppPreference().getLong(key, defaultValue);
+    }
+
+
+    public static void put(@NonNull final String key, final float value) {
+        getAppPreference().edit().putFloat(key, value).apply();
+    }
+
+
+    public static float getFloat(@NonNull final String key) {
+        return getFloat(key, -1f);
+    }
+
+
+    public static float getFloat(@NonNull final String key, final float defaultValue) {
+        return getAppPreference().getFloat(key, defaultValue);
+    }
+
+
+    public static void put(@NonNull final String key, final boolean value) {
+        getAppPreference().edit().putBoolean(key, value).apply();
+    }
+
+
+    public static boolean getBoolean(@NonNull final String key) {
+        return getBoolean(key, false);
+    }
+
+
+    public static boolean getBoolean(@NonNull final String key, final boolean defaultValue) {
+        return getAppPreference().getBoolean(key, defaultValue);
+    }
+
+
+    public static void put(@NonNull final String key,
+                           final Set<String> value
+    ) {
+
+        getAppPreference().edit().putStringSet(key, value).apply();
+
+    }
+
+
+    public static Set<String> getStringSet(@NonNull final String key) {
+        return getStringSet(key, Collections.<String>emptySet());
+    }
+
+
+    public static Set<String> getStringSet(@NonNull final String key,
+                                           final Set<String> defaultValue) {
+        return getAppPreference().getStringSet(key, defaultValue);
+    }
+
+
+    public static Map<String, ?> getAll() {
+        return getAppPreference().getAll();
+    }
+
+
+    public static boolean contains(@NonNull final String key) {
+        return getAppPreference().contains(key);
+    }
+
+
+    public static void remove(@NonNull final String key) {
+        getAppPreference().edit().remove(key).apply();
+    }
+
+    public static void clear() {
+        getAppPreference()
+                .edit()
+                .clear()
+                .apply();
+    }
+
+
+}

--
Gitblit v1.8.0