Comments (4)
FragmentViewBinding 里面代码为
`class FragmentViewBinding(
classes: Class,
fragment: Fragment
) : FragmentDelegate(fragment) {
private val layoutInflater = classes.inflateMethod()
private val bindView = classes.bindMethod()
override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
return viewBinding?.run {
return this
} ?: let {
try {
/**
* 检查目的,是为了防止在 onCreateView() or after onDestroyView() 使用 binding。
* 另外在销毁之后,如果再次使用,由于 delegate property 会被再次初始化出现的异常
*
* 捕获这个异常的原因,是为了兼容之前的版本,防止因为升级,造成崩溃
*/
check(thisRef.viewLifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) {
"cannot use binding in before onCreateView() or after onDestroyView() from 1.1.4. about [issue](https://github.com/hi-dhl/Binding/issues/31#issuecomment-1109733307)"
}
} catch (e: Exception) {
e.printStackTrace()
}
val bind: T
if (thisRef.view == null) {
// 这里为了兼容在 navigation 中使用 Fragment
bind = layoutInflater.invoke(null, thisRef.layoutInflater) as T
} else {
bind = bindView.invoke(null, thisRef.view) as T
}
return bind.apply { viewBinding = this }
}
}
}`
from binding.
收到,能贴一下,使用这部分的代码吗
from binding.
你说的是调用的时候吗? 就是正常调用呀
from binding.
手机多次运行也不会报错,这个错误是在GP后台看到的。
from binding.
Related Issues (20)
- 在Navigation启动的Fragment中使用报错 HOT 1
- ActivityDataBinding里OS版本小于Q时为什么要添加一个空白的fragment? HOT 1
- 在BRAVH中怎么使用呢 HOT 1
- NoSuchMethodException问题 HOT 2
- 使用viewbind时,如何在使用xml布局的自定义ViewGroup中使用呢 HOT 4
- 版本时间写错啦,都2021年啦 HOT 5
- ActivityViewBinding 是否应该主动在onCreate时调用setContentView HOT 1
- 自定义View的混淆规则 HOT 2
- 遇到个bug HOT 9
- Fatal Exception: java.lang.IllegalStateException: onGetLayoutInflater() cannot be executed until the Fragment is attached to the FragmentManager. HOT 13
- 更新kotlin后,出现一下问题 HOT 2
- 关于ViewGroupDataBinding的一个问题 HOT 6
- SmartRefreshLayout自定义RefreshHeader时,报java.lang.NoSuchMethodException的错误 HOT 13
- 1.1.6版本找不到databind了 HOT 3
- 同一类型的多个 fragment 实例的 binding.view 引用错位问题 HOT 2
- Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option HOT 1
- 开启混淆会报错,按照文档添加了混淆规则
- 有一定的几率会报错闪退,Android 12 红米手机 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 binding.