All Projects → epicmars → LiteRefresh

epicmars / LiteRefresh

Licence: other
Nested scrolling UI library for Android based on CoordinatorLayout. Pull-to-refresh and pull-to-load-more are supported.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to LiteRefresh

react-native-nested-scroll-view
react-native wrapper for android NestedScrollView
Stars: ✭ 77 (+108.11%)
Mutual labels:  coordinatorlayout, nested-scrolling
Learn Coordinatorlayout Behavior
CoordinatorLayout 自定义Behavior 高仿美团商家详情界面 实现页面内容复杂联动效果
Stars: ✭ 527 (+1324.32%)
Mutual labels:  behavior, coordinatorlayout
MaterialDesignSample
Android transition元素共享动画、CoordinatorLayout、AppBarLayout、FloatingActionButton、BottomSheet、SnackBar、自定义behavior实现动画效果。
Stars: ✭ 28 (-24.32%)
Mutual labels:  behavior, coordinatorlayout
Materialdesignsamples
Material Design 系列控件samples,讲了Material Design 系列新控件的使用方法和一些场景示例,使用详情请看对应博客,持续更新中...
Stars: ✭ 900 (+2332.43%)
Mutual labels:  behavior, coordinatorlayout
NestedScrollingDemo
😋😋😋A good app for understanding android nested scrolling
Stars: ✭ 98 (+164.86%)
Mutual labels:  behavior, coordinatorlayout
android-materialButton-behavior
Android Material Button(Extended FAB) Behavior on RecyclerView
Stars: ✭ 25 (-32.43%)
Mutual labels:  behavior, coordinatorlayout
SwipeScreenBehavior
A CoordinatorLayout Behavior for implementing swipe screen transition behavior.
Stars: ✭ 27 (-27.03%)
Mutual labels:  coordinatorlayout
Scroller
React版iScroll并且集成下拉刷新,上拉加载更多,Sticky等功能
Stars: ✭ 52 (+40.54%)
Mutual labels:  pull-to-refresh
UCPullRefresh
This is a beautiful drop-down refresh as well as the effect of back to the home page lick UCBrowser
Stars: ✭ 44 (+18.92%)
Mutual labels:  pull-to-refresh
LuaKit
Lua核心工具包,包含对面向对象,组件系统(灵活的绑定解绑模式),mvc分模块加载,事件分发系统等常用模式的封装。同时提供打印,内存泄漏检测,性能分析等常用工具类。
Stars: ✭ 112 (+202.7%)
Mutual labels:  behavior
ParticlesRefreshLayout-android
Particles Refresh Layout library for Android
Stars: ✭ 15 (-59.46%)
Mutual labels:  pull-to-refresh
yii2-linkable-behavior
Yii2 behavior to help creating urls easier
Stars: ✭ 12 (-67.57%)
Mutual labels:  behavior
behavior-trait
Allows handling events via inline declared methods, which can be added by traits
Stars: ✭ 18 (-51.35%)
Mutual labels:  behavior
XCPullToLoadMoreListView
XCPullToLoadMoreListView-下拉加载更多ListView控件(仿QQ、微信聊天对话列表控件)
Stars: ✭ 24 (-35.14%)
Mutual labels:  pull-to-refresh
XSPullRefresh
下拉刷新日蚀效果 eclipse
Stars: ✭ 24 (-35.14%)
Mutual labels:  pull-to-refresh
react-native-smooth-pull-to-refresh
Custom pull to refresh component for React Native
Stars: ✭ 36 (-2.7%)
Mutual labels:  pull-to-refresh
SJLineRefresh
pull-to-refresh by line path
Stars: ✭ 36 (-2.7%)
Mutual labels:  pull-to-refresh
beehive
A flexible, modern, header-only implementation of behavior trees
Stars: ✭ 37 (+0%)
Mutual labels:  behavior
anchored-behavior
A CoordinatorLayout Behavior to anchor views with an animation.
Stars: ✭ 17 (-54.05%)
Mutual labels:  coordinatorlayout
behaiv-java
User Behavior Prediction for everyone
Stars: ✭ 12 (-67.57%)
Mutual labels:  behavior

