Expandable Recyclerview makes it easy to integrate nested recycler view...🔨 📝

Overview

SSExpandableRecyclerView

Expandable Recyclerview make it easy to integrate nested recyclerview

Build Status Kotlin Version Platform API

Features

  • Simple and easy to use ( no complex adapter required )
  • Just extend BaseRecyclerAdapter and good to go.
  • Get onClick event for parent recycler item as well child item.
  • Customize where you want to collapse/expand effect.

🎬 Preview

Expandable RecyclerView Expandable RecyclerView Expandable RecyclerView
me

Installation

  1. Extend BaseRecyclerAdapter in recycler adapter and implement below methods.
class ListAdapter : BaseRecyclerAdapter<ListDataModel, ChildDataModel>() {
// Pass parent and child model in BaseRecyclerAdapter

    override fun getLayoutIdForType(): Int = R.layout.item_parent  // Provide parent recycler item id

    override fun getLayoutIdForChild(): Int = R.layout.item_child  // Provide child recycler item id

    // Click event fot parent recycler item
    override fun onParentItemClick(triple: Triple<Int, Any, View>, viewDataBinding: ViewDataBinding) {
        val data = triple.second as ListDataModel // Here you can get parent item data for clicked item
        val position = triple.first // Get position of clicked item
        val view = triple.third // Get view of clicked item

        when (view.id) {
            R.id.text_movie_year -> {
                // Call this function where you want to expand collapse childView
                expandCollapse(triple.first, viewDataBinding)
            }
        }
    }

    // Click event for child rectycler item
    override fun onChildItemClicked(triple: Triple<Int, Any, View>, parentIndex: Int) {
        val data = triple.second as ChildDataModel // Here you can get child item data for clicked item
        val position = triple.first // Get position of clicked item
        val view = triple.third // Get view of clicked item

        when (view.id) {
            R.id.img_download_movie -> {
                // Here you can perform your action
            }
        }
    }
}
  1. Create variables in parent recycler item as par below and bind it as per requirement.
    <data>
        <variable
            name="data" // Variable name should be same
            type="com.expandable.recyclerview.model.ListDataModel" />
        <variable
            name="clickHandler" // Variable name should be same
            type="android.view.View.OnClickListener" />
        <variable
            name="adapter" // Variable name should be same and give type  BaseChildRecyclerAdapter
            type="com.expandable.recyclerview.base.BaseChildRecyclerAdapter" />
        <variable
            name="isVisible" // Variable name should be same
            type="Boolean" />
        <import type="android.view.View" />
    </data>
  1. SetUp child recyclerview with adapter and visiblty like this
    <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/childRecycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_8sdp"
                android:visibility="@{isVisible ? View.VISIBLE : View.GONE }" // Important line
                app:setAdapter="@{adapter}" //Important line
                .... />
  1. Create variables in child recycler item as par below and bind it as per requirement.
    <data>
        <variable
            name="data" // Variable name should be same
            type="com.expandable.recyclerview.model.ChildDataModel" />
        <variable
            name="clickHandler" // Variable name should be same
            type="android.view.View.OnClickListener" />
        <import type="android.view.View" />
    </data>
  1. Assign click handler where you want to recive click event
  <TextView
        android:id="@+id/movieTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="@{clickHandler::onClick}" /> // Important line

Find this sample useful? ❤️

Support it by joining stargazers for this repository.

🤝 How to Contribute

Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! 💪 Check out our Contributing Guide for ideas on contributing.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

License

Copyright 2021 Simform Solutions

 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.
Issues
A better ExpandableListView, with animated expandable views for each list item

SlideExpandableListView for Android Not happy with the Android ExpandableListView android offers? Want something like the Spotify app. This library al

Tjerk Wolterink 2k Jul 29, 2021
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Emil Sjölander 5.5k Jul 22, 2021
This is a very simple library for Android that allows you to stick an header to a scrollable view and easily apply animation to it

StikkyHeader This is a very simple library for Android that allows you to stick an header to a ListView and easily apply animation to it Usage To use

Carlo Marinangeli 849 Jun 16, 2021
Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.

CommonPullToRefresh Android widget with pull to refresh for all the views,and support loadMore for ListView,RecyclerView,GridView and SwipeRefreshLayo

null 1.1k Jul 30, 2021
A generic, customizable, open source Android ListView implementation that has 'Pull to Refresh' functionality.

Android 'Pull to Refresh' ListView library Demo video: http://www.youtube.com/watch?v=VjmdELnm3GI Project A generic, customizable, open source Android

Erik Wallentinsen 644 May 1, 2021
Horizontal list view for Android which allows variable items widths

Deprecated This widget is now deprecated and it won't be updated anymore. Use RecyclerView instead Horizontal Variable ListView Horizontal ListView fo

Alessandro Crugnola 859 Jul 14, 2021
Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.

ListBuddies This library is not maintained anymore and there will be no further releases Android library of a pair of auto-scroll circular parallax Li

JPARDOGO 973 Jul 22, 2021
Phoenix Pull-to-Refresh

Phoenix Pull-to-Refresh This project aims to provide a simple and customizable pull to refresh implementation. Made in [Yalantis] (https://yalantis.co

Yalantis 4k Jul 31, 2021
Easy to use ListView with pinned sections for Android.

Easy to use ListView with pinned sections for Android 2.1 and higher. Pinned section is a header view which sticks to the top of the list until at lea

Sergej Shafarenka 2.6k Jul 27, 2021
HorizontalListView is an Android ListView widget which scrolls in a horizontal manner (in contrast with the SDK-provided ListView which scrolls vertically).

HorizontalListView HorizontalListView is an Android ListView widget which scrolls in a horizontal manner (in contrast with the SDK-provided ListView w

MeetMe 727 Jul 25, 2021
A ListView with pinned section headers for Android

PinnedHeaderListView This library provides a sectioned ListView with pinned headers. It looks and feels much like the default contacts app does on And

James Smith 675 Feb 18, 2021
An easy to use Drag & Drop List for Android. Direct replacement of the android ListView.

DragNDropListView DragNDropListView is a direct replacement for the stock Android ListView. If you know how to use ListView, you already know how to u

null 186 Dec 14, 2020
A small android library for tagging views inside a ScrollView as "sticky" making them stick to the top of the scroll container until a new sticky view comes and takes it's place

StickyScrollViewItems StickyScrollViewItems is a ScrollView subclass that allowed you to mark items inside the ScrollView as sticky. The items marked

Emil Sjölander 1k Jul 21, 2021
StackExpandableView - A custom view that resembles the iOS notification group behavior

StackExpandableView - A custom view that resembles the iOS notification group behavior

Fabio Sassu 134 Jul 13, 2021