• This repository has been archived on 06/Jan/2020
  • Stars
    star
    1,300
  • Rank 36,189 (Top 0.8 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[DEPRECATED] Super fast and easy way to create header for Android RecyclerView

DEPRECATED

I created this library back in the day when I thought RecyclerView was all new and difficult. Writing an adapter that could inflate multiple types of Views seemed like a difficult job to do. In reality, RecyclerViewHeader is just a complex solution to a simple problem. Instead of using this library, just learn how to create a multi-type RecyclerView.Adapter. It will bring you a lot of value in the long run, and it is not difficult at all. Check the Migration section for the simplest example of such Adapter.

No new development will be taking place.

Thanks for all the support!


RecyclerViewHeader

License Maven Central

If you still wanna use this library, check the old README.md.

Migration

Just use a RecyclerView.Adapter that can inflate multiple types of items.

Here's the simplest one you could use:

class ExampleAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    companion object {
        private const val VIEW_TYPE_HEADER = 4815
        private const val VIEW_TYPE_ITEM = 1623
    }

    private val itemDataSetSize: Int get() = TODO("provide the size of your `ITEM` dataset")

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        when (viewType) {
            VIEW_TYPE_HEADER -> TODO("create your HEADER ViewHolder")
            VIEW_TYPE_ITEM -> TODO("create your ITEM ViewHolder")
            else -> error("Unhandled viewType=$viewType")
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        when (val viewType = getItemViewType(position)) {
            VIEW_TYPE_HEADER -> TODO("bind your HEADER ViewHolder")
            VIEW_TYPE_ITEM -> TODO("bind your ITEM ViewHolder")
            else -> error("Unhandled viewType=$viewType")
        }
    }

    override fun getItemCount(): Int = itemDataSetSize + 1 // 1 for header

    override fun getItemViewType(position: Int) = when (position) {
        0 -> VIEW_TYPE_HEADER
        else -> VIEW_TYPE_ITEM
    }
}

Developed by

  • Bartosz Lipiński

License

Copyright 2015 Bartosz Lipiński

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.

More Repositories

1

FlippableStackView

An Android library introducing a stack of Views with the first item being flippable.
Java
810
star
2

ViewPropertyObjectAnimator

Wrapper of the ObjectAnimator that can be used similarly to ViewPropertyAnimator
Java
339
star
3

cortado

Android Espresso made more fluent ☕
Java
331
star
4

StaggeredAnimationGroup

A ConstraintLayout group that allows for simple staggered animations.
Java
89
star
5

RxAnimationBinding

RxJava binding APIs for Android's animations
Java
82
star
6

dagger2-ktx

Kotlin extension bridge library for Dagger2 (proof-of-concept)
Java
40
star
7

XmlTag

[DEPRECATED] The easiest way to simplify custom View tags in Android layout xmls.
Java
35
star
8

disable-animations-rule

JUnit TestRule for Android instrumented tests, which automatically disables and enables animations
Java
32
star
9

cold-reboot

🤖 Rebooting Android Emulators with Cold Boot
Python
30
star
10

Android-ParseModel

[DEPRECATED] Annotation-based library that allows for easy data model creation for Parse Android SDK
Java
23
star
11

awesome-auto-value-extensions

:shipit: A curated list of awesome AutoValue extensions
23
star
12

trigger

[DEPRECATED] Simple command pattern helper class
Java
20
star
13

butterknife-ktx

Kotlin extension bridge library for Butterknife (proof-of-concept)
Java
20
star
14

app-startup-hilt-sample

App Startup 🚀 + Hilt 🗡 (a sample project that combines both to provide dependencies to Initializers)
Kotlin
18
star
15

IntDefs

Android constants wrapped in @IntDef annotations
Java
17
star
16

data-class-builder

🏗 Automatically generating builders 👷‍♂️for Kotlin data classes
Kotlin
16
star
17

GroupOfX

[DEPRECATED] When Android's Pair class is just not enough.
Java
15
star
18

PositioningDrawables-Examples

Simplifying layouts with layer-list drawables: a reliable way to position drawables within layer-lists
Java
13
star
19

StreetViewProbe

A simple (although a bit hacky) way to check if StreetView is available for a specific location.
Java
12
star
20

til

A collection of `Today I Learned` snippets
5
star
21

ExoPlayer1

[DEPRECATED] An external packaging of Google's ExoPlayer versions 1.x.x
4
star
22

test-case-factory

A multi-type combinations builder, designed specifically for creating test cases for parameterized testing.
Kotlin
2
star
23

issue-compose-painterResource

the minimal example showing an issue with `painterResource` in jetpack compose
Kotlin
2
star
24

generating-kotlin-extension-functions

Code examples from my 2018/2019 tech talk on "Generating Kotlin extension functions for Annotation Processing"
Kotlin
1
star
25

git-split-commit

↔ A bash script which splits a git commit into multiple commits, one for each modified file.
Shell
1
star
26

parse-lint-baseline

A simple shell script which parses the lint-baseline.xml file, counts the instances of every type of violation and produces a csv file with results
Shell
1
star