Giter Site home page Giter Site logo

mikepenz / fastadapter Goto Github PK

View Code? Open in Web Editor NEW
3.8K 87.0 494.0 19.4 MB

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...

Home Page: https://mikepenz.dev

License: Apache License 2.0

Java 3.17% Ruby 0.31% Shell 0.22% Kotlin 96.30%
recyclerview fastadapter viewholder multi-select click-listeners drag-and-drop swipe recyclerview-adapter adapter android

fastadapter's Introduction

FastAdapter

The FastAdapter is here to simplify creating adapters for RecyclerViews. Don't worry about the adapter anymore. Just write the logic for how your view/item should look like, and you are done. It's blazing fast, minimizing the code you need to write, and is easy to extend.


What's included 🚀Setup 🛠️Migration Guide 🧬Used bySample App


What's included 🚀

Preview

Screenshots 🎉

Image

Setup

Latest releases 🛠

  • Kotlin | v5.7.0
  • [Deprecated] Java && AndroidX | v3.3.1
  • [Deprecated] Java && AppCompat | v3.2.9

Provide the gradle dependency

The library is split up into core, commons, and extensions. The core functions are included in the following dependency.

implementation "com.mikepenz:fastadapter:${latestFastAdapterRelease}"
implementation "androidx.appcompat:appcompat:${androidX}"
implementation "androidx.recyclerview:recyclerview:${androidX}"

Expandable support is included and can be added via this

implementation "com.mikepenz:fastadapter-extensions-expandable:${latestFastAdapterRelease}"

Many helper classes are included in the following dependency.

implementation "com.mikepenz:fastadapter-extensions-binding:${latestFastAdapterRelease}" // view binding helpers
implementation "com.mikepenz:fastadapter-extensions-diff:${latestFastAdapterRelease}" // diff util helpers
implementation "com.mikepenz:fastadapter-extensions-drag:${latestFastAdapterRelease}" // drag support
implementation "com.mikepenz:fastadapter-extensions-paged:${latestFastAdapterRelease}" // paging support
implementation "com.mikepenz:fastadapter-extensions-scroll:${latestFastAdapterRelease}" // scroll helpers
implementation "com.mikepenz:fastadapter-extensions-swipe:${latestFastAdapterRelease}" // swipe support
implementation "com.mikepenz:fastadapter-extensions-ui:${latestFastAdapterRelease}" // pre-defined ui components
implementation "com.mikepenz:fastadapter-extensions-utils:${latestFastAdapterRelease}" // needs the `expandable`, `drag` and `scroll` extension.

// required for the ui components and the utils
implementation "com.google.android.material:material:${androidX}"

How to use

1. Implement your item

1a. Implement your item as usual (the easy way)

Just create a class which extends the AbstractItem as shown below. Implement the methods, and your item is ready.

open class SimpleItem : AbstractItem<SimpleItem.ViewHolder>() {
    var name: String? = null
    var description: String? = null

    /** defines the type defining this item. must be unique. preferably an id */
    override val type: Int
        get() = R.id.fastadapter_sample_item_id

    /** defines the layout which will be used for this item in the list */
    override val layoutRes: Int
        get() = R.layout.sample_item

    override fun getViewHolder(v: View): ViewHolder {
        return ViewHolder(v)
    }

    class ViewHolder(view: View) : FastAdapter.ViewHolder<SimpleItem>(view) {
        var name: TextView = view.findViewById(R.id.material_drawer_name)
        var description: TextView = view.findViewById(R.id.material_drawer_description)

        override fun bindView(item: SimpleItem, payloads: List<Any>) {
            name.text = item.name
            description.text = item.name
        }

        override fun unbindView(item: SimpleItem) {
            name.text = null
            description.text = null
        }
    }
}

1b. Implement item with ViewBinding (the easiest way)

class BindingIconItem : AbstractBindingItem<IconItemBinding>() {
    var name: String? = null

    override val type: Int
        get() = R.id.fastadapter_icon_item_id

    override fun bindView(binding: IconItemBinding, payloads: List<Any>) {
        binding.name.text = name
    }

    override fun createBinding(inflater: LayoutInflater, parent: ViewGroup?): IconItemBinding {
        return IconItemBinding.inflate(inflater, parent, false)
    }
}

