Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#### 使用Gradle构建时添加一下依赖即可:
```
compile 'com.dvsnier:cacheLib:0.0.5'
implementation 'com.dvsnier:cacheLib:0.0.6'
```

#### 使用前配置
Expand Down
22 changes: 12 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
compileSdkVersion rootProject.ext.compile_sdk_version
buildToolsVersion rootProject.ext.build_tools_version

defaultConfig {
applicationId "com.dvsnier.demo"
minSdkVersion 10
targetSdkVersion 26
versionCode 2
versionName "1.0.0"
minSdkVersion rootProject.ext.min_sdk_version
targetSdkVersion rootProject.ext.target_sdk_version
versionCode 3
versionName "1.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -20,10 +21,11 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation("com.android.support.test.espresso:espresso-core:${rootProject.ext.espresso_core_version}", {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile project(':cacheLib')
implementation "com.android.support:support-annotations:${rootProject.ext.support_annotations_version}"
testImplementation "junit:junit:${rootProject.ext.junit_version}"
implementation project(':cacheLib')
}
24 changes: 23 additions & 1 deletion app/src/main/java/com/dvsnier/demo/Bean.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dvsnier.demo;

import android.support.annotation.NonNull;

import java.io.Serializable;

/**
Expand All @@ -8,13 +10,15 @@
public class Bean implements Serializable {

private static final long serialVersionUID = 8219150308909916068L;
@NonNull
private String name;
@NonNull
private String version;

public Bean() {
}

public Bean(String name, String version) {
public Bean(@NonNull String name, @NonNull String version) {
this.name = name;
this.version = version;
}
Expand All @@ -35,6 +39,24 @@ public void setVersion(String version) {
this.version = version;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Bean bean = (Bean) o;

if (!name.equals(bean.name)) return false;
return version.equals(bean.version);
}

@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + version.hashCode();
return result;
}

@Override
public String toString() {
return "Bean{" +
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/com/dvsnier/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
test = (TextView) findViewById(R.id.test);
content = (TextView) findViewById(R.id.content);
obtainContent();
test.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CacheManager.getInstance().put(key0, "测试数据: " + System.currentTimeMillis())
.putString(key1, "测试字符串: " + view.toString())
.putObject(key2, new Bean("cache", "0.0.5"))
.putObject(key2, new Bean("cache object " + System.currentTimeMillis(), BuildConfig.VERSION_NAME))
.commit();
obtainContent();
Toast.makeText(MainActivity.this, "测试完成,60s 后准备关闭...", Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, "测试完成,6s 后准备关闭...", Toast.LENGTH_SHORT).show();
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 60 * 1000);
}, 6 * 1000);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions cacheLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile("com.android.support.test.espresso:espresso-core:${rootProject.ext.espresso_core_version}", {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation("com.android.support.test.espresso:espresso-core:${rootProject.ext.espresso_core_version}", {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:support-annotations:${rootProject.ext.support_annotations_version}"
testCompile "junit:junit:${rootProject.ext.junit_version}"
implementation "com.android.support:support-annotations:${rootProject.ext.support_annotations_version}"
testImplementation "junit:junit:${rootProject.ext.junit_version}"
}

task sourcesJar(type: Jar) {
Expand Down
2 changes: 1 addition & 1 deletion cacheLib/src/main/java/com/dvsnier/cache/CacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void initialize(@NonNull ICacheConfig cacheConfig) {
if (null != cache) {
//noinspection ConstantConditions
if (null != cacheConfig) {
cache.initialize(cacheConfig.getContext());
cache.initialize(cacheConfig);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ext {
// 配置环境
min_sdk_version = 10
target_sdk_version = 27
version_code = 5
version_name = "0.0.5"
version_code = 6
version_name = "0.0.6"

// support SDK 配置
support_appcompat_version = "24.2.0"
Expand Down