parent
11b8ca624a
commit
3f16482614
@ -0,0 +1,53 @@ |
||||
package com.github.catvod.utils; |
||||
|
||||
import static android.content.Context.MODE_PRIVATE; |
||||
|
||||
import android.content.SharedPreferences; |
||||
|
||||
import com.github.catvod.spider.Init; |
||||
|
||||
public class Prefers { |
||||
|
||||
private static SharedPreferences getPrefers() { |
||||
return Init.context().getSharedPreferences(Init.context().getPackageName() + "_preferences", MODE_PRIVATE); |
||||
} |
||||
|
||||
public static String getString(String key, String defaultValue) { |
||||
return getPrefers().getString(key, defaultValue); |
||||
} |
||||
|
||||
public static String getString(String key) { |
||||
return getString(key, ""); |
||||
} |
||||
|
||||
public static int getInt(String key, int defaultValue) { |
||||
return getPrefers().getInt(key, defaultValue); |
||||
} |
||||
|
||||
public static int getInt(String key) { |
||||
return getInt(key, 0); |
||||
} |
||||
|
||||
public static boolean getBoolean(String key, boolean defaultValue) { |
||||
return getPrefers().getBoolean(key, defaultValue); |
||||
} |
||||
|
||||
public static boolean getBoolean(String key) { |
||||
return getPrefers().getBoolean(key, false); |
||||
} |
||||
|
||||
public static void put(String key, Object obj) { |
||||
if (obj == null) return; |
||||
if (obj instanceof String) { |
||||
getPrefers().edit().putString(key, (String) obj).apply(); |
||||
} else if (obj instanceof Boolean) { |
||||
getPrefers().edit().putBoolean(key, (Boolean) obj).apply(); |
||||
} else if (obj instanceof Float) { |
||||
getPrefers().edit().putFloat(key, (Float) obj).apply(); |
||||
} else if (obj instanceof Integer) { |
||||
getPrefers().edit().putInt(key, (Integer) obj).apply(); |
||||
} else if (obj instanceof Long) { |
||||
getPrefers().edit().putLong(key, (Long) obj).apply(); |
||||
} |
||||
} |
||||
} |
||||
@ -1,6 +1,7 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
android:layout_height="match_parent" |
||||
android:background="#000000"> |
||||
|
||||
</FrameLayout> |
||||
Binary file not shown.
@ -1 +1 @@ |
||||
cdac5d0feef2fb20bb47496ec835a0a2 |
||||
ada79cfb8f05a9146ecc90b844b760b9 |
||||
|
||||
Loading…
Reference in new issue