Comments (20)
ok thanks.
from recycler-view-divider.
Just released the version 3.2.0 which uses android:listDivider
by default to get the divider's Drawable
.
from recycler-view-divider.
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.
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.
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.
I'll try it soon, thanks!
from recycler-view-divider.
Please let me know about it.
from recycler-view-divider.
@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.
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.
OK for now I will use the previous method. It still works fine.
from recycler-view-divider.
Is there a shorter workaround than using what I wrote, BTW?
from recycler-view-divider.
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.
I need in code. Anyway, please let me know when you fix this.
from recycler-view-divider.
Yes, I'll notify you for any update
from recycler-view-divider.
Thank you. If you with, this is my app that uses this repository.
from recycler-view-divider.
@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.
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.
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.
OK your choice. Are there more extension functions on the library now?
from recycler-view-divider.
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)
- Animate divider
- Expose 'absoluteCellIndex'? HOT 11
- GridLayoutManager item height not equal HOT 4
- Run tests on Android Q HOT 1
- Update Android 11
- "GridLayoutManager.multipleSpanGrid" It takes too much time with a large data set HOT 4
- visibilityProvider is not working fine with GridLayoutMananger HOT 3
- Grag Item,the space will bigger and bigger HOT 4
- Fix sourceSets deprecation in CoveragePlugin
- Crash: The grid doesn't contain the item at position... HOT 3
- Equal Spacing HOT 2
- How to set float size decoration? HOT 2
- The size of the divider is wrong after notifyItemRemoved() HOT 2
- How to use the SizeProvider HOT 1
- 使用说明可以详细一些么 HOT 2
- Try JaCoCo report aggregation
- Upgrade Releases Hub Plugin to v4.0.0 HOT 1
- Failed to allocate a xxx0 byte allocation with xxx free bytes and 503MB until OOM, HOT 2
- Dependency Dashboard
- GridView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recycler-view-divider.