Fixed broken photo viewer after main activity destroy

This commit is contained in:
DrKLO 2014-07-12 02:14:13 +04:00
parent fa1734518d
commit 780ca63d8d
3 changed files with 18 additions and 1 deletions

View file

@ -83,7 +83,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 274 versionCode 275
versionName "1.6.0" versionName "1.6.0"
} }
} }

View file

@ -500,6 +500,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
@Override @Override
protected void onDestroy() { protected void onDestroy() {
PhotoViewer.getInstance().destroyPhotoViewer();
super.onDestroy(); super.onDestroy();
onFinish(); onFinish();
} }

View file

@ -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) { private void onPhotoClosed(PlaceProviderObject object) {
disableShowCheck = true; disableShowCheck = true;
currentMessageObject = null; currentMessageObject = null;