Skip to content

Commit

Permalink
解决bug
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xiaojun committed May 4, 2017
1 parent 3ab8327 commit ba6cfa2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.xrefreshlayout.sample;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.lxj.xrefreshlayout.XRefreshLayout;
import com.lxj.xrefreshlayout.loadinglayout.ILoadingLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -36,6 +40,7 @@ public void onLoadMore() {
doNothing();
}
});

}

private void doNothing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
return super.dispatchTouchEvent(ev) ;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_UP){
L.d("action up -------------------->");
}
return super.onTouchEvent(event);
}

@Override
public void onNestedScrollAccepted(View child, View target, int axes) {
Expand All @@ -128,7 +135,7 @@ public void onNestedScrollAccepted(View child, View target, int axes) {
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
isPullHeader = false;
isPullFooter = false;
return true && !isSmoothScrolling;
return true;
}

/**
Expand All @@ -138,7 +145,8 @@ public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes
*/
@Override
public void onStopNestedScroll(View child) {
L.d("onStopNestedScroll, isPullHeader: "+isPullHeader +" isPullFooter:"+isPullFooter );
L.d("onStopNestedScroll isRelease:"+isRelease + " isPullHeader:"+isPullHeader
+" isPullFooter: "+isPullFooter);
isRelease = true;
if (isPullHeader) {
if (getScrollY() <= -header.getMeasuredHeight()) {
Expand Down Expand Up @@ -171,6 +179,11 @@ public void onStopNestedScroll(View child) {
int dy = 0 - getScrollY();
smoothScroll(dy);
}
}else {
//hide footer smoothly.
isNeedInitLoadingLayout = true;
int dy = 0 - getScrollY();
smoothScroll(dy);
}
}

Expand Down Expand Up @@ -273,7 +286,7 @@ public void scrollTo(@Px int x, @Px int y) {
float percent = Math.abs(y) * 1f / footer.getMeasuredHeight();
percent = Math.min(percent, 1f);
if(!isRelease){
loadingLayout.onPullFooter(Math.min(percent, 1f));
loadingLayout.onPullFooter(percent);
}
}
super.scrollTo(x, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public void initAndResetFooter() {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class L {
private static final String TAG = "XRefreshLayout";
public static boolean isDebug = false;
public static boolean isDebug = true;
public static void d(String msg){
if(isDebug){
Log.d(TAG,msg);
Expand Down

0 comments on commit ba6cfa2

Please sign in to comment.