Merge branch 'r3.3'
This commit is contained in:
commit
d252de010a
2 changed files with 13 additions and 40 deletions
|
@ -916,6 +916,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean searchFinished(SearchPhrase phrase) {
|
public boolean searchFinished(SearchPhrase phrase) {
|
||||||
|
SearchWord lastSelectedWord = phrase.getLastSelectedWord();
|
||||||
|
if (mainSearchFragment != null && mainSearchFragment.isShowResult() &&
|
||||||
|
isResultEmpty() && lastSelectedWord != null) {
|
||||||
|
mainSearchFragment.showResult(lastSelectedWord.getResult());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,8 +11,6 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.ResultMatcher;
|
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.City;
|
import net.osmand.data.City;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -36,7 +34,6 @@ import net.osmand.search.core.ObjectType;
|
||||||
import net.osmand.search.core.SearchResult;
|
import net.osmand.search.core.SearchResult;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -46,6 +43,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
private QuickSearchListAdapter listAdapter;
|
private QuickSearchListAdapter listAdapter;
|
||||||
private boolean touching;
|
private boolean touching;
|
||||||
private boolean scrolling;
|
private boolean scrolling;
|
||||||
|
private boolean showResult;
|
||||||
|
|
||||||
enum SearchListFragmentType {
|
enum SearchListFragmentType {
|
||||||
HISTORY,
|
HISTORY,
|
||||||
|
@ -101,13 +99,8 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
showResult(sr);
|
showResult(sr);
|
||||||
} else {
|
} else {
|
||||||
if ((sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE)
|
if (sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE) {
|
||||||
&& sr.file != null && sr.object instanceof City) {
|
showResult = true;
|
||||||
City c = (City) sr.object;
|
|
||||||
if (isCityEmpty(c, sr)) {
|
|
||||||
showResult(sr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dialogFragment.completeQueryWithObject(sr);
|
dialogFragment.completeQueryWithObject(sr);
|
||||||
}
|
}
|
||||||
|
@ -116,36 +109,6 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCityEmpty(City c, SearchResult sr) {
|
|
||||||
final boolean isEmpty[] = new boolean[1];
|
|
||||||
isEmpty[0] = true;
|
|
||||||
if (c.getStreets().isEmpty()) {
|
|
||||||
ResultMatcher<Street> resultMatcher = new ResultMatcher<Street>() {
|
|
||||||
boolean isCancelled = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean publish(Street object) {
|
|
||||||
isCancelled = true;
|
|
||||||
isEmpty[0] = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
sr.file.preloadStreets(c, BinaryMapIndexReader.buildAddressRequest(resultMatcher));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isEmpty[0] = false;
|
|
||||||
}
|
|
||||||
return isEmpty[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
@ -196,7 +159,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
dialogFragment.onSearchListFragmentResume(this);
|
dialogFragment.onSearchListFragmentResume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowResult() {
|
||||||
|
return showResult;
|
||||||
|
}
|
||||||
|
|
||||||
public void showResult(SearchResult searchResult) {
|
public void showResult(SearchResult searchResult) {
|
||||||
|
showResult = false;
|
||||||
if (searchResult.location != null) {
|
if (searchResult.location != null) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
|
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
|
||||||
|
|
Loading…
Reference in a new issue