Browse Source

Fixed threading issue with all bookmarks list

master
Anthony Restaino 8 years ago
parent
commit
aec90b4ae2
  1. 23
      app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java

23
app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java

@ -15,6 +15,13 @@ import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.anthonycr.bonsai.Action;
import com.anthonycr.bonsai.Observable;
import com.anthonycr.bonsai.OnSubscribe;
import com.anthonycr.bonsai.Scheduler;
import com.anthonycr.bonsai.Schedulers;
import com.anthonycr.bonsai.Subscriber;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,14 +40,6 @@ import acr.browser.lightning.database.BookmarkManager;
import acr.browser.lightning.database.HistoryDatabase; import acr.browser.lightning.database.HistoryDatabase;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import com.anthonycr.bonsai.Action;
import com.anthonycr.bonsai.Observable;
import com.anthonycr.bonsai.OnSubscribe;
import com.anthonycr.bonsai.Scheduler;
import com.anthonycr.bonsai.Schedulers;
import com.anthonycr.bonsai.Subscriber;
import acr.browser.lightning.utils.ThemeUtils; import acr.browser.lightning.utils.ThemeUtils;
public class SuggestionsAdapter extends BaseAdapter implements Filterable { public class SuggestionsAdapter extends BaseAdapter implements Filterable {
@ -99,8 +98,16 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
} }
public void refreshBookmarks() { public void refreshBookmarks() {
Observable.create(new Action<Void>() {
@Override
public void onSubscribe(@NonNull Subscriber<Void> subscriber) {
mAllBookmarks.clear(); mAllBookmarks.clear();
mAllBookmarks.addAll(mBookmarkManager.getAllBookmarks(true)); mAllBookmarks.addAll(mBookmarkManager.getAllBookmarks(true));
subscriber.onComplete();
}
}).subscribeOn(Schedulers.io())
.subscribe();
} }
@Override @Override

Loading…
Cancel
Save