diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-12-08 10:35:02 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-12-08 10:35:02 +0100 |
commit | 77647cc154b5acbbde3f7535e74edb2df0da8acf (patch) | |
tree | 9a9a7e04f766f9746df8b72855cba1829e845d0c /app/src/main/java/de | |
parent | bf0257a405f5ad7dee39c52ddd6f669c3893ed31 (diff) | |
download | AntennaPod-77647cc154b5acbbde3f7535e74edb2df0da8acf.zip |
Destroy webview when it is no longer used
Not destroying the webview might have caused crashes on some devices
Diffstat (limited to 'app/src/main/java/de')
3 files changed, 49 insertions, 25 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java index cf7de1709..811628ebf 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -4,29 +4,43 @@ import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.widget.LinearLayout; + import de.danoeh.antennapod.R; -/** Displays the 'about' screen */ +/** + * Displays the 'about' screen + */ public class AboutActivity extends ActionBarActivity { - private WebView webview; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getSupportActionBar().hide(); - setContentView(R.layout.about); - webview = (WebView) findViewById(R.id.webvAbout); - webview.setWebViewClient(new WebViewClient() { - - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - view.loadUrl(url); - return false; - } - - }); - webview.loadUrl("file:///android_asset/about.html"); - } + private WebView webview; + private LinearLayout webviewContainer; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getSupportActionBar().hide(); + setContentView(R.layout.about); + webviewContainer = (LinearLayout) findViewById(R.id.webvContainer); + webview = (WebView) findViewById(R.id.webvAbout); + webview.setWebViewClient(new WebViewClient() { + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + view.loadUrl(url); + return false; + } + + }); + webview.loadUrl("file:///android_asset/about.html"); + } + @Override + protected void onDestroy() { + super.onDestroy(); + if (webviewContainer != null && webview != null) { + webviewContainer.removeAllViews(); + webview.destroy(); + } + } } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemDialog.java index 613cd1fec..eeed10b98 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemDialog.java @@ -16,6 +16,7 @@ import android.util.Log; import android.util.TypedValue; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebView; @@ -54,6 +55,7 @@ public class FeedItemDialog extends Dialog { private FeedItem item; private QueueAccess queue; + private ViewGroup contentContainer; private View header; private TextView txtvTitle; private WebView webvDescription; @@ -107,6 +109,7 @@ public class FeedItemDialog extends Dialog { requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.feeditem_dialog); + contentContainer = (ViewGroup) findViewById(R.id.contentContainer); txtvTitle = (TextView) findViewById(R.id.txtvTitle); header = findViewById(R.id.header); webvDescription = (WebView) findViewById(R.id.webview); @@ -225,6 +228,14 @@ public class FeedItemDialog extends Dialog { updateMenuAppearance(); } + @Override + public void dismiss() { + super.dismiss(); + if (contentContainer != null && webvDescription != null) { + contentContainer.removeAllViews(); + webvDescription.destroy(); + } + } private final FeedItemMenuHandler.MenuInterface popupMenuInterface = new FeedItemMenuHandler.MenuInterface() { @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java index 4a5c3f718..c0222de8e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java @@ -162,11 +162,6 @@ public class ItemDescriptionFragment extends Fragment { } @Override - public void onDestroyView() { - super.onDestroyView(); - } - - @Override public void onAttach(Activity activity) { super.onAttach(activity); if (BuildConfig.DEBUG) @@ -191,6 +186,10 @@ public class ItemDescriptionFragment extends Fragment { if (webViewLoader != null) { webViewLoader.cancel(true); } + if (webvDescription != null) { + webvDescription.removeAllViews(); + webvDescription.destroy(); + } } @SuppressLint("NewApi") |