Skip to content

Commit 84beb83

Browse files
modify
1 parent e50e3a6 commit 84beb83

25 files changed

Lines changed: 43 additions & 1119 deletions

File tree

README.md

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,49 @@ BaseActivity中添加取出数据和存储数据代码:
1111
protected void onCreate(@Nullable Bundle savedInstanceState) {
1212
super.onCreate(savedInstanceState);
1313

14-
//get data
14+
//DataAutoAccessTool 取数据
1515
Bundle data;
16+
boolean isFromIntent = true;
1617
data = getIntent().getExtras();
17-
//judge data source
18+
//判断数据源
1819
if (data == null) {
1920
data = savedInstanceState;
21+
isFromIntent = false;
2022
}
21-
DataAutoAccess.getData(this, data);
23+
DataAutoAccessTool.getData(this, data, isFromIntent);
24+
2225
}
2326

27+
28+
2429
@Override
2530
protected void onSaveInstanceState(Bundle outState) {
2631
super.onSaveInstanceState(outState);
27-
//save data
28-
DataAutoAccess.saveData(this, outState);
32+
//系统由于内存不足而杀死activity,此时保存数据
33+
DataAutoAccessTool.saveData(this, outState);
2934
}
3035

3136
启动Activity时传入参数:
3237

33-
Intent intent = new Intent(this, TestActivity.class);
34-
intent.putExtra("name", "DataAutoAccess");
35-
intent.putExtra("description", "Android bundle data auto access.");
36-
startActivity(intent);
38+
Intent intent = new Intent(this, TestActivity.class);
39+
intent.putExtra("name", "DataAutoAccess");
40+
intent.putExtra("description", "Android bundle data auto access.");
41+
startActivity(intent);
3742

38-
给ExampleActivity中需要自动存储的变量添加注解
43+
给TestActivity中需要自动存储的变量添加注解
3944

40-
@AutoAccess(dataName = "name")
45+
@DataAutoAccess(dataName = "name")
4146
private String name;
42-
@AutoAccess(dataName = "description")
47+
@DataAutoAccess(dataName = "description")
4348
private String description;
4449

45-
经过以上配置之后,DataAutoAccess会自动从intent中取出数据,给name和description变量赋值,而且当activity由于系统内存不足被杀死时,也会自动保存变量值,在onCreate时取出进行赋值
50+
经过以上配置之后,DataAutoAccessTool会自动从intent中取出数据,给name和description变量赋值,而且当activity由于系统内存不足被杀死时,也会自动保存变量值,在onCreate时取出进行自动赋值
4651

4752

4853
##Download
49-
Configure your project-level build.gradle to include the 'android-apt' plugin:
50-
51-
buildscript {
52-
repositories {
53-
mavenCentral()
54-
}
55-
dependencies {
56-
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
57-
}
58-
}
59-
60-
allprojects {
61-
repositories {
62-
maven {
63-
url "https://dl.bintray.com/thirtydegreesray/maven/"
64-
}
65-
}
66-
}
67-
68-
Then, apply the 'android-apt' plugin in your module-level build.gradle and add the Data Auto Access dependencies:
6954

70-
apply plugin: 'android-apt'
71-
72-
android {
73-
...
74-
}
75-
7655
dependencies {
77-
compile 'com.thirtydegreesray:dataautoaccess:1.2.0'
78-
apt 'com.thirtydegreesray:dataautoaccess-compiler:1.2.0'
56+
compile 'com.thirtydegreesray.dataautoaccess:Library:1.0.5'
7957
}
8058

8159
##License

Sample/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'android-apt'
32

43
android {
54
compileSdkVersion 24
@@ -30,6 +29,6 @@ dependencies {
3029
})
3130
compile 'com.android.support:appcompat-v7:24.2.0'
3231
testCompile 'junit:junit:4.12'
33-
compile project(':dataautoaccess')
34-
apt project(':dataautoaccess-compiler')
32+
33+
compile project (':Library')
3534
}

Sample/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<category android:name="android.intent.category.LAUNCHER" />
1212
</intent-filter>
1313
</activity>
14-
<activity android:name=".ExampleActivity" />
14+
<activity android:name=".TestActivity" />
1515
</application>
1616

