Skip to content

Commit ba6cfa2

Browse files
author
li-xiaojun
committed
解决bug
1 parent 3ab8327 commit ba6cfa2

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

sample/src/main/java/com/xrefreshlayout/sample/NestedScrollViewActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.xrefreshlayout.sample;
22

3+
import android.content.Context;
34
import android.os.Bundle;
45
import android.os.Handler;
56
import android.support.annotation.Nullable;
67
import android.support.v7.app.AppCompatActivity;
8+
import android.view.View;
9+
import android.view.ViewGroup;
710
import android.widget.Toast;
811

912
import com.lxj.xrefreshlayout.XRefreshLayout;
13+
import com.lxj.xrefreshlayout.loadinglayout.ILoadingLayout;
1014

1115
import butterknife.BindView;
1216
import butterknife.ButterKnife;
@@ -36,6 +40,7 @@ public void onLoadMore() {
3640
doNothing();
3741
}
3842
});
43+
3944
}
4045

4146
private void doNothing() {

xrefreshlayout/src/main/java/com/lxj/xrefreshlayout/XRefreshLayout.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
118118
return super.dispatchTouchEvent(ev) ;
119119
}
120120

121+
@Override
122+
public boolean onTouchEvent(MotionEvent event) {
123+
if(event.getAction()==MotionEvent.ACTION_UP){
124+
L.d("action up -------------------->");
125+
}
126+
return super.onTouchEvent(event);
127+
}
121128

122129
@Override
123130
public void onNestedScrollAccepted(View child, View target, int axes) {
@@ -128,7 +135,7 @@ public void onNestedScrollAccepted(View child, View target, int axes) {
128135
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
129136
isPullHeader = false;
130137
isPullFooter = false;
131-
return true && !isSmoothScrolling;
138+
return true;
132139
}
133140

134141
/**
@@ -138,7 +145,8 @@ public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes
138145
*/
139146
@Override
140147
public void onStopNestedScroll(View child) {
141-
L.d("onStopNestedScroll, isPullHeader: "+isPullHeader +" isPullFooter:"+isPullFooter );
148+
L.d("onStopNestedScroll isRelease:"+isRelease + " isPullHeader:"+isPullHeader
149+
+" isPullFooter: "+isPullFooter);
142150
isRelease = true;
143151
if (isPullHeader) {
144152
if (getScrollY() <= -header.getMeasuredHeight()) {
@@ -171,6 +179,11 @@ public void onStopNestedScroll(View child) {
171179
int dy = 0 - getScrollY();
172180
smoothScroll(dy);
173181
}
182+
}else {
183+
//hide footer smoothly.
184+
isNeedInitLoadingLayout = true;
185+
int dy = 0 - getScrollY();
186+
smoothScroll(dy);
174187
}
175188
}
176189

@@ -273,7 +286,7 @@ public void scrollTo(@Px int x, @Px int y) {
273286
float percent = Math.abs(y) * 1f / footer.getMeasuredHeight();
274287
percent = Math.min(percent, 1f);
275288
if(!isRelease){
276-
loadingLayout.onPullFooter(Math.min(percent, 1f));
289+
loadingLayout.onPullFooter(percent);
277290
}
278291
}
279292
super.scrollTo(x, y);

xrefreshlayout/src/main/java/com/lxj/xrefreshlayout/loadinglayout/DefaultLoadingLayout.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public void initAndResetFooter() {
6464

6565
@Override
6666
public void onPullHeader(float percent) {
67-
tvHeaderState.setText("释放立即刷新");
67+
tvHeaderState.setText(percent==1f?"释放立即刷新":"下拉刷新");
6868
ivHeaderArrow.setRotation(360*percent);
6969
}
7070

7171
@Override
7272
public void onPullFooter(float percent) {
73-
tvFooterState.setText("释放立即加载");
73+
tvFooterState.setText(percent==1f?"释放立即加载":"上拉加载");
7474
ivFooterArrow.setRotation(360*percent);
7575
}
7676

xrefreshlayout/src/main/java/com/lxj/xrefreshlayout/util/L.java

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

99
public class L {
1010
private static final String TAG = "XRefreshLayout";
11-
public static boolean isDebug = false;
11+
public static boolean isDebug = true;
1212
public static void d(String msg){
1313
if(isDebug){
1414
Log.d(TAG,msg);

0 commit comments

Comments
 (0)