Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ public class SwipeToLoadLayout extends ViewGroup {
*/
private boolean mLoadMoreEnabled = true;

/**
* a switcher whither hiding headerView when refreshing
*/

private boolean isHideHeaderWhenRefreshing = false;

/**
* a switcher whither hiding footerView when loadingmore
*/

private boolean isHideFooterWhenLoadingMore = false;

/**
* <b>ATTRIBUTE:</b>
* the style default classic
Expand Down Expand Up @@ -496,6 +508,19 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
if (mActivePointerId == INVALID_POINTER) {
return false;
}

//hide headerView when refreshing , it will improve the user experience
if (mHasHeaderView && isRefreshing() && isHideHeaderWhenRefreshing){
mRefreshCallback.onReset();
scrollRefreshingToDefault();
}

//hide footerView when loadingmore , it will improve the user experience
if (mHasFooterView && isLoadingMore() && isHideFooterWhenLoadingMore){
mLoadMoreCallback.onReset();
scrollLoadingMoreToDefault();
}

float y = getMotionEventY(event, mActivePointerId);
float x = getMotionEventX(event, mActivePointerId);
final float yInitDiff = y - mInitDownY;
Expand All @@ -513,6 +538,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
// intercept the move action event and pass it to SwipeToLoadLayout#onTouchEvent()
return true;
}

break;
case MotionEvent.ACTION_POINTER_UP: {
onSecondaryPointerUp(event);
Expand All @@ -538,6 +564,7 @@ public boolean onTouchEvent(MotionEvent event) {
return true;

case MotionEvent.ACTION_MOVE:

// take over the ACTION_MOVE event from SwipeToLoadLayout#onInterceptTouchEvent()
// if condition is true
final float y = getMotionEventY(event, mActivePointerId);
Expand Down Expand Up @@ -687,6 +714,24 @@ public boolean isLoadingMore() {
return STATUS.isLoadingMore(mStatus);
}

/**
* a switcher whither hiding headerView when refreshing
*
* @param hideable
*/
public void setHideHeaderWhenRefreshing(boolean hideable) {
this.isHideHeaderWhenRefreshing = hideable;
}

/**
* a switcher whither hiding footerView when loadingmore
*
* @param hideable
*/
public void setHideFooterWhenLoadingMore(boolean hideable) {
this.isHideFooterWhenLoadingMore = hideable;
}

/**
* set refresh header view, the view must at lease be an implement of {@code SwipeRefreshTrigger}.
* the view can also implement {@code SwipeTrigger} for more extension functions
Expand Down