diff options
author | Alexander Martinz <amartinz@shiftphones.com> | 2020-04-03 16:22:11 +0200 |
---|---|---|
committer | Alexander Martinz <amartinz@shiftphones.com> | 2020-04-03 16:41:16 +0200 |
commit | 35abddd0936cdf02e79a42bb5ad634f026ad4be9 (patch) | |
tree | f3bef0ac70af5fdffc70c928a6d1f7291cef2f41 | |
parent | 9cdc2f497b882f4add7bc6e119b586d5718f8556 (diff) | |
download | android_packages_apps_Updater-35abddd0936cdf02e79a42bb5ad634f026ad4be9.tar.gz android_packages_apps_Updater-35abddd0936cdf02e79a42bb5ad634f026ad4be9.tar.bz2 android_packages_apps_Updater-35abddd0936cdf02e79a42bb5ad634f026ad4be9.zip |
Updater: remove dialog before showing a new one and when detaching
2020-04-03 16:18:18.286 28742-28742/org.lineageos.updater E/WindowManager: android.view.WindowLeaked: Activity org.lineageos.updater.UpdatesActivity has leaked window DecorView@5dd12b3[UpdatesActivity] that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:621)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:377)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:96)
at android.app.Dialog.show(Dialog.java:342)
at androidx.appcompat.app.AlertDialog$Builder.show(AlertDialog.java:1009)
at org.lineageos.updater.UpdatesListAdapter.showInfoDialog(UpdatesListAdapter.java:552)
at org.lineageos.updater.UpdatesListAdapter.lambda$setButtonAction$5$UpdatesListAdapter(UpdatesListAdapter.java:375)
at org.lineageos.updater.-$$Lambda$UpdatesListAdapter$xtQzmsol8pO3BlYZkbKcb5gVAq4.onClick(Unknown Source:2)
at org.lineageos.updater.UpdatesListAdapter.lambda$setButtonAction$9(UpdatesListAdapter.java:408)
at org.lineageos.updater.-$$Lambda$UpdatesListAdapter$M4hRQyNgJseuHrw6EfkhK_yrGK8.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7259)
at android.view.View.performClickInternal(View.java:7236)
at android.view.View.access$3600(View.java:801)
at android.view.View$PerformClick.run(View.java:27896)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Change-Id: I7877b02b8526c7c12331a660a7ac934d02656e6f
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
-rw-r--r-- | src/org/lineageos/updater/UpdatesListAdapter.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 959d1e0..33f4c2d 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -78,6 +78,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. private UpdaterController mUpdaterController; private UpdatesListActivity mActivity; + private AlertDialog infoDialog; + private enum Action { DOWNLOAD, PAUSE, @@ -127,6 +129,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. return new ViewHolder(view); } + @Override + public void onViewDetachedFromWindow(ViewHolder holder) { + super.onViewDetachedFromWindow(holder); + + if (infoDialog != null) { + infoDialog.dismiss(); + } + } + public void setUpdaterController(UpdaterController updaterController) { mUpdaterController = updaterController; notifyDataSetChanged(); @@ -545,12 +556,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. Utils.getUpgradeBlockedURL(mActivity)); SpannableString message = new SpannableString(messageString); Linkify.addLinks(message, Linkify.WEB_URLS); - AlertDialog dialog = new AlertDialog.Builder(mActivity) + if (infoDialog != null) { + infoDialog.dismiss(); + } + infoDialog = new AlertDialog.Builder(mActivity) .setTitle(R.string.blocked_update_dialog_title) .setPositiveButton(android.R.string.ok, null) .setMessage(message) .show(); - TextView textView = (TextView) dialog.findViewById(android.R.id.message); + TextView textView = (TextView) infoDialog.findViewById(android.R.id.message); textView.setMovementMethod(LinkMovementMethod.getInstance()); } |