add progress for transport activity
git-svn-id: https://osmand.googlecode.com/svn/trunk@280 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
d5214f02c6
commit
ccbf031587
2 changed files with 35 additions and 16 deletions
|
@ -26,7 +26,7 @@ public class ToDoConstants {
|
||||||
// Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha]
|
// Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha]
|
||||||
// 33. Build transport locations. Create transport index (transport-stops) (investigate)
|
// 33. Build transport locations. Create transport index (transport-stops) (investigate)
|
||||||
// DONE : Load transport routes in swing, init
|
// DONE : Load transport routes in swing, init
|
||||||
// TODO : add progress calculating, add intermediate points, add menu for stops
|
// TODO : add intermediate points, add menu for stops (show map)
|
||||||
|
|
||||||
|
|
||||||
// 66. Transport routing (show next stop, total distance, show stop get out).
|
// 66. Transport routing (show next stop, total distance, show stop get out).
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.osmand.Messages;
|
import com.osmand.Messages;
|
||||||
|
@ -49,6 +50,7 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
private final static int finalZoom = 13;
|
private final static int finalZoom = 13;
|
||||||
private final static int initialZoom = 17;
|
private final static int initialZoom = 17;
|
||||||
private int zoom = initialZoom;
|
private int zoom = initialZoom;
|
||||||
|
private ProgressBar progress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,9 +70,11 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
progress = (ProgressBar) findViewById(R.id.ProgressBar);
|
||||||
|
progress.setVisibility(View.INVISIBLE);
|
||||||
stopsAdapter = new TransportStopAdapter(new ArrayList<RouteInfoLocation>());
|
stopsAdapter = new TransportStopAdapter(new ArrayList<RouteInfoLocation>());
|
||||||
setListAdapter(stopsAdapter);
|
setListAdapter(stopsAdapter);
|
||||||
|
searchArea.setText(getSearchArea());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,17 +86,22 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchFurther(){
|
public void searchFurther(){
|
||||||
// TODO use progress
|
// use progress
|
||||||
|
searchTransportLevel.setEnabled(false);
|
||||||
if (lastKnownMapLocation != null) {
|
if (lastKnownMapLocation != null) {
|
||||||
List<TransportIndexRepository> rs = ResourceManager.getResourceManager().searchTransportRepositories(lastKnownMapLocation.getLatitude(),
|
List<TransportIndexRepository> rs = ResourceManager.getResourceManager().searchTransportRepositories(lastKnownMapLocation.getLatitude(),
|
||||||
lastKnownMapLocation.getLongitude());
|
lastKnownMapLocation.getLongitude());
|
||||||
if(!rs.isEmpty()){
|
if(!rs.isEmpty()){
|
||||||
repo = rs.get(0);
|
repo = rs.get(0);
|
||||||
searchTransportLevel.setEnabled(isSearchFurtherAvailable());
|
progress.setVisibility(View.VISIBLE);
|
||||||
List<RouteInfoLocation> res = repo.searchTransportRouteStops(lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude(),
|
new Thread(new Runnable(){
|
||||||
locationToGo, zoom);
|
@Override
|
||||||
|
public void run() {
|
||||||
stopsAdapter.setNewModel(res);
|
List<RouteInfoLocation> res = repo.searchTransportRouteStops(lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude(),
|
||||||
|
locationToGo, zoom);
|
||||||
|
updateUIList(res);
|
||||||
|
}
|
||||||
|
},"SearchingTransport").start(); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
repo = null;
|
repo = null;
|
||||||
stopsAdapter.clear();
|
stopsAdapter.clear();
|
||||||
|
@ -100,8 +109,6 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
} else {
|
} else {
|
||||||
stopsAdapter.clear();
|
stopsAdapter.clear();
|
||||||
}
|
}
|
||||||
searchTransportLevel.setEnabled(isSearchFurtherAvailable());
|
|
||||||
searchArea.setText(getSearchArea());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,8 +118,19 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
locationToGo = OsmandSettings.getPointToNavigate(this);
|
locationToGo = OsmandSettings.getPointToNavigate(this);
|
||||||
searchFurther();
|
searchFurther();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateUIList(final List<RouteInfoLocation> stopsList){
|
||||||
|
runOnUiThread(new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
stopsAdapter.setNewModel(stopsList);
|
||||||
|
searchTransportLevel.setEnabled(isSearchFurtherAvailable());
|
||||||
|
searchArea.setText(getSearchArea());
|
||||||
|
progress.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onListItemClick(ListView parent, View v, int position, long id) {
|
public void onListItemClick(ListView parent, View v, int position, long id) {
|
||||||
RouteInfoLocation item = ((TransportStopAdapter)getListAdapter()).getItem(position);
|
RouteInfoLocation item = ((TransportStopAdapter)getListAdapter()).getItem(position);
|
||||||
|
@ -123,8 +141,9 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
String n = st.getName(OsmandSettings.usingEnglishNames(this));
|
String n = st.getName(OsmandSettings.usingEnglishNames(this));
|
||||||
if(locationToGo != null){
|
if(locationToGo != null){
|
||||||
n += " - [" + MapUtils.getFormattedDistance((int) MapUtils.getDistance(locationToGo, st.getLocation())) +"]"; //$NON-NLS-1$ //$NON-NLS-2$
|
n += " - [" + MapUtils.getFormattedDistance((int) MapUtils.getDistance(locationToGo, st.getLocation())) +"]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
} else {
|
||||||
n = MapUtils.getFormattedDistance((int) MapUtils.getDistance(lastKnownMapLocation, st.getLocation())) +" - " + n; //$NON-NLS-1$
|
n = MapUtils.getFormattedDistance((int) MapUtils.getDistance(lastKnownMapLocation, st.getLocation())) +" - " + n; //$NON-NLS-1$
|
||||||
|
}
|
||||||
items.add(n);
|
items.add(n);
|
||||||
}
|
}
|
||||||
// TODO show menu mark as intermediate mark on map
|
// TODO show menu mark as intermediate mark on map
|
||||||
|
@ -167,12 +186,12 @@ public class SearchTransportActivity extends ListActivity {
|
||||||
if (locationToGo != null) {
|
if (locationToGo != null) {
|
||||||
labelW.append(MapUtils.getFormattedDistance(stop.getDistToLocation()));
|
labelW.append(MapUtils.getFormattedDistance(stop.getDistToLocation()));
|
||||||
} else {
|
} else {
|
||||||
labelW.append("no target");
|
labelW.append("none");
|
||||||
}
|
}
|
||||||
labelW.append("]\n").append(route.getName(OsmandSettings.usingEnglishNames(SearchTransportActivity.this))); //$NON-NLS-1$
|
labelW.append("]\n").append(route.getName(OsmandSettings.usingEnglishNames(SearchTransportActivity.this))); //$NON-NLS-1$
|
||||||
label.setText(labelW.toString());
|
label.setText(labelW.toString());
|
||||||
// TODO icons
|
// TODO icons
|
||||||
if (stop.getDistToLocation() < 400) {
|
if (locationToGo == null || stop.getDistToLocation() < 400) {
|
||||||
icon.setImageResource(R.drawable.poi);
|
icon.setImageResource(R.drawable.poi);
|
||||||
} else {
|
} else {
|
||||||
icon.setImageResource(R.drawable.closed_poi);
|
icon.setImageResource(R.drawable.closed_poi);
|
||||||
|
|
Loading…
Reference in a new issue