You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A highly efficient refresh library for Android.Can support all Views.It's easy to use and more powerful than SwipeRefreshLayout.
Features:
Can support all Views, according to the specific needs to adaptation.
Support Multi-Touch.
Support Nested-Scroll feature, implemented the NestedScrollingChild3, NestedScrollingParent3 interface.
Extends the ViewGroup, has excellent performance,support similar FameLayout feature(Gravity、Margin).
Support Auto-Refresh、Auto-LoadMore、Scroll to bottom to Auto-LoadMore(Recommended to use the Adapter while use ListView/GridView/RecyclerView)、Scroll to top to Auto-Refresh.
Support Cross boundary rebound(OverScroll), supports Physics-based motion.
Support Horizontal refresh.
Support Drawer-Style(Refresh view below the Content view and Refresh view has been pinned).
Support Refresh view has six styles: STYLE_DEFAULT(Do not change the height by default)、 STYLE_SCALE(Dynamically change the height)、 STYLE_PIN(Pinned the refresh view)、 STYLE_FOLLOW_SCALE(When the moved position large than the view height, SmoothRefreshLayout will dynamically change the height)、 STYLE_FOLLOW_PIN(When the moved position large than the view height,pinned the refresh view)、 STYLE_FOLLOW_CENTER(When the moved position large than the view height, make refresh view in center) .
Support Two-Level refresh(TwoLevelSmoothRefreshLayout), PS:TaoBao-Second-Floor、JD-Activity.
Support ListView, GridView, RecyclerView on LoadMore to smooth scrolling.
Support synchronous Fling gestures.
Support Scale effect, PS:XIAOMI phone settings page effects.
Support Horizontal Scale effect.
Many callback interface and debugging information.
Installation
Add the following dependency to your build.gradle file:
public interface IRefreshView<T extends IIndicator> {
byte TYPE_HEADER = 0;
byte TYPE_FOOTER = 1;
byte STYLE_DEFAULT = 0;
byte STYLE_SCALE = 1;
//desc start
//added in version 1.4.8
byte STYLE_PIN = 2;
byte STYLE_FOLLOW_SCALE = 3;
byte STYLE_FOLLOW_PIN = 4;
byte STYLE_FOLLOW_CENTER = 5;
//desc end
/**
* Get the view type.
*
* @return type {@link #TYPE_HEADER}, {@link #TYPE_FOOTER}.
*/
@RefreshViewType
int getType();
/**
* Get the view style. If return {@link #STYLE_SCALE} SmoothRefreshLayout will dynamically
* change the height, so the performance will be reduced. If return {@link #STYLE_FOLLOW_SCALE}
* , when the moved position large than the view height, SmoothRefreshLayout will dynamically
* change the height, so the performance will be reduced.
*
* @return style {@link #STYLE_DEFAULT}, {@link #STYLE_SCALE}, {@link #STYLE_PIN},
* {@link #STYLE_FOLLOW_SCALE}, {@link #STYLE_FOLLOW_PIN}, {@link #STYLE_FOLLOW_CENTER}.
*/
@RefreshViewStyle
int getStyle();
/**
* Get the custom height, When the return style is {@link #STYLE_SCALE} or
* {@link #STYLE_FOLLOW_SCALE} , you must return a accurate height<br/>
* Since version 1.6.1, If you want the height equal to the srl height, you can return `-1`
* {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}
*
* @return Custom height
*/
int getCustomHeight();
/**
* Get the target view.
*
* @return The returned view must be the view that will be added to the Layout
*/
@NonNull
View getView();
/**
* This method will be triggered when the touched finger is lifted.
*
* @param layout The layout {@link SmoothRefreshLayout}
* @param indicator The indicator {@link IIndicator}
*/
void onFingerUp(SmoothRefreshLayout layout, T indicator);
/**
* This method will be triggered when the refresh state is reset to
* {@link SmoothRefreshLayout#SR_STATUS_INIT}.
*
* @param layout The layout {@link SmoothRefreshLayout}
*/
void onReset(SmoothRefreshLayout layout);
/**
* This method will be triggered when the frame is ready to refreshing.
*
* @param layout The layout {@link SmoothRefreshLayout}
*/
void onRefreshPrepare(SmoothRefreshLayout layout);
/**
* This method will be triggered when the frame begin to refresh.
*
* @param layout The layout {@link SmoothRefreshLayout}
* @param indicator The indicator {@link IIndicator}
*/
void onRefreshBegin(SmoothRefreshLayout layout, T indicator);
/**
* This method will be triggered when the frame is refresh completed.
*
* @param layout The layout {@link SmoothRefreshLayout}
* @param isSuccessful The layout refresh state
*/
void onRefreshComplete(SmoothRefreshLayout layout, boolean isSuccessful);
/**
* This method will be triggered when the position of the refresh view changes.
*
* @param layout The layout {@link SmoothRefreshLayout}
* @param status Current status @see{@link SmoothRefreshLayout#SR_STATUS_INIT},
* {@link SmoothRefreshLayout#SR_STATUS_PREPARE},
* {@link SmoothRefreshLayout#SR_STATUS_REFRESHING},
* {@link SmoothRefreshLayout#SR_STATUS_LOADING_MORE},
* {@link SmoothRefreshLayout#SR_STATUS_COMPLETE}.
* @param indicator The indicator {@link IIndicator}
*/
void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);
/**
* Before the transaction of the refresh view has not yet been processed completed。
* This method will be triggered when the position of the other refresh view changes.<br/>
* <p>
* Added in version 1.4.6
*
* @param layout The layout {@link SmoothRefreshLayout}
* @param status Current status @see{@link SmoothRefreshLayout#SR_STATUS_INIT},
* {@link SmoothRefreshLayout#SR_STATUS_PREPARE},
* {@link SmoothRefreshLayout#SR_STATUS_REFRESHING},
* {@link SmoothRefreshLayout#SR_STATUS_LOADING_MORE},
* {@link SmoothRefreshLayout#SR_STATUS_COMPLETE}.
* @param indicator The indicator {@link IIndicator}
*/
void onPureScrollPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);
}
Add custom refresh view
Global static code construction
SmoothRefreshLayout.setDefaultCreator(new IRefreshViewCreator() {
@Override
public IRefreshView<IIndicator> createHeader(SmoothRefreshLayout layout) {
ClassicHeader header = new ClassicHeader(layout.getContext());
return header;
}
@Override
public IRefreshView<IIndicator> createFooter(SmoothRefreshLayout layout) {
ClassicFooter footer = new ClassicFooter(layout.getContext());
return footer;
}
});
Use Java code to config
ClassicHeader header = new ClassicHeader(mRefreshLayout.getContext());
mRefreshLayout.setHeaderView(header);
ClassicFooter footer = new ClassicFooter(mRefreshLayout.getContext());
mRefreshLayout.setFooterView(footer);
Please write directly to the Xml file,SmoothRefreshLayout will find the view that impl the IRefreshView interface to added inside.
Impl the QQ pull down damping effect(Custom offset calculator)
MIT License
Copyright (c) 2017 dkzwm
Copyright (c) 2015 liaohuqiu.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.