Skip to content

Commit 7556410

Browse files
authored
Merge pull request #9 from DovSnier/developer
[DONE]合并分支
2 parents b80d9ec + 1e783eb commit 7556410

File tree

7 files changed

+46
-23
lines changed

7 files changed

+46
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#### 使用Gradle构建时添加一下依赖即可:
1010
```
11-
compile 'com.dvsnier:cacheLib:0.0.5'
11+
implementation 'com.dvsnier:cacheLib:0.0.6'
1212
```
1313

1414
#### 使用前配置

app/build.gradle

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion rootProject.ext.compile_sdk_version
5+
buildToolsVersion rootProject.ext.build_tools_version
6+
67
defaultConfig {
78
applicationId "com.dvsnier.demo"
8-
minSdkVersion 10
9-
targetSdkVersion 26
10-
versionCode 2
11-
versionName "1.0.0"
9+
minSdkVersion rootProject.ext.min_sdk_version
10+
targetSdkVersion rootProject.ext.target_sdk_version
11+
versionCode 3
12+
versionName "1.0.1"
1213
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1314
}
1415
buildTypes {
@@ -20,10 +21,11 @@ android {
2021
}
2122

2223
dependencies {
23-
compile fileTree(include: ['*.jar'], dir: 'libs')
24-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
24+
implementation fileTree(include: ['*.jar'], dir: 'libs')
25+
androidTestImplementation("com.android.support.test.espresso:espresso-core:${rootProject.ext.espresso_core_version}", {
2526
exclude group: 'com.android.support', module: 'support-annotations'
2627
})
27-
testCompile 'junit:junit:4.12'
28-
compile project(':cacheLib')
28+
implementation "com.android.support:support-annotations:${rootProject.ext.support_annotations_version}"
29+
testImplementation "junit:junit:${rootProject.ext.junit_version}"
30+
implementation project(':cacheLib')
2931
}

app/src/main/java/com/dvsnier/demo/Bean.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.dvsnier.demo;
22

3+
import android.support.annotation.NonNull;
4+
35
import java.io.Serializable;
46

57
/**
@@ -8,13 +10,15 @@
810
public class Bean implements Serializable {
911

1012
private static final long serialVersionUID = 8219150308909916068L;
13+
@NonNull
1114
private String name;
15+
@NonNull
1216
private String version;
1317

1418
public Bean() {
1519
}
1620

17-
public Bean(String name, String version) {
21+
public Bean(@NonNull String name, @NonNull String version) {
1822
this.name = name;
1923
this.version = version;
2024
}
@@ -35,6 +39,24 @@ public void setVersion(String version) {
3539
this.version = version;
3640
}
3741

42+
@Override
43+
public boolean equals(Object o) {
44+
if (this == o) return true;
45+
if (o == null || getClass() != o.getClass()) return false;
46+
47+
Bean bean = (Bean) o;
48+
49+
if (!name.equals(bean.name)) return false;
50+
return version.equals(bean.version);
51+
}
52+
53+
@Override
54+
public int hashCode() {
55+
int result = name.hashCode();
56+
result = 31 * result + version.hashCode();
57+
return result;
58+
}
59+
3860
@Override
3961
public String toString() {
4062
return "Bean{" +

app/src/main/java/com/dvsnier/demo/MainActivity.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,21 @@ protected void onCreate(Bundle savedInstanceState) {
2222
setContentView(R.layout.activity_main);
2323
test = (TextView) findViewById(R.id.test);
2424
content = (TextView) findViewById(R.id.content);
25-
obtainContent();
2625
test.setOnClickListener(new View.OnClickListener() {
2726
@Override
2827
public void onClick(View view) {
2928
CacheManager.getInstance().put(key0, "测试数据: " + System.currentTimeMillis())
3029
.putString(key1, "测试字符串: " + view.toString())
31-
.putObject(key2, new Bean("cache", "0.0.5"))
30+
.putObject(key2, new Bean("cache object " + System.currentTimeMillis(), BuildConfig.VERSION_NAME))
3231
.commit();
3332
obtainContent();
34-
Toast.makeText(MainActivity.this, "测试完成,60s 后准备关闭...", Toast.LENGTH_SHORT).show();
33+
Toast.makeText(MainActivity.this, "测试完成,6s 后准备关闭...", Toast.LENGTH_SHORT).show();
3534
view.postDelayed(new Runnable() {
3635
@Override
3736
public void run() {
3837
finish();
3938
}
40-
}, 60 * 1000);
39+
}, 6 * 1000);
4140
}
4241
});
4342
}

cacheLib/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ android {
3131
}
3232

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

4242
task sourcesJar(type: Jar) {

cacheLib/src/main/java/com/dvsnier/cache/CacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void initialize(@NonNull ICacheConfig cacheConfig) {
5555
if (null != cache) {
5656
//noinspection ConstantConditions
5757
if (null != cacheConfig) {
58-
cache.initialize(cacheConfig.getContext());
58+
cache.initialize(cacheConfig);
5959
}
6060
}
6161
}

dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ext {
88
// 配置环境
99
min_sdk_version = 10
1010
target_sdk_version = 27
11-
version_code = 5
12-
version_name = "0.0.5"
11+
version_code = 6
12+
version_name = "0.0.6"
1313

1414
// support SDK 配置
1515
support_appcompat_version = "24.2.0"

0 commit comments

Comments
 (0)