mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 852787 - Do keyword DB lookup on background thread r=bnicholson
This commit is contained in:
parent
7a8a0a3313
commit
51c8294c45
@ -383,28 +383,33 @@ public class AwesomeBar extends GeckoActivity {
|
||||
finishWithResult(resultIntent);
|
||||
}
|
||||
|
||||
private void openUserEnteredAndFinish(String url) {
|
||||
int index = url.indexOf(' ');
|
||||
String keywordUrl = null;
|
||||
String keywordSearch = null;
|
||||
private void openUserEnteredAndFinish(final String url) {
|
||||
final int index = url.indexOf(' ');
|
||||
|
||||
// Check for a keyword if the URL looks like a search query
|
||||
if (StringUtils.isSearchQuery(url, true)) {
|
||||
if (index == -1) {
|
||||
keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url);
|
||||
keywordSearch = "";
|
||||
} else {
|
||||
keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url.substring(0, index));
|
||||
keywordSearch = url.substring(index + 1);
|
||||
}
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String keywordUrl = null;
|
||||
String keywordSearch = "";
|
||||
if (index == -1) {
|
||||
keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url);
|
||||
} else {
|
||||
keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url.substring(0, index));
|
||||
keywordSearch = url.substring(index + 1);
|
||||
}
|
||||
if (keywordUrl == null) {
|
||||
openUrlAndFinish(url, "", true);
|
||||
} else {
|
||||
String search = URLEncoder.encode(keywordSearch);
|
||||
openUrlAndFinish(keywordUrl.replace("%s", search), "", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openUrlAndFinish(url, "", true);
|
||||
}
|
||||
|
||||
if (keywordUrl != null) {
|
||||
String search = URLEncoder.encode(keywordSearch);
|
||||
url = keywordUrl.replace("%s", search);
|
||||
}
|
||||
|
||||
openUrlAndFinish(url, "", true);
|
||||
}
|
||||
|
||||
private void openSearchAndFinish(String url, String engine) {
|
||||
|
Loading…
Reference in New Issue
Block a user