Git Product home page Git Product logo

powerrefresh's Introduction

PowerReresh

This library support nested scroll for refresh and load more,so you can use it with CoordinatorLayout and AppBarLayout and so no.You can design your self header or footer easily. 中文文档

screen

Download Android Arsenal

Add Header

   CircleHeaderView header = new CircleHeaderView(getContext());
    mRefreshLayout.addHeader(header);

Add footer

FootView footView = new FootView(getContext());
mRefreshLayout.addFooter(header);

Callback

you should make Header impl HeaderListener,so you can know the refresh state.and to Footer with FooterListener.

mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
		//doRefresh
    }

    @Override
    public void onLoadMore() {
      //doLoadmore
    }
});

Layout

<com.lovejjfg.powerrefresh.PowerRefreshLayout
android:id="@+id/refresh_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.lovejjfg.demo.MainActivity">
    </android.support.v7.widget.RecyclerView>

</com.lovejjfg.powerrefresh.PowerRefreshLayout>

Tips

  • If you want to refresh when first init call setAutoRefresh(true) on MainThread.

  • If you don't want to add any Footer,but loadmore, you should call setAutoRefresh(true) ,and at last, you should call setLoadEnable(mAdapter.getList().size() < 50) to make RefreshLayout konw whether is there any more nor not.

  • Refresh finish,you should call stopRefresh(boolean isSuccess) to make RefreshLayout konw that refresh is over,then the header will disappeared as soon as possible. if you want header disappeare delay, you can call stopRefresh(boolean isSuccess, long delay)

  • which height should go to start refresh ? If height is not specified,the default is the header's height. you can return the height by impl HeaderListener:

      @Override
      public int getRefreshHeight() {
          return (int) (getMeasuredHeight()*0.8f);
      }
    
  • If there is only one header or footer in you project ,dont forget to extend PowerRefreshLoayout and add header or footer once.

Thanks

Thanks to @dalong982242260 and Android SwipeRefreshLayout.

License

   Copyright (c) 2017.  Joe
   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.

powerrefresh's People

Contributors

lovejjfg avatar tachikoma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

powerrefresh's Issues

Add to update status without calling refresh listener

This is great, but I think it needs a method where you can set the view to specific state such as refreshing state without calling on refresh listener, it should be maybe to setRefresing() in android SwipeRefreshLayout

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.