/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/GeoCoordEnterDialog.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/GeoCoordEnterDialog.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 27 Revision 28
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20package com.zoffcc.applications.zanavi; 20package com.zoffcc.applications.zanavi;
21 21
22import net.technologichron.manacalc.NumberPicker;
22import android.app.Activity; 23import android.app.Activity;
24import android.content.Intent;
23import android.os.Bundle; 25import android.os.Bundle;
26import android.view.View;
27import android.widget.Button;
28import android.widget.ToggleButton;
24 29
25public class GeoCoordEnterDialog extends Activity 30public class GeoCoordEnterDialog extends Activity
26{ 31{
32 float lat;
33 float lon;
34
27 /** Called when the activity is first created. */ 35 /** Called when the activity is first created. */
28 @Override 36 @Override
29 public void onCreate(Bundle savedInstanceState) 37 public void onCreate(Bundle savedInstanceState)
30 { 38 {
31 super.onCreate(savedInstanceState); 39 super.onCreate(savedInstanceState);
32 setContentView(R.layout.geocoordenter); 40 setContentView(R.layout.geocoordenter);
33 // setContentView(R.layout.numpicker2); 41 // setContentView(R.layout.numpicker2);
42 final Button ok_button = (Button) findViewById(R.id.ok01);
43 final Button destination_button = (Button) findViewById(R.id.dst01);
44 final Button cancel_button = (Button) findViewById(R.id.cancel01);
45 ok_button.setOnClickListener(new View.OnClickListener()
46 {
47 public void onClick(View v)
48 {
49 executeDone("view");
50 }
51 });
52
53 destination_button.setOnClickListener(new View.OnClickListener()
54 {
55 public void onClick(View v)
56 {
57 executeDone("dest");
58 }
59 });
60
61 cancel_button.setOnClickListener(new View.OnClickListener()
62 {
63 public void onClick(View v)
64 {
65 Intent resultIntent = new Intent();
66 setResult(Activity.RESULT_CANCELED, resultIntent);
67 finish();
68 }
69 });
70 }
71
72 private void executeDone(String what)
73 {
74 Intent resultIntent = new Intent();
75 final NumberPicker value_lat1 = (NumberPicker) findViewById(R.id.lat1);
76 final NumberPicker value_lat2 = (NumberPicker) findViewById(R.id.lat2);
77 final NumberPicker value_lat3 = (NumberPicker) findViewById(R.id.lat3);
78 lat = value_lat1.getValue() + ((float) value_lat2.getValue() / 60) + ((float) value_lat3.getValue() / 3600);
79
80 final NumberPicker value_lon1 = (NumberPicker) findViewById(R.id.lon1);
81 final NumberPicker value_lon2 = (NumberPicker) findViewById(R.id.lon2);
82 final NumberPicker value_lon3 = (NumberPicker) findViewById(R.id.lon3);
83 lon = value_lon1.getValue() + ((float) value_lon2.getValue() / 60) + ((float) value_lon3.getValue() / 3600);
84
85 resultIntent.putExtra("lat", String.valueOf(this.lat));
86 resultIntent.putExtra("lon", String.valueOf(this.lon));
87 final ToggleButton toggle_NS = (ToggleButton) findViewById(R.id.toggleButtonNS);
88 if (!toggle_NS.isSelected())
89 {
90 this.lat = -this.lat;
91 }
92 final ToggleButton toggle_WE = (ToggleButton) findViewById(R.id.toggleButtonWE);
93 if (toggle_WE.isSelected())
94 {
95 this.lon = -this.lon;
96 }
97 setResult(Activity.RESULT_OK, resultIntent);
98 if (what.equals("view"))
99 {
100 resultIntent.putExtra("what", "view");
101 }
102 else
103 {
104 resultIntent.putExtra("what", "-");
105 }
106 finish();
34 } 107 }
35} 108}

Legend:
Removed from v.27  
changed lines
  Added in v.28

   
Visit the ZANavi Wiki