Use the binding extension dependency in your application for this.

2. Set the Adapter to the RecyclerView

//create the ItemAdapter holding your Items
val itemAdapter = ItemAdapter<SimpleItem>()
//create the managing FastAdapter, by passing in the itemAdapter
val fastAdapter = FastAdapter.with(itemAdapter)

//set our adapters to the RecyclerView
recyclerView.setAdapter(fastAdapter)

//set the items to your ItemAdapter
itemAdapter.add(ITEMS)

3. Extensions

By default the FastAdapter only provides basic functionality, which comes with the abstraction of items as Item and Model. And the general functionality of adding/removing/modifying elements. To enable selections, or expandables the provided extensions need to be activated.

3.1. SelectExtension

// Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`
val selectExtension = fastAdapter.getSelectExtension()
// configure as needed
selectExtension.isSelectable = true
selectExtension.multiSelect = true
selectExtension.selectOnLongClick = false
// see the API of this class for more options.

3.2. ExpandableExtension

This requires the fastadapter-extensions-expandable extension.

// Gets (or creates and attaches if not yet existing) the extension.
val expandableExtension = fastAdapter.getExpandableExtension()
// configure as needed
expandableExtension.isOnlyOneExpandedItem = true

For further details scroll down to the ExpandableItems (under advanced usage) section.

3. Click listener

fastAdapter.onClickListener = { view, adapter, item, position ->
    // Handle click here
    false
}

4. Click listeners for views inside your item

// just add an `EventHook` to your `FastAdapter` by implementing either a `ClickEventHook`, `LongClickEventHook`, `TouchEventHook`, `CustomEventHook`
fastAdapter.addEventHook(object : ClickEventHook<SimpleImageItem>() {
    override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
        //return the views on which you want to bind this event
        return if (viewHolder is SimpleImageItem.ViewHolder) {
            viewHolder.viewWhichReactsOnClick
        } else {
	    null
	}
    }

    override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<SimpleImageItem>, item: SimpleImageItem) {
        //react on the click event
    }
})

5. Filter

// Call this in onQueryTextSubmit() & onQueryTextChange() when using SearchView
itemAdapter.filter("yourSearchTerm")
itemAdapter.itemFilter.filterPredicate = { item: SimpleItem, constraint: CharSequence? ->
    item.name?.text.toString().contains(constraint.toString(), ignoreCase = true)
}

filter() should return true for items to be retained and false for items to be removed.

6. Drag and drop

This requires the fastadapter-extensions-drag extension.

First, attach ItemTouchHelper to RecyclerView.

val dragCallback = SimpleDragCallback()
val touchHelper = ItemTouchHelper(dragCallback)
touchHelper.attachToRecyclerView(recyclerView)

Implement ItemTouchCallback interface in your Activity, and override the itemTouchOnMove() method.

override fun itemTouchOnMove(oldPosition: Int, newPosition: Int): Boolean {
    DragDropUtil.onMove(fastItemAdapter.itemAdapter, oldPosition, newPosition) // change position
    return true
}

7. Using different ViewHolders (like HeaderView)

Start by initializing your adapters:

// Header is a model class for your header
val headerAdapter = ItemAdapter<Header>()

Initialize a Model FastAdapter:

val itemAdapter = GenericItemAdapter()

Finally, set the adapter:

val fastAdapter: GenericFastAdapter = FastAdapter.with(headerAdapter, itemAdapter) //the order defines in which order the items will show up
// alternative the super type of both item adapters can be used. e.g.:
recyclerView.setAdapter(fastAdapter)

8. Infinite (endless) scrolling

