kandi background
Explore Kits

FlexibleAdapter | Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :) | Android library

 by   davideas Java Version: 5.1.0 License: Apache-2.0

 by   davideas Java Version: 5.1.0 License: Apache-2.0

Download this library from

kandi X-RAY | FlexibleAdapter Summary

FlexibleAdapter is a Java library typically used in Mobile, Android applications. FlexibleAdapter has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub.
Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • FlexibleAdapter has a medium active ecosystem.
  • It has 3418 star(s) with 534 fork(s). There are 117 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 60 open issues and 668 have been closed. On average issues are closed in 23 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of FlexibleAdapter is 5.1.0
FlexibleAdapter Support
Best in #Android
Average in #Android
FlexibleAdapter Support
Best in #Android
Average in #Android

quality kandi Quality

  • FlexibleAdapter has 0 bugs and 0 code smells.
FlexibleAdapter Quality
Best in #Android
Average in #Android
FlexibleAdapter Quality
Best in #Android
Average in #Android

securitySecurity

  • FlexibleAdapter has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • FlexibleAdapter code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
FlexibleAdapter Security
Best in #Android
Average in #Android
FlexibleAdapter Security
Best in #Android
Average in #Android

license License

  • FlexibleAdapter is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
FlexibleAdapter License
Best in #Android
Average in #Android
FlexibleAdapter License
Best in #Android
Average in #Android

buildReuse

  • FlexibleAdapter releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • FlexibleAdapter saves you 10050 person hours of effort in developing the same functionality from scratch.
  • It has 20461 lines of code, 1816 functions and 248 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
FlexibleAdapter Reuse
Best in #Android
Average in #Android
FlexibleAdapter Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi has reviewed FlexibleAdapter and discovered the below as its top functions. This is intended to give you an instant insight into FlexibleAdapter implemented functionality, and help decide if they suit your requirements.

  • Gets the offsets for the child items in the RecyclerView .
  • Swap all the selected items in the given list .
  • Handle the item swiped
  • Internal method to animate a view .
  • Ends all animations .
  • Initialize the RecyclerView .
  • Translate the header item offset .
  • Create overall database .
  • Do the animation .
  • Called when a parameter is selected .

FlexibleAdapter Key Features

Simple, Single & Multi selection mode.

Mapping multi-view types with Item interfaces.

Predefined ViewHolders with (child) click listeners and others callbacks.

Async Updates with optional DiffUtil for small lists.

Async Filter with spannable text (:eyeglasses:); Result list is animated; With optional original list; Works with sub items; Multi filter.

High performance filter and updates for medium and big lists.

Headers and Sections with sticky behaviour fully clickable and collapsible, elevation, transparency and automatic linkage on item move!

Scrollable Headers and Footers items that lay respectively at the top and at the bottom of the main items.

Expandable items with Selection Coherence and multi-level expansion.

Drag&Drop and Swipe-To-Dismiss with Leave-Behind pattern and with Selection Coherence.

Innovative bottom and top EndlessScroll (No OnScrollListener).

Customizable FastScroller with several features.

Customizable Scrolling Animations based on adapter position and beyond.

Customizable Animations when adding and removing items.

LayoutUtils for orientation, span count and visible items calculation.

Support for any thirds LayoutManagers.

Easy runtime position calculation for adding/moving items in sections.

Custom Tags for multiple adapter instances that ease our debug.

Comprehensive Wiki pages and JavaDoc documentation.

Setup

copy iconCopydownload iconDownload
repositories {
    jcenter()
}

License

copy iconCopydownload iconDownload
Copyright 2015-2018 Davide Steduto, Davidea Solutions Sprl

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.

Recyclerview with sticky header and subheader

copy iconCopydownload iconDownload
val newList = mutableListOf<SomeKindOfInterface>()

fun setData(list: List<YourJsonObject>) {
    newList.clear()

    var previousMonth = 0
    var previousDay = 0
    for (yourJsonObject in list) {

        if (yourJsonObject.month != previousMonth) {
            previousMonth = yourJsonObject.month
            newList.add(MonthObject(yourJsonObject.month))
        }

        if (yourJsonObject.day != previousDay) {
            previousDay = yourJsonObject.day
            newList.add(DayObject(yourJsonObject.day))
        }

        newList.add(yourJsonObject)
    }
}



