Comments (17)
I actually think the default one should hide the last divider. Weird that the library didn't set it as such.
Updated now.
from recycler-view-divider.
Found the problem. It's related to the implementation of the method obtainStyledAttributes()
which access getTheme()
. The implementation of getTheme()
is different between Application
and Activity
. That's why it wasn't working.
You can change the implementation of provideDividerBuilder()
from this:
val result = RecyclerViewDivider.Builder(context)
obtainStyledAttributes(intArrayOf(android.R.attr.listDivider)).use { typedArray ->
typedArray.getDrawable(0)?.let { result.drawable(it) }
}
return result
To this:
val result = RecyclerViewDivider.Builder(context)
// Invoke it on the Activity instead of the Application.
context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider)).use { typedArray ->
typedArray.getDrawable(0)?.let { result.drawable(it) }
}
return result
from recycler-view-divider.
And BTW yes, I think the method hideLastDivider()
could become the default visibility. I didn't make it as default only following the theory "the default is most basic implementation", but I should have reasoned with "the default is the most common usage".
from recycler-view-divider.
Why would the default be the basic implementation?
Also, you said I can call the default theming on the application class. Not on the Activity.
Now it's even more important to ditch the option to put it on the application class, and use more commonly used ways, like for Views.
There was actually a talk about Context by Google developers, when ApplicationContext isn't the good choice and that you should try to use the one of the Activity when possible.
from recycler-view-divider.
Why would the default be the basic implementation?
Cause I did this library 3 years ago and I thought it was a good choice, now I can see it's a mistake.
Also, you said I can call the default theming on the application class. Not on the Activity.
I said the library checks if the Application
implements RecyclerViewDivider.BuilderProvider
to pick the default configuration and I also said the Context
passed in the method is the same of the in-place call of RecyclerViewDivider.with(Context)
, so in your case, the Activity
.
If that wasn't clear, it can be I wasn't understood before.
Now it's even more important to ditch the option to put it on the application class, and use more commonly used ways, like for Views.
There was actually a talk about Context by Google developers, when ApplicationContext isn't the good choice and that you should try to use the one of the Activity when possible.
I haven't any other idea to give the user the possibility to specify a common dynamic configuration for all the dividers of the app if not using an interface on the Application
. I'll add the theme attributes for a basic common customization, but they won't solve cases like:
RecyclerViewDivider.with(this)
.drawableManager(object : DrawableManager {
override fun itemDrawable(groupCount: Int, groupIndex: Int): Drawable {
val color = if (groupCount % 2 == 0) Color.BLACK else Color.RED
return ColorDrawable(color)
}
})
.build()
from recycler-view-divider.
I don't understand. You can provide both. If the user doesn't set a drawable, the default one is what you can have from the system.
After all, you already chose a default one...
Anyway, please just think about it. I think you can reach something like what Android provides for Views, attributes, and styles, while also allowing to customize at runtime.
from recycler-view-divider.
With:
I'll add the theme attributes for a basic common customization, but they won't solve cases like [...]
I meant to say that I'll use both, but that I can't remove the RecyclerViewDivider.BuilderProvider
.
from recycler-view-divider.
So you want to support 3 things that can override...
I think you are going too far. Could complicate things...
from recycler-view-divider.
I have to think a bit if that's too far or not. BTW the theme attributes will be added anyway.
from recycler-view-divider.
OK. I guess you are right. Sorry.
from recycler-view-divider.
No problem at all, your help is appreciated and the ideas we discussed about in the two issues are added to the milestone 4.x.
So thanks again, if anything else comes to your mind, don't hesitate to comment or open other issues.
from recycler-view-divider.
BTW I'm closing this issue since it can be solved using context.obtainStyledAttributes()
. Check the milestone 4.x for what we've discussed about.
from recycler-view-divider.
I don't understand what you mean.
Please consider using default style for dividers.
from recycler-view-divider.
I meant only to move this conversation to the related issues: #45 and #46
I'll implement all of this, just move the conversation on those issues since I'll refer to them for the milestone.
from recycler-view-divider.
Oh ok.
from recycler-view-divider.
Just released the version 3.2.0 which uses android:listDivider
by default to get the divider's Drawable
and other theme attributes (wiki).
from recycler-view-divider.
It also hides the last divider by default.
from recycler-view-divider.
Related Issues (20)
- StaggeredDividerItemDecoration bug HOT 3
- 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
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.