-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zprovozneni vyberu souradnic jako activity result
- Loading branch information
Showing
6 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<com.google.android.maps.MapView | ||
android:id="@+id/msc_Map" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:enabled="true" | ||
android:clickable="true" | ||
android:apiKey="0FWL-kvtGWbNHGzJfBDEDEGUfv-3YSFzDjNXJAw" | ||
/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/cz/cvut/fel/nur/zavody/activity/MapSelectCoordinates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package cz.cvut.fel.nur.zavody.activity; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.app.AlertDialog.Builder; | ||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import com.google.android.maps.GeoPoint; | ||
import com.google.android.maps.MapActivity; | ||
import com.google.android.maps.MapView; | ||
import cz.cvut.fel.nur.zavody.R; | ||
import cz.cvut.fel.nur.zavody.maps.MapTapOverlay; | ||
|
||
/** | ||
* This activity can finish with result of coordinates of selected point. This | ||
* point is save in intent (POINT string) as int array where first is Latitude and second is | ||
* Longitude. | ||
* | ||
* @author saljack | ||
*/ | ||
public class MapSelectCoordinates extends MapActivity { | ||
|
||
public static String POINT = "cz.cvut.fel.nur.zavody.activity.Point"; | ||
private MapView _mapView; | ||
|
||
/** | ||
* Called when the activity is first created. | ||
*/ | ||
@Override | ||
public void onCreate(Bundle icicle) { | ||
super.onCreate(icicle); | ||
setContentView(R.layout.map_select_coordinates); | ||
|
||
_mapView = (MapView) findViewById(R.id.msc_Map); | ||
_mapView.setBuiltInZoomControls(true); | ||
_mapView.getOverlays().add(new MapTapOverlay(this)); | ||
} | ||
|
||
@Override | ||
protected boolean isRouteDisplayed() { | ||
return false; | ||
} | ||
|
||
public void acceptPoint(GeoPoint arg0) { | ||
final GeoPoint point = arg0; | ||
DialogInterface.OnClickListener negative = new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int which) { | ||
dialog.dismiss(); | ||
} | ||
}; | ||
DialogInterface.OnClickListener positive = new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int which) { | ||
//TODO finisActivity | ||
endActivityWithPoint(point); | ||
} | ||
}; | ||
Dialog _dlg = new AlertDialog.Builder(this).setTitle(R.string.msc_wantSelect) | ||
.setMessage(getString(R.string.msc_point) + "\n" + arg0.toString()) | ||
.setNegativeButton(android.R.string.cancel, negative) | ||
.setPositiveButton(android.R.string.ok, positive).create(); | ||
|
||
_dlg.show(); | ||
} | ||
|
||
private void endActivityWithPoint(GeoPoint point) { | ||
Intent result = new Intent(); | ||
result.putExtra(POINT, new int[]{point.getLatitudeE6(), point.getLongitudeE6()}); | ||
setResult(Activity.RESULT_OK, result); | ||
finish(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package cz.cvut.fel.nur.zavody.maps; | ||
|
||
import android.app.AlertDialog; | ||
import android.app.Dialog; | ||
import android.graphics.Canvas; | ||
import android.util.Log; | ||
import com.google.android.maps.GeoPoint; | ||
import com.google.android.maps.MapView; | ||
import com.google.android.maps.Overlay; | ||
import cz.cvut.fel.nur.zavody.activity.MapSelectCoordinates; | ||
|
||
/** | ||
* | ||
* @author saljack | ||
*/ | ||
public class MapTapOverlay extends Overlay { | ||
|
||
public static final String TAG = "MapTapOverlay"; | ||
private MapSelectCoordinates _mapsAc; | ||
|
||
public MapTapOverlay(MapSelectCoordinates _mapsAc) { | ||
this._mapsAc = _mapsAc; | ||
} | ||
|
||
@Override | ||
public void draw(Canvas arg0, MapView arg1, boolean arg2) { | ||
|
||
super.draw(arg0, arg1, arg2); | ||
} | ||
|
||
@Override | ||
public boolean onTap(GeoPoint arg0, MapView arg1) { | ||
//TODO co se souradnicema | ||
final GeoPoint point = arg0; | ||
if (_mapsAc != null) { | ||
_mapsAc.runOnUiThread(new Runnable() { | ||
public void run() { | ||
_mapsAc.acceptPoint(point); | ||
} | ||
}); | ||
|
||
} | ||
return true; | ||
} | ||
} |