From bb7ec7fd3fae10c82d25c597b42796b567fd7c1b Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Wed, 14 Jun 2017 22:50:05 -0400 Subject: [PATCH] Switching to IO scheduler and cleaning up cache method --- .../lightning/constant/BookmarkPage.java | 4 +- .../lightning/fragment/BookmarksFragment.java | 2 +- .../lightning/view/LightningChromeClient.java | 40 ++++++++----------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java index f377df8..9a78c3f 100644 --- a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java +++ b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java @@ -190,8 +190,8 @@ public final class BookmarkPage { if (bookmarkUri != null) { File faviconFile = FaviconModel.getFaviconCacheFile(mApp, bookmarkUri); if (!faviconFile.exists()) { - mFaviconModel.cacheFaviconForUrl(mFaviconModel.getDefaultBitmapForString(item.getTitle()), item.getUrl()) - .subscribe(); + Bitmap defaultFavicon = mFaviconModel.getDefaultBitmapForString(item.getTitle()); + mFaviconModel.cacheFaviconForUrl(defaultFavicon, item.getUrl()).subscribe(); } faviconFileUrl = Constants.FILE + faviconFile; diff --git a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java index cf62cec..f998eaa 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java @@ -538,7 +538,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, SubscriptionUtils.safeUnsubscribe(oldSubscription); final Subscription faviconSubscription = mFaviconModel.faviconForUrl(url, web.getTitle()) - .subscribeOn(Schedulers.worker()) + .subscribeOn(Schedulers.io()) .observeOn(Schedulers.main()) .subscribe(new SingleOnSubscribe() { @Override diff --git a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java index 80f40bc..020813a 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java @@ -73,15 +73,9 @@ public class LightningChromeClient extends WebChromeClient { return; } - Uri uri = Uri.parse(url); - - if (uri.getHost() == null) { - return; - } - mFaviconModel.cacheFaviconForUrl(icon, url) - .subscribeOn(Schedulers.io()) - .subscribe(); + .subscribeOn(Schedulers.io()) + .subscribe(); } @@ -114,21 +108,21 @@ public class LightningChromeClient extends WebChromeClient { org = origin; } builder.setMessage(org + mActivity.getString(R.string.message_location)) - .setCancelable(true) - .setPositiveButton(mActivity.getString(R.string.action_allow), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - callback.invoke(origin, true, remember); - } - }) - .setNegativeButton(mActivity.getString(R.string.action_dont_allow), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - callback.invoke(origin, false, remember); - } - }); + .setCancelable(true) + .setPositiveButton(mActivity.getString(R.string.action_allow), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + callback.invoke(origin, true, remember); + } + }) + .setNegativeButton(mActivity.getString(R.string.action_dont_allow), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + callback.invoke(origin, false, remember); + } + }); AlertDialog alert = builder.create(); alert.show(); BrowserDialog.setDialogSize(mActivity, alert);