Browse Source

Switching from task thread to IO thread where appropriate

master
anthony restaino 8 years ago
parent
commit
2723abcfd0
  1. 12
      app/src/main/java/acr/browser/lightning/database/BookmarkManager.java
  2. 4
      app/src/main/java/acr/browser/lightning/utils/AdBlock.java

12
app/src/main/java/acr/browser/lightning/database/BookmarkManager.java

@ -29,6 +29,7 @@ import java.util.List; @@ -29,6 +29,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -36,6 +37,7 @@ import javax.inject.Inject; @@ -36,6 +37,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.utils.Utils;
@ -54,12 +56,12 @@ public class BookmarkManager { @@ -54,12 +56,12 @@ public class BookmarkManager {
private Map<String, HistoryItem> mBookmarksMap;
@NonNull private String mCurrentFolder = "";
@NonNull private final ExecutorService mExecutor;
@NonNull private final Executor mExecutor;
private File mFilesDir;
@Inject
public BookmarkManager(@NonNull Context context) {
mExecutor = Executors.newSingleThreadExecutor();
mExecutor = BrowserApp.getIOThread();
DEFAULT_BOOKMARK_TITLE = context.getString(R.string.untitled);
mExecutor.execute(new BookmarkInitializer(context));
}
@ -177,12 +179,6 @@ public class BookmarkManager { @@ -177,12 +179,6 @@ public class BookmarkManager {
}
}
@Override
protected void finalize() throws Throwable {
mExecutor.shutdownNow();
super.finalize();
}
public boolean isBookmark(String url) {
return mBookmarksMap.containsKey(url);
}

4
app/src/main/java/acr/browser/lightning/utils/AdBlock.java

@ -53,7 +53,7 @@ public class AdBlock { @@ -53,7 +53,7 @@ public class AdBlock {
}
private void loadBlockedDomainsList(@NonNull final Context context) {
BrowserApp.getTaskThread().execute(new Runnable() {
BrowserApp.getIOThread().execute(new Runnable() {
@Override
public void run() {
@ -137,7 +137,7 @@ public class AdBlock { @@ -137,7 +137,7 @@ public class AdBlock {
* @param context the context needed to read the file
*/
private void loadHostsFile(@NonNull final Context context) {
BrowserApp.getTaskThread().execute(new Runnable() {
BrowserApp.getIOThread().execute(new Runnable() {
@Override
public void run() {

Loading…
Cancel
Save