LiteRefresh

Download

Behaviors

There are three type of behaviors can be used to attached to direct children of CoordinatorLayout.

  • RefreshContentBehavior

    • Make nested scrolling content partially visible
    • Add scrolling listeners to observe content view's scrolling offset
    • Add refreshing state listener to observe the refreshing state
    • Add loading state listener to observe the loading state
  • RefreshHeaderBehavior

    • Make header view partially visible or totally visible
    • Make header view follow with content view or not
    • Add scrolling listeners to observe header view's scrolling offset
    • Add refreshing state listener to observe the refreshing state
  • RefreshFooterBehavior

    • Make footer view partially visible or totally visible
    • Make footer view follow with content view or not
    • Add scrolling listeners to observe footer view's scrolling offset
    • Add loading state listener to observe the loading state

Mode of header and footer behaviors

Follow Follow Up Follow Down Still
img img img img

When the content view is scrolling, the header and footer can decide whether to follow or not. Four modes are defined:

  • Follow: follow with content
  • Follow up: follow with content when scrolling up, but not down
  • Follow down: follow with content when scrolling down, but not up
  • Still: stay still

Samples

Showcases from sample application can be visited in the showcases page.

QuickStart

Attach behaviors in layout

Use content behavior standalone

Just make your nested scrollable view a direct child of CoordinatorLayout, and set the layout_behavior attribute to @string/lr_refresh_content_behavior.

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/lr_refresh_content_behavior">
        </androidx.recyclerview.widget.RecyclerView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

Work with header and footer view

Below is an example from the sample application, notice that there is an anchored view that is a feature of CoordinatorLayout which make the behaviors more powerful.

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.androidpi.literefresh.sample.ui.widget.SampleHeaderView
            android:id="@+id/view_header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/lr_refresh_header_behavior"
            app:lr_maxOffsetRatio="100%p"
            app:lr_mode="follow"
            app:lr_visibleHeightRatio="50%" />

        <com.androidpi.literefresh.sample.ui.widget.SampleFooterView
            android:id="@+id/view_footer"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            app:layout_behavior="@string/lr_refresh_footer_behavior"
            app:lr_maxOffsetRatio="100%p" />

        <com.androidpi.literefresh.sample.ui.widget.SampleContentView
            android:id="@+id/view_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:lr_minOffset="64dp"
            app:layout_behavior="@string/lr_refresh_content_behavior"/>

        <com.androidpi.literefresh.sample.ui.widget.SampleAnchoredView
            android:id="@+id/view_anchored"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_anchor="@id/view_content"
            app:layout_anchorGravity="top|center_horizontal" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

Attach behaviors from code

Unlike attach behavior in the layout that you can configure the behavior with attributes. Add behavior through code has some limitations that the configuration is not supported right now, but will be supported soon in a later version.

Set behaviors in CoordinatorLayout.LayoutParams

When using this method you must be sure the layout params has been generated.

    CoordinatorLayout.LayoutParams params = ((CoordinatorLayout.LayoutParams) getLayoutParams());
    RefreshHeaderBehavior headerBehavior = new RefreshHeaderBehavior(context);
    params.setBehavior(headerBehavior);

In this way the configuration should be set with code too. Because we don't use a layout.

Implement interface AttachedBehavior for custom view

If you implement a custom view and want to attach a behavior you can implement the AttachedBehavior interface.

public class RefreshHeaderLayout extends FrameLayout implements CoordinatorLayout.AttachedBehavior{

    protected RefreshHeaderBehavior behavior;
    
    // ...

    public RefreshHeaderLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        behavior = new RefreshHeaderBehavior(context, attrs);
    }

    @NonNull
    @Override
    public CoordinatorLayout.Behavior getBehavior() {
        return behavior;
    }
}

Supported nested scrolling view

The supported nested scrolling view for content are list below.

View API level
NestedScrollingView 7
RecyclerView 7
ListView 21

Download

dependencies {
    implementation 'com.androidpi:literefresh:0.10.3'
    implementation 'com.androidpi:literefresh-widgets:0.10.3'
}

Licence

Copyright 2018 [email protected]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].