All Projects → Joseph82 → Pinnedrecyclerview Android

Joseph82 / Pinnedrecyclerview Android

Licence: apache-2.0
Add a list pinned by a floating label (text or image)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pinnedrecyclerview Android

Countdowntask
⌛️A countdown library for Android.
Stars: ✭ 64 (-20.99%)
Mutual labels:  recyclerview
Android Cardview Recyclerview
Let's play with Android CardView, RecyclerView, Retrofit and Picasso Library. You can read details procedure about those library in my Bengali blog site.
Stars: ✭ 72 (-11.11%)
Mutual labels:  recyclerview
Rxbanner
一个灵活可制定的基于 Recyclerview 的轮播图控件,支持自动轮播,无限循环。 同时可关闭无限循环变成 引导页 ,带有引导完成接口回调
Stars: ✭ 77 (-4.94%)
Mutual labels:  recyclerview
Dividers For Recyclerview
📋 A simple demo to demonstrate how to draw dividers for RecyclerView
Stars: ✭ 65 (-19.75%)
Mutual labels:  recyclerview
Indexrecyclerview
[DEPRECATED] a Contact list implements by RecyclerView
Stars: ✭ 1,163 (+1335.8%)
Mutual labels:  recyclerview
Recyclerpager
Using RecyclerView and SnapHelper replace ViewPager
Stars: ✭ 73 (-9.88%)
Mutual labels:  recyclerview
Ultimaterefreshview
UltimateRefreshView 实现下拉刷新,上拉加载更多的轻量级库;支持RecyclerView ,ListView ,ScrollView & WebView
Stars: ✭ 64 (-20.99%)
Mutual labels:  recyclerview
Flexadapter
The easiest way to use a RecyclerView on Android
Stars: ✭ 80 (-1.23%)
Mutual labels:  recyclerview
Groupedrecyclerviewadapter
GroupedRecyclerViewAdapter可以很方便的实现RecyclerView的分组显示,并且每个组都可以包含组头、组尾和子项;可以方便实现多种Type类型的列表,可以实现如QQ联系人的列表一样的列表展开收起功能,还可以实现头部悬浮吸顶功能等。
Stars: ✭ 1,163 (+1335.8%)
Mutual labels:  recyclerview
Elements
⚒ Modular components for RecyclerView development enforcing clean, reusable and testable code, with built-in support for paging and complex hierarchies of data.
Stars: ✭ 75 (-7.41%)
Mutual labels:  recyclerview
Autorecycleradapter
Automated configuration RecyclerView.Adapter for Android
Stars: ✭ 67 (-17.28%)
Mutual labels:  recyclerview
Collapsingrefresh
AppBarLayout+ViewPager+RecyclerView的刷新功能
Stars: ✭ 69 (-14.81%)
Mutual labels:  recyclerview
Gencycler
Gencycler is the fastest way to write RecyclerView adapters
Stars: ✭ 73 (-9.88%)
Mutual labels:  recyclerview
Tc Material Design
Série de artigos sobre o Material Design Android
Stars: ✭ 64 (-20.99%)
Mutual labels:  recyclerview
Inifiniterecyclerview
Library for implementing endless loading list easily in Android applications
Stars: ✭ 79 (-2.47%)
Mutual labels:  recyclerview
Verticalviewpager
A vertical scroll ViewPager implementation. Use with scrollable views(ListView, ScrollView, RecyclerView).
Stars: ✭ 64 (-20.99%)
Mutual labels:  recyclerview
Coordinatorlayout.forms
CoordinatorLayout for Xamarin.Forms
Stars: ✭ 73 (-9.88%)
Mutual labels:  coordinatorlayout
Expandable Recycler View
[DEPRECATED]
Stars: ✭ 1,234 (+1423.46%)
Mutual labels:  recyclerview
Multitype
【MultiType】可以轻松地实现RecyclerView显示多种数据类型,数据对应布局一对多、多对多、多对一,可以注册全局类型、局部类型、默认类型
Stars: ✭ 80 (-1.23%)
Mutual labels:  recyclerview
Mao Rn Android Kit
⚙️ Android Native (ui components and modules) wrap in React Native
Stars: ✭ 74 (-8.64%)
Mutual labels:  coordinatorlayout

PinnedRecyclerView Android library

This library allows you to create a list of items that are pinned by a floating label (text or image) on the left of the list .

PinnedRecyclerView in action

Demo Text Pinned

Demo Image Pinned

Usage

Add library

Gradle

compile 'com.gvillani:pinnedlist:0.9.2'

Maven

<dependency>
  <groupId>com.gvillani</groupId>
  <artifactId>pinnedlist</artifactId>
  <version>0.9.2</version>
  <type>pom</type>
</dependency>

Pinned Text List

Add the PinnedListLayout in your Layout.

<com.gvillani.pinnedlist.PinnedListLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/pinned_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:pin_text_color="@color/colorAccent"
    app:type="text"
    app:fade_effect="true"
    app:pin_vertical_position="top"
    app:pin_text_size="30sp">

Get a reference to the PinnedLayout and get the RecyclerView that it contains.

mListLayout = (PinnedListLayout)findViewById(R.id.pinned_layout);
mRecyclerView = mListLayout.getRecyclerView();

Create a GroupListWrapper with the static method createAlphabeticList(). You can also create it manually managing each group, but if you want a simple alphabetically ordered list using create createAlphabeticList() is the fastest way.

GroupListWrapper listGroup = GroupListWrapper.createAlphabeticList(contacts, GroupListWrapper.ASCENDING);

And finally instantiate your custom Adapter (it must extend PinnedAdapter) and set it to the RecyclerView

mListAdapter = new ContactAdapter(this, listGroup, mListLayout);
mRecyclerView.setAdapter(mListAdapter);

Moreover, if you want create a GroupListWrapper using the createAlphabeticList you need to tell the system which label will be applied for your object and the related order. For example if you have a Contact object that contains name and surname you can do something like this:

public class Contact implements GroupListWrapper.Selector{
    private String name;
    private String surname;

    @Override
    public String select() {
        return name+surname;
    }
}

In this way you are telling the system that you want that your pin label will have the first letter of the name and they should be ordered using the name and the surname (if the name is the same).

Pinned Image List

In order to use a pinned list with image you need to set in your layout:

app:type="image"

You create your GroupListWrapper

GroupListWrapper listGroup = new GroupListWrapper();

Then you need to create a list of wrapping object (ItemPinned) that contain your costom object (for example a Contact) and then you add

ItemPinned itemD1 = new ImageItemPinned(new Contact("Ben","Weber", R.drawable.contact1)); 
ItemPinned itemD2 = new ImageItemPinned(new Contact("Emma","Hartmann", R.drawable.contact9)); 

List<ItemPinned> listD = new ArrayList<>();
listD.add(itemD1);
listD.add(itemD2);

Group groupD = new Group(listD, R.drawable.germany);

And eventually you add one or more Group object to the GroupListWrapper

listGroup.addGroup(groupD);

Finally instantiate your custom Adapter (it must extend PinnedAdapter) and set it to the RecyclerView

mListAdapter = new ContactAdapter(this, listGroup, mListLayout);
mRecyclerView.setAdapter(mListAdapter);

The Adapter

As before mentioned, you need to create your custom Adapter extending PinnedAdapter class.

When you override the method onCreateViewHolder you need to create your custom row layout (for example using inflater) and then you need to allow the system to wrap that layout inside a layout that contains the pin. So, you simply need to obtain a wrapped version of your layout passing it to getRowLayout() as shown in the example below:

@Override
public PinnedViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = mLayoutInflater.inflate(R.layout.item_contact, parent, false);
    ViewHolderContact viewHolderContact = new ViewHolderContact(getRowLayout(view));
    return viewHolderContact;
}

Note

Currently the Library is created as a compound View wrapped inside a CoordinatorLayout. So, if you need to use a CoordinatorLayout you can use it: for example you can add a Toolbar inside it, or a FAB that will be automatically coordinated with the Snackbar.

The library support only the LinearLayoutManager, so if you try to set a different layout it will be ignored.

TODO

  • Allow the user to manipulate the content of the adapter without replacing the entire dataset.
  • Support for GridLayoutManager
  • Find different strategy that make the wrapping of the custom layout inside the pinner layout more transparent (user should not call getRowLayout() from his adapter)
  • Allow groups manipulation
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].