Giter Site home page Giter Site logo

miaotaoii / irecyclerview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aspsine/irecyclerview

0.0 2.0 0.0 30.91 MB

IRecyclerView is a custom RecyclerView that supports pull-to-refresh, pull-to-loadmore, customize refresh header and loadmore footer, add header views and footer views.

Java 100.00%

irecyclerview's Introduction

Android Arsenal

IRecyclerView

IRecyclerView is a custom RecyclerView that supports pull-to-refresh, pull-to-loadmore, customize refresh header and loadmore footer, add header views and footer views.

Features:

  • pull-to-refresh
  • pull-to-loadmore
  • customize refresh header
  • customize loadmore footer
  • add multiple header view
  • add multiple footer view
  • support vertical LinearLayoutManager/GridLayoutManager/StaggeredGridLayoutManager

Demo

Download

Demo ScreenShot

  • Bat Man vs Super Man Refresh header

Bat Man vs Super Man

  • Classic Refresh header

classic

  • Load more footer

load more

How to use

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
    compile 'com.github.Aspsine:IRecyclerView:0.0.7'
}

Step 3. Edit your Activity/Fragment content view layout

<com.aspsine.irecyclerview.IRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/iRecyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:loadMoreEnabled="true"
    app:loadMoreFooterLayout="@layout/layout_irecyclerview_load_more_footer"
    app:refreshEnabled="true"
    app:refreshHeaderLayout="@layout/layout_irecyclerview_refresh_header"/>

Available attributes:

<declare-styleable name="IRecyclerView">
    <attr name="refreshHeaderLayout" format="reference" />  <!--refresh header layout res id-->
    <attr name="loadMoreFooterLayout" format="reference" /> <!--loadmore fotter layout res id-->
    <attr name="refreshEnabled" format="boolean" />
    <attr name="loadMoreEnabled" format="boolean" />
    <attr name="refreshFinalMoveOffset" format="dimension" />   <!--refresh header max move distance-->
</declare-styleable>

Then Editor your Activity/Fragment

IRecyclerView iRecyclerView = (IRecyclerView) findViewById(R.id.iRecyclerView);

iRecyclerView.setLayoutManager(new LinearLayoutManager(this));

// an custom load more footer view, you can customize it yourself.
LoadMoreFooterView loadMoreFooterView = (LoadMoreFooterView) iRecyclerView.getLoadMoreFooterView();

// you can also add header and footer like this
// note: header and refresh header are different, footer and load more footer are different too. 
iRecyclerView.addHeaderView(headerView);
iRecyclerView.addFooterView(footerView);

// adapter
ImageAdapter mAdapter = new ImageAdapter();
// note: here use setIAdapter(...) method not setAdapter(...)
iRecyclerView.setIAdapter(mAdapter);

iRecyclerView.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
    
    }
});
iRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore(View loadMoreView) {

    }
});

// set auto refreshing
iRecyclerView.post(new Runnable() {
    @Override
   public void run() {
       iRecyclerView.setRefreshing(true);
   }
});

// stop refreshing
iRecyclerView.setRefreshing(false);

Please check out the demo code for more details .

Contact Me

License

Copyright 2016 Aspsine. All rights reserved.

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.

irecyclerview's People

Contributors

aspsine avatar frankwang-zf avatar

Watchers

James Cloos avatar miaotao avatar

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.