Comments (2)
@moonGosun 我大概了解了问题出现在哪了。这个问题不会对正常使用有什么影响。
问题原因
直接原因
RecyclerView
被创建的时候没有设置 Adapter
的时候会抛出这个错误。
分析
在 FilePickerActivity.kt
文件的 prepareLauncher()
方法中,我用了协程来实现异步文件 I/O 然后更新 UI 的操作。(参看 #7 )
注意两点:
-
prepareLauncher()
是在onCreate()
中调用的
在该 launch
作用域最后调用了initView()
这个方法:
private fun prepareLauncher() {
// 执行顺序 ①
launch {
...
// 执行顺序 ③
initView()
}
// 执行顺序 ②
}
所以最后的执行顺序会变成
onCreate() --> prepareLauncher() --> onCreate() 结束 --> initView()
在 onCreate()
结束后没有为 RecyclerView
设置Adapter
,所以提示了错误。
这是协程的黑魔法
感谢提出建议~
from androidfilepicker.
good~
from androidfilepicker.
Related Issues (20)
- AbstractFileFilter 过滤器问题 HOT 4
- 添加过滤器之后怎么过滤掉空文件夹呢 HOT 1
- 能否支持外置SD卡 HOT 2
- androidx 适配 HOT 1
- please update to version 30 HOT 2
- All About Scope Storage. HOT 1
- 怎么少了最基本的Excel HOT 5
- How to show PDF files? HOT 9
- 是否可以考虑使用文件头来识别文件类型 HOT 2
- 可否考虑使用 SAF 方式来实现在 Android 11 及以上系统访问 Android/data 目录 HOT 3
- 文件返回错误 HOT 1
- java.lang.NullPointerException: dataList[position] must not be null HOT 1
- 请问为什么pdf txt等文件无法显示? HOT 2
- 没有适配Android11 HOT 1
- Android 11+授予MANAGE_EXTERNAL_STORAGE后依旧不可用 HOT 1
- 发布的版本打包kotlin插件版本号能否弄低一点? HOT 1
- 为什么没有FilePickerManager类 HOT 11
- 如何实现模糊搜索文件功能和跨文件夹多选功能 HOT 1
- 是否支持把根目录下所有指定格式文件检测出来呢? HOT 1
- NOT WORKING IN ANDROID 11 EVEN AFTER REQUESTING MANAGE_EXTERNAL_STORAGE HOT 1
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 androidfilepicker.