version23.8Beta accede a warehouse

This commit is contained in:
Sergio De la torre 2023-03-06 15:50:36 +01:00
parent b28c3b2c84
commit c2f4239ff0
6 changed files with 162 additions and 237 deletions

View File

@ -40,7 +40,15 @@
</configurations> </configurations>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3b8bed57-fcd9-4c4b-a644-0b0381aae011" name="Default" comment="Versión 23.4Beta en Sfusion"> <list default="true" id="3b8bed57-fcd9-4c4b-a644-0b0381aae011" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Ruta.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Ruta.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java" afterDir="false" />
</list>
<list id="bb82280e-2612-45ba-bd45-0d90b078e5b6" name="ignore" comment="ignore">
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" afterDir="false" />
@ -51,34 +59,17 @@
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/javaCompile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/javaCompile.lock" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/javaCompile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/javaCompile.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/taskHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/taskHistory.bin" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/taskHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/javaCompile/taskHistory.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/cache.properties" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/cache.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.hgignore" beforeDir="false" afterPath="$PROJECT_DIR$/.hgignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/deploymentTargetDropDown.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.main.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.main.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.unitTest.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/app/vn-delivery.app.unitTest.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apk/release/output.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/google-services.json" beforeDir="false" afterPath="$PROJECT_DIR$/app/google-services.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/release/app-release.apk" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/release/output.json" beforeDir="false" afterPath="$PROJECT_DIR$/app/release/output.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtilsSalix.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtilsSalix.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml" beforeDir="false" afterPath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml" beforeDir="false" afterPath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/master-index.xml" beforeDir="false" afterPath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/master-index.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/master-index.xml" beforeDir="false" afterPath="$PROJECT_DIR$/build/intermediates/lint-cache/maven.google/master-index.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vn-delivery.iml" beforeDir="false" afterPath="$PROJECT_DIR$/vn-delivery.iml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[C:\Users\sergiodt\.android\avd\Pixel_2_API_24.avd]" /> <component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[21114523025303]" />
<component name="ExternalProjectsData"> <component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$"> <projectState path="$PROJECT_DIR$">
<ProjectState /> <ProjectState />
@ -369,7 +360,7 @@
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" type="kotlin-line"> <line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt</url> <url>file://$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt</url>
<line>319</line> <line>317</line>
<option name="timeStamp" value="5" /> <option name="timeStamp" value="5" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>

View File

@ -23,10 +23,10 @@ android {
getByName("release") { getByName("release") {
applicationIdSuffix = ".sfusion" applicationIdSuffix = ".sfusion"
} }
/*
getByName("debug") { getByName("debug") {
applicationIdSuffix = ".sfusion" applicationIdSuffix = ".sfusion"
}*/ }
/* getByName("release") { /* getByName("release") {
applicationIdSuffix = ".sfusion" applicationIdSuffix = ".sfusion"
} }

View File

@ -6,6 +6,7 @@ import android.content.Intent
import android.media.MediaPlayer import android.media.MediaPlayer
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View import android.view.View
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.* import android.widget.*
@ -57,7 +58,7 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_expedition_summary) setContentView(R.layout.activity_expedition_summary)
Log.d("VERDNATURA::",""+ localClassName)
mpError = MediaPlayer.create((this), R.raw.error) mpError = MediaPlayer.create((this), R.raw.error)
mpOk = MediaPlayer.create((this), R.raw.ok) mpOk = MediaPlayer.create((this), R.raw.ok)
mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat) mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
@ -76,11 +77,8 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
if (bundle != null) { if (bundle != null) {
if (bundle.get("app") == "picking") { if (bundle.get("app") == "picking") {
/* Utils.saveTokenUser(this,bundle.get("token").toString()) routeOfLoad = bundle.get("routeId").toString()
Utils.saveUserPass(this,bundle.get("user").toString(),bundle.get("password").toString()) route = Ruta(routeOfLoad)
Utils.saveIdUser(this,bundle.get("userId").toString())*/
routeOfLoad = bundle.get("routeId").toString()
} else { } else {
route = bundle.getSerializable("route") as Ruta route = bundle.getSerializable("route") as Ruta
routeOfLoad = route!!.id.toString() routeOfLoad = route!!.id.toString()

View File

@ -51,6 +51,9 @@ public class Ruta implements Serializable {
Chofer = chofer; Chofer = chofer;
isLoaded=isloaded; isLoaded=isloaded;
} }
public Ruta(String id) {
Id = id;
}
public Ruta(){} public Ruta(){}

