Closed panovvitalik closed 1 year ago
You can find the old java sources of the project here: https://github.com/mikepenz/MaterialDrawer/tree/v6.1.2
v6.x was still depending on the FastAdapter
v3.3.0 -> https://github.com/mikepenz/FastAdapter/blob/v3.3.0/library-core/src/main/java/com/mikepenz/fastadapter/items/AbstractItem.java
The error itself is logged from here: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/listeners/OnBindViewHolderListenerImpl.java#L56
Which is expecting the item to be found via: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L1422
Normally this should already get set here: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/listeners/OnBindViewHolderListenerImpl.java#L25C3-L34
Versions below v9 are provided
as-is
and I sadly can't provide any major support for these.
You can find the old java sources of the project here: https://github.com/mikepenz/MaterialDrawer/tree/v6.1.2 v6.x was still depending on the
FastAdapter
v3.3.0 -> https://github.com/mikepenz/FastAdapter/blob/v3.3.0/library-core/src/main/java/com/mikepenz/fastadapter/items/AbstractItem.javaThe error itself is logged from here: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/listeners/OnBindViewHolderListenerImpl.java#L56
Which is expecting the item to be found via: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L1422
Normally this should already get set here: https://github.com/mikepenz/FastAdapter/blob/v3.3.1/library-core/src/main/java/com/mikepenz/fastadapter/listeners/OnBindViewHolderListenerImpl.java#L25C3-L34
Versions below v9 are provided
as-is
and I sadly can't provide any major support for these.
As I see you set IItem objects:
IItem item = fastAdapter.getItem(position);
...
//set the R.id.fastadapter_item tag of this item to the item object (can be used when retrieving the view)
viewHolder.itemView.setTag(R.id.fastadapter_item, item);
Always item is PrimaryDrawerItem or SecondaryDrawerItem, and not a FastAdapter object. But you try to find for FastAdapter class:
Object item = holder.itemView.getTag(com.mikepenz.fastadapter.R.id.fastadapter_item);
if (item instanceof FastAdapter) {
return (Item) item;
}
}
return null; // !!!! THIS LINE WORKS ALL THE TIME !!!!
Is there any way to fix the issue?
p.s. Of course, except getting full sources and copy/paste inside my project
The solution I have found is below. I have created this class:
public class OnBindViewHolderListenerImplBase extends OnBindViewHolderListenerImpl {
@Override
public void unBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
IItem item = FastAdapter.getHolderAdapterItemTag(viewHolder);
if (item != null) {
super.unBindViewHolder(viewHolder, position);
}
}
}
And use this class this way:
Drawer mMenu;
mMenu.getAdapter().withOnBindViewHolderListener(new OnBindViewHolderListenerImplBase());
This is resolved my issue.
But I'm afraid maybe I have broken something else? Or it's correct solution?
@panovvitalik nothing should be broken with this approach, it may only be slightly less efficient as getHolderAdapterItemTag(viewHolder);
is being called twice
@panovvitalik nothing should be broken with this approach, it may only be slightly less efficient as
getHolderAdapterItemTag(viewHolder);
is being called twice
Ok. Thank you for your help!
I reopen bug: #2729
You wrote "use kotlin", but I can't use kotlin version lib due to this bug: #2786
You wrote "use kotlin classes inside java project", but I can't migrate these classes from java to kotlin.
Now I try to extend all DrawerItem.... classes and add
viewHolder.itemView.setTag(R.id.fastadapter_item, this);
But it doesnt work :(
How can I resolve this issue? Do you have java sources for 6.1.2 lib?
Details [ ] Used library version: com.mikepenz:materialdrawer:6.1.2
[ ] Used support library version: 'androidx.legacy:legacy-support-v4:1.0.0' 'androidx.legacy:legacy-support-v4:1.0.0' 'androidx.legacy:legacy-support-v13:1.0.0'
[ ] Used gradle build tools version: com.android.tools.build:gradle:7.3.1
[ ] Android Studio version: Android Studio Dolphin | 2021.3.1 Patch 1
How can I resolve this issue?