refs #5400 quitar opción coordendas
This commit is contained in:
parent
dad2ff478a
commit
5842c696d1
|
@ -47,7 +47,7 @@ public class CargarBultosActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_cargar_bultos);
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
listView = findViewById(R.id.listCheck);
|
||||
txtRuta = findViewById(R.id.txtRuta);
|
||||
txtEscaner = findViewById(R.id.txtEscaner);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ConfigureActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
Intent intent = this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
route = (Ruta) bundle.getSerializable("route");
|
||||
|
|
|
@ -52,7 +52,7 @@ class ExpeditionInfoActivity : AppCompatActivity() {
|
|||
setContentView(R.layout.activity_expedition_info)
|
||||
mperror = MediaPlayer.create((this), R.raw.error)
|
||||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
listView = findViewById(R.id.listExpeditionInfo)
|
||||
txtScanned = findViewById(R.id.txtScanned)
|
||||
textViewTitle = findViewById(R.id.textViewTitle)
|
||||
|
|
|
@ -48,7 +48,7 @@ class ExpeditionScanActivity : AppCompatActivity() {
|
|||
setContentView(R.layout.activity_scan)
|
||||
mperror = MediaPlayer.create((this), R.raw.error)
|
||||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
listView = findViewById(R.id.listRoute)
|
||||
txtRuta = findViewById(R.id.txtRuta)
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
|
|||
mpError = MediaPlayer.create((this), R.raw.error)
|
||||
mpOk = MediaPlayer.create((this), R.raw.ok)
|
||||
mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
|
||||
listView = findViewById(R.id.listExpeditionSummary)
|
||||
textViewRoute = findViewById(R.id.textViewRoute)
|
||||
|
|
|
@ -44,7 +44,7 @@ class ExpeditionSummaryActivityOld : AppCompatActivity() {
|
|||
setContentView(R.layout.activity_expedition_summary)
|
||||
mperror = MediaPlayer.create((this), R.raw.error)
|
||||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
|
||||
listView = findViewById(R.id.listExpeditionSummary)
|
||||
textViewTitle = findViewById(R.id.textViewRoute)
|
||||
|
|
|
@ -78,7 +78,7 @@ public class InfoActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
|
||||
Intent intent = this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
|
|
|
@ -54,7 +54,7 @@ class LoadVanActivity : AppCompatActivity() {
|
|||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
|
||||
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
listView = findViewById(R.id.listRoute)
|
||||
txtRuta = findViewById(R.id.txtRuta)
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
restClientSalix = ApiUtilsSalix.getAPIService();
|
||||
|
||||
setViews();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
restClientSalix = ApiUtilsSalix.getAPIService();
|
||||
setViews();
|
||||
getRoutes(null);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class NetworkStateReveiver extends BroadcastReceiver {
|
|||
//TENEMOS INTERNET
|
||||
Set<String> listPendientes = LocalStorage.getPendingSigns(context);
|
||||
if (listPendientes.size() != 0){
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(context);
|
||||
restClientSalix = ApiUtilsSalix.getAPIService();
|
||||
Gson gson = new Gson();
|
||||
listData = new ArrayList<>();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class NoteActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_note);
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
Intent intent = this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
clientTicket = (ClientTickets) bundle.getSerializable("clientTicket");
|
||||
|
|
|
@ -12,10 +12,9 @@ import android.location.Criteria;
|
|||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -27,22 +26,17 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import okio.ByteString;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.http.QueryMap;
|
||||
import verdnatura.es.repartoverdnatura.INTERFACES.RestClientSalix;
|
||||
import verdnatura.es.repartoverdnatura.MODELS.ClientTickets;
|
||||
import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload;
|
||||
|
@ -50,7 +44,7 @@ import verdnatura.es.repartoverdnatura.UTILS.ApiUtilsSalix;
|
|||
import verdnatura.es.repartoverdnatura.UTILS.LocalStorage;
|
||||
import verdnatura.es.repartoverdnatura.UTILS.Utils;
|
||||
|
||||
public class SignActivity extends AppCompatActivity implements LocationListener{
|
||||
public class SignActivity extends AppCompatActivity implements LocationListener {
|
||||
|
||||
private InkView ink;
|
||||
public ClientTickets clientTickets;
|
||||
|
@ -74,30 +68,28 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
MY_PERMISSIONS_REQUEST_FINE_LOCATION);
|
||||
}else{
|
||||
} else {
|
||||
location = locationManager.getLastKnownLocation(provider);
|
||||
}
|
||||
try {
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0, 0,this);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0, 0,this);
|
||||
}
|
||||
catch(Exception e) {
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Intent intent = this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
clientTickets = (ClientTickets) bundle.getSerializable("clientTicket");
|
||||
// Log.d("VERDNATURA::","El consignatario es "+clientTickets.getAddress());
|
||||
// Log.d("VERDNATURA::","El consignatario es "+clientTickets.getAddress());
|
||||
idRuta = bundle.getString("idRuta");
|
||||
setViews();
|
||||
setScreen();
|
||||
}
|
||||
|
||||
|
||||
private void setViews(){
|
||||
private void setViews() {
|
||||
ink = findViewById(R.id.ink);
|
||||
ink.setColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
ink.setMinStrokeWidth(1.5f);
|
||||
|
@ -108,64 +100,63 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
txtCliente = findViewById(R.id.txtCliente);
|
||||
}
|
||||
|
||||
private void setScreen(){
|
||||
private void setScreen() {
|
||||
StringBuffer auxText = new StringBuffer();
|
||||
int sumPackages = 0;
|
||||
boolean isFirst = true;
|
||||
for(Map<String,String> ticket : clientTickets.getTickets()){
|
||||
if (isFirst){
|
||||
for (Map<String, String> ticket : clientTickets.getTickets()) {
|
||||
if (isFirst) {
|
||||
auxText.append(ticket.get("Id"));
|
||||
isFirst = false;
|
||||
}else{
|
||||
auxText.append(" , "+ticket.get("Id"));
|
||||
} else {
|
||||
auxText.append(" , " + ticket.get("Id"));
|
||||
}
|
||||
|
||||
sumPackages += Integer.parseInt(ticket.get("Packages"));
|
||||
tickets.add(Integer.parseInt(ticket.get("Id")));
|
||||
}
|
||||
txtTickets.setText(auxText.toString());
|
||||
txtPackages.setText(""+sumPackages);
|
||||
txtPackages.setText("" + sumPackages);
|
||||
txtCliente.setText(clientTickets.getClientName());
|
||||
}
|
||||
|
||||
|
||||
public void saveSign(View v){
|
||||
public void saveSign(View v) {
|
||||
|
||||
final SignActivity that = this;
|
||||
new AlertDialog.Builder(this)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(getResources().getString(R.string.firma))
|
||||
.setMessage(getResources().getString(R.string.estas_seguro_firma))
|
||||
.setPositiveButton(getResources().getString(R.string.si), new DialogInterface.OnClickListener()
|
||||
{
|
||||
.setPositiveButton(getResources().getString(R.string.si), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
Log.d("VERDNATURA::","entramos gps");
|
||||
Log.d("VERDNATURA::", "entramos gps");
|
||||
|
||||
|
||||
final Bitmap drawing = ink.getBitmap();
|
||||
|
||||
|
||||
|
||||
if(clientTickets.getLongitude()!=null && !clientTickets.getLongitude().equals("")){
|
||||
if (clientTickets.getLongitude() != null && !clientTickets.getLongitude().equals("")) {
|
||||
Location l2 = new Location("");
|
||||
|
||||
l2.setLatitude(Double.parseDouble(clientTickets.getLatitude()));
|
||||
l2.setLongitude(Double.parseDouble(clientTickets.getLongitude()));
|
||||
|
||||
if(location != null && distanceTwoPoints(location,l2)>30.0){
|
||||
|
||||
if (location != null && distanceTwoPoints(location, l2) > 100.0) {
|
||||
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(that).create();
|
||||
alertDialog.setTitle("Alert");
|
||||
alertDialog.setMessage(that.getResources().getString(R.string.diferente_loc));
|
||||
alertDialog.setMessage(that.getResources().getString(R.string.diferente_loc) + getString(R.string.distance) + distanceTwoPoints(location, l2));
|
||||
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, that.getResources().getString(R.string.mantener),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(clientTickets.getLongitude(),clientTickets.getLatitude()));
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location(clientTickets.getLongitude(), clientTickets.getLatitude()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -179,7 +170,7 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude())));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -189,9 +180,10 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
});
|
||||
alertDialog.show();
|
||||
|
||||
}else{
|
||||
//sergio: No subido para comprobar si location == null.
|
||||
if (location==null) {
|
||||
} else {
|
||||
|
||||
//sergio: No subido para comprobar si location == null.
|
||||
if (location == null) {
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets), tickets);
|
||||
|
@ -200,26 +192,27 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
}
|
||||
// SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location("0.0", "0.0"));
|
||||
confirmSave(data);
|
||||
}else{
|
||||
} else {
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude())));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
confirmSave(data);}
|
||||
confirmSave(data);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
|
||||
if (location != null){
|
||||
if (location != null) {
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
|
||||
data = new SignDataUpload(that.BitMapToString(drawing, tickets), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude())));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
confirmSave(data);
|
||||
}else{
|
||||
} else {
|
||||
//SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location("0.0","0.0"));
|
||||
SignDataUpload data = null;
|
||||
try {
|
||||
|
@ -241,10 +234,10 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
|
||||
}
|
||||
|
||||
public void confirmSave(final SignDataUpload data){
|
||||
Log.d("VERDNATURA::","La firma es "+data.getSignedTime());
|
||||
public void confirmSave(final SignDataUpload data) {
|
||||
Log.d("VERDNATURA::", "La firma es " + data.getSignedTime());
|
||||
|
||||
Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
|
||||
Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
|
||||
|
||||
final SignActivity that = this;
|
||||
|
||||
|
@ -260,21 +253,21 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
@Override
|
||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||
Utils.progressBar.getDialog().dismiss();
|
||||
if(response.isSuccessful()){
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
// if (response.body().equals("OK")){
|
||||
// if (response.body().equals("OK")){
|
||||
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("idCliente",clientTickets.getClient());
|
||||
setResult(Activity.RESULT_OK,returnIntent);
|
||||
finish();
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("idCliente", clientTickets.getClient());
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
finish();
|
||||
/* }else{
|
||||
saveLocal(data);
|
||||
}*/
|
||||
|
||||
}else{
|
||||
// Log.i("ERROR","error al guardar");
|
||||
Utils.showErrorDialog(that,response.message());
|
||||
} else {
|
||||
// Log.i("ERROR","error al guardar");
|
||||
Utils.showErrorDialog(that, response.message());
|
||||
saveLocal(data);
|
||||
}
|
||||
}
|
||||
|
@ -282,24 +275,24 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
@Override
|
||||
public void onFailure(Call<Void> call, Throwable t) {
|
||||
Utils.progressBar.getDialog().dismiss();
|
||||
Utils.showErrorDialog(that,t.getMessage());
|
||||
Utils.showErrorDialog(that, t.getMessage());
|
||||
saveLocal(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveLocal(SignDataUpload data){
|
||||
public void saveLocal(SignDataUpload data) {
|
||||
data.setIdClient(clientTickets.getAddress());
|
||||
LocalStorage.saveSign(this,data,clientTickets.getAddress(),idRuta);
|
||||
LocalStorage.saveSign(this, data, clientTickets.getAddress(), idRuta);
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("idCliente",clientTickets.getAddress());
|
||||
setResult(Activity.RESULT_OK,returnIntent);
|
||||
returnIntent.putExtra("idCliente", clientTickets.getAddress());
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
public String BitMapToString(Bitmap bitmap, List<Integer> tickets) throws IOException {
|
||||
String fileNameSign = getBaseContext().getExternalCacheDir() + "/sign";
|
||||
for (Integer ticket: tickets) {
|
||||
String fileNameSign = getBaseContext().getExternalCacheDir() + "/sign";
|
||||
for (Integer ticket : tickets) {
|
||||
fileNameSign += "_" + ticket.toString();
|
||||
}
|
||||
|
||||
|
@ -309,8 +302,8 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
|
||||
//Convert bitmap to byte array
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
|
||||
byte [] b = baos.toByteArray();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
|
||||
byte[] b = baos.toByteArray();
|
||||
|
||||
//write the bytes in file
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
|
@ -321,11 +314,11 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
|
|||
return fileNameSign + ".png";
|
||||
}
|
||||
|
||||
public void clearSign(View v){
|
||||
public void clearSign(View v) {
|
||||
ink.clear();
|
||||
}
|
||||
|
||||
public float distanceTwoPoints(Location l1 , Location l2){
|
||||
public float distanceTwoPoints(Location l1, Location l2) {
|
||||
|
||||
return l1.distanceTo(l2);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class Tickets extends AppCompatActivity {
|
|||
Intent intent = this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
route = (Ruta) bundle.getSerializable("route");
|
||||
restClient = ApiUtils.getAPIService();
|
||||
restClient = ApiUtils.getAPIService(this);
|
||||
restClientSalix = ApiUtilsSalix.getAPIService();
|
||||
setViews();
|
||||
checkPendingSigns();
|
||||
|
@ -451,85 +451,22 @@ public class Tickets extends AppCompatActivity {
|
|||
if (isGoogleMapsInstalled()) {
|
||||
|
||||
if (isSignedShowed) {
|
||||
if (listClientesTicketsFirmados.get(pos).getLatitude() == null || listClientesTicketsFirmados.get(pos).getLatitude().equals("0.0")) {
|
||||
uri = "geo:0,0?q=" + listClientesTicketsFirmados.get(pos).getClientName() +
|
||||
|
||||
uri = "geo:0,0?q=" + listClientesTicketsFirmados.get(pos).getClientName() +
|
||||
" " + listClientesTicketsFirmados.get(pos).getAddressName() +
|
||||
" " + listClientesTicketsFirmados.get(pos).getCity() +
|
||||
" " + listClientesTicketsFirmados.get(pos).getPostalCode();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
} else {
|
||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
|
||||
builder1.setMessage(that.getResources().getString(R.string.ver_loc));
|
||||
builder1.setCancelable(true);
|
||||
|
||||
builder1.setPositiveButton(
|
||||
that.getResources().getString(R.string.nombre),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
uri = "geo:0,0?q=" + listClientesTicketsFirmados.get(posicion).getClientName() +
|
||||
" " + listClientesTicketsFirmados.get(posicion).getAddressName() +
|
||||
" " + listClientesTicketsFirmados.get(posicion).getCity() +
|
||||
" " + listClientesTicketsFirmados.get(posicion).getPostalCode();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
}
|
||||
});
|
||||
|
||||
builder1.setNegativeButton(
|
||||
that.getResources().getString(R.string.coordenadas),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
uri = "geo:0,0?q=" + listClientesTicketsFirmados.get(posicion).getLatitude() +
|
||||
" " + listClientesTicketsFirmados.get(posicion).getLongitude();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert11 = builder1.create();
|
||||
alert11.show();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (listClientesTickets.get(pos).getLatitude() == null || listClientesTickets.get(pos).getLatitude().equals("0.0")) {
|
||||
uri = "geo:0,0?q=" + listClientesTickets.get(pos).getClientName() +
|
||||
|
||||
uri = "geo:0,0?q=" + listClientesTickets.get(pos).getClientName() +
|
||||
" " + listClientesTickets.get(pos).getAddressName() +
|
||||
" " + listClientesTickets.get(pos).getCity() +
|
||||
" " + listClientesTickets.get(pos).getPostalCode();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
} else {
|
||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
|
||||
builder1.setMessage(that.getResources().getString(R.string.ver_loc));
|
||||
builder1.setCancelable(true);
|
||||
|
||||
builder1.setPositiveButton(
|
||||
that.getResources().getString(R.string.nombre),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
uri = "geo:0,0?q=" + listClientesTickets.get(posicion).getClientName() +
|
||||
" " + listClientesTickets.get(posicion).getAddressName() +
|
||||
" " + listClientesTickets.get(posicion).getCity() +
|
||||
" " + listClientesTickets.get(posicion).getPostalCode();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
}
|
||||
});
|
||||
|
||||
builder1.setNegativeButton(
|
||||
that.getResources().getString(R.string.coordenadas),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
uri = "geo:0,0?q=" + listClientesTickets.get(posicion).getLatitude() +
|
||||
" " + listClientesTickets.get(posicion).getLongitude();
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert11 = builder1.create();
|
||||
alert11.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package verdnatura.es.repartoverdnatura.UTILS;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
@ -7,10 +12,19 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
|
|||
public class RetrofitClient {
|
||||
private static Retrofit retrofit = null;
|
||||
|
||||
public static Retrofit getClient(String baseUrl){
|
||||
public static Retrofit getClient(String baseUrl, Context context){
|
||||
if (retrofit==null) {
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.addInterceptor(new SilexInterceptor(context))
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(40, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(baseUrl)
|
||||
.client(client)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class UnLoadVanActivity : AppCompatActivity() {
|
|||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
|
||||
|
||||
restClient = ApiUtils.getAPIService()
|
||||
restClient = ApiUtils.getAPIService(this)
|
||||
listView = findViewById(R.id.listRoute)
|
||||
txtRuta = findViewById(R.id.txtRuta)
|
||||
txtEscaner = findViewById(R.id.txtEscaner)
|
||||
|
|
Loading…
Reference in New Issue