я получаю следующее падение при использовании быстрого адаптера
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.get(ArrayList.java:411)
at com.android.server.wm.WindowAnimator.updateAppWindowsLocked(WindowAnimator.java:248)
at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:919)
at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:180)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:925)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:635)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
и иногда это крушение
java.lang.NullPointerException: Attempt to invoke interface method 'androidx.recyclerview.widget.RecyclerView$ViewHolder com.mikepenz.fastadapter.IItem.getViewHolder(android.view.ViewGroup)' on a null object reference
at com.mikepenz.fastadapter.listeners.OnCreateViewHolderListenerImpl.onPreCreateViewHolder(OnCreateViewHolderListenerImpl.java:23)
at com.mikepenz.fastadapter.FastAdapter.onCreateViewHolder(FastAdapter.java:684)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3336)
at android.view.View.measure(View.java:21045)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:9119)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1583)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1331)
at androidx.recyclerview.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1075)
at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1832)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5067)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:635)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
вот мой код
class ListingAttributes(private val activity: ListingDetailsActivity, private val viewModel: ListingAttributesViewModel) : AbstractItem<ListingAttributes, ListingAttributes.ViewHolder>() {
override fun getLayoutRes() = R.layout.recycler_view_listing_attributes_item
override fun getType() = R.id.recycler_view_listing_attributes_item
override fun getViewHolder(v: View) = ListingAttributes.ViewHolder(
RecyclerViewListingAttributesItemBinding.bind(v), activity, viewModel)
class ViewHolder(private val binding: RecyclerViewListingAttributesItemBinding, private val activity: ListingDetailsActivity, private val viewModel: ListingAttributesViewModel) :
FastAdapter.ViewHolder<ListingAttributes>(binding.root) {
private var itemAdapter = ItemAdapter<IItem<*, *>>()
private val loadAttributesFromDBObserver = Observer<Unit> {
//binding.recyclerView.addView(AttributeBoolViewGrid(activity, viewModel.attributes.filter { it.type == AttributeType.BOOL.value }))
viewModel.attributes.forEach { item ->
when (item.type) {
AttributeType.TEXT.value, AttributeType.NUMBER.value, AttributeType.DROP_DOWN.value -> {
val listAttr = viewModel.listingAttribute.find { it.id.toInt() == item.id }
listAttr?.let { AttributeView(activity, listAttr, item, AttributeViewViewModel(viewModel.optionDao)).also { item -> itemAdapter.add(item) } }
}
}
}
itemAdapter?.let {
val fastAdapter: FastAdapter<IItem<*, *>> = FastAdapter.with(
listOf(
itemAdapter
)
)
fastAdapter.apply {
setHasStableIds(true)
withSelectable(true)
}
binding.recyclerView.apply {
layoutManager = LinearLayoutManager(context)
adapter = fastAdapter
}
}
}
override fun bindView(item: ListingAttributes, payloads: MutableList<Any>) {
viewModel.loadAttributesFromDBEvent?.observe(activity, loadAttributesFromDBObserver)
}
override fun unbindView(item: ListingAttributes) {
viewModel.loadAttributesFromDBEvent.removeObservers(activity)
}
}
}
а это моя модель взгляда
class ListingAttributesViewModel(val activity: Activity, val listingAttribute: List<ListingExtraAttr>) : BaseStatefulViewModel() {
private val extraAttributesRepository: ExtraAttributeRawRepository by inject()
val optionDao: ExtraAttributeOptionDao by inject()
lateinit var attributes: List<ExtraAttributeEntity>
val loadAttributesFromDBEvent = LiveEvent<Unit>()
init {
getAttributes(listingAttribute.joinToString { it.id })
}
private fun getAttributes(attributesIds: String) {
launch(Dispatchers.IO) {
extraAttributesRepository?.let {
attributes = extraAttributesRepository.getExtraAttributesByIds(attributesIds)
loadAttributesFromDBEvent.call()
}
}
}
}
Может кто-нибудь помочь, пожалуйста, авария не говорит никакой информации о том, где это произошло?