第一次提交

This commit is contained in:
被淹死的鱼
2026-03-11 18:26:29 +08:00
commit cd3b53759e
8532 changed files with 522078 additions and 0 deletions

1
storage/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

34
storage/build.gradle Normal file
View File

@@ -0,0 +1,34 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.code.gson:gson:2.4'
}

21
storage/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package com.fengliyan.storage;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.caivideo.storage.test", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fengliyan.storage" />

View File

@@ -0,0 +1,89 @@
package com.fengliyan.storage;
import android.content.Context;
import android.content.SharedPreferences;
import com.google.gson.Gson;
import java.lang.reflect.Type;
/**
* Created by abby on 2016/12/12.
*/
public class StorageManager {
private static StorageManager mInstance;
private SharedPreferences mSharedPreferences;
private Context mContext;
public static StorageManager getInstance(Context context) {
if (null == mInstance) {
mInstance = new StorageManager(context);
}
return mInstance;
}
private StorageManager(Context context) {
mContext = context;
mSharedPreferences = mContext.getSharedPreferences("MaleSocialBase", Context.MODE_PRIVATE);
}
public StorageManager getStorage(String name) {
mSharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE);
return this;
}
public void putString(String name, String data) {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(name, data);
editor.commit();
}
public void putBean(String name, Object object) {
Gson gson = new Gson();
String toJson = gson.toJson(object);
putString(name, toJson);
}
public Object getBean(String name, Type classType) {
Gson gson = new Gson();
String fromJson = getString(name);
return gson.fromJson(fromJson, classType);
}
public String getString(String name) {
return mSharedPreferences.getString(name, null);
}
public void putInt(String name, int data) {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putInt(name, data);
editor.commit();
}
public int getInt(String name) {
return mSharedPreferences.getInt(name, -1);
}
public int getInt(String name, int def) {
return mSharedPreferences.getInt(name, def);
}
public void clear() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.clear();
editor.commit();
}
public void putBoolean(String name, boolean data) {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(name, data);
editor.commit();
}
public boolean getBoolean(String name, boolean dev) {
return mSharedPreferences.getBoolean(name, dev);
}
}

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Storage</string>
</resources>

View File

@@ -0,0 +1,17 @@
package com.fengliyan.storage;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}