最有价值球员。当 activity 正在重新创建时,将演示者的缓存存储在哪里?

MVP. Where to store presenter`s cache when activity is recreating?

我正在尝试使用 MVP 模式重构我的应用程序,并且希望将来用视图替换片段。

当 activity 配置发生变化时,如何存储演示者的缓存数据?我不想使用 SQLite、共享首选项、静态字段、单例、保留片段。我想要的是根据 Activity 生命周期正确存储和终止缓存。

我想我找到了解决方案。

http://blog.bradcampbell.nz/mvp-presenters-that-survive-configuration-changes-part-2/

那家伙将每个演示者保存在某种 PresenterCacheManager 中,然后存储该缓存视图 Activity 的 onRetainCustomNonConfigurationInstance 方法并使用 getLastCustomNonConfigurationInstance 恢复它。

这就是我要找的东西。