Search adapter shouldnt spawn new worker threads if current ones havent finished
This commit is contained in:
parent
04c4d202b2
commit
35c585b3f4
@ -33,6 +33,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private boolean mUseGoogle = true;
|
private boolean mUseGoogle = true;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private boolean mIsExecuting = false;
|
||||||
private boolean mIncognito;
|
private boolean mIncognito;
|
||||||
private BookmarkManager mBookmarkManager;
|
private BookmarkManager mBookmarkManager;
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
@ -167,7 +168,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
if (query == null) {
|
if (query == null) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
if (mUseGoogle && !mIncognito) {
|
if (mUseGoogle && !mIncognito && !mIsExecuting) {
|
||||||
new RetrieveSearchSuggestions().execute(query);
|
new RetrieveSearchSuggestions().execute(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +223,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<HistoryItem> doInBackground(String... arg0) {
|
protected List<HistoryItem> doInBackground(String... arg0) {
|
||||||
|
mIsExecuting = true;
|
||||||
if (!isNetworkConnected(mContext)) {
|
if (!isNetworkConnected(mContext)) {
|
||||||
return new ArrayList<HistoryItem>();
|
return new ArrayList<HistoryItem>();
|
||||||
}
|
}
|
||||||
@ -259,7 +261,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
eventType = mXpp.next();
|
eventType = mXpp.next();
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return filter;
|
return filter;
|
||||||
} finally {
|
} finally {
|
||||||
if (download != null) {
|
if (download != null) {
|
||||||
@ -282,6 +284,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
mFilteredList = getSuggestions();
|
mFilteredList = getSuggestions();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
mIsExecuting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user