Closed callmexiaolu closed 5 years ago
在使用库之前进行了activity的判空操作,然后运行中还会发生异常抛出。 ` activity?.let { it.window.decorView.postDelayed({ if (showSwitchChild) { NewbieGuide.with(this) .setLabel("Dynamic") .alwaysShow(true) .addGuidePage(GuidePage.newInstance() .addHighLight(la_animation) .setLayoutRes(R.layout.dynamic_flag_guide)) .addGuidePage(GuidePage.newInstance() .addHighLight(RectF(0f, 0f, 0f, 0f)) .setLayoutRes(R.layout.dynamic_guide_hint)) .setOnGuideChangedListener(object : OnGuideChangedListener { override fun onRemoved(p0: Controller?) {
} override fun onShowed(p0: Controller?) { } }) .show() } else { NewbieGuide.with(this) .setLabel("Dynamic") .alwaysShow(true) .addGuidePage(GuidePage.newInstance() .addHighLight(la_animation) .setLayoutRes(R.layout.dynamic_flag_guide)) .setOnGuideChangedListener(object : OnGuideChangedListener { override fun onRemoved(p0: Controller?) { } override fun onShowed(p0: Controller?) { } }) .show() } }, 1000) }`
找到原因了:是因为fragment实例化后,所依附的activity后续被回收了,但是该fragment实例依旧存在,导致使用库的时候通过该fragment获取的activity为null
在使用库之前进行了activity的判空操作,然后运行中还会发生异常抛出。 ` activity?.let { it.window.decorView.postDelayed({ if (showSwitchChild) { NewbieGuide.with(this) .setLabel("Dynamic") .alwaysShow(true) .addGuidePage(GuidePage.newInstance() .addHighLight(la_animation) .setLayoutRes(R.layout.dynamic_flag_guide)) .addGuidePage(GuidePage.newInstance() .addHighLight(RectF(0f, 0f, 0f, 0f)) .setLayoutRes(R.layout.dynamic_guide_hint)) .setOnGuideChangedListener(object : OnGuideChangedListener { override fun onRemoved(p0: Controller?) {