Create a FooterAdapter. We need this to display a loading ProgressBar at the end of our list. (Don't forget to pass it into FastAdapter.with(..))

val footerAdapter = ItemAdapter<ProgressItem>()

Keep in mind that ProgressItem is provided by FastAdapter’s extensions.

recyclerView.addOnScrollListener(object : EndlessRecyclerOnScrollListener(footerAdapter) {
     override fun onLoadMore(currentPage: Int) {
         footerAdapter.clear()
         footerAdapter.add(ProgressItem())
         
	 // Load your items here and add it to FastAdapter
         itemAdapter.add(NEWITEMS)
    }
})

For the complete tutorial and more features such as multi-select and CAB check out the sample app.

Advanced Usage

Proguard

  • As of v2.5.0 there are no more known requirements to use the FastAdapter with Proguard

ExpandableItems

The FastAdapter comes with support for expandable items. After adding the dependency set up the Expandable extension via:

val expandableExtension = fastAdapter.getExpandableExtension()

Expandable items have to implement the IExpandable interface, and the sub items the ISubItem interface. This allows better support. The sample app provides sample implementations of those. (Those in the sample are kept Model which allows them to be used with different parent / subitems)

As of the way how SubItems and their state are handled it is highly recommended to use the identifier based StateManagement. Just add withPositionBasedStateManagement(false) to your FastAdapter setup.

A simple item just needs to extend from the AbstractExpandableItem and provide the ViewHolder as type.

open class SimpleSubExpandableItem : AbstractExpandableItem<SimpleSubExpandableItem.ViewHolder>() {

    /**
     * BASIC ITEM IMPLEMENTATION
     */
}

// See the SimpleSubExpandableItem.kt of the sample application for more details.

Articles

Used by

Mike Penz:

Developed By

Contributors

This free, open source software was also made possible by a group of volunteers that put many hours of hard work into it. See the CONTRIBUTORS.md file for details.

Special mentions

A special thanks to the very active contributors who added many improvements to this library.

License

Copyright 2021 Mike Penz

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.

fastadapter's People

Contributors

allanwang avatar bachhuberdesign avatar benjiko99 avatar ceees2 avatar cketti avatar dependabot[bot] avatar deweyreed avatar fabianterhorst avatar fuhrmann avatar gotev avatar gpulido avatar ialokim avatar jasonsparc avatar ligol avatar mattiasbe avatar meness avatar mflisar avatar mikepenz avatar pi143 avatar rainer-lang avatar robbwatershed avatar rubengees avatar sapher avatar scheams avatar stustirling avatar suleiman19 avatar urob0ros avatar ylogx avatar yuriheupa avatar ztrap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastadapter's Issues

Use IdDistributor

  • reimplement usage of the IdDistributor, which defines ID's for items which do not come with an ID. This improves performance, and also allows view animations.

Wrong click position in recyclerview

Hi, Mike, i have tested the library with a simple example of a list in a recyclerview, only 2 items in the list.

I created a new proyect with the class and layout of your example, class "SampleItem" and the layout "sample_item"

The layout of the list item is the same as the example of the library, the only difference is i add a cardview around the items (name and description).

the list shows fine, with only 2 cardview, but when i click in the first item, the click event shows in the second item, is like add +1 position to the item i click, and viceversa, when i click in the second, the click shows in the first XD:

Questions to the devs/users of this lib

I would like to make this really great lib a bit more popular.
Therefore it would be great if the "users" of the FastAdapter could write a few reasons why they like this lib, what's special about,...

I like:

  • the generic-adapter (separation of view and model)
  • the chaining of other adapters fastscroller (MaterialScrollBar)
  • that I simply could through every item (AbstractItem)
  • the FastAdapter because it's SO EASY and FAST

Could you please help to find arguments/reasons to help so other devs are able to recognize that FastAdapter is GREAT! :)

Thanks.

FastScroller

  • find a good implementation for a fastScroller to add as nice addon

[Error] When ItemAdapter.Set() get lower item count then before

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{2e77778 position=3 id=-1, oldPos=3, pLpos:-1 scrap [attachedScrap] tmpDetached no parent}
  at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:4251)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4382)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
  at android.support.v7.widget.LayoutState.next(LayoutState.java:86)
  at android.support.v7.widget.StaggeredGridLayoutManager.fill(StaggeredGridLayoutManager.java:1423)
  at android.support.v7.widget.StaggeredGridLayoutManager.onLayoutChildren(StaggeredGridLayoutManager.java:610)
  at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2864)
  at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
  at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
  at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
  at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
  at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreograph
 mFastAdapter = new FastAdapter();
 mItemAdapter = new ItemAdapter();
 mList = (RecyclerView) rowView.findViewById(R.id.recyclerView);
 mList.setLayoutManager(Utils.getDefaultLayoutManager(getActivity()));
 mList.setAdapter(mItemAdapter.wrap(mFastAdapter));
