DT @25.09.2015: Added marker adding position
This commit is contained in:
@@ -4,24 +4,43 @@ import android.app.SearchManager;
|
|||||||
import android.app.SearchableInfo;
|
import android.app.SearchableInfo;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.google.android.gms.maps.CameraUpdate;
|
import com.google.android.gms.maps.CameraUpdate;
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
import com.google.android.gms.maps.SupportMapFragment;
|
||||||
|
import com.google.android.gms.maps.model.Circle;
|
||||||
|
import com.google.android.gms.maps.model.CircleOptions;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.android.gms.maps.model.Marker;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
|
|
||||||
|
import org.deke.risk.riskahead.helper.AppConfig;
|
||||||
|
import org.deke.risk.riskahead.helper.AppController;
|
||||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||||
import org.deke.risk.riskahead.helper.PlaceProvider;
|
import org.deke.risk.riskahead.helper.PlaceProvider;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<Cursor> {
|
public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
@@ -30,6 +49,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
private static final String TAG = MapsActivity.class.getSimpleName();
|
private static final String TAG = MapsActivity.class.getSimpleName();
|
||||||
|
|
||||||
private static GoogleMap mMap;
|
private static GoogleMap mMap;
|
||||||
|
Marker mMarker;
|
||||||
private LatLng myLocation;
|
private LatLng myLocation;
|
||||||
private LatLng markedLocation;
|
private LatLng markedLocation;
|
||||||
|
|
||||||
@@ -41,27 +61,33 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||||
handleIntent(getIntent());
|
handleIntent(getIntent());
|
||||||
|
|
||||||
//setUpMap();
|
|
||||||
|
|
||||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
|
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
|
||||||
|
|
||||||
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMapClick(LatLng point) {
|
public void onMapClick(LatLng point) {
|
||||||
|
if (mMarker != null) {
|
||||||
|
mMarker.remove();
|
||||||
|
}
|
||||||
markedLocation = point;
|
markedLocation = point;
|
||||||
mMap.clear();
|
mMarker = mMap.addMarker(new MarkerOptions().position(point));
|
||||||
mMap.addMarker(new MarkerOptions().position(point));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, 12.0f));
|
||||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.VISIBLE);
|
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
findViewById(R.id.btn_maps_confirm_position).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.btn_maps_confirm_position).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
gotoReportActivity(markedLocation.latitude+":"+markedLocation.longitude);
|
gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//setUpMap();
|
||||||
|
|
||||||
|
String tag_string_req = "getincidentswithposition";
|
||||||
|
StringRequest strReq = getStringRequestGetAllIncidentsWithPosition();
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleIntent(Intent intent){
|
private void handleIntent(Intent intent){
|
||||||
@@ -155,7 +181,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
mMap.setMyLocationEnabled(true);
|
mMap.setMyLocationEnabled(true);
|
||||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||||
// For dropping a marker at a point on the Map
|
// For dropping a marker at a point on the Map
|
||||||
|
|
||||||
mMap.addMarker(new MarkerOptions().position(myLocation).title("My Home").snippet("Home Address"));
|
mMap.addMarker(new MarkerOptions().position(myLocation).title("My Home").snippet("Home Address"));
|
||||||
|
|
||||||
// For zooming automatically to the Dropped PIN Location
|
// For zooming automatically to the Dropped PIN Location
|
||||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 12.0f));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 12.0f));
|
||||||
}
|
}
|
||||||
@@ -179,4 +207,73 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
return mActivityTitle;
|
return mActivityTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestGetAllIncidentsWithPosition() {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
Log.d(TAG, "Map positions response: " + response);
|
||||||
|
hideDialog();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jObj = new JSONObject(response);
|
||||||
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
|
// Check for error node in json
|
||||||
|
if (!error) {
|
||||||
|
JSONArray incidents = jObj.getJSONArray("message");
|
||||||
|
for(int i=0;i<incidents.length();i++){
|
||||||
|
JSONObject incident = incidents.getJSONObject(i);
|
||||||
|
LatLng pos = new LatLng(Double.parseDouble(incident.getString("latitude")),Double.parseDouble(incident.getString("longitude")));
|
||||||
|
Log.d(TAG, "Adding marker with position: " + pos.latitude +" : "+ pos.longitude);
|
||||||
|
mMap.addMarker(new MarkerOptions().position(pos).title(incident.getString("text_short")).snippet("Test" + i));
|
||||||
|
|
||||||
|
CircleOptions circleOptions = new CircleOptions()
|
||||||
|
.center(pos)
|
||||||
|
.strokeColor(Color.BLACK)
|
||||||
|
.strokeWidth(2)
|
||||||
|
.fillColor(Color.argb(50, 255, 0, 0))
|
||||||
|
.radius(incident.getInt("radius")); // In meters
|
||||||
|
|
||||||
|
Circle circle = mMap.addCircle(circleOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Error in login. Get the error message
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// JSON error
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Report Error: " + error.getMessage());
|
||||||
|
Toast.makeText(getApplicationContext(),
|
||||||
|
error.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
hideDialog();
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
// Posting parameters to login url
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "getincidentswithposition");
|
||||||
|
params.put("uid", user.get("uid"));
|
||||||
|
params.put("token", user.get("token"));
|
||||||
|
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,24 +4,36 @@ import android.app.DatePickerDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.location.Address;
|
import android.location.Address;
|
||||||
import android.location.Geocoder;
|
import android.location.Geocoder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
|
||||||
|
import org.deke.risk.riskahead.helper.AppConfig;
|
||||||
|
import org.deke.risk.riskahead.helper.AppController;
|
||||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ReportActivity extends BaseActivity {
|
public class ReportActivity extends BaseActivity {
|
||||||
|
|
||||||
@@ -44,6 +56,8 @@ public class ReportActivity extends BaseActivity {
|
|||||||
private EditText txtDay;
|
private EditText txtDay;
|
||||||
private EditText txtTime;
|
private EditText txtTime;
|
||||||
|
|
||||||
|
private String latitude, longitude;
|
||||||
|
|
||||||
private int year, month, day;
|
private int year, month, day;
|
||||||
private int hour, minute;
|
private int hour, minute;
|
||||||
|
|
||||||
@@ -70,12 +84,19 @@ public class ReportActivity extends BaseActivity {
|
|||||||
txtTime = (EditText) findViewById(R.id.input_report_time);
|
txtTime = (EditText) findViewById(R.id.input_report_time);
|
||||||
txtPosition = (EditText) findViewById(R.id.input_report_position);
|
txtPosition = (EditText) findViewById(R.id.input_report_position);
|
||||||
|
|
||||||
|
restoreSharedPreferences();
|
||||||
|
|
||||||
|
|
||||||
|
if(txtDay.getText().toString() == "") {
|
||||||
txtDay.setText(new StringBuilder()
|
txtDay.setText(new StringBuilder()
|
||||||
.append(day).append("-").append(month + 1).append("-")
|
.append(day).append("-").append(month + 1).append("-")
|
||||||
.append(year).append(" "));
|
.append(year).append(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(txtTime.getText().toString() == "") {
|
||||||
txtTime.setText(new StringBuilder().append(hour)
|
txtTime.setText(new StringBuilder().append(hour)
|
||||||
.append(":").append(minute).append(" "));
|
.append(":").append(minute).append(" "));
|
||||||
|
}
|
||||||
|
|
||||||
findViewById(R.id.btn_report_position).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.btn_report_position).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -95,11 +116,22 @@ public class ReportActivity extends BaseActivity {
|
|||||||
try {
|
try {
|
||||||
List<Address> addresses = geocoder.getFromLocation(Double.parseDouble(position[0]), Double.parseDouble(position[1]), 1);
|
List<Address> addresses = geocoder.getFromLocation(Double.parseDouble(position[0]), Double.parseDouble(position[1]), 1);
|
||||||
txtPosition.setText(addresses.get(0).getLocality());
|
txtPosition.setText(addresses.get(0).getLocality());
|
||||||
|
latitude = position[0];
|
||||||
|
longitude = position[1];
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findViewById(R.id.btn_report_report).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String tag_string_req = "addincidentwithposition";
|
||||||
|
StringRequest strReq = getStringRequestAddIncidentWithPosition(txtTitle.getText().toString(), txtDescription.getText().toString(), txtCrimeCategory.getSelectedItemPosition(), latitude, longitude, 10, 1, txtDay.getText().toString(), txtTime.getText().toString());
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
txtDay.setOnClickListener(new View.OnClickListener() {
|
txtDay.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -115,15 +147,92 @@ public class ReportActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restoreSharedPreferences() {
|
||||||
|
SharedPreferences prefs = getPreferences(MODE_PRIVATE);
|
||||||
|
String title = prefs.getString(SAVED_TITLE, null);
|
||||||
|
if (title != null) txtTitle.setText(title);
|
||||||
|
|
||||||
|
String descr = prefs.getString(SAVED_DESCRIPTION_LONG, null);
|
||||||
|
if (descr != null) txtDescription.setText(descr);
|
||||||
|
|
||||||
|
int crimec = prefs.getInt(SAVED_CRIME_CATEGORY, 0);
|
||||||
|
txtCrimeCategory.setSelection(crimec);
|
||||||
|
|
||||||
|
String day = prefs.getString(SAVED_DATE_INCIDENT, null);
|
||||||
|
if (day != null) txtDay.setText(day);
|
||||||
|
|
||||||
|
String time = prefs.getString(SAVED_DATE_TIME, null);
|
||||||
|
if (time != null) txtTime.setText(time);
|
||||||
|
|
||||||
|
String posi = prefs.getString(SAVED_POSITION, null);
|
||||||
|
if (posi != null) txtPosition.setText(posi);
|
||||||
|
|
||||||
|
latitude = prefs.getString("latitude",null);
|
||||||
|
longitude = prefs.getString("longitude",null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestAddIncidentWithPosition(final String textshort, final String textlong, final int crimecategory, final String latitude, final String longitude, final int status, final int radius, final String day, final String time) {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
public void onResponse(String response) {
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
Log.d(TAG, "Report response: " + response);
|
||||||
txtTitle.setText(savedInstanceState.getString(SAVED_TITLE));
|
hideDialog();
|
||||||
txtDescription.setText(savedInstanceState.getString(SAVED_DESCRIPTION_LONG));
|
|
||||||
txtCrimeCategory.setSelection(savedInstanceState.getInt(SAVED_CRIME_CATEGORY));
|
try {
|
||||||
txtDay.setText(savedInstanceState.getString(SAVED_DATE_INCIDENT));
|
JSONObject jObj = new JSONObject(response);
|
||||||
txtTime.setText(savedInstanceState.getString(SAVED_DATE_TIME));
|
boolean error = jObj.getBoolean("error");
|
||||||
txtPosition.setText(savedInstanceState.getString(SAVED_POSITION));
|
|
||||||
|
if (!error) {
|
||||||
|
showMessage("Report added!");
|
||||||
|
SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
|
||||||
|
editor.clear();
|
||||||
|
editor.commit();
|
||||||
|
editor.apply();
|
||||||
|
gotoMapActivity();
|
||||||
|
} else {
|
||||||
|
// Error in login. Get the error message
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Report Error: " + error.getMessage());
|
||||||
|
Toast.makeText(getApplicationContext(),
|
||||||
|
error.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
hideDialog();
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
// Posting parameters to login url
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "addincidentwithposition");
|
||||||
|
params.put("uid", user.get("uid"));
|
||||||
|
params.put("token", user.get("token"));
|
||||||
|
params.put("textshort",textshort);
|
||||||
|
params.put("textlong",textlong);
|
||||||
|
params.put("fiduser",user.get("uid"));
|
||||||
|
params.put("fidcategory", Integer.toString(crimecategory));
|
||||||
|
params.put("latitude",latitude);
|
||||||
|
params.put("longitude",longitude);
|
||||||
|
params.put("status",Integer.toString(status));
|
||||||
|
params.put("radius",Integer.toString(radius));
|
||||||
|
params.put("happened_at",year+"-"+month+"-"+day+" "+hour+":"+minute+":00");
|
||||||
|
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -151,7 +260,6 @@ public class ReportActivity extends BaseActivity {
|
|||||||
month = selectedMonth;
|
month = selectedMonth;
|
||||||
day = selectedDay;
|
day = selectedDay;
|
||||||
|
|
||||||
// set selected date into textview
|
|
||||||
txtDay.setText(new StringBuilder().append(day)
|
txtDay.setText(new StringBuilder().append(day)
|
||||||
.append("-").append(month + 1).append("-").append(year)
|
.append("-").append(month + 1).append("-").append(year)
|
||||||
.append(" "));
|
.append(" "));
|
||||||
@@ -167,7 +275,6 @@ public class ReportActivity extends BaseActivity {
|
|||||||
hour = selectedHour;
|
hour = selectedHour;
|
||||||
minute = selectedMinute;
|
minute = selectedMinute;
|
||||||
|
|
||||||
// set selected date into textview
|
|
||||||
txtTime.setText(new StringBuilder().append(hour)
|
txtTime.setText(new StringBuilder().append(hour)
|
||||||
.append(":").append(minute).append(" "));
|
.append(":").append(minute).append(" "));
|
||||||
}
|
}
|
||||||
@@ -184,16 +291,19 @@ public class ReportActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
protected void onStop() {
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
super.onStop(); // Always call the superclass method first
|
||||||
savedInstanceState.putString(SAVED_TITLE, txtTitle.getText().toString());
|
|
||||||
savedInstanceState.putString(SAVED_DESCRIPTION_LONG, txtDescription.getText().toString());
|
SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
|
||||||
savedInstanceState.putInt(SAVED_CRIME_CATEGORY, txtCrimeCategory.getSelectedItemPosition());
|
editor.putString(SAVED_TITLE, txtTitle.getText().toString());
|
||||||
savedInstanceState.putString(SAVED_DATE_INCIDENT, txtDay.getText().toString());
|
editor.putString(SAVED_DESCRIPTION_LONG, txtDescription.getText().toString());
|
||||||
savedInstanceState.putString(SAVED_DATE_TIME, txtTime.getText().toString());
|
editor.putInt(SAVED_CRIME_CATEGORY, txtCrimeCategory.getSelectedItemPosition());
|
||||||
savedInstanceState.putString(SAVED_POSITION, txtPosition.getText().toString());
|
editor.putString(SAVED_DATE_INCIDENT, txtDay.getText().toString());
|
||||||
|
editor.putString(SAVED_DATE_TIME, txtTime.getText().toString());
|
||||||
|
editor.putString(SAVED_POSITION, txtPosition.getText().toString());
|
||||||
|
editor.putString("latitude", latitude);
|
||||||
|
editor.putString("longitude", longitude);
|
||||||
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.helper;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.deke.risk.riskahead.helper;
|
package org.deke.risk.riskahead.helper;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
@@ -45,6 +48,8 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
public SessionManager session;
|
public SessionManager session;
|
||||||
public HashMap<String, String> user;
|
public HashMap<String, String> user;
|
||||||
|
|
||||||
|
public ProgressDialog pDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -53,6 +58,9 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
// SqLite database handler
|
// SqLite database handler
|
||||||
db = new SQLiteHandler(getApplicationContext());
|
db = new SQLiteHandler(getApplicationContext());
|
||||||
|
|
||||||
|
pDialog = new ProgressDialog(this);
|
||||||
|
pDialog.setCancelable(false);
|
||||||
|
|
||||||
// session manager
|
// session manager
|
||||||
session = new SessionManager(getApplicationContext());
|
session = new SessionManager(getApplicationContext());
|
||||||
|
|
||||||
@@ -265,4 +273,14 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
protected abstract int getLayoutResourceId();
|
protected abstract int getLayoutResourceId();
|
||||||
|
|
||||||
protected abstract String getActivityName();
|
protected abstract String getActivityName();
|
||||||
|
|
||||||
|
public void showDialog() {
|
||||||
|
if (!pDialog.isShowing())
|
||||||
|
pDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideDialog() {
|
||||||
|
if (pDialog.isShowing())
|
||||||
|
pDialog.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
android:textColorHint="@color/input_login_hint"
|
android:textColorHint="@color/input_login_hint"
|
||||||
android:layout_below="@+id/lbl_report_long"
|
android:layout_below="@+id/lbl_report_long"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:minLines="5"/>
|
android:minLines="3"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/lbl_report_category"
|
android:id="@+id/lbl_report_category"
|
||||||
@@ -146,6 +146,18 @@
|
|||||||
android:layout_alignRight="@+id/input_report_time"
|
android:layout_alignRight="@+id/input_report_time"
|
||||||
android:layout_alignEnd="@+id/input_report_time" />
|
android:layout_alignEnd="@+id/input_report_time" />
|
||||||
|
|
||||||
|
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||||
|
android:id="@+id/btn_report_report"
|
||||||
|
android:text="@string/btn_main_report"
|
||||||
|
android:minWidth="300dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
bootstrap:bb_icon_left="fa-map-marker"
|
||||||
|
bootstrap:bb_type="danger"
|
||||||
|
bootstrap:bb_roundedCorners="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user