class YourJsonObject(
    val month: Int,
    val day: Int
) : SomeKindOfInterface

class MonthObject(val month: Int) : SomeKindOfInterface

class DayObject(val day: Int) : SomeKindOfInterface

interface SomeKindOfInterface
override fun getItemViewType(position: Int): Int {
    return when (newList.get(position)) {
        is YourJsonObject -> 0
        is MonthObject -> 1
        is DayObject -> 2
    }
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
    return when (viewType) {
        0 -> createYourJsonObjectViewHolder
        1 -> createMonthObjectViewHolder
        2 -> createDayObjectViewHolder
    }
}
-----------------------
val newList = mutableListOf<SomeKindOfInterface>()

fun setData(list: List<YourJsonObject>) {
    newList.clear()

    var previousMonth = 0
    var previousDay = 0
    for (yourJsonObject in list) {

        if (yourJsonObject.month != previousMonth) {
            previousMonth = yourJsonObject.month
            newList.add(MonthObject(yourJsonObject.month))
        }

        if (yourJsonObject.day != previousDay) {
            previousDay = yourJsonObject.day
            newList.add(DayObject(yourJsonObject.day))
        }

        newList.add(yourJsonObject)
    }
}



class YourJsonObject(
    val month: Int,
    val day: Int
) : SomeKindOfInterface

class MonthObject(val month: Int) : SomeKindOfInterface

class DayObject(val day: Int) : SomeKindOfInterface

interface SomeKindOfInterface
override fun getItemViewType(position: Int): Int {
    return when (newList.get(position)) {
        is YourJsonObject -> 0
        is MonthObject -> 1
        is DayObject -> 2
    }
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
    return when (viewType) {
        0 -> createYourJsonObjectViewHolder
        1 -> createMonthObjectViewHolder
        2 -> createDayObjectViewHolder
    }
}

Trying to use FlexibleAdapter for Android

copy iconCopydownload iconDownload
// Initialize the RecyclerView and attach the Adapter to it as usual
RecyclerView recyclerView = findViewById(R.id.recyclerView1);

recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

recyclerView.setAdapter(adapter);

Community Discussions

Trending Discussions on FlexibleAdapter
  • Explanation required: Type mismatch Required: Nothing Found: MyItem
  • Recyclerview with sticky header and subheader
  • Initialization of a fragment causes the animation lag
  • Trying to use FlexibleAdapter for Android
Trending Discussions on FlexibleAdapter

QUESTION

Explanation required: Type mismatch Required: Nothing Found: MyItem

Asked 2019-Aug-22 at 05:57

Currently I converting my android app to Kotlin. The app currently use a third party library called "FlexibleAdapter". I converted my adapter extension to Kotlin without any errors. But when I try to use this adapter I get an type mismatch error when calling the method addItem() which is not overriden by my adapter extension.

Due to the lack of Kotlin experience I don't understand whats going wrong here and how to fix it. Could someone explain what I need to change?

I strip down the code to the very basics to see whats going on! myfragment contains the code where the error appears

Kotlin implementation of the fragment