mItemAdapter.set(mItems);//count 14

mItemAdapter.set(mItems);//count 13 and here it crashes

Feature request: Sorting

So I just started to try this lib. One thing I am missing is sorting of items.
Sure we could sort our datasets ourself every time but it would be very handy to have something like withComperator(Comparator comparator) or withEnableNaturalSorting(boolean enable).
This could also allow to later just throw a new comparator in and have the data resorted.
I think this would be a very nice feature as most modern apps feature something like "Sort entries by label" and "Sort entries by modification time" like my App does.

JavaDoc

  • document all methods inside the code

get models from GenericItemAdapter

if possible, add method to get models from GenericItemAdapter.
getAdapterItems return GenericItems of adapter, i want all models

p.s : i can't sync 1.2.4 version with gradle, stuck too many time and not successful, please check .

thanks

Changer RED color highlight when clicked item

My english very bad! I hope you can know my mine! I have problem like "how to changer RED color highlight when clicked Item recyclerview" in SimpleItemListActivity! Please tell me how to do this?

Pagination feature

Could you add something like a "pagination listener",something that invokes a method when bottom or for example 3 items before bottom is reached?

NPE when removing an item from the adapter

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at com.mikepenz.fastadapter.FastAdapter.getPreItemCount(FastAdapter.java:570)
    at com.mikepenz.fastadapter.adapters.ItemAdapter.remove(ItemAdapter.java:332)
    at com.mikepenz.fastadapter.adapters.FastItemAdapter.remove(FastItemAdapter.java:225)
02-27 02:15:38.524 30132-30132/liam.franco.selene D/liam.franco.selene: adapter item count 2
02-27 02:15:38.524 30132-30132/liam.franco.selene D/liam.franco.selene: layout pos: 0

The code is a simple getAdapter().remove(int) as you can see the adapter had plenty items to remove position 0. And that's after I run a simple cycle to make the specific item I want to remove is inside the adapter, so there's no way it should fail.

On the latest release 1.2.0.

Thanks for your work.

Just a typo

Line 73 in 'app/src/main/java/com/mikepenz/fastadapter/app/items/ExpandableItem.java'
expaned instead of expanded.

Set OnClickListener on subview

I Have complex view holder, I have three buttons inside it

I need click listener for item view and each buttons.

How I can do it, in the best way?

(Sticky)-Header View

Provide a sample / or implement a feature which allows headers, and sticky headers

Expandable RecyclerView

Hi,

Thanks for the great library.

I am trying to implement the Expandable view, but within a fragment instead of an Activity. I had the expansion and contraction working without issue within an Activity, but when moving it to a Fragment it stops expanding.

On some tests, I set the expansion to true initially and that has the list expanded, but upon setting it back to false initially. The list returns to not expanding.

Have you ever implemented this sample within an Activity Fragment model? I have a feeling it is to do with the Fragment not expanding, but I wanted to see what others have experienced.

API filter on endlessScroll

I'm currently implementing the FastAdapter library in my application which has a list of messages received from an API. I'd like to implement the endlessScroll search with this API instead of the current loaded messages. Is there any way to do this within the FastAdapter library I could use or you recommend to use?

Thanks.

MultiSelect behavior

  • MultiSelect should be available
    • via Single click
    • via Long Click
  • Contextual Action Bar for Multiselect

Swipe remove with in-place undo and "leave-behind"

Request for enhancement: Swipe remove with in-place undo and "leave-behind"
The UndoHelper is great (snackbar undo of removal of item), but Gmail and other apps have a swipe to remove/archive/whatever that instead of showing a snackbar with UNDO shows what happened "in-place" where that item was along with providing an UNDO action "in-place" where the item used to be.
Furthermore, starting the swipe reveals an icon indicating what will happen if swiping further (and in some implementations also colors the background accordingly, red for deleting etc).

See also the material design guidelines ragarding "leave-behinds" for indicating what happens when swiping:
https://www.google.com/design/spec/components/lists-controls.html#lists-controls-types-of-list-controls
Scroll down to "leave-behinds".

Implementation idea for a first shot at it could be to enable a choice of swipe directions in the ItemTouchHelper. Upon swipe of item, swap out the displayed item in the adapter and replace back that on timeout similar to the current UndoHelper. The replaced item could have an action. Of course handling the "leave-behinds" requires better integration with the actual swipe.

Set Adapter Items

In the ItemAdapter:

public void set(List<IItem> items) {
        if (mUseIdDistributor) {
            IdDistributor.checkIds(items);
        }
        mItems = items;
        mapPossibleTypes(mItems);
        getFastAdapter().notifyAdapterItemRangeChanged(getFastAdapter().getItemCount(getOrder()), getAdapterItemCount());
    }

maybe use:

public void set(List<? extends IItem> items) {

Kotlin compatibility: Reflection fails for ViewHolder with initializer blocks

So this may be well beyond the scope of this library, but I'm not able to get the adapter to work when writing my implementation of AbstractItem in Kotlin, and using an initializer block ( init{} ) in the AbstractItem.ViewHolder class.

If init{} is used, the ReflectionBasedViewHolderFactory constructor.newInstance() call fails with an InvocationTargetException.

So, by way of example:

This is all within my 'AbstractItem' subclass,

class EventCard(val event: Event) : AbstractItem<EventCard, EventCard.ViewHolder>() {
...

This code is OK, and will run just fine:

   class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imageView: ImageView = itemView?.findViewById(R.id.imageView) as ImageView
   ....

But this code will fail, with the above-mentioned InvocationTargetException:

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imageView: ImageView 
        init{
            imageView = itemView?.findViewById(R.id.imageView) as ImageView
        }

So it's not possible to do any sort of initialisation in the ViewHolder, when written in Kotlin, due to some sort of reflection issue, which I am not able to understand!! I've tried subclassing AbstractItem and looking at the ReflectionBasedViewHolderFactory.create(View v) method, but I just don't understand enough about Kotlin or reflection to figure out the problem.

Thanks in anticipation of your assistance!

Recyclerview with videos

Note: If this is out of scope, then close and I'll find another way.

I am attempting to improve my apps video playback with multiple videos in a RecyclerView. I came across another great library https://github.com/danylovolokh/VideoPlayerManager, but the issue is getting hold of the items that that have an additional couple of extends.

I have tried getting hold of the items via the ItemAdapter.getAdapterItems(), but it returns List.

The question, is it best for me to create an ItemAdapter of my own, for my item type or is it best to come up with a more generic approach (of which I am yet to think of). I am thinking that for the future it maybe be beneficial to others as well if they need the list returned in another form that isn't of type Item. Or at least a way of further customisation.

Load more

Is load more included in your library?

Get selected items back

How can I get the selected items back?
Is there a method?

I only found this: Set<Integer> getSelections()

Drop callback

Hi,

I have a user case that I need to do some actions after a drag and drop. The problem with the current implementation is I don't know when the item is really dropped. It is very expensive to execute the call every time the item move over the list. Any suggestion how should I implement that?

Another issue I have with drag and drop is that I don't want all my items in the recyclerView to be draggable.

Collapseable Items

  • implement a hierarchy for items and implement collapsable functionality
    • if a collapsable structure get's closed we have to
      • deselect all child elements
      • close all child collapsable hirachies
  • if an item is moved in the list of items we have to update remembered positions of opened collapsed items
  • save collapsed state in savedStateInstance

Undo Action

  • Evaluate if an out of the box undo feature would be helpful

[Error] Proguard

Hi!

When i run the application without proguard, everything works but if i use proguard, the application crash and give me this error

java.lang.RuntimeException: something really bad happened. if this happens more often, head over to GitHub and read how to switch to the ViewHolderFactory
   at com.mikepenz.fastadapter.items.AbstractItem.getViewHolder(AbstractItem.java:226)
   at com.mikepenz.fastadapter.items.AbstractItem.getViewHolder(AbstractItem.java:184)
   at com.mikepenz.fastadapter.FastAdapter$OnCreateViewHolderListenerImpl.onPreCreateViewHolder(FastAdapter.java:1087)
   at com.mikepenz.fastadapter.FastAdapter.onCreateViewHolder(FastAdapter.java:264)
   at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228)
   at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453)
   at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
   at android.support.v7.widget.bt.a(LinearLayoutManager.java:1961)
   at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
   at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
   at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
   at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
   at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
   at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
   at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:761)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
   at android.view.View.layout(View.java:15596)
   at android.view.ViewGroup.layout(ViewGroup.java:4966)
    at android.view.Vie

