Finalizing search functionality
git-svn-id: https://osmand.googlecode.com/svn/trunk@108 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
03b52f348f
commit
bd4c191a23
4 changed files with 93 additions and 21 deletions
|
@ -16,24 +16,20 @@ public class ToDoConstants {
|
||||||
|
|
||||||
// TODO ANDROID
|
// TODO ANDROID
|
||||||
// 25. POI search near to map location (show categories & type). Second cut. (implement incremental search)
|
// 25. POI search near to map location (show categories & type). Second cut. (implement incremental search)
|
||||||
|
// 13. Save point as favorite & introduce favorite points dialog
|
||||||
|
|
||||||
// 3. Revise osmand UI. Preparing new icons (revise UI 18, 2, ). Main application icon, back to location icon.
|
// 3. Revise osmand UI. Preparing new icons (revise UI 18, 2, ). Main application icon, back to location icon.
|
||||||
// 13. Save point as favorite & introduce favorite points dialog
|
|
||||||
// 14. Show zoom level on map
|
// 14. Show zoom level on map
|
||||||
|
|
||||||
// 24. Implement ResourceManager, load cities/streets/buildings on Low memory (clear previous all addresses cities).
|
// 24. Implement ResourceManager, load cities/streets/buildings on Low memory (clear previous all addresses cities).
|
||||||
// 5. Search for city/streets/buildings
|
|
||||||
|
// 25. Show opened/closed amenities.
|
||||||
|
// 27. Search intersection of streets.
|
||||||
|
// 26. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets.
|
||||||
|
|
||||||
// 8. Enable change POI directly on map (requires OSM login)
|
// 8. Enable change POI directly on map (requires OSM login)
|
||||||
// 16. Support open street bugs api.
|
// 16. Support open street bugs api.
|
||||||
// 20. Implement save track/route to gpx (?)
|
// 20. Implement save track/route to gpx (?)
|
||||||
// 24. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets.
|
|
||||||
// 25. Show opened/closed amenities.
|
|
||||||
|
|
||||||
// TODO search story :
|
|
||||||
// 2) Find intersection of streets
|
|
||||||
// 9) Loading cities (data) in another thread
|
|
||||||
// 10) fix bug with landscape layout (search address)
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME Bugs Android :
|
// FIXME Bugs Android :
|
||||||
|
@ -44,6 +40,7 @@ public class ToDoConstants {
|
||||||
// Call ResourceManager.close when it is needed.
|
// Call ResourceManager.close when it is needed.
|
||||||
// 8. Introduce activity search by location (unify with existing dialog)
|
// 8. Introduce activity search by location (unify with existing dialog)
|
||||||
// 9. When all features will be ready we can remove show location from context menu
|
// 9. When all features will be ready we can remove show location from context menu
|
||||||
|
// 10. Notification is gone after clear all notifications
|
||||||
|
|
||||||
// Performance improvements Android :
|
// Performance improvements Android :
|
||||||
// 1. Introducing one place where refreshMap will be called using postMessage mechanism (delay more than > 50 ? ms)
|
// 1. Introducing one place where refreshMap will be called using postMessage mechanism (delay more than > 50 ? ms)
|
||||||
|
@ -60,6 +57,7 @@ public class ToDoConstants {
|
||||||
|
|
||||||
|
|
||||||
// DONE ANDROID :
|
// DONE ANDROID :
|
||||||
|
// 5. Search for city/streets/buildings
|
||||||
// 15. Investigate interruption of any long running operation & implement where it is needed.
|
// 15. Investigate interruption of any long running operation & implement where it is needed.
|
||||||
// ProgressDialogImplementation should support setOnCancelListener or obtain CANCEL message &
|
// ProgressDialogImplementation should support setOnCancelListener or obtain CANCEL message &
|
||||||
// throw InterruptedException in all methods (remaining, progress, startTask, ...) when call it.
|
// throw InterruptedException in all methods (remaining, progress, startTask, ...) when call it.
|
||||||
|
|
|
@ -42,12 +42,23 @@
|
||||||
<ImageButton android:id="@+id/ResetBuilding" android:background="@drawable/icon" android:layout_marginRight = "5dp">
|
<ImageButton android:id="@+id/ResetBuilding" android:background="@drawable/icon" android:layout_marginRight = "5dp">
|
||||||
</ImageButton>
|
</ImageButton>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
<TableRow android:id="@+id/TableRow" android:layout_marginLeft = "5dp" >
|
||||||
</ScrollView>
|
<RadioGroup android:orientation="horizontal" android:layout_span="3">
|
||||||
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"
|
<RadioButton android:text="Building" android:id="@+id/RadioBuilding" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
|
||||||
android:gravity="right|bottom">
|
<RadioButton android:text="Intersected street" android:id="@+id/RadioIntersStreet" android:layout_width="wrap_content" android:layout_marginLeft = "5dp" android:layout_height="wrap_content"></RadioButton>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow android:id="@+id/TableRow" android:layout_marginLeft = "5dp" >
|
||||||
|
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:layout_span="3" android:gravity="right|bottom" android:layout_marginRight = "5dp" android:layout_marginTop = "10dp">
|
||||||
<Button android:text="Show on map" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ShowOnMap">
|
<Button android:text="Show on map" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ShowOnMap">
|
||||||
</Button>
|
</Button>
|
||||||
</LinearLayout>
|
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -188,7 +188,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
|
region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
|
||||||
String progressMsg = null;
|
String progressMsg = null;
|
||||||
// try to determine whether progress dialog & new thread needed
|
// try to determine whether progress dialog & new thread needed
|
||||||
if(region.areCitiesPreloaded()){
|
if(!region.areCitiesPreloaded()){
|
||||||
progressMsg = "Loading cities...";
|
progressMsg = "Loading cities...";
|
||||||
} else if(city == null || city.getId() != OsmandSettings.getLastSearchedCity(this)){
|
} else if(city == null || city.getId() != OsmandSettings.getLastSearchedCity(this)){
|
||||||
progressMsg = "Loading streets/buildings...";
|
progressMsg = "Loading streets/buildings...";
|
||||||
|
|
|
@ -4,6 +4,9 @@ import java.util.List;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -20,6 +23,7 @@ import com.osmand.R;
|
||||||
public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
|
|
||||||
private EditText searchText;
|
private EditText searchText;
|
||||||
|
private Handler handlerToLoop;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -56,11 +60,36 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
public Editable getFilter(){
|
public Editable getFilter(){
|
||||||
return searchText.getText();
|
return searchText.getText();
|
||||||
}
|
}
|
||||||
public void setText(String filter){
|
|
||||||
((NamesAdapter)getListAdapter()).clear();
|
protected void updateUIList(final List<T> objects){
|
||||||
for(T o : getObjects(filter)){
|
runOnUiThread(new Runnable(){
|
||||||
((NamesAdapter)getListAdapter()).add(o);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for(T o : objects){
|
||||||
|
((NamesAdapter)getListAdapter()).add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(final String filter) {
|
||||||
|
((NamesAdapter) getListAdapter()).clear();
|
||||||
|
|
||||||
|
if(handlerToLoop == null){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
handlerToLoop.removeMessages(1);
|
||||||
|
Message msg = Message.obtain(handlerToLoop, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<T> loadedObjects = getObjects(filter);
|
||||||
|
if(!handlerToLoop.hasMessages(1)){
|
||||||
|
updateUIList(loadedObjects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
msg.what = 1;
|
||||||
|
handlerToLoop.sendMessageDelayed(msg, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<T> getObjects(String filter);
|
public abstract List<T> getObjects(String filter);
|
||||||
|
@ -76,6 +105,40 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
itemSelected(repo);
|
itemSelected(repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
synchronized (this) {
|
||||||
|
if (handlerToLoop == null) {
|
||||||
|
new Thread("Filter data") {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Looper.prepare();
|
||||||
|
handlerToLoop = new Handler();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
synchronized (this) {
|
||||||
|
if(handlerToLoop != null){
|
||||||
|
handlerToLoop.post(new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Looper.myLooper().quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
handlerToLoop = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NamesAdapter extends ArrayAdapter<T> {
|
class NamesAdapter extends ArrayAdapter<T> {
|
||||||
NamesAdapter(List<T> list) {
|
NamesAdapter(List<T> list) {
|
||||||
|
|
Loading…
Reference in a new issue