-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dialog.java
102 lines (70 loc) · 2.21 KB
/
Dialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.d_andaman;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Dialog extends Activity{
private TextView txt,txt1;
private Button cancle,send;
private String subject,message;
private Alert_database db;
private View view;
private String lat,lon;
private GPSTracker gps;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popup);
db = new Alert_database(this);
cancle=(Button) findViewById(R.id.cancle);
send=(Button) findViewById(R.id.send);
txt=(TextView) findViewById(R.id.alert_sub);
txt1=(TextView)findViewById(R.id.alert_message);
//lat=getIntent().getExtras().getString("latitude");
//lon=getIntent().getExtras().getString("longitude");
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subject=txt.getText().toString().trim();
message=txt1.getText().toString().trim();
db.addContact(new Alert_list(1,message));
lat=null;
lon=null;
gps = new GPSTracker(Dialog.this);
// check if GPS enabled
if(gps.canGetLocation()){
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
lat=""+latitude;
lon=""+longitude;
}
if(lat==null&lon==null){
ProgressDialog dialog = new ProgressDialog(getApplicationContext());
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("Fetching your location...");
dialog.setIndeterminate(true);
dialog.setCanceledOnTouchOutside(false);
dialog.show();
}else{
Intent i = new Intent(getApplicationContext(),
Send_popup.class);
i.putExtra("latitude",lat);
i.putExtra("longitude", lon);
i.putExtra( "message",message);
startActivity(i);
finish();
}
}
});
cancle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//closeContextMenu();
finish();
}
});
}
}