Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java

Issue 29671734: Issue 6265 - Create shared AdblockEngine instance in AdblockWebView in background (Closed)
Patch Set: Sergey's comments Created Jan. 22, 2018, 6:19 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java
diff --git a/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java b/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java
index fea433ca5b1b8a3bca36723c49c9254724329447..73f9711b3c42108928b7c10bac8031f39ee62d4b 100644
--- a/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java
+++ b/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/MainActivity.java
@@ -40,9 +40,6 @@ public class MainActivity extends Activity
// webView can create AdblockEngine instance itself if not passed with `webView.setAdblockEngine()`
public static final boolean USE_EXTERNAL_ADBLOCKENGINE = true;
- // adblock retain() may be long-running, pass `true` to do it in background thread
- public static final boolean ADBLOCKENGINE_RETAIN_ASYNC = true;
-
private ProgressBar progress;
private EditText url;
private Button ok;
@@ -201,13 +198,8 @@ public class MainActivity extends Activity
{
if (USE_EXTERNAL_ADBLOCKENGINE)
{
- // external adblockEngine
- AdblockHelper.get().retain(ADBLOCKENGINE_RETAIN_ASYNC);
-
- if (!ADBLOCKENGINE_RETAIN_ASYNC)
- {
- webView.setAdblockEngine(AdblockHelper.get().getEngine());
- }
+ // external AdblockEngine
+ webView.setProvider(AdblockHelper.get().getProvider());
}
else
{
@@ -251,30 +243,13 @@ public class MainActivity extends Activity
private void loadUrl()
{
hideSoftwareKeyboard();
-
- // if retained with `true` we need to make sure it's ready now
- if (USE_EXTERNAL_ADBLOCKENGINE && ADBLOCKENGINE_RETAIN_ASYNC)
- {
- AdblockHelper.get().waitForReady();
- webView.setAdblockEngine(AdblockHelper.get().getEngine());
- }
webView.loadUrl(prepareUrl(url.getText().toString()));
}
@Override
protected void onDestroy()
{
- webView.dispose(new Runnable()
- {
- @Override
- public void run()
- {
- if (USE_EXTERNAL_ADBLOCKENGINE)
- {
- AdblockHelper.get().release();
- }
- }
- });
+ webView.dispose(null);
super.onDestroy();
}

Powered by Google App Engine
This is Rietveld