Giter VIP home page Giter VIP logo

Comments (20)

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024 1

ok thanks.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

Just released the version 3.2.0 which uses android:listDivider by default to get the divider's Drawable.

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

And in code, like this:

RecyclerViewDivider.with(context).addTo(this) 

Meaning no need for this:

fun RecyclerView.setDefaultDividers() {
    val context = this.context
    context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider)).use { typedArray ->
        typedArray.getDrawable(0)
                ?.let { RecyclerViewDivider.with(context).drawable(it).hideLastDivider().build().addTo(this) }
    }
}

?

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

The RecyclerViewDivider API is deprecated in favour of the new DividerBuilder API.

You can replace this whole function:

fun RecyclerView.setDefaultDividers() {
    val context = this.context
    context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider)).use { typedArray ->
        typedArray.getDrawable(0)
                ?.let { RecyclerViewDivider.with(context).drawable(it).hideLastDivider().build().addTo(this) }
    }
}

With just:

recyclerView.addDivider()

Because:

  • now the default divider reads the value of android.R.attr.listDivider
  • now the default divider hides the last divider by default

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

Seems not working for me on dark theme for some reason, while working fine on normal theme.

Can you test, or should I try on POC ?

At least using the old method I've made seems to still work as before.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

I'll try it soon, thanks!

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

Please let me know about it.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

@AndroidDeveloperLB I reproduced it and I found the line of code which causes it.
It's the following one:

DrawableCompat.setTintList(wrappedDrawable, null)

This line is necessary to reset the tint of the single divider to avoid the tint color to propagate to the other dividers.

Now I have to understand why it changes the Drawable on night theme.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

It's very similar to this issue on Android: https://issuetracker.google.com/issues/141678225
The problem is that the default divider color on API > 21 is #ffdadce0 on light theme and #85ffffff on dark theme.

The problem is tinting a GradientDrawable with a color which isn't fully opaque, that's why it fails only on dark theme.

I'll replace the call to setTintList with a ColorFilter if I can't succeed to make it working in the standard way.

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

OK for now I will use the previous method. It still works fine.

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

Is there a shorter workaround than using what I wrote, BTW?

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

You can probably change the value of android:listDivider to a plain color with those values that I wrote above (the one in the Android material version). But I'll release a fix pretty soon so I don't think it's worth

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

I need in code. Anyway, please let me know when you fix this.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

Yes, I'll notify you for any update

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

Thank you. If you with, this is my app that uses this repository.

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

@AndroidDeveloperLB Released the version 3.2.1 containing the fix. Can you let me know if addDivider() works for you now?

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

I think now it's indeed fixed and working well.
Thank you.

BTW, why add extension function?
This isn't something that's common for libraries. Usually it's reserved for the main project itself, not for libraries, unless it's a very core function (kotlin basic classes, for example).

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

Nice, to hear.

I added the extension function to create a divider using the shortest syntax and made it more accessible for Kotlin users of this library since creating the divider is the core API of this library (other APIs like RecyclerViewDividerLog which aren't related to the core one, are still expressed without extension functions). I did it also following bigger repositories written in Kotlin like Coil.

I honestly think it's more a matter of personal taste than something objective in general.

(I'm closing this issue since the bug was fixed)

from recycler-view-divider.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 4, 2024

OK your choice. Are there more extension functions on the library now?

from recycler-view-divider.

fondesa avatar fondesa commented on June 4, 2024

Since the version 3.2.0 (the one with new APIs) there are these 4 extensions, all 4 on RecyclerView:

  • addDivider()
  • dividerBuilder()
  • addStaggeredDivider()
  • staggeredDividerBuilder()

from recycler-view-divider.

Related Issues (20)

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.