Comments (12)
it is released now as 4.3.2
Thanks again for your contribution
from adapterdelegates.
I have created this PR, simply adding @Nullable
annotations:
#107
from adapterdelegates.
thanks for your contribution. I will take a look at it tomorrow.
from adapterdelegates.
just out of curiosity: what is your use case to actually access ˋitemsˋ or create a subclass of ˋListDelegationAdapterˋ
from adapterdelegates.
Sure, I will try to explain. Our entire app is written in Kotlin. We have a very dynamic screen (consisting of a recycler view mainly) where depending on some conditions we might need to insert or remove something into our adapter's list. For this we have declared our own adapter, subclassing ListDelegationAdapter
and passing our various AdapterDelegates inside the constructor. In the body of that adapter we have functions like e.g.
fun insertItem(index: Int, item: MyDisplayItem) {
items = items?.toMutableList()?.apply { add(index, item) }
notifyItemInserted(index)
}
fun removeItem(index: Int) {
items = items?.toMutableList()?.apply { removeAt(index) }
notifyItemRemoved(index)
}
where items
is not considered nullable therefore no issues arise if we omit the ?
after a call to it.
Additionally, some of the views we have are a bit complex with nested scrolling and we have some custom tracking inside our fragment, where we need to get the position of certain views, something like:
newsPromotionAdapter.items?.indexOfFirst { it is MySpecificDisplayItem }
The second case can be worked around with that custom base adapter, but the first case (inside our adapter) will always allow a non-nulllable access to the items
variable.
This is not something that prevents us from using the library of course. It is just a safety measure we would like to have for future implementations and for using this excellent library throughout more places in our app.
Thank you for looking into it.
from adapterdelegates.
Thanks for sharing
from adapterdelegates.
Thank you for reviewing and merging! I will close this issue.
from adapterdelegates.
@sockeqwe any idea when we will have the change available in a release? Thanks!
from adapterdelegates.
@Sab44 could you give the latest snapshot a try to see if everything works as expected? If that is the case I will create a new release
from adapterdelegates.
@sockeqwe can confirm with the snapshot version that for both the inherited items
variable inside the adapter as welll as calls to getItems()
outside the adapter, the Kotlin compiler will enforce null-safety.
from adapterdelegates.
@sockeqwe any news on a release? Thanks.
from adapterdelegates.
Sorry, I almost forgot about it.
I'm on vacation right now, I'm back on Wednesday. Will then create a new release!
from adapterdelegates.
Related Issues (20)
- Classes design question
- PagingDataAdapter support HOT 2
- Nullable block in adapterDelegateViewBinding
- An error occurs when trying to bind a data variable
- Infinite loop HOT 1
- problem in ver > 4.3.0
- Nullable `items` property in AbsDelegationAdapter after 4.3.2. HOT 2
- Global RecycledViewPool HOT 4
- The adapter creates all list elements at once.
- Update object inside nested RecyclerView
- Anyway to support Drag and Drop in AdapterDelegates ?
- AdapterDelegateManager#getItemViewType always returning same Type regardless of position HOT 1
- Jetpack Paging 3 support HOT 5
- Reuse AdapterDelegate<List<T>> in a domain specific way HOT 3
- How make sticky headers? HOT 2
- Delegates hierarchy and reusability
- [CRASH] adapterDelegateViewBinding's block crashing HOT 4
- Kotlinx synthetic not working
- SortedList implementation
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 adapterdelegates.