From 780ca63d8d0575917c028d3de2701f84290800d5 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Sat, 12 Jul 2014 02:14:13 +0400 Subject: [PATCH] Fixed broken photo viewer after main activity destroy --- TMessagesProj/build.gradle | 2 +- .../java/org/telegram/ui/LaunchActivity.java | 1 + .../main/java/org/telegram/ui/PhotoViewer.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 720603a3a..ec66a3382 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -83,7 +83,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 274 + versionCode 275 versionName "1.6.0" } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index f9b627349..0b9e21bd0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -500,6 +500,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen @Override protected void onDestroy() { + PhotoViewer.getInstance().destroyPhotoViewer(); super.onDestroy(); onFinish(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index d7211fb67..becadcd99 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -1697,6 +1697,22 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } + public void destroyPhotoViewer() { + if (parentActivity == null || windowView == null) { + return; + } + try { + WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); + if (windowView.getParent() != null) { + wm.removeViewImmediate(windowView); + } + windowView = null; + } catch (Exception e) { + FileLog.e("tmessages", e); + } + Instance = null; + } + private void onPhotoClosed(PlaceProviderObject object) { disableShowCheck = true; currentMessageObject = null;