class myfragment : Fragment() {
private lateinit var myLayoutAdapter: MultiPurposeListAdapter<*>
private var myItems = mutableListOf<AbstractFlexibleItem<*>>()

override fun onActivityCreated(savedInstanceState: Bundle?) {
    super.onActivityCreated(savedInstanceState)

    myLayoutAdapter = MultiPurposeListAdapter(myItems, this, true)

    // Prepare the RecyclerView and attach the Adapter to it
    fragment_recycler_view.apply {
        layoutManager = createNewLinearLayoutManager()
        adapter = mIngredientsLayoutAdapter
        setHasFixedSize(false) //Size of RecyclerView will change
    }
}

/******
 * A function to add items
 ******
fun addNewItem(itemToAdd: MyItem) {
    //Note: itemToAdd is from MyItem that extends AbstractFlexibleItem

    // If I try to invoke the addOtem method from the FlexibleAdapter
    // I get a Type mismatch error
    // addItem is not overriden by MultiplePurposeListAdapter!

    myLayoutAdapter.addItem(itemToAdd)  // <- Here I get a Type mismatch error
                                        // Required: Nothing
                                        // Found: MyItem
    }
}

Kotlin implementation of my Flexible Adapter extension

open class MultiPurposeListAdapter<T: AbstractFlexibleItem<*>>
@JvmOverloads constructor(items: List<T>?, listeners: Any? = null, stableIds: Boolean = true)
: FlexibleAdapter<T>(items, listeners, stableIds) {

    // Here we extend the FlexibleAdapter with custom filters
    }

Java implementation of the adapter that comes from a third part library called FlexibleAdapter Note: I strip out only the things that seems necessarry to understand!

public class FlexibleAdapter<T extends IFlexible> extends AnimatorAdapter {

private List<T> mItems // The main container for ALL items

/**
 * Simply append the provided item to the end of the list.
 * <p>Convenience method of {@link #addItem(int, IFlexible)} with
 * {@code position = getMainItemCount()}.</p>
 *
 * @param item the item to add
 * @return true if the internal list was successfully modified, false otherwise
 */
public boolean addItem(@NonNull T item) {
    return addItem(getItemCount(), item);
}

/**
 * Returns the total number of items in the data set held by the adapter.
 *
 * @return the total number of items (headers and footers INCLUDED) held by the adapter
 */
@Override
public int getItemCount() {
    return mItems.size();
}

/**
 * Inserts the given item at the specified position or Adds the item to the end of the list
 * (no matters if the new position is out of bounds!).
 *
 * @param position position inside the list, if negative, items will be added to the end
 * @param item     the item to add
 * @return true if the internal list was successfully modified, false otherwise
 */
public boolean addItem(@IntRange(from = 0) int position, @NonNull T item) {
    if (item == null) {
        log.e("addItem No item to add!");
        return false;
    }
    log.v("addItem delegates addition to addItems!");
    return addItems(position, Collections.singletonList(item));
}

/**
 * Inserts a set of items at specified position or Adds the items to the end of the list
 * (no matters if the new position is out of bounds!).
 *
 * @param position position inside the list, if negative, items will be added to the end
 * @param items    the set of items to add
 * @return true if the internal list was successfully modified, false otherwise
 */
public boolean addItems(@IntRange(from = 0) int position, @NonNull List<T> items) {
    if (items == null || items.isEmpty()) {
        log.e("addItems No items to add!");
        return false;
    }
    int initialCount = getMainItemCount(); // Count only main items!
    if (position < 0) {
        log.w("addItems Position is negative! adding items to the end");
        position = initialCount + mScrollableHeaders.size();
    }
    // Insert the items properly
    performInsert(position, items, true);
    // Show the headers of new items
    showOrUpdateHeaders(items);
    // Call listener to update EmptyView
    if (!recursive && mUpdateListener != null && !multiRange && initialCount == 0 && getItemCount() > 0) {
        mUpdateListener.onUpdateEmptyView(getMainItemCount());
    }
    return true;
}
}

The error message inside the Android Studio is: Type mismatch. Required: Nothing Found: MyItem

I expect that AbstractFlexibleItem is required. This happens only in the Kotlin converted code. Other fragment implementations (in java) doesn't show that error.

ANSWER

Answered 2019-Aug-22 at 05:57

In this line: private lateinit var myLayoutAdapter: MultiPurposeListAdapter<*> you just have to specify an Item type (java doesn´t require it) for example: MultiPurposeListAdapter<MyItem> or MultiPurposeListAdapter<AbstractFlexibleItem<*>>. For more information, see generic types overview

Source https://stackoverflow.com/questions/57601964

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install FlexibleAdapter

You can download it from GitHub.
You can use FlexibleAdapter like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the FlexibleAdapter component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with FlexibleAdapter
Try Top Libraries by davideas
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.