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>
</component>
<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.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" />
@ -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/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/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$/.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/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</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">
<projectState path="$PROJECT_DIR$">
<ProjectState />
@ -369,7 +360,7 @@
<breakpoints>
<line-breakpoint enabled="true" type="kotlin-line">
<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" />
</line-breakpoint>
</breakpoints>

View File

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

View File

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

View File

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

View File

@ -9,9 +9,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
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.Ruta;
import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload;
import verdnatura.es.repartoverdnatura.MODELS.Version;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
import verdnatura.es.repartoverdnatura.UTILS.LocalStorage;
import verdnatura.es.repartoverdnatura.UTILS.Utils;
@ -105,53 +102,53 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
super.onRestart();
}
private void setViews(){
private void setViews() {
listViewRutas = findViewById(R.id.listRutas);
listViewPendingTickets = findViewById(R.id.listPendingTickets);
heightCellRoute = Utils.convertDipToPixels(160f,this);
heightCellHeader = Utils.convertDipToPixels(45f,this);
heightCellRoute = Utils.convertDipToPixels(160f, this);
heightCellHeader = Utils.convertDipToPixels(45f, this);
txtDriver = findViewById(R.id.textView3);
btnUpload = findViewById(R.id.btnUpload);
}
}
public void getRoutes(View v){
public void getRoutes(View v) {
date = new Date();
final MainActivity that = this;
listaRutas = new ArrayList<>();
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>>() {
@Override
public void onResponse(Call<List<Ruta>> call, Response<List<Ruta>> response) {
Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){
if (response.isSuccessful()) {
//d("VERDNATURA::","recibidos datos");
for (Ruta ruta : response.body()){
// d("VERDNATURA::","ruta"+ruta.getId());
LocalStorage.saveRutas(that,response.body());
//d("VERDNATURA::","guardado");
//txtDriver.setText(ruta.getDriver());
try {
for (Ruta ruta : response.body()) {
// d("VERDNATURA::","ruta"+ruta.getId());
LocalStorage.saveRutas(that, response.body());
//d("VERDNATURA::","guardado");
//txtDriver.setText(ruta.getDriver());
try {
if (date.compareTo(format.parse(ruta.getDate())) == 0){
listaRutas.add(ruta);
}else{
date = format.parse(ruta.getDate());
Ruta rutaHeader = new Ruta();
rutaHeader.setHeader(true);
rutaHeader.setDate(ruta.getDate());
listaRutas.add(rutaHeader);
listaRutas.add(ruta);
}
} catch (ParseException e) {
e.printStackTrace();
}
if (date.compareTo(format.parse(ruta.getDate())) == 0) {
listaRutas.add(ruta);
} else {
date = format.parse(ruta.getDate());
Ruta rutaHeader = new Ruta();
rutaHeader.setHeader(true);
rutaHeader.setDate(ruta.getDate());
listaRutas.add(rutaHeader);
listaRutas.add(ruta);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
that.rutaAdapter = new RutaAdapter(that,listaRutas);
that.rutaAdapter = new RutaAdapter(that, listaRutas);
that.listViewRutas.setAdapter(that.rutaAdapter);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size()));
@ -160,9 +157,9 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
// checkVersion();
LocalStorage.checkDateForClear(that);
// getExpeditions();
// getExpeditions();
}else{
} else {
getLocalData();
}
@ -177,32 +174,32 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
}
public void goToCargarBultos(View v){
// Intent i = new Intent(this,CargarBultosActivity.class);
public void goToCargarBultos(View v) {
// Intent i = new Intent(this,CargarBultosActivity.class);
Intent i = new Intent(this,LoadVanActivity.class);
Intent i = new Intent(this, LoadVanActivity.class);
startActivity(i);
}
public void goToExpeditionInfo(View v){
public void goToExpeditionInfo(View v) {
/*
Intent i = new Intent(this,ExpeditionInfoActivity.class);
startActivity(i);*/
Utils.startPicking(this,"log");
Utils.startPicking(this, "log");
}
public void getLocalData(){
public void getLocalData() {
List<Ruta> list = LocalStorage.getRutas(this);
if (list.size() > 0){
for (Ruta ruta : list){
if (list.size() > 0) {
for (Ruta ruta : list) {
txtDriver.setText(ruta.getDriver());
try {
if (date.compareTo(format.parse(ruta.getDate())) == 0){
if (date.compareTo(format.parse(ruta.getDate())) == 0) {
listaRutas.add(ruta);
}else{
} else {
date = format.parse(ruta.getDate());
Ruta rutaHeader = new Ruta();
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);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size()));
listViewRutas.setLayoutParams(params);
}else{
} else {
txtDriver.setText(this.getResources().getString(R.string.reparto));
listViewRutas.setVisibility(View.GONE);
}
}
public void getExpeditions(){
public void getExpeditions() {
List<Ruta> list = LocalStorage.getRutas(this);
if (list.size() > 0){
for (Ruta ruta : list){
if (list.size() > 0) {
for (Ruta ruta : list) {
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);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
params.height = (heightCellRoute * (listaRutas.size()));
listViewRutas.setLayoutParams(params);
}else{
} else {
txtDriver.setText(this.getResources().getString(R.string.reparto));
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);
Gson gson = new Gson();
if (listPendientes.size() > 0 ){
for(String s : listPendientes){
listExpeditionPending.add(gson.fromJson(s,Check.class));
if (listPendientes.size() > 0) {
for (String s : listPendientes) {
listExpeditionPending.add(gson.fromJson(s, Check.class));
}
// Log.d("VERDNATURA::","Pendientes:"+ listExpeditionPending.size());
if (listExpeditionPending.size()>0) {
sendPengingExpeditionsList(listExpeditionPending,"DELIVERED");
// Log.d("VERDNATURA::","Pendientes:"+ listExpeditionPending.size());
if (listExpeditionPending.size() > 0) {
sendPengingExpeditionsList(listExpeditionPending, "DELIVERED");
}
}else{
// Log.d("VERDNATURA::","No hay Pendientes"+ listExpeditionPending.size());
} else {
// 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;
Object[] stateData = new Object[2];
stateData[0]= listPending;
stateData[1]=state;
stateData[0] = listPending;
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
public void onResponse(Call<Void> call, Response<Void> response) {
Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){
if (response.isSuccessful()) {
// Log.d("VERDNATURA::","enviados pendientes");
// Log.d("VERDNATURA::","enviados pendientes");
clearPendingExpedition(that);
}else{
} else {
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<>();
Set<String> listPendientes = LocalStorage.getPendingSigns(this);
Gson gson = new Gson();
for(String s : listPendientes){
listaPendientes.add(gson.fromJson(s,SignDataUpload.class));
for (String s : listPendientes) {
listaPendientes.add(gson.fromJson(s, SignDataUpload.class));
}
ViewGroup.LayoutParams params = listViewPendingTickets.getLayoutParams();
params.height = (heightCellRoute * (listaPendientes.size()));
listViewPendingTickets.setLayoutParams(params);
pendingAdapter = new PendingTickets(this,listaPendientes);
pendingAdapter = new PendingTickets(this, listaPendientes);
listViewPendingTickets.setAdapter(pendingAdapter);
if (listPendientes.size() > 0 ){
if (listPendientes.size() > 0) {
btnUpload.setVisibility(View.VISIBLE);
}else{
} else {
btnUpload.setVisibility(View.GONE);
}
}
public void onRouteSelected(int pos){
Intent i = new Intent(this,Tickets.class);
i.putExtra("route",listaRutas.get(pos));
public void onRouteSelected(int pos) {
Intent i = new Intent(this, Tickets.class);
i.putExtra("route", listaRutas.get(pos));
startActivity(i);
}
public void onLoadSelected(int pos){
// Intent i = new Intent(this,LoadVanActivity.class);
Intent i=new Intent(this,ExpeditionSummaryActivity.class);
i.putExtra("route",listaRutas.get(pos));
public void onLoadSelected(int pos) {
// Intent i = new Intent(this,LoadVanActivity.class);
Intent i = new Intent(this, ExpeditionSummaryActivity.class);
i.putExtra("route", listaRutas.get(pos));
startActivity(i);
}
public void logOut(View v) {
final MainActivity that = this;
public void logOut(View v){
final MainActivity that = this;
if (listaPendientes.size() > 0) {
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)
.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();
}
})
.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();
} 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();
}
}
public void goToInfo(View v){
// startActivity(new Intent(this,InfoActivity.class));
Utils.startPicking(this,"info");
public void goToInfo(View v) {
// startActivity(new Intent(this,InfoActivity.class));
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){
Intent i = new Intent(this,LoadersActivity.class);
@ -398,37 +392,37 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
startActivity(i);
}*/
public void savePending(int pos){
public void savePending(int pos) {
SignDataUpload data = listaPendientes.get(pos);
confirmSave(data);
}
public void confirmSave(final SignDataUpload data){
Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
public void confirmSave(final SignDataUpload data) {
Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
final MainActivity that = this;
Object[] args = new Object[1];
args[0] = data;
restClient.saveSign(Utils.getMapWhitUser(this),args).enqueue(new Callback<Void>() {
restClient.saveSign(Utils.getMapWhitUser(this), args).enqueue(new Callback<Void>() {
@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")){
ArrayList<SignDataUpload> listAux = new ArrayList<>();
// if (response.body().equals("OK")){
ArrayList<SignDataUpload> listAux = new ArrayList<>();
listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that,listaPendientes);
getPending();
listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that, listaPendientes);
getPending();
/* }else{
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
}*/
}else{
} else {
//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());
}
}
@ -436,12 +430,12 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
@Override
public void onFailure(Call<Void> call, Throwable t) {
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) {
Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
final SignDataUpload data = listaPendientes.get(0);
@ -454,13 +448,13 @@ public class MainActivity<RouteLoaded> extends AppCompatActivity {
if (response.isSuccessful()) {
listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that, listaPendientes);
confirmSavePos(null);
listaPendientes.remove(data);
LocalStorage.udpatePendingSigns(that, listaPendientes);
confirmSavePos(null);
} else {
Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
}
} else {
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));
}
});
}else{
} else {
Utils.progressBar.getDialog().dismiss();
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
protected void onDestroy() {
super.onDestroy();

View File

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