1717
</manifest>

Sample/src/main/java/com/thirtydegreesray/sample/BaseActivity.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,37 @@
44
import android.support.annotation.Nullable;
55
import android.support.v7.app.AppCompatActivity;
66

7-
import com.thirtydegreesray.dataautoaccess.DataAutoAccess;
7+
import com.thirtydegreesray.dataautoaccess.DataAutoAccessTool;
88

99
/**
1010
* Created by ThirtyDegreesRay on 2016/9/1 09:58
1111
*/
1212

1313
public class BaseActivity extends AppCompatActivity {
14+
1415
@Override
1516
protected void onCreate(@Nullable Bundle savedInstanceState) {
1617
super.onCreate(savedInstanceState);
17-
//get data
18+
19+
//DataAutoAccessTool 取数据
1820
Bundle data;
21+
boolean isFromIntent = true;
1922
data = getIntent().getExtras();
20-
//judge data source
23+
//判断数据源
2124
if (data == null) {
2225
data = savedInstanceState;
26+
isFromIntent = false;
2327
}
24-
DataAutoAccess.getData(this, data);
28+
DataAutoAccessTool.getData(this, data, isFromIntent);
29+
2530
}
2631

32+
33+
2734
@Override
2835
protected void onSaveInstanceState(Bundle outState) {
2936
super.onSaveInstanceState(outState);
30-
//save data
31-
DataAutoAccess.saveData(this, outState);
37+
//系统由于内存不足而杀死activity,此时保存数据
38+
DataAutoAccessTool.saveData(this, outState);
3239
}
3340
}

Sample/src/main/java/com/thirtydegreesray/sample/ExampleActivity.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

Sample/src/main/java/com/thirtydegreesray/sample/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {
1616
}
1717

1818
public void onDataAutoAccessClick(View view){
19-
Intent intent = new Intent(this, ExampleActivity.class);
19+
Intent intent = new Intent(this, TestActivity.class);
2020
intent.putExtra("name", "DataAutoAccess");
2121
intent.putExtra("description", "Android bundle data auto access.");
2222
startActivity(intent);

Sample/src/main/java/com/thirtydegreesray/sample/TestClass.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

Sample/src/main/res/layout/activity_test.xml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,17 @@
33
android:orientation="vertical" android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:background="@color/app_bg"
6-
android:padding="8dp"
7-
android:gravity="center">
6+
android:padding="8dp">
87
<TextView
98
android:id="@+id/tv_name"
109
android:layout_width="match_parent"
1110
android:layout_height="wrap_content"
1211
android:textSize="20sp"
13-
android:textColor="@android:color/black"
14-
android:gravity="center"/>
12+
android:textColor="@android:color/black"/>
1513
<TextView
1614
android:id="@+id/tv_description"
1715
android:layout_width="match_parent"
1816
android:layout_height="wrap_content"
1917
android:textSize="16sp"
20-
android:textColor="@android:color/black"
21-
android:gravity="center"/>
22-
23-
<Button
24-
android:layout_width="120dp"
25-
android:layout_height="wrap_content"
26-
android:text="SaveData"
27-
android:onClick="onSaveDataClick"
28-
android:layout_marginTop="20dp"/>
29-
<Button
30-
android:layout_width="120dp"
31-
android:layout_height="wrap_content"
32-
android:text="ChangeData"
33-
android:onClick="onChangeDataClick"/>
34-
<Button
35-
android:layout_width="120dp"
36-
android:layout_height="wrap_content"
37-
android:text="GetData"
38-
android:onClick="onGetDataClick"/>
18+
android:textColor="@android:color/black"/>
3919
</LinearLayout>

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
buildscript {
44
repositories {
5-
mavenCentral()
5+
maven {
6+
url "https://plugins.gradle.org/m2/"
7+
}
68
jcenter()
79
}
810
dependencies {
911
classpath 'com.android.tools.build:gradle:2.1.3'
10-
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
1112

1213
classpath "com.github.dcendents:android-maven-gradle-plugin:1.5"
1314
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'

dataautoaccess-annotations/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)