git-svn-id: https://osmand.googlecode.com/svn/trunk@238 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-27 20:13:16 +00:00
parent e9ab2e0eb8
commit 1e960c1cbf
4 changed files with 56 additions and 19 deletions

View file

@ -224,8 +224,8 @@ public class AmenityIndexRepository {
String latCol = IndexPoiTable.LATITUDE.name(); String latCol = IndexPoiTable.LATITUDE.name();
String lonCol = IndexPoiTable.LONGITUDE.name(); String lonCol = IndexPoiTable.LONGITUDE.name();
db.execSQL("DELETE FROM " + IndexPoiTable.getTable() + " WHERE " + //$NON-NLS-1$ //$NON-NLS-2$ db.execSQL("DELETE FROM " + IndexPoiTable.getTable() + " WHERE " + //$NON-NLS-1$ //$NON-NLS-2$
lonCol + ">= ? AND ? <=" + lonCol + " AND " + //$NON-NLS-1$//$NON-NLS-2$ lonCol + ">= ? AND ? >=" + lonCol + " AND " + //$NON-NLS-1$//$NON-NLS-2$
latCol + ">= ? AND ? <=" + latCol, new Double[] { leftLon, rightLon, bottomLat, topLat }); //$NON-NLS-1$ latCol + ">= ? AND ? >=" + latCol, new Double[] { leftLon, rightLon, bottomLat, topLat }); //$NON-NLS-1$
SQLiteStatement stat = db.compileStatement(IndexConstants.generatePrepareStatementToInsert(IndexPoiTable.getTable(), 8)); SQLiteStatement stat = db.compileStatement(IndexConstants.generatePrepareStatementToInsert(IndexPoiTable.getTable(), 8));
for (Amenity a : amenities) { for (Amenity a : amenities) {

View file

@ -139,6 +139,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
setContentView(R.layout.main); setContentView(R.layout.main);
mapView = (OsmandMapTileView) findViewById(R.id.MapView); mapView = (OsmandMapTileView) findViewById(R.id.MapView);
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener(){
@Override
public boolean onTrackBallEvent(MotionEvent e) {
return MapActivity.this.onTrackballEvent(e);
}
@Override
public boolean onTrackBallPressed() {
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude(), true);
return true;
}
});
MapTileDownloader.getInstance().addDownloaderCallback(new IMapDownloaderCallback(){ MapTileDownloader.getInstance().addDownloaderCallback(new IMapDownloaderCallback(){
@Override @Override
public void tileDownloaded(DownloadRequest request) { public void tileDownloaded(DownloadRequest request) {
@ -236,6 +248,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}); });
backToMenu = (ImageButton)findViewById(R.id.BackToMenu); backToMenu = (ImageButton)findViewById(R.id.BackToMenu);
backToMenu.setOnClickListener(new OnClickListener() { backToMenu.setOnClickListener(new OnClickListener() {
@Override @Override
@ -285,10 +298,6 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x); double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x);
setMapLocation(lat, lon); setMapLocation(lat, lon);
return true; return true;
// that doesn't work for now
// } else if(event.getAction() == MotionEvent.ACTION_UP){
// contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
// return true;
} }
return super.onTrackballEvent(event); return super.onTrackballEvent(event);
} }

View file

@ -24,6 +24,7 @@ import com.osmand.osm.MapUtils;
public class SearchHistoryActivity extends ListActivity { public class SearchHistoryActivity extends ListActivity {
private LatLon location; private LatLon location;
private SearchHistoryHelper helper; private SearchHistoryHelper helper;
private Button clearButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -36,15 +37,7 @@ public class SearchHistoryActivity extends ListActivity {
helper = SearchHistoryHelper.getInstance(); helper = SearchHistoryHelper.getInstance();
clearButton = new Button(this);
}
@Override
protected void onResume() {
super.onResume();
List<HistoryEntry> historyEntries = helper.getHistoryEntries(this);
if (!historyEntries.isEmpty()) {
Button clearButton = new Button(this);
clearButton.setText(R.string.clear_all); clearButton.setText(R.string.clear_all);
clearButton.setOnClickListener(new View.OnClickListener() { clearButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -53,6 +46,14 @@ public class SearchHistoryActivity extends ListActivity {
setListAdapter(new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this))); setListAdapter(new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this)));
} }
}); });
}
@Override
protected void onResume() {
super.onResume();
List<HistoryEntry> historyEntries = helper.getHistoryEntries(this);
getListView().removeFooterView(clearButton);
if (!historyEntries.isEmpty()) {
getListView().addFooterView(clearButton); getListView().addFooterView(clearButton);
} }
setListAdapter(new HistoryAdapter(historyEntries)); setListAdapter(new HistoryAdapter(historyEntries));

View file

@ -19,6 +19,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.FloatMath; import android.util.FloatMath;
import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
@ -45,6 +46,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
protected final int timeForDraggingAnimation = 300; protected final int timeForDraggingAnimation = 300;
protected final int minimumDistanceForDraggingAnimation = 40; protected final int minimumDistanceForDraggingAnimation = 40;
public interface OnTrackBallListener{
public boolean onTrackBallEvent(MotionEvent e);
public boolean onTrackBallPressed();
}
public interface OnLongClickListener { public interface OnLongClickListener {
public boolean onLongPressEvent(PointF point); public boolean onLongPressEvent(PointF point);
} }
@ -76,6 +82,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
private OnClickListener onClickListener; private OnClickListener onClickListener;
private OnTrackBallListener trackBallDelegate;
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>(); private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>();
// UI Part // UI Part
@ -131,6 +139,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
setClickable(true); setClickable(true);
setLongClickable(true); setLongClickable(true);
setFocusable(true);
super.setOnLongClickListener(this); super.setOnLongClickListener(this);
super.setOnClickListener(this); super.setOnClickListener(this);
@ -142,8 +151,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
refreshMap(); refreshMap();
@ -660,6 +667,26 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
return true; return true;
} }
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(trackBallDelegate != null && keyCode == KeyEvent.KEYCODE_DPAD_CENTER){
return trackBallDelegate.onTrackBallPressed();
}
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
if(trackBallDelegate != null){
trackBallDelegate.onTrackBallEvent(event);
}
return super.onTrackballEvent(event);
}
public void setTrackBallDelegate(OnTrackBallListener trackBallDelegate) {
this.trackBallDelegate = trackBallDelegate;
}
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
PointF point = startDragging; PointF point = startDragging;