Closed Iridescentangle closed 3 years ago
请教一下,我想要结合ViewBinding来使用,目前选择了hi-dhl/Binding 因为现有对ViewBinding的封装都是针对Activity Fragment Dialog Adapter和自定义View的,所以我考虑自己来做这个Scene.viewbind()的扩展函数.然后在过程中发现
* 感谢 architecture-components-samples 提供的思路 * * 最原始的处理的方案 监听 Fragment 的生命周期,会存在 Fragment 和 Fragment 中的 View 生命周期不一致问题 * 详情查看 [issue][https://github.com/hi-dhl/Binding/issues/15] */ fragment.lifecycle.observerWhenCreated { fragment.viewLifecycleOwnerLiveData.observe(fragment) { viewOwner -> viewOwner.lifecycle.observerWhenDestroyed { viewBinding = null } } }
Issue-Fragment生命周期监听方法不正确 我想知道Scene是否也要考虑到同样的问题,如果有的话应该在哪个时机去执行viewBinding的回收操作呢
Scene 没这问题,只有一套 Lifecycle,Support Fragment 实际上有两套 Lifecycle,View 和 Fragment 本身
请教一下,我想要结合ViewBinding来使用,目前选择了hi-dhl/Binding 因为现有对ViewBinding的封装都是针对Activity Fragment Dialog Adapter和自定义View的,所以我考虑自己来做这个Scene.viewbind()的扩展函数.然后在过程中发现
Issue-Fragment生命周期监听方法不正确 我想知道Scene是否也要考虑到同样的问题,如果有的话应该在哪个时机去执行viewBinding的回收操作呢