How can I solve this?

Thanks

EndlessRecyclerOnScrollListener load top

Request for enhancement: With the current EndlessRecyclerOnScrollListenerit is possible to add more items to the bottom of the list. Would it be possible to add a onLoadMoreTop to EndlessRecyclerOnScrollListener, so that we know when the users reaches the threshold at the top of the list?

Question: Handle click in image (Example)

Hi Mike, i created an activity in my app, (i get from your example ImageListActivity.java) with the same layout and class, every works perfect, but i need to handle the click in the image.

by the way the click in others views in the layout works well, for example:

FastItemAdapter.withOnCreateViewHolderListener(new FastAdapter.OnCreateViewHolderListener() {
            @Override
            public RecyclerView.ViewHolder onPreCreateViewHolder(ViewGroup parent, int viewType) {
                return mFastItemAdapter.getTypeInstance(viewType).getViewHolder(parent);
            }

            @Override
            public RecyclerView.ViewHolder onPostCreateViewHolder(final RecyclerView.ViewHolder viewHolder) {
                if (viewHolder instanceof ListaFotosArtAdapter.ViewHolder) {
                    mClickListenerHelper.listen(viewHolder, ((ListaFotosArtAdapter.ViewHolder) viewHolder).picDescripcion, new ClickListenerHelper.OnClickListener<ListaFotosArtAdapter>() {
                        @Override
                        public void onClick(View v, int position, ListaFotosArtAdapter item) {
                            new MaterialDialog.Builder(ListaFotosArt.this)
                                    .title("Descripción")
                                    .content(item.mDescripcion)
                                    .positiveText("OK")
                                    .show();
                        }
                    });
                }

                return viewHolder;
            }
        });`

the code above handle the click in the view "picDescripcion" , but i need to handle other view called "picFoto" (this is the imageview with the photo), i add the same code but doesn't work.

I change the picDescripcion with picFoto in the code and is the same.

what i'm missing ?

Thanks

Remove item

When I remove an item, it appears again...

Is it possible to use Drag and Drop together with CAB?

Is it possible to use Drag and Drop together with CAB? Like the google app Keep or google drive?

In case a press and hold would enable drag and drop and the CAB, once I drag the item to another position, the CAB would disapear.

IndexOutOfBoundsException

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:2).state:2
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4405)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
  at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
  at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
  at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:584)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
  at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
  at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
  at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
  at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
  at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
  at android.view.View.layout(View.java:16636)
  at android.view.ViewGroup.layout(ViewGroup.java:5437)
  at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
  at android.view.Choreographer.doCallbacks(Choreographer.java:670)
  at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreogra

Crash occurs when re-creating the related Fragment - might have something to do with notifyItemRemoved(position)

Use RecyclerViewCacheUtil

  • reimplement usage of the RecyclerViewCacheUtil to improve scroll speed if many different item types are used

Click and LongClick animation

Hello Mike,

I use your lib for my app and it works fine. One thing I noticed is that if I use FastAdapter.OnClickListener or the LongClickListener the items don't show any click or long click animations. Am I missing something? The ItemAnimators are only used when moving, deleting something I guess.

Best Regards,

Sebastian

Documentation

It is a great library.
I tried to use it but it is almost impossible to do without reading the source code of the sample app.
JavaDocs should also have example usages and descriptions.

AbstractItem error

I'm using your simple implementation, but when I rename the class I get this error on bindView method.
'bindView(ViewHolder)' in 'com.test.orion.sample.HistoryItem' clashes with 'bindView(VH)' in
'com.mikepenz.fastadapter.items.AbstractItem'; both methods have same erasure yet neither overrides the other. How can I solve this?

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.