Git Product home page Git Product logo

titanrecyclerview's Introduction

TitanRecyclerView

Build Status

A handy RecyclerView can deal with all headers, footers, and loading shit.

Demo

header view & footer view

load more

Dependencies

compile 'com.youzan:titan:0.4.3'

Features

  • Header View
  • Footer View
  • Load More
  • Customizable Loading Style
  • Empty View
  • More comming soon!

Usage

Use TitanRecyclerView in xml.

<com.youzan.titan.TitanRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/titan_recycler_view"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"/>

Use QuickAdapter.

mAdapter = new QuickAdapter<String>(R.layout.text_item, mData) {
  @Override
  public void bindView(AutoViewHolder holder, int position, String model) {
    holder.getTextView(R.id.text_item_textview).setText( 
      "0".equals(model) ? attachActivity.getString(R.string.close) : model + attachActivity.getString(R.string.people));
  }
};

Use TitanAdapter.

public class ItemsAdapter extends TitanAdapter<DemoItem> {
  
  @Override
  protected RecyclerView.ViewHolder createVHolder(ViewGroup parent, int viewType) {
      return new NormalTextViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_text, parent, false), this);
  }
  
  @Override
  protected void showItemView(RecyclerView.ViewHolder holder, int position) {
      ((NormalTextViewHolder) holder).mTextView.setText(mData.get(position).title);
  }
  
  @Override
  public long getAdapterItemId(int position) {
      return 0;
  }
  
  public static class NormalTextViewHolder extends RecyclerView.ViewHolder {
      TextView mTextView;
      ItemsAdapter mAdapter;
  
      NormalTextViewHolder(View view, ItemsAdapter adapter) {
          super(view);
          mTextView = (TextView) view.findViewById(R.id.text_view);
          mAdapter = adapter;
      }
  }
}

Use setEmptyView.

//inflate ViewGroup use TitanRecyclerView
mTitanAdapter.setEmptyView(LayoutInflater.from(getContext()).inflate(R.layout.empty_view, mTitanRecyclerView, false));
  • add setDefaultView, setBadNetView. use them for net status and others

Use setOnScrolledListener.

  • can listener Titan scroll

Acknowledgement

License

MIT

titanrecyclerview's People

Contributors

mosnter avatar liangfeidotme avatar radishwu avatar danke77 avatar faceace avatar

Watchers

 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.