SmoothRefreshLayout


Source link: https://github.com/dkzwm/SmoothRefreshLayout

SmoothRefreshLayout

English | ??

?????Android???????????????????SwipeRefreshLayout????????.
??????????? android-Ultra-Pull-To-Refresh.
?????????????????

??:

  • ???????????????????????.
  • ??????,?????NestedScrollingChild?NestedScrollingParent ??,??CoordinatorLayout.
  • ?????ViewGroup,???????,???FameLayout????Gravity?Margin).
  • ???????????????????????????????Adapter???????????????????????.
  • ??????.
  • ??????????,STYLE_DEFAULT(???????)?STYLE_SCALE(?????????????????????????)?STYLE_PIN(??????????????????)?STYLE_FOLLOW_SCALE(???????????????????????????????????????)?STYLE_FOLLOW_PIN(??????????????????????????)?STYLE_FOLLOW_CENTER(??????????????????????????????????????).
  • ?????????TwoLevelSmoothRefreshLayout??PS:?????????.
  • ??????(HorizontalSmoothRefreshLayout).
  • ??ListView?GridView?RecyclerView?????????.
  • ???????,STATE_CONTENT(????)?STATE_ERROR(????),STATE_EMPTY(???),STATE_CUSTOM(?????).
  • ????????????,?????Api???????.

????

?? Demo.apk

????

?????????

????

??

  • ???????1.5.0?????

  • ????RecyclerView???1.5.0?????

  • ???????????

  • ??QQ?????

  • ??QQ????

  • ??2???

  • ??ListView

  • ??GridView

  • ??RecyclerView

  • ??ViewPager

  • CoordinatorLayout

  • ??????

  • ??????

??

Gradle

repositories {

 ...
  maven {
 url 'https://jitpack.io' 
}

}
  dependencies {

  //????????????????????????
  compile 'com.github.dkzwm.SmoothRefreshLayout:core:1.5.0.3'
  //?????????
  compile 'com.github.dkzwm.SmoothRefreshLayout:ext-two-level:1.5.0.3'
  //?????????
  compile 'com.github.dkzwm.SmoothRefreshLayout:ext-horizontal:1.5.0.3' 
}
 

?Xml???

<?xml version="1.0" encoding="utf-8"?> <me.dkzwm.widget.srl.SmoothRefreshLayout  xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:id="@+id/refreshLayout"  android:layout_width="match_parent"  android:layout_height="match_parent">  <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"/> </me.dkzwm.widget.srl.SmoothRefreshLayout> 

Java????

SmoothRefreshLayout refreshLayout = (SmoothRefreshLayout)findViewById(R.id.smoothRefreshLayout);
 refreshLayout.setHeaderView(new ClassicHeader(this));
 refreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
  @Override  public void onRefreshBegin(boolean isRefresh) {

mHandler.postDelayed(new Runnable() {

 @Override
 public void run() {

  refreshLayout.refreshComplete();

 
}

}
, 4000);
  
}
 
}
);
 

???????

????
public interface IRefreshView <T extends IIndicator> {

 byte TYPE_HEADER = 0;
  byte TYPE_FOOTER = 1;

byte STYLE_DEFAULT = 0;
  byte STYLE_SCALE = 1;
  byte STYLE_PIN = 2;
  byte STYLE_FOLLOW_SCALE = 3;
  byte STYLE_FOLLOW_PIN = 4;
  byte STYLE_FOLLOW_CENTER = 5;

/**

* ?????????????;

*/
  int getType();

/**

* ??????View??????????this;

*/
  View getView();

/**

* ????????1.4.8?????6????STYLE_DEFAULT?STYLE_SCALE?STYLE_PIN?STYLE_FOLLOW_SCALE?STYLE_FOLLOW_PIN?STYLE_FOLLOW_CENTER;

*/
  int getStyle();

/**

* ?????????????????STYLE_SCALE?STYLE_FOLLOW_SCALE?????????????0????????????????????????????;

*/
  int getCustomHeight();

/**

* ??????;

*/
  void onFingerUp(SmoothRefreshLayout layout, T indicator);

/**

* ????;

*/
  void onReset(SmoothRefreshLayout layout);

/**

* ???????????;

*/
  void onRefreshPrepare(SmoothRefreshLayout layout);

/**

* ????;

*/
  void onRefreshBegin(SmoothRefreshLayout layout, T indicator);

/**

* ????;

*/
  void onRefreshComplete(SmoothRefreshLayout layout,boolean isSuccessful);

/**

* ???????????????;

*/
  void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);

/**

* ?????????????????????????????????????;

* ?1.4.6?????;

*/
  void onPureScrollPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);
 
}
 
?????????
  • ????????


SmoothRefreshLayout.setDefaultCreator(new IRefreshViewCreator() {

 @Override

 public void createHeader(SmoothRefreshLayout layout) {

  ClassicHeader header = new ClassicHeader(layout.getContext());

  layout.setHeaderView(header);

 
}

  @Override

 public void createFooter(SmoothRefreshLayout layout) {

  ClassicFooter footer = new ClassicFooter(layout.getContext());

  layout.setFooterView(footer);

 
}

}
);
  
  • ??????
mRefreshLayout.setHeaderView(header);
 mRefreshLayout.setFooterView(footer);
 
  • ?????Xml??,SmoothRefreshLayout??????View??????IRefreshView??????

???QQ??????



 mRefreshLayout.setIndicatorOffsetCalculator(new IIndicator.IOffsetCalculator() {

@Override

public float calculate(@IIndicator.MovingStatus int status, int currentPos, float offset) {

 if (status == IIndicator.MOVING_HEADER) {

  if (offset < 0) {

//???????????QQ??????????????????????????offset

//???????????QQ????????????????????

return offset;

  
}

  return (float) Math.pow(Math.pow(currentPos / 2, 1.28d) + offset, 1 / 1.28d) * 2 - currentPos;

 
}
 else if (status == IIndicator.MOVING_FOOTER) {

  if (offset > 0) {

//???????????QQ??????????????????????????offset

//???????????QQ????????????????????

return offset;

  
}

  return -((float) Math.pow(Math.pow(currentPos / 2, 1.28d) - offset, 1 / 1.28d) * 2 - currentPos);

 
}
 else {

  if (offset > 0) {

return (float) Math.pow(offset, 1 / 1.28d) * 2;

  
}
 else if (offset < 0) {

return -(float) Math.pow(-offset, 1 / 1.28d) * 2;

  
}
 else {

return offset;

  
}

 
}

}

  
}
);
 

Xml??

SmoothRefreshLayout ????
?? ?? ??
sr_content reference ?????????ID
sr_resistance float ????????????????: 1.65f?
sr_resistance_of_footer float ??Footer????????????: 1.65f?
sr_resistance_of_header float ??Header????????????: 1.65f?
sr_ratio_of_refresh_height_to_refresh float ???????????????????: 1.1f?
sr_ratio_of_header_height_to_refresh float ????????Header?????????: 1.1f?
sr_ratio_of_footer_height_to_refresh float ??????????Footer?????????: 1.1f?
sr_offset_ratio_to_keep_refresh_while_Loading float ?????????????????????: 1f?,???????????????????????
sr_offset_ratio_to_keep_header_while_Loading float ??????????Header?????????: 1f?,???????????????????????
sr_offset_ratio_to_keep_footer_while_Loading float ??????????Footer?????????: 1f?,???????????????????????
sr_can_move_the_max_ratio_of_refresh_height float ??????????????????: 0f????????
sr_can_move_the_max_ratio_of_header_height float ???????Header?????????: 0f????????
sr_can_move_the_max_ratio_of_footer_height float ???????Footer?????????: 0f????????
sr_duration_to_close_of_refresh integer ???????????????????: 500?
sr_duration_to_close_of_header integer ????Header?????????????: 500?
sr_duration_to_close_of_footer integer ????Footer?????????????: 500?
sr_duration_of_back_to_keep_refresh_pos integer ???????????????????: 200?
sr_duration_of_back_to_keep_header_pos integer ???????Header??????????: 200?
sr_duration_of_back_to_keep_header_pos integer ???????Footer??????????: 200?
sr_enable_pin_content boolean ?????????: false?
sr_enable_keep_refresh_view boolean ????????????????????????: true?
sr_enable_pull_to_refresh boolean ????,???????????????????????: false?
sr_enable_over_scroll boolean ???????: true?
sr_empty_layout reference ?????????????ID
sr_error_layout reference ??????????????ID
sr_custom_layout reference ???????????????ID
sr_state enum ???? ???: STATE_CONTENT?
sr_enable_refresh boolean ?????????????: ture?
sr_enable_load_more boolean ?????????????: false?
sr_header_background_color color ??Header??????????
sr_footer_background_color color ??Footer??????????
TwoLevelSmoothRefreshLayout ????
?? ?? ??
sr_enable_two_level_refresh boolean ?????????????: true?
SmoothRefreshLayout??????View????
?? ?? ??
layout_gravity flag ??????????????(? targetView??refreshView)

SmoothRefreshLayout java??????

?? ?? ??
setHeaderView IRefreshView ??????
setFooterView IRefreshView ??????
setContentView int,View ??????,??1:???????????,??2:?????????
setState int ??????
setState int,boolean ??????,??1:????,??2:??????????
setDisableWhenAnotherDirectionMove boolean ??????????????????????ture???: false?
setEnableNextPtrAtOnce boolean ??????????
setOverScrollDurationRatio float ???????,??????????????????????????,???????? mMaxOverScrollDuration?????: 0.5f?.
setMaxOverScrollDuration int ???????????????: 500?
setMinOverScrollDuration int ???????????????: 150?
setResistance float ????????????????: 1.65f?
setResistanceOfFooter float ??Footer????????????: 1.65f?
setResistanceOfHeader float ??Header????????????: 1.65f?
setRatioOfRefreshViewHeightToRefresh float ???????????????????: 1.1f?
setRatioOfHeaderHeightToRefresh float ????????Header?????????: 1.1f?
setRatioOfFooterHeightToRefresh float ??????????Footer?????????: 1.1f?
setOffsetRatioToKeepRefreshViewWhileLoading float ?????????????????????: 1f?,???????????????????????
setOffsetRatioToKeepHeaderWhileLoading float ??????????Header?????????: 1f?,???????????????????????
setOffsetRatioToKeepFooterWhileLoading float ??????????Footer?????????: 1f?,???????????????????????
setCanMoveTheMaxRatioOfRefreshViewHeight float ??????????????????: 0f????????
setCanMoveTheMaxRatioOfHeaderHeight float ???????Header?????????: 0f????????
setCanMoveTheMaxRatioOfFooterHeight float ???????Footer?????????: 0f????????
setDurationToClose int ???????????????????: 500?
setDurationToCloseHeader int ????Header?????????????: 500?
setDurationToCloseFooter int ????Footer?????????????: 500?
setDurationOfBackToKeepRefreshViewPosition integer ???????????????????: 200?
setDurationOfBackToKeepHeaderPosition integer ???????Header??????????: 200?
setDurationOfBackToKeepFooterPosition integer ???????Footer??????????: 200?
setEnablePinContentView boolean ?????????: false?
setEnabledPullToRefresh boolean ????,???????????????????????: false?
setEnableOverScroll boolean ???????: true?
setEnabledInterceptEventWhileLoading boolean ???????????????: false?
setEnableHeaderDrawerStyle boolean Header????,?Header????????????: false?
setEnableFooterDrawerStyle boolean Footer????,?Footer????????????: false?
setDisablePerformRefresh boolean ????Header?????: false?
setDisablePerformLoadMore boolean ????Footer?????: false?
setEnableLoadMoreNoMoreData boolean ??Footer???????????? true??Frame??? setDisablePerformLoadMore??? true??????????????????????, ClassicFooter???????????????: false?
isEnabledLoadMoreNoMoreDataNoNeedSpringBack boolean ??Footer?????????????
setDisableRefresh boolean ??Header?????: false?
setDisableLoadMore boolean ??Footer?????: false?
setEnableKeepRefreshView boolean ????????????????????????: true?
setEnableScrollToBottomAutoLoadMore boolean ??????????: false?
setEnablePinRefreshViewWhileLoading boolean ????????????????????????????Material?????: false?,???????? setEnablePinContentView? setEnableKeepRefreshView2??????????????
setSpringInterpolator Interpolator ??????????
setOverScrollInterpolator Interpolator ?????????????
setEnableCheckFingerInsideAnotherDirectionView boolean ??????????????????????????????????????? setDisableWhenAnotherDirectionMove
setEnableCompatLoadMoreScroll boolean ???????????????????: true?
setHeaderBackgroundColor int ??Header?????????????????Header???????????????????????????????????
setFooterBackgroundColor int ??Footer?????????????????Footer???????????????????????????????????

SmoothRefreshLayout ??

?? ?? ??
setOnRefreshListener T extends OnRefreshListener ??????????
setOnStateChangedListener OnStateChangedListener ????????
setChangeStateAnimatorCreator IChangeStateAnimatorCreator ???????????????
addOnUIPositionChangedListener OnUIPositionChangedListener ?????????????
removeOnUIPositionChangedListener OnUIPositionChangedListener ?????????????
setOnLoadMoreScrollCallback OnLoadMoreScrollCallback ??Footer??????????????
setOnPerformAutoLoadMoreCallBack OnPerformAutoLoadMoreCallBack ????????????????????? canAutoLoadMore()???? true??????????
setOnChildNotYetInEdgeCannotMoveHeaderCallBack OnChildNotYetInEdgeCannotMoveHeaderCallBack ???????????????????SmoothRefreshLayout?? isChildNotYetInEdgeCannotMoveHeader()???
setOnChildNotYetInEdgeCannotMoveFooterCallBack OnChildNotYetInEdgeCannotMoveFooterCallBack ???????????????????SmoothRefreshLayout?? isChildNotYetInEdgeCannotMoveFooter()???
setOnHookHeaderRefreshCompleteCallback OnHookUIRefreshCompleteCallBack ??Header?????Hook????????????
setOnHookFooterRefreshCompleteCallback OnHookUIRefreshCompleteCallBack ??Footer?????Hook????????????
setOnFingerInsideAnotherDirectionViewCallback OnFingerInsideAnotherDirectionViewCallback ?????????????????????????????????????????

SmoothRefreshLayout ??

?? ?? ??
debug?????? boolean Debug??
setDefaultCreator?????? IRefreshViewCreator ?????????,?????????????????????????????????????
refreshComplete ?? ????,??????????????
refreshComplete boolean ????,??:??????????????
refreshComplete boolean,long ????,??1:??????????????,??2:???????????????????????????????????????????????????
refreshComplete long ????,??????????????,??:???????????????????????????????????????????????????
setLoadingMinTime long ?????????????????(??: 500),??:???
autoRefresh ?? ????Header??,??????????????Header????
autoRefresh boolean ????Header??,??:??????????,??????Header????
autoRefresh boolean,boolean ????Header??,??1:??????????,??2:???????Header????
autoLoadMore ?? ????Footer??,??????????????Footer????
autoLoadMore boolean ????Footer??,??:??????????,??????Footer????
autoLoadMore boolean,boolean ????Footer??,??1:??????????,??2:???????Footer????
setLoadMoreScrollTargetView View ??Footer???,???????????,???SmoothRefreshLayout????CoordinatorLayout,CoordinatorLayout??AppbarLayout?RecyclerView????????????????RecyclerView???CoordinatorLayout,????RecyclerView?TargetView??

TwoLevelSmoothRefreshLayout java??????

?? ?? ??
setRatioOfHeaderHeightToHintTwoLevelRefresh float ???????????????Header??????
setRatioOfHeaderHeightToTwoLevelRefresh float ?????????????Header??????
setOffsetRatioToKeepTwoLevelHeaderWhileLoading float ????????????Header?????????: 1f?
setDisableTwoLevelRefresh boolean ?????????????: false?
setDurationOfBackToKeepTwoLevelHeaderViewPosition int ???????????Header??????????: 500?
setDurationToCloseTwoLevelHeader int ??????Header?????????????????: 500?

TwoLevelSmoothRefreshLayout ??

?? ?? ??
autoTwoLevelRefreshHint ?? ????????????????????????????
autoTwoLevelRefreshHint int ??????????????????????????????:??????
autoTwoLevelRefreshHint boolean ????????????????????????????????:?????????
autoTwoLevelRefreshHint boolean,int ??????????,??1:????????????2:??????
autoTwoLevelRefreshHint boolean,int,boolean ??????????,??1:????????????2:?????????3:????????????????????????????????????????????

Thanks

License

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. 

Resources

Binds views and resources easily. Really easily. Everywhere.

The Shared Memory library allows for the creation of memory regions that may be simultaneously accessed by multiple Android processes or applications. Developed to overcome the Android 1MB IPC limitation, this Shared Memory library allows you to exchange larger amounts of data between your Android applications.

The missing library manager for Android Developers.

This project allows you to create a custom Toast in android in simplest way.

A layout that arranges other views in a circle.

You can use this library to create your calendar, customizing UI and behaviour.

Features

  • Custom header (should be implemented by the user);
  • Custom sub view (month name by default);
  • Custom weekly days view;
  • Custom date view;
  • Possibility to implement selection on day click;
  • Possibility to implement weekly day calculation;
  • Receive updates of Calendar (with AUCalendar);
  • Every change to AUCalendar is notified and automatically refreshes UI;

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes