CymChad / CymChad/BaseRecyclerViewAdapterHelper

ViewPager2 中 context 无法初始化

Open
#3,331 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
24.6k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

如果还是没有找到答案,提问请带上这几个必要信息

  1. 3.0.4
  2. viewpager2 上面使用
  3. mAdapter=xxxxAdapter(listData)
  4. kotlin.UninitializedPropertyAccessException: lateinit property context has not been initialized

BaseQuickAdapter 中 context 为私有的 lateinit

在 onAttachedToRecyclerView 中

this.context = recyclerView.context

因为我这边想在ViewPager2 上使用Brvah context一直无法初始化

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with BaseQuickAdapter and its onAttachedToRecyclerView entry point, then reproduce the reported setup using ViewPager2, mAdapter=xxxxAdapter(listData), and version 3.0.4. Check when the private lateinit context is accessed relative to attachment; done means the ViewPager2 usage no longer raises UninitializedPropertyAccessException.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.