Fragment UI在执行事务时出现冻结,但是从片段返回栈中恢复同一片段时却运行顺畅。

4
我有一个活动,每次只显示一个片段,总共有三个不同的片段。其中FirstFragmentSecondFragment包含RecyclerView,而ThirdFragment具有ScrollView
问题在于当运行时附加片段时,UI会冻结,但自定义的OnItemClickListener监听器正常工作。当我选择FirstFragment的任何列表项时,它将重定向到另一个列表视图SecondFragmentSecondFragment也会冻结。但是,如果我使用返回按钮返回,FirstFragment就可以平稳地工作。同样地,当我选择SecondFragment的列表项时,我会被重定向到最后一个即ThirdFragment,这是一个也会冻结的滚动视图,如果我回到SecondFragment,它就开始平稳地工作,但如果我回到FirstFragment,再次选择任何列表项并回到SecondFragment,UI就会冻结。 注意:这个问题只出现在5.0版本(棒棒糖以上)的操作系统上,在4.2.2 Jelly Bean上一切正常。支持库的TextInputLayout动画在安卓5.0上也存在同样的冻结问题,但在4.2.2 Jelly Bean上表现良好。

我已经创建了Gist,其中包含了activity,三个对应的fragmentsRecyclerView.Adapter和自定义的OnItemClickListener

ProductActivity.java, ProductCategoryFragment.java, ProductListFragment.java, ProductDetailFragment.java, ItemClickSupport.java

感谢您的帮助。谢谢。

编辑

activity启动时,我得到以下日志。
04-01 16:28:47.241 32176-32176/com.example.omkar D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
04-01 16:28:47.371 32176-32176/com.example.omkar I/Timeline: Timeline: Activity_launch_request id:com.example.omkar time:77715999
04-01 16:28:47.381 32176-32176/com.example.omkar W/ResourcesManager: getTopLevelResources: com.example.omkar for user  0
04-01 16:28:47.391 32176-32176/com.example.omkar W/ResourcesManager: getTopLevelResources: com.example.omkar for user  0
04-01 16:28:47.401 32176-32176/com.example.omkar D/PhoneWindow: *FMB* installDecor mIsFloating : false
04-01 16:28:47.401 32176-32176/com.example.omkar D/PhoneWindow: *FMB* installDecor flags : -2139029248
04-01 16:28:47.431 32176-32176/com.example.omkar D/Activity: performCreate Call Injection manager
04-01 16:28:47.431 32176-32176/com.example.omkar I/InjectionManager: dispatchOnViewCreated > Target : com.example.omkar.userInterface.activity.product.ProductActivity isFragment :false
04-01 16:28:47.431 32176-32176/com.example.omkar D/DisplayManager: DisplayManager()
04-01 16:28:47.461 32176-32176/com.example.omkar D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
04-01 16:28:47.461 32176-32176/com.example.omkar D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
04-01 16:28:47.491 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.501 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.511 32176-32176/com.example.omkar I/InjectionManager: dispatchCreateOptionsMenu :com.example.omkar.userInterface.activity.product.ProductActivity
04-01 16:28:47.511 32176-32176/com.example.omkar I/InjectionManager: dispatchPrepareOptionsMenu :com.example.omkar.userInterface.activity.product.ProductActivity
04-01 16:28:47.531 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.561 32176-32176/com.example.omkar I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1d12fb86 time:77716194
04-01 16:28:47.921 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.961 32176-32191/com.example.omkar I/art: Background sticky concurrent mark sweep GC freed 32383(1734KB) AllocSpace objects, 7(112KB) LOS objects, 9% free, 16MB/18MB, paused 5.876ms total 38.048ms
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接