SherlockGougou / BigImageViewPager

🔥🔥🔥 BigImage ImageView ViewPager 支持超长图、超大图的图片浏览器,优化内存,支持手势放大、下拉关闭、查看原图、加载百分比、保存图片等功能。
Other
2.18k stars 249 forks source link

如何获取ImagePreviewActivity当前的上下文 #92

Closed dary123 closed 4 years ago

dary123 commented 4 years ago

如何获取ImagePreviewActivity当前的上下文

SherlockGougou commented 4 years ago

先描述一下你的需求场景

dary123 commented 4 years ago

我的需求场景是在ImagePreviewActivity当前页面跳转到一个新页面,需要用到转场动画,所以必须要有当前页面的上下文

SherlockGougou commented 4 years ago

你的跳转是如何触发的?

dary123 commented 4 years ago

Intent intent = new Intent(AppManager.AppManager.currentActivity(), ShareMsgInfoFromFindActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); AppManager.AppManager.currentActivity().startActivity(intent); AppManager.AppManager.currentActivity().overridePendingTransition(R.anim.slide_in_up, R.anim.anim_hold);

SherlockGougou commented 4 years ago

你使用了:AppManager.AppManager.currentActivity() 应该没问题吧,你可以看一下AppManager.AppManager.currentActivity()获取的是不是ImagePreviewActivity。

SherlockGougou commented 4 years ago

如果获取的不是查看大图的activity,你可能需要更改一下Appmanager的实现。推荐使用ActivityLifecycleCallbacks进行监听当前activity。

dary123 commented 4 years ago

AppManager.AppManager.currentActivity()获取到当前activity的前提是我必须要在AppManager.AppManager这个枚举里存储每一个打开activity,因为在ImagePreviewActivity没有add到存储的Activity栈里,所以currentActivity获取到的是上一个activity

dary123 commented 4 years ago

ActivityLifecycleCallback会影响性能吗

SherlockGougou commented 4 years ago

建议你去了解一下ActivityLifecycleCallback。

SherlockGougou commented 4 years ago

建议不要使用addActivity的方式管理activity栈。

dary123 commented 4 years ago

因为我之前用过ActivityLifecycleCallback,放在application里面,结果会导致App卡顿