Skip to content

Commit e3c9004

Browse files
committed
2016-10-20 11:26:55 rxandroid的使用学习
1 parent 667add3 commit e3c9004

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

app/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ dependencies {
5050

5151
//other
5252
compile 'uk.co.chrisjenx:calligraphy:2.2.0'//在xml中加载字体 2016-8-25
53+
54+
//rxandroid
55+
compile 'io.reactivex:rxandroid:1.2.1'
5356
}

app/src/main/java/com/ywzheng/znote/Znote.java

+19
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.util.List;
22+
import java.util.concurrent.TimeUnit;
23+
24+
import rx.Observable;
25+
import rx.android.schedulers.AndroidSchedulers;
26+
import rx.functions.Action1;
2227

2328
/**
2429
* 杂记
@@ -79,6 +84,18 @@ public void onClick(DialogInterface dialog, int which) {
7984
return;
8085
}
8186
}
87+
88+
// 2016-10-20 11:23:28 rxadnroid 的使用
89+
90+
Observable.timer(1000, TimeUnit.SECONDS)
91+
.observeOn(AndroidSchedulers.mainThread())
92+
.subscribe(new Action1<Long>() {
93+
@Override
94+
public void call(Long aLong) {
95+
//延时要做的事
96+
}
97+
});
98+
8299
}
83100

84101
public String loadJSONFromAsset() {
@@ -96,4 +113,6 @@ public String loadJSONFromAsset() {
96113
}
97114
return json;
98115
}
116+
117+
99118
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<ImageView
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:contentDescription="@string/about_body"
12+
tools:targetApi="m"/>
13+
</LinearLayout>
14+
15+
<!--Android Tools Attributes,让布局设计所见即所得 -->
16+
<!--http://yifeng.studio/2016/10/13/android-tools-attributes/-->

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
mavenCentral()//butterknife
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.2.0'
9+
classpath 'com.android.tools.build:gradle:2.2.1'
1010
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'//butterknife
1111
classpath "io.realm:realm-gradle-plugin:1.1.1"//realm
1212
// NOTE: Do not place your application dependencies here; they belong

0 commit comments

Comments
 (0)