Skip to content

Commit 38f2f89

Browse files
committed
1.修复LogFragment 无法滑动到最底部的问题
1 parent 27987d4 commit 38f2f89

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22
apply plugin: 'android-apt'
33
android {
44
compileSdkVersion 24
5-
buildToolsVersion "24.0.3"
5+
buildToolsVersion '25.0.0'
66
defaultConfig {
77
applicationId "com.demo.maat.hello_rxjava"
88
minSdkVersion 16
@@ -20,16 +20,14 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
2424
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
2727
compile 'com.android.support:appcompat-v7:24.2.1'
2828
testCompile 'junit:junit:4.12'
29-
3029
compile 'com.jakewharton:butterknife:8.4.0'
3130
apt 'com.jakewharton:butterknife-compiler:8.4.0'
32-
3331
compile 'io.reactivex:rxandroid:1.0.1'
3432
// Because RxAndroid releases are few and far between, it is recommended you also
3533
// explicitly depend on RxJava's latest version for bug fixes and new features.
@@ -41,6 +39,5 @@ dependencies {
4139
compile 'com.squareup.retrofit2:converter-gson:+'
4240
compile 'com.squareup.retrofit2:adapter-rxjava:+'
4341
compile 'com.google.code.gson:gson:+'
44-
4542
compile 'io.reactivex:rxandroid:1.2.1'
4643
}

app/src/main/java/com/demo/maat/hello_rxjava/common/logger/LogFragment.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {}
9898

9999
@Override
100100
public void afterTextChanged(Editable s) {
101-
mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
101+
//afterTextChanged 在 text发生改变后马上被调用,此时可能text还未被绘制,导致无法滑动到最底部
102+
//所以不能直接调用,而应该使用post
103+
mScrollView.post(new Runnable(){
104+
@Override
105+
public void run() {
106+
mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
107+
}
108+
});
102109
}
103110
});
104111
return result;

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.0'
8+
classpath 'com.android.tools.build:gradle:2.2.3'
99
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

0 commit comments

Comments
 (0)