简体   繁体   English

莫斯比和方向改变后的恢复状态

[英]Mosby and restoring state after orientation change

In our app (which uses Mosby) we have a SearchActivity that uses Retrofit to fetch results. 在我们的应用程序(使用Mosby)中,我们有一个SearchActivity,它使用Retrofit来获取结果。 The basic flow currently is that the SearchActivity has a List<Results> (which has a @State annotation) which I add the retrieved results. 目前的基本流程是SearchActivity有一个List<Results> (有一个@State注释),我将其添加到检索结果中。 From the SearchActivity I do a call to presenter.doSearch(searchquery) In our Retrofit onSuccess callback I then call getView().populateResults(results) . 从SearchActivity我调用presenter.doSearch(searchquery)在我们的Retrofit onSuccess回调中,然后调用getView().populateResults(results) This then adds the retrieved results to the List in the activity and also adds to the recycler view. 然后,将检索到的结果添加到活动中的List,并添加到recycleler视图。

This is not the correct way to do it because we now get TransactionTooLargeExcpetion's. 这不是正确的方法,因为我们现在得到TransactionTooLargeExcpetion。

So then what is the correct way using Mosby of saving those fetched results and restoring them on orientation change. 那么使用Mosby保存这些获取结果并在方向更改时恢复它们的正确方法是什么呢?

Not sure if this is really Mosby related. 不确定这是否真的与莫斯比有关。 It seems that you store too much data in Bundle (has a limit of 1MB or 512kb depending on Android Version). 您似乎在Bundle中存储了太多数据(根据Android版本限制为1MB或512kb)。 You better cache your result in a disk cache and reload them ... 您最好将结果缓存到磁盘缓存中并重新加载它们......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM