RollerTrack - A navigational roller track companion for RecyclerView lists

Overview

RollerTrack

Release

This library allows attaching a roller track to a RecyclerView. The roller track provides faster navigation and visualisation for users facing long lists. It is designed to work with sorted lists of related content with fixed, pre-determined datasets. Example good use cases are a catalogue of items grouped alphabetically or a list of events grouped by starting time.

Gradle Setup

Add Jitpack to your project

repositories {
    maven { url 'https://jitpack.io' }
    jcenter()
}

Then add this library to your dependencies

dependencies {
    compile 'com.github.derek-cheung:RollerTrack:v1.0.0'
}

Usage

Start by adding your RecyclerView and RollerTrack to your layout file. You are free to position these however you want.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.tofi.rollertrack.rollertrack.RollerTrack
        android:id="@+id/roller_track"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.2"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list_track_items"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.8"
        android:clipToPadding="false"/>

</LinearLayout>

Next have your data model implement AlphabeticalTrackItem

data class DemoTrackItem(var title: String = "",
                         var description: String = ""): AlphabeticalTrackItem {

    override fun getTrackItemName(): String = title
}

Then sort your list of items, set up your RecyclerView normally and attach it to an AlphabeticalTrackRollerHelper

val trackItems: List<DemoTrackItem> = loadTrackItems().sortedBy { it.title }

val adapter = RollerTrackAdapter(trackItems)
list_track_items.adapter = adapter

val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
list_track_items.layoutManager = layoutManager

val rollerTrackHelper: AlphabeticalRollerTrackHelper<DemoTrackItem> = AlphabeticalRollerTrackHelper()
rollerTrackHelper.attachToRecyclerView(list_track_items, roller_track, trackItems)

If you wish to create your own list of RollerTrackItems, just extend RollerTrackHelper and return your own items in generateRollerTrackItems.

class CityRollerTrackHelper: RollerTrackHelper<City>() {

    override fun generateRollerTrackItems(listItems: List<City>): MutableList<RollerTrackItem<City>> {
        val rollerTrackItems = mutableListOf<RollerTrackItem<City>>()

        var currentRollerTrackItemData: MutableList<City> = mutableListOf()
        var currentRollerTrackItem: RollerTrackItem<City> = RollerTrackItem("", currentRollerTrackItemData)
        listItems.forEach {
            val countryCode = it.countryCode
            
            if (currentRollerTrackItem.trackItemName != countryCode) {
                currentRollerTrackItemData = mutableListOf()
                currentRollerTrackItemData.add(it)
                currentRollerTrackItem = RollerTrackItem(countryCode, currentRollerTrackItemData)
                rollerTrackItems.add(currentRollerTrackItem)

            } else {
                currentRollerTrackItemData.add(it)
            }
        }

        return rollerTrackItems
    }
}

Customisation

You can customise the appearance of the RollerTrack with xml styling.

<com.tofi.rollertrack.rollertrack.RollerTrack
        xmlns:demo="http://schemas.android.com/apk/res-auto"
        android:id="@+id/roller_track"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.2"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        demo:rollerTrackTrackLineColor="#FF5722"
        demo:rollerTrackCurrentTextColor="#4CAF50"
        demo:rollerTrackBackgroundTextColor="#4CAF50"
        demo:rollerTrackCurrentItemTextSize="40sp"
        demo:rollerTrackBackgroundItemTextSize="10sp"/>

Demo

A demo is provided under the demo module. Clone this repo and run the demo app to see it in action.

License

Provided with MIT license. See LICENSE for full details.

You might also like...
DogglersApp - Criação de um App para estudo de RecyclerView no Android Studio. Parte do curso Android Basics in Kotlin

Dogglers - Starter Code Starter code for the second independent project for Android Basics in Kotlin. Introduction This is the starter code for the Do

Enemigos5 - Recyclerview-ViewModel-LiveData on Android with Kotlin

Enemigos5 Recyclerview-VievModel-LiveData on Android with Kotlin. Es muy simple:

Dice Roller App For Android

Dice-roller Kotlin App Screenrecording_20211228_172332.mp4

DiceRoller - A simple android dice roller app
DiceRoller - A simple android dice roller app

DiceRoller A simple android dice roller app License Copyright 2022 Srihitha Tadi

This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS --

PlaceHolderView An advance view for lists and stacks Some Implementations Documentation You can find the PlaceHolderView documentation here which has

This is a project designed to help controlling Android MediaPlayer class. It makes it easier to use MediaPlayer ListView and RecyclerView. Also it tracks the most visible item in scrolling list. When new item in the list become the most visible, this library gives an API to track it. Companion App for the book
Companion App for the book

Kotlin for Android Developers (the book) This is the code you can use to follow the book. https://antonioleiva.com/kotlin-android-developers-book/ Are

Companion App for the book
Companion App for the book

Kotlin for Android Developers (the book) This is the code you can use to follow the book. https://antonioleiva.com/kotlin-android-developers-book/ Are

An unofficial companion app for DJI's Digital FPV System.
An unofficial companion app for DJI's Digital FPV System.

fpv-dvca An unofficial companion app for DJI's Digital FPV System for Android devices. Plug your Android device into your Googles and watch a live fee

Valetudo Companion App for Android
Valetudo Companion App for Android

Valetudo Companion (Android) This app listens for Bonjour broadcasts of recent (2021.07.0++) Valetudo instances on your network and will display each

📱 Home Assistant Companion for Android

📱 Home Assistant Companion for Android

Open Source Magic: The Gathering life tracker and companion app
Open Source Magic: The Gathering life tracker and companion app

SpellCounter SpellCounter is a free, open source Magic: The Gathering life and counter tracking app Features 100% free with no ads Supports up to 8 pl

🏝️ A companion mod to MCC Island!

Islander 🏝️ A companion mod to MCC Island! ETA? Soon ™️ Features Current Hey, it's not done yet! Planned Discord Rich Presence Hide particle trails b

📱 AppListManager (Android Library) makes managing application and activity lists easy.
📱 AppListManager (Android Library) makes managing application and activity lists easy.

AppListManager (Android Library) AppListManager is easy to use Android library, which minimizes developing time when working on application or activit

The library that removes all boilerplate code allowing you to display lists with few lines of code.

VsRecyclerView The library that removes all boilerplate code allowing you to display lists with few lines of code. Gradle androidExtensions { expe

Project BlueWeather is an android app that lists the closest locations to you and shows the 7-day weather forecast for the location you select.
Project BlueWeather is an android app that lists the closest locations to you and shows the 7-day weather forecast for the location you select.

Project BLUEWEATHER Description Project BlueWeather is a weather forecast application for android. It lists the locations closest to you. It then prov

Take beautiful markdown notes and stay organized with task lists.
Take beautiful markdown notes and stay organized with task lists.

Take beautiful markdown notes whenever you feel inspired. Place them in notebooks and tag them accordingly. Stay organized by making task lists, set reminders and keep everything in one place by attaching related files.

An android app that lists all planets in our solar system and brings some information about them.
An android app that lists all planets in our solar system and brings some information about them.

SolarSystem This application was developed in Android Studio and uses Kotlin as programming language. In short, it is an app that lists all the planet

This App lists Maverl comics and its detail
This App lists Maverl comics and its detail

DisneyCodeChallenge This App lists Maverl comics and its detail. Development Environment The app is written entirely in Kotlin and uses the Gradle bui

Releases(1.0.1)
Owner
Derek
Derek
Companion App for the book

Kotlin for Android Developers (the book) This is the code you can use to follow the book. https://antonioleiva.com/kotlin-android-developers-book/ Are

Antonio Leiva 2.6k Dec 14, 2022
Take beautiful markdown notes and stay organized with task lists.

Take beautiful markdown notes whenever you feel inspired. Place them in notebooks and tag them accordingly. Stay organized by making task lists, set reminders and keep everything in one place by attaching related files.

null 412 Dec 27, 2022
This App lists Maverl comics and its detail

DisneyCodeChallenge This App lists Maverl comics and its detail. Development Environment The app is written entirely in Kotlin and uses the Gradle bui

null 0 Nov 10, 2021
KSP-based library that generates lists from your annotation usages

ListGen, Generate Lists From Functions That Have @Listed Annotations! Welcome to ListGen! ListGen is a KSP-based library that can generate lists (and

Adib Faramarzi 24 Dec 6, 2022
The app is composed of 2 screens, first is the profile screen, it has the user_name and address pinned at the top and then it lists all of this user’s albums.

The app is composed of 2 screens, first is the profile screen, it has the user_name and address pinned at the top and then it lists all of this user’s albums. When you press on any album it navigates to the second screen which is an album details screen that contains list of the images in an recyclerview grid. Also you have search bar that you can filter within the photos album by the image title.

Mahmoud Ibrahim 4 Jul 10, 2022
Explore-KiiT-App - An app to simplify the complicated website navigation and keep track of Attendance

KiiT Explore App "An app to simplify the complicated website navigation and keep

Ajay Khatri 17 Oct 12, 2022
ViewModel-Lifecycle - ViewModel Lifecycle allows you to track and observe Jetpack ViewModel's lifecycle changes

ViewModel Lifecycle ?? ViewModel Lifecycle allows you to track and observe Jetpa

Jaewoong Eum 97 Nov 25, 2022
Viewmodel-lifecycle - ViewModel Lifecycle allows you to track and observe Jetpack ViewModel's lifecycle changes

ViewModel Lifecycle ?? ViewModel Lifecycle allows you to track and observe Jetpa

Jaewoong Eum 36 Feb 6, 2022
Track RPG Playthrough Details

Shattered Ring Tracker This project is an RPG game tracker where the user can keep a journal of details about their game, including: NPCs Track the NP

Nathan Contino 1 Mar 16, 2022
Mobile App that shows Random Products in a Nested Recyclerview for Android [Kotlin] Developer Role at Edvora

EdvoraAndroidTest An simple Android App for Edvora Android Assessment. It consum

Joel Kanyi 6 Jul 12, 2022