View File

@ -9,9 +9,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -40,7 +38,6 @@ import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
import verdnatura.es.repartoverdnatura.MODELS.Check; import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.MODELS.Ruta; import verdnatura.es.repartoverdnatura.MODELS.Ruta;
import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload; import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload;
import verdnatura.es.repartoverdnatura.MODELS.Version;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils; import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
import verdnatura.es.repartoverdnatura.UTILS.LocalStorage; import verdnatura.es.repartoverdnatura.UTILS.LocalStorage;
import verdnatura.es.repartoverdnatura.UTILS.Utils; import verdnatura.es.repartoverdnatura.UTILS.Utils;
@ -105,53 +102,53 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
super.onRestart(); super.onRestart();
} }
private void setViews(){ private void setViews() {
listViewRutas = findViewById(R.id.listRutas); listViewRutas = findViewById(R.id.listRutas);
listViewPendingTickets = findViewById(R.id.listPendingTickets); listViewPendingTickets = findViewById(R.id.listPendingTickets);
heightCellRoute = Utils.convertDipToPixels(160f,this); heightCellRoute = Utils.convertDipToPixels(160f, this);
heightCellHeader = Utils.convertDipToPixels(45f,this); heightCellHeader = Utils.convertDipToPixels(45f, this);
txtDriver = findViewById(R.id.textView3); txtDriver = findViewById(R.id.textView3);
btnUpload = findViewById(R.id.btnUpload); btnUpload = findViewById(R.id.btnUpload);
} }
public void getRoutes(View v){ public void getRoutes(View v) {
date = new Date(); date = new Date();
final MainActivity that = this; final MainActivity that = this;
listaRutas = new ArrayList<>(); listaRutas = new ArrayList<>();
listViewRutas.setVisibility(View.VISIBLE); listViewRutas.setVisibility(View.VISIBLE);
Utils.progressBar.show(this,getResources().getString(R.string.please_wait)); Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
restClient.getRoutes(Utils.getMapWhitUser(this)).enqueue(new Callback<List<Ruta>>() { restClient.getRoutes(Utils.getMapWhitUser(this)).enqueue(new Callback<List<Ruta>>() {
@Override @Override
public void onResponse(Call<List<Ruta>> call, Response<List<Ruta>> response) { public void onResponse(Call<List<Ruta>> call, Response<List<Ruta>> response) {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){ if (response.isSuccessful()) {
//d("VERDNATURA::","recibidos datos"); //d("VERDNATURA::","recibidos datos");
for (Ruta ruta : response.body()){ for (Ruta ruta : response.body()) {
// d("VERDNATURA::","ruta"+ruta.getId()); // d("VERDNATURA::","ruta"+ruta.getId());
LocalStorage.saveRutas(that,response.body()); LocalStorage.saveRutas(that, response.body());
//d("VERDNATURA::","guardado"); //d("VERDNATURA::","guardado");
//txtDriver.setText(ruta.getDriver()); //txtDriver.setText(ruta.getDriver());
try { try {
if (date.compareTo(format.parse(ruta.getDate())) == 0){ if (date.compareTo(format.parse(ruta.getDate())) == 0) {
listaRutas.add(ruta); listaRutas.add(ruta);
}else{ } else {
date = format.parse(ruta.getDate()); date = format.parse(ruta.getDate());
Ruta rutaHeader = new Ruta(); Ruta rutaHeader = new Ruta();
rutaHeader.setHeader(true); rutaHeader.setHeader(true);
rutaHeader.setDate(ruta.getDate()); rutaHeader.setDate(ruta.getDate());
listaRutas.add(rutaHeader); listaRutas.add(rutaHeader);
listaRutas.add(ruta); listaRutas.add(ruta);
} }
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
that.rutaAdapter = new RutaAdapter(that,listaRutas); that.rutaAdapter = new RutaAdapter(that, listaRutas);
that.listViewRutas.setAdapter(that.rutaAdapter); that.listViewRutas.setAdapter(that.rutaAdapter);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams(); ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size())); params.height = (heightCellRoute * (listaRutas.size()));
@ -160,9 +157,9 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
// checkVersion(); // checkVersion();
LocalStorage.checkDateForClear(that); LocalStorage.checkDateForClear(that);
// getExpeditions(); // getExpeditions();
}else{ } else {
getLocalData(); getLocalData();
} }
@ -177,32 +174,32 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
} }
public void goToCargarBultos(View v){ public void goToCargarBultos(View v) {
// Intent i = new Intent(this,CargarBultosActivity.class); // Intent i = new Intent(this,CargarBultosActivity.class);
Intent i = new Intent(this,LoadVanActivity.class); Intent i = new Intent(this, LoadVanActivity.class);
startActivity(i); startActivity(i);
} }
public void goToExpeditionInfo(View v){ public void goToExpeditionInfo(View v) {
/* /*
Intent i = new Intent(this,ExpeditionInfoActivity.class); Intent i = new Intent(this,ExpeditionInfoActivity.class);
startActivity(i);*/ startActivity(i);*/
Utils.startPicking(this,"log"); Utils.startPicking(this, "log");
} }
public void getLocalData(){ public void getLocalData() {
List<Ruta> list = LocalStorage.getRutas(this); List<Ruta> list = LocalStorage.getRutas(this);
if (list.size() > 0){ if (list.size() > 0) {
for (Ruta ruta : list){ for (Ruta ruta : list) {
txtDriver.setText(ruta.getDriver()); txtDriver.setText(ruta.getDriver());
try { try {
if (date.compareTo(format.parse(ruta.getDate())) == 0){ if (date.compareTo(format.parse(ruta.getDate())) == 0) {
listaRutas.add(ruta); listaRutas.add(ruta);
}else{ } else {
date = format.parse(ruta.getDate()); date = format.parse(ruta.getDate());
Ruta rutaHeader = new Ruta(); Ruta rutaHeader = new Ruta();
rutaHeader.setHeader(true); rutaHeader.setHeader(true);
@ -215,22 +212,22 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
} }
} }
this.rutaAdapter = new RutaAdapter(this,listaRutas); this.rutaAdapter = new RutaAdapter(this, listaRutas);
this.listViewRutas.setAdapter(this.rutaAdapter); this.listViewRutas.setAdapter(this.rutaAdapter);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams(); ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size())); params.height = (heightCellRoute * (listaRutas.size()));
listViewRutas.setLayoutParams(params); listViewRutas.setLayoutParams(params);
}else{ } else {
txtDriver.setText(this.getResources().getString(R.string.reparto)); txtDriver.setText(this.getResources().getString(R.string.reparto));
listViewRutas.setVisibility(View.GONE); listViewRutas.setVisibility(View.GONE);
} }
} }
public void getExpeditions(){ public void getExpeditions() {
List<Ruta> list = LocalStorage.getRutas(this); List<Ruta> list = LocalStorage.getRutas(this);
if (list.size() > 0){ if (list.size() > 0) {
for (Ruta ruta : list){ for (Ruta ruta : list) {
try { try {
@ -241,59 +238,59 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
} }
} }
this.rutaAdapter = new RutaAdapter(this,listaRutas); this.rutaAdapter = new RutaAdapter(this, listaRutas);
this.listViewRutas.setAdapter(this.rutaAdapter); this.listViewRutas.setAdapter(this.rutaAdapter);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams(); ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size())); params.height = (heightCellRoute * (listaRutas.size()));
listViewRutas.setLayoutParams(params); listViewRutas.setLayoutParams(params);
}else{ } else {
txtDriver.setText(this.getResources().getString(R.string.reparto)); txtDriver.setText(this.getResources().getString(R.string.reparto));
listViewRutas.setVisibility(View.GONE); listViewRutas.setVisibility(View.GONE);
} }
} }
private void getPengingExpeditions(){ private void getPengingExpeditions() {
ArrayList<Check>listExpeditionPending = new ArrayList<>(); ArrayList<Check> listExpeditionPending = new ArrayList<>();
Set<String> listPendientes = LocalStorage.getPendingExpeditions(this); Set<String> listPendientes = LocalStorage.getPendingExpeditions(this);
Gson gson = new Gson(); Gson gson = new Gson();
if (listPendientes.size() > 0 ){ if (listPendientes.size() > 0) {
for(String s : listPendientes){ for (String s : listPendientes) {
listExpeditionPending.add(gson.fromJson(s,Check.class)); listExpeditionPending.add(gson.fromJson(s, Check.class));
} }
// Log.d("VERDNATURA::","Pendientes:"+ listExpeditionPending.size()); // Log.d("VERDNATURA::","Pendientes:"+ listExpeditionPending.size());
if (listExpeditionPending.size()>0) { if (listExpeditionPending.size() > 0) {
sendPengingExpeditionsList(listExpeditionPending,"DELIVERED"); sendPengingExpeditionsList(listExpeditionPending, "DELIVERED");
} }
}else{ } else {
// Log.d("VERDNATURA::","No hay Pendientes"+ listExpeditionPending.size()); // Log.d("VERDNATURA::","No hay Pendientes"+ listExpeditionPending.size());
} }
} }
public void sendPengingExpeditionsList(final List<Check> listPending, String state){ public void sendPengingExpeditionsList(final List<Check> listPending, String state) {
final MainActivity that = this; final MainActivity that = this;
Object[] stateData = new Object[2]; Object[] stateData = new Object[2];
stateData[0]= listPending; stateData[0] = listPending;
stateData[1]=state; stateData[1] = state;
restClient.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this),stateData).enqueue(new Callback<Void>() { restClient.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this), stateData).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){ if (response.isSuccessful()) {
// Log.d("VERDNATURA::","enviados pendientes"); // Log.d("VERDNATURA::","enviados pendientes");
clearPendingExpedition(that); clearPendingExpedition(that);
}else{ } else {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
} }
@ -307,90 +304,87 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
} }
private void getPending(){ private void getPending() {
// Log.d("VERDNATURA::","Se ha cambiado la red"); // Log.d("VERDNATURA::","Se ha cambiado la red");
listaPendientes = new ArrayList<>(); listaPendientes = new ArrayList<>();
Set<String> listPendientes = LocalStorage.getPendingSigns(this); Set<String> listPendientes = LocalStorage.getPendingSigns(this);
Gson gson = new Gson(); Gson gson = new Gson();
for(String s : listPendientes){ for (String s : listPendientes) {
listaPendientes.add(gson.fromJson(s,SignDataUpload.class)); listaPendientes.add(gson.fromJson(s, SignDataUpload.class));
} }
ViewGroup.LayoutParams params = listViewPendingTickets.getLayoutParams(); ViewGroup.LayoutParams params = listViewPendingTickets.getLayoutParams();
params.height = (heightCellRoute * (listaPendientes.size())); params.height = (heightCellRoute * (listaPendientes.size()));
listViewPendingTickets.setLayoutParams(params); listViewPendingTickets.setLayoutParams(params);
pendingAdapter = new PendingTickets(this,listaPendientes); pendingAdapter = new PendingTickets(this, listaPendientes);
listViewPendingTickets.setAdapter(pendingAdapter); listViewPendingTickets.setAdapter(pendingAdapter);
if (listPendientes.size() > 0 ){ if (listPendientes.size() > 0) {
btnUpload.setVisibility(View.VISIBLE); btnUpload.setVisibility(View.VISIBLE);
}else{ } else {
btnUpload.setVisibility(View.GONE); btnUpload.setVisibility(View.GONE);
} }
} }
public void onRouteSelected(int pos){ public void onRouteSelected(int pos) {
Intent i = new Intent(this,Tickets.class); Intent i = new Intent(this, Tickets.class);
i.putExtra("route",listaRutas.get(pos)); i.putExtra("route", listaRutas.get(pos));
startActivity(i); startActivity(i);
} }
public void onLoadSelected(int pos){ public void onLoadSelected(int pos) {
// Intent i = new Intent(this,LoadVanActivity.class); // Intent i = new Intent(this,LoadVanActivity.class);
Intent i=new Intent(this,ExpeditionSummaryActivity.class); Intent i = new Intent(this, ExpeditionSummaryActivity.class);
i.putExtra("route",listaRutas.get(pos)); i.putExtra("route", listaRutas.get(pos));
startActivity(i); startActivity(i);
} }
public void logOut(View v) {
final MainActivity that = this;
public void logOut(View v){ if (listaPendientes.size() > 0) {
final MainActivity that = this; new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("ATENCIÓN")
.setMessage("Tienes tickets pendientes de actualizar,¿Estás seguro de cerrar sesión?")
.setPositiveButton("Si", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Utils.logOut(that);
finish();
}
if (listaPendientes.size() > 0){ })
new AlertDialog.Builder(this) .setNegativeButton("No", null)
.setIcon(android.R.drawable.ic_dialog_alert) .show();
.setTitle("ATENCIÓN") } else {
.setMessage("Tienes tickets pendientes de actualizar,¿Estás seguro de cerrar sesión?") new AlertDialog.Builder(this)
.setPositiveButton("Si", new DialogInterface.OnClickListener() .setIcon(android.R.drawable.ic_dialog_alert)
{ .setTitle("Cerrar sesión")
@Override .setMessage("¿Estás seguro de cerrar sesión?")
public void onClick(DialogInterface dialog, int which) { .setPositiveButton("Si", new DialogInterface.OnClickListener() {
Utils.logOut(that); @Override
finish(); public void onClick(DialogInterface dialog, int which) {
} Utils.logOut(that);
finish();
}) }
.setNegativeButton("No", null)
.show();
}else{
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Cerrar sesión")
.setMessage("¿Estás seguro de cerrar sesión?")
.setPositiveButton("Si", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
Utils.logOut(that);
finish();
}
})
.setNegativeButton("No", null)
.show();
}
})
.setNegativeButton("No", null)
.show();
}
} }
public void goToInfo(View v){ public void goToInfo(View v) {
// startActivity(new Intent(this,InfoActivity.class)); // startActivity(new Intent(this,InfoActivity.class));
Utils.startPicking(this,"info"); Utils.startPicking(this, "info");
} }
public void goToFound(View v){
startActivity(new Intent(this,ExpeditionScanActivity.class)); public void goToFound(View v) {
startActivity(new Intent(this, ExpeditionScanActivity.class));
} }
/* public void goToLoaders(int pos){ /* public void goToLoaders(int pos){
Intent i = new Intent(this,LoadersActivity.class); Intent i = new Intent(this,LoadersActivity.class);
@ -398,37 +392,37 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
startActivity(i); startActivity(i);
}*/ }*/
public void savePending(int pos){ public void savePending(int pos) {
SignDataUpload data = listaPendientes.get(pos); SignDataUpload data = listaPendientes.get(pos);
confirmSave(data); confirmSave(data);
} }
public void confirmSave(final SignDataUpload data){ public void confirmSave(final SignDataUpload data) {
Utils.progressBar.show(this,getResources().getString(R.string.please_wait)); Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
final MainActivity that = this; final MainActivity that = this;
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0] = data; args[0] = data;
restClient.saveSign(Utils.getMapWhitUser(this),args).enqueue(new Callback<Void>() { restClient.saveSign(Utils.getMapWhitUser(this), args).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){ if (response.isSuccessful()) {
// if (response.body().equals("OK")){ // if (response.body().equals("OK")){
ArrayList<SignDataUpload> listAux = new ArrayList<>(); ArrayList<SignDataUpload> listAux = new ArrayList<>();
listaPendientes.remove(data); listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that,listaPendientes); LocalStorage.udpatePendingSigns(that, listaPendientes);
getPending(); getPending();
/* }else{ /* }else{
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion)); Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
}*/ }*/
}else{ } else {
//Log.i("ERROR","error al guardar"); //Log.i("ERROR","error al guardar");
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion)); Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
//Utils.showErrorDialog(that,response.message()); //Utils.showErrorDialog(that,response.message());
} }
} }
@ -436,12 +430,12 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
@Override @Override
public void onFailure(Call<Void> call, Throwable t) { public void onFailure(Call<Void> call, Throwable t) {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion)); Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
} }
}); });
} }
public void confirmSavePos(View v){ public void confirmSavePos(View v) {
if (listaPendientes.size() > 0) { if (listaPendientes.size() > 0) {
Utils.progressBar.show(this, getResources().getString(R.string.please_wait)); Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
final SignDataUpload data = listaPendientes.get(0); final SignDataUpload data = listaPendientes.get(0);
@ -454,13 +448,13 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
if (response.isSuccessful()) { if (response.isSuccessful()) {
listaPendientes.remove(data); listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that, listaPendientes); LocalStorage.udpatePendingSigns(that, listaPendientes);
confirmSavePos(null); confirmSavePos(null);
} else { } else {
Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion)); Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
} }
} }
@ -470,75 +464,12 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion)); Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
} }
}); });
}else{ } else {
Utils.progressBar.getDialog().dismiss(); Utils.progressBar.getDialog().dismiss();
getPending(); getPending();
} }
} }
public void checkVersion(){
String[] userData = new String[1];
userData[0] = "delivery";
final MainActivity that = this;
//sergio: se cambia llamada Callback porque requeria un objeto y se le pasaba un true o false
restClient.getVersion(Utils.getMapWhitUser(this),userData).enqueue(new Callback<Version>() {
//restClient.getVersion(Utils.getMapWhitUser(this),userData).enqueue(new Callback<String>() {
@Override
public void onResponse(Call<Version> call, Response<Version> response) {
if (response.isSuccessful()){
final Version v = response.body();
PackageManager manager = that.getPackageManager();
try{
PackageInfo info = manager.getPackageInfo(that.getPackageName(), 0);
if (!v.getVersion().equals(info.versionName)){
AlertDialog.Builder builderVersion = new AlertDialog.Builder(that);
builderVersion.setMessage("Existe una nueva versión. Se recomienda actualizar.");
builderVersion.setCancelable(false);
builderVersion.setPositiveButton(
"Actualizar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(v.getUrl())));
}
});
if (!v.getVersionIsCritical().equals("1")){
builderVersion.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
}else{
builderVersion.setMessage("Existe una nueva versión. Es necesario actualizar para un correcto funcionamiento");
}
AlertDialog alertVersion = builderVersion.create();
alertVersion.show();
}
}catch (Exception e){
}
}else{
}
}
@Override
public void onFailure(Call<Version> call, Throwable t) {
}
});
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();

View File

@ -15,6 +15,8 @@ import android.widget.EditText;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import verdnatura.es.repartoverdnatura.LoginActivity;
public class Utils { public class Utils {
static SharedPreferences sp; static SharedPreferences sp;
@ -212,12 +214,12 @@ public class Utils {
Intent i = new Intent(); Intent i = new Intent();
//i.setClassName("es.verdnatura", "es.verdnatura.presentation.view.feature.login.activity.LoginActivity") //i.setClassName("es.verdnatura", "es.verdnatura.presentation.view.feature.login.activity.LoginActivity")
i.setClassName("es.verdnatura.sfusion", "es.verdnatura.presentation.view.feature.main.activity.MainActivity");
i.setClassName("es.verdnatura", "es.verdnatura.presentation.view.feature.main.activity.MainActivity");
i.putExtra("user", getUser(context)); i.putExtra("user", getUser(context));
i.putExtra("password", getPass(context)); i.putExtra("password", getPass(context));
i.putExtra("userfk", Utils.getIdUserLogin(context));
i.putExtra("menu", option); i.putExtra("menu", option);
context.startActivity(i); context.startActivity(i);
} }
} }