Browse Source

Fixed a memory leak

master
Anthony Restaino 8 years ago
parent
commit
15cb950af3
  1. 6
      app/src/main/java/acr/browser/lightning/search/SuggestionsManager.java

6
app/src/main/java/acr/browser/lightning/search/SuggestionsManager.java

@ -1,5 +1,6 @@
package acr.browser.lightning.search; package acr.browser.lightning.search;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -26,13 +27,14 @@ class SuggestionsManager {
} }
static Observable<List<HistoryItem>> getObservable(@NonNull final String query, @NonNull final Context context, @NonNull final Source source) { static Observable<List<HistoryItem>> getObservable(@NonNull final String query, @NonNull final Context context, @NonNull final Source source) {
final Application application = BrowserApp.get(context);
return Observable.create(new Action<List<HistoryItem>>() { return Observable.create(new Action<List<HistoryItem>>() {
@Override @Override
public void onSubscribe(@NonNull final Subscriber<List<HistoryItem>> subscriber) { public void onSubscribe(@NonNull final Subscriber<List<HistoryItem>> subscriber) {
sIsTaskExecuting = true; sIsTaskExecuting = true;
switch (source) { switch (source) {
case GOOGLE: case GOOGLE:
new GoogleSuggestionsTask(query, BrowserApp.get(context), new SuggestionsResult() { new GoogleSuggestionsTask(query, application, new SuggestionsResult() {
@Override @Override
public void resultReceived(@NonNull List<HistoryItem> searchResults) { public void resultReceived(@NonNull List<HistoryItem> searchResults) {
subscriber.onNext(searchResults); subscriber.onNext(searchResults);
@ -41,7 +43,7 @@ class SuggestionsManager {
}).run(); }).run();
break; break;
case DUCK: case DUCK:
new DuckSuggestionsTask(query, BrowserApp.get(context), new SuggestionsResult() { new DuckSuggestionsTask(query, application, new SuggestionsResult() {
@Override @Override
public void resultReceived(@NonNull List<HistoryItem> searchResults) { public void resultReceived(@NonNull List<HistoryItem> searchResults) {
subscriber.onNext(searchResults); subscriber.onNext(searchResults);

Loading…
Cancel
Save