diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin
index dd09cb7..798b2c1 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock
index 41b05b6..b4bf239 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin
index 5f42a1c..abf2334 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock
index 8fd5c15..b069111 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
index 91c880b..211a36c 100644
Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin
index 13f3185..d3a1c0f 100644
Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/jarAnalysis.bin b/.gradle/5.4.1/javaCompile/jarAnalysis.bin
index 4c9c01d..aa1d18d 100644
Binary files a/.gradle/5.4.1/javaCompile/jarAnalysis.bin and b/.gradle/5.4.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock
index e7da753..1f56630 100644
Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/5.4.1/javaCompile/taskHistory.bin b/.gradle/5.4.1/javaCompile/taskHistory.bin
index c28b162..5d3a8fd 100644
Binary files a/.gradle/5.4.1/javaCompile/taskHistory.bin and b/.gradle/5.4.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 0537e5e..562182b 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index cbdca2a..80c8fe4 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fb7f4a8..61a9130 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
deleted file mode 100644
index 716b52b..0000000
--- a/.idea/deploymentTargetDropDown.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4660ee8..c49333c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -96,7 +96,7 @@
-
+
diff --git a/.idea/modules/app/vn-delivery.app.iml b/.idea/modules/app/vn-delivery.app.iml
index b6290d5..eaa4acc 100644
--- a/.idea/modules/app/vn-delivery.app.iml
+++ b/.idea/modules/app/vn-delivery.app.iml
@@ -10,17 +10,12 @@
-
-
-
-
- generateReleaseSources
-
+
-
-
+
+
diff --git a/.idea/modules/app/vn-delivery.app.main.iml b/.idea/modules/app/vn-delivery.app.main.iml
index 068e68c..c201235 100644
--- a/.idea/modules/app/vn-delivery.app.main.iml
+++ b/.idea/modules/app/vn-delivery.app.main.iml
@@ -7,12 +7,15 @@
-
-
+
+
-
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
@@ -98,17 +95,16 @@
+
+
-
-
-
@@ -153,6 +149,8 @@
+
+
diff --git a/.idea/modules/app/vn-delivery.app.unitTest.iml b/.idea/modules/app/vn-delivery.app.unitTest.iml
index 8f59da8..c69c224 100644
--- a/.idea/modules/app/vn-delivery.app.unitTest.iml
+++ b/.idea/modules/app/vn-delivery.app.unitTest.iml
@@ -3,17 +3,12 @@
-
-
-
-
- generateReleaseSources
-
+
-
-
+
+
@@ -23,18 +18,18 @@
-
-
+
+
-
+
-
-
-
-
+
+
+
+
@@ -52,24 +47,23 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
@@ -91,6 +85,7 @@
+
@@ -99,9 +94,7 @@
-
-
@@ -147,6 +140,8 @@
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5c6b7eb..e569763 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -40,157 +40,45 @@
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
-
+
-
+
@@ -241,11 +129,16 @@
-
+
+
-
-
+
+
+
+
+
+
@@ -255,43 +148,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {
+ "keyToString": {
+ "ApkExportedModule": "vn-delivery.app",
+ "ExportApk.ApkPathForvn-delivery.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-delivery\\",
+ "PROJECT_TRUSTED_KEY": "true",
+ "RunOnceActivity.cidr.known.project.marker": "true",
+ "android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-28/android/widget/AbsListView.java_SELECTED": "AbsListView",
+ "android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-28/android/widget/ListView.java_SELECTED": "ListView",
+ "cidr.known.project.marker": "true",
+ "last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-picture/platforms/android"
+ },
+ "keyToStringList": {
+ "ExportApk.BuildVariants": [
+ "release"
+ ]
+ }
+}
@@ -330,8 +203,8 @@
-
-
+
+
@@ -339,13 +212,14 @@
+
-
+
@@ -375,7 +249,7 @@
-
+
@@ -450,7 +324,14 @@
1667978187874
-
+
+ 1673366849427
+
+
+
+ 1673366849427
+
+
@@ -473,14 +354,26 @@
-
-
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt
+ 319
+
+
+
+
diff --git a/apk/release/output.json b/apk/release/output.json
deleted file mode 100644
index 0178c9f..0000000
--- a/apk/release/output.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":30,"versionName":"23.2Beta","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 421fc27..1794cca 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,8 +7,9 @@ android {
applicationId "verdnatura.es.repartoverdnatura"
minSdkVersion 19
//targetSdkVersion 28
- versionCode 30
+ versionCode 33
versionName "23.2Beta"
+ //versionName "23.2Beta" Madrid 33
//versionName "9.6.1Beta" //versionCode 27
//versionName "9.6"
//versionName "9.5" versionCode 26
@@ -22,9 +23,19 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
- getByName("release") {
+ /* getByName("release") {
applicationIdSuffix = ".sfusion"
}
+ getByName("debug") {
+ applicationIdSuffix = ".sfusion"
+ }*/
+ getByName("release") {
+ applicationIdSuffix = ".sfusionMadrid"
+ }
+ getByName("debug") {
+ applicationIdSuffix = ".sfusionMadrid"
+ }
+
}
}
diff --git a/app/google-services.json b/app/google-services.json
index 1a1dca9..856ce03 100644
--- a/app/google-services.json
+++ b/app/google-services.json
@@ -10,7 +10,7 @@
"client_info": {
"mobilesdk_app_id": "1:622584359076:android:49dda1d8a6dc59f9",
"android_client_info": {
- "package_name": "verdnatura.es.repartoverdnatura.sfusion"
+ "package_name": "verdnatura.es.repartoverdnatura.sfusionMadrid"
}
},
"oauth_client": [
@@ -18,7 +18,7 @@
"client_id": "622584359076-0ph8u7jfg7ifgs6qe4ueb6oqj9c8mv36.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
- "package_name": "verdnatura.es.repartoverdnatura.sfusion",
+ "package_name": "verdnatura.es.repartoverdnatura.sfusionMadrid",
"certificate_hash": "1495f9252766a51f3c48f2e9c8789c85cee831d0"
}
},
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
deleted file mode 100644
index 14bf209..0000000
Binary files a/app/release/app-release.apk and /dev/null differ
diff --git a/app/release/output.json b/app/release/output.json
index f1e2939..0178c9f 100644
--- a/app/release/output.json
+++ b/app/release/output.json
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"9","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":30,"versionName":"23.2Beta","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt b/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt
index 84c066f..129f852 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/ExpeditionSummaryActivity.kt
@@ -6,13 +6,10 @@ import android.content.Intent
import android.media.MediaPlayer
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
+import android.util.Log.d
import android.view.View
-import android.view.View.OnFocusChangeListener
import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import android.widget.ListView
-import android.widget.TextView
-import android.widget.Toast
+import android.widget.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@@ -25,7 +22,6 @@ import verdnatura.es.repartoverdnatura.UTILS.ApiUtils
import verdnatura.es.repartoverdnatura.UTILS.LocalStorage
import verdnatura.es.repartoverdnatura.UTILS.Utils
-
class ExpeditionSummaryActivity : AppCompatActivity() {
var mpError: MediaPlayer? = null
var mpOk: MediaPlayer? = null
@@ -56,7 +52,7 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
var totalSend = 0
var totalSendSuccessful = 0
var positionSelected: Int? = null
-
+ var positionOnScreen: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -89,6 +85,7 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
changeTitle(route = routeOfLoad)
setEvents()
+ setViews()
}
@@ -97,14 +94,30 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
+ private fun setViews() {
+ listView!!.setOnScrollListener(object : AbsListView.OnScrollListener {
+ override fun onScrollStateChanged(view: AbsListView, scrollState: Int) {
+ }
+
+ override fun onScroll(
+ view: AbsListView,
+ firstVisibleItem: Int,
+ visibleItemCount: Int,
+ totalItemCount: Int
+ ) {
+ positionOnScreen = firstVisibleItem
+
+ }
+ })
+ }
override fun onResume() {
- super.onResume()
+ super.onResume()
listExpeditionSummary.clear()
+
expedition_getSummary()
if (textAddressSelected!!.text.isNotEmpty()) {
-
checks
txtScan!!.requestFocus()
}
@@ -114,25 +127,40 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
adress: String?,
position: Int
) {
-
//itemScaneed es para ver si se ha escaneado algo y es diferente los consignatarios
positionSelected = position
if (itemScanned && !(textAddressSelected!!.text).equals(adress)) {
totalSend = 2
- Utils.progressBar.show(this, getResources().getString(R.string.please_wait))
- expeditionState_addByExpeditionMulti(listCheck
- .filter { it.addressFk == textAddressSelected!!.text }
- .filter { it.routeFk == textViewRoute!!.text }
- .filter { it.code == "ON DELIVERY" }, "ON DELIVERY"
- )
+ if (listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code == "ON DELIVERY" }.isNotEmpty()
+ ) {
+ Utils.progressBar.show(this, getResources().getString(R.string.please_wait))
+ expeditionState_addByExpeditionMulti(listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code == "ON DELIVERY" }, "ON DELIVERY"
+ )
+ } else {
+ totalSend = -1
+ }
- expeditionState_addByExpeditionMulti(listCheck
- .filter { it.addressFk == textAddressSelected!!.text }
- .filter { it.routeFk == textViewRoute!!.text }
- .filter { it.code != "ON DELIVERY" }, "LOST"
- )
+ if (listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code != "ON DELIVERY" }.isNotEmpty()
+ ) {
+ expeditionState_addByExpeditionMulti(listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code != "ON DELIVERY" }, "LOST"
+ )
+ } else {
+ totalSend = -1
+ }
itemScanned = false
}
@@ -145,7 +173,8 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
- private val checks: Unit
+ private
+ val checks: Unit
get() {
val listDownload: ArrayList = ArrayList()
@@ -166,7 +195,6 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
if (response.isSuccessful) {
for (c in response.body()!!) {
-
if (!c.code.isNullOrBlank()) {
if (c.code.equals("ON DELIVERY")) {
@@ -208,7 +236,6 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
fun getLocalDataExpedition() {
-
val list: List = LocalStorage.getExpeditions(this)
listCheck = LocalStorage.getExpeditions(this)
if (list.size > 0) {
@@ -221,19 +248,18 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
.filter { it.routeFk == textViewRoute!!.text }
.filter { it.checked == "1" || it.code == "ON DELIVERY" }.size
- textLoaded!!.text = checked.toString() + "/" + totalChecks.toString() + " cargadas"
+ textLoaded!!.text =
+ checked.toString() + "/" + totalChecks.toString() + " cargadas"
hideKeyboard()
}
-
}
-
private fun expedition_getSummary() {
-
+ var oldPosition = positionOnScreen
Utils.progressBar.show(this, resources.getString(R.string.please_wait))
val routeData: Array = arrayOfNulls(1)
@@ -242,7 +268,6 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
restClient!!.route_getExpeditionSummary(Utils.getMapWhitUser(this), routeData)
.enqueue(object : Callback> {
-
override fun onResponse(
call: Call>,
response: Response>
@@ -263,6 +288,8 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
setAdapter(listExpeditionSummary)
+ listView!!.setSelection(oldPosition)
+
} else {
Utils.progressBar.dialog.dismiss()
@@ -275,7 +302,10 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
- override fun onFailure(call: Call>, t: Throwable) {
+ override fun onFailure(
+ call: Call>,
+ t: Throwable
+ ) {
Utils.progressBar.dialog.dismiss()
Utils.showErrorDialog(
this@ExpeditionSummaryActivity,
@@ -285,27 +315,29 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
})
}
-
private fun setEvents() {
-
- txtScan!!.setOnEditorActionListener { _, _, _ ->
- Toast.makeText(this, "Expedición :" + txtScan!!.text, Toast.LENGTH_SHORT).show()
- findExpedition(txtScan!!.text.toString())
- itemScanned = true
- false
- }
- txtScan!!.onFocusChangeListener = OnFocusChangeListener { _, b ->
-
-
- if (b) {
- txtScan!!.setText("")
+ txtScan!!.setOnEditorActionListener { _, actionId, _ ->
+ if (!txtScan!!.text.isNullOrEmpty()) {
+ Toast.makeText(this, "Expedición :" + txtScan!!.text, Toast.LENGTH_SHORT).show()
+ findExpedition(txtScan!!.text.toString())
+ itemScanned = true
}
- }
-
- listView!!.setOnFocusChangeListener { _, _ ->
- txtScan!!.requestFocus()
+ true
+ //txtScan!!.requestFocus()
}
+ /* txtScan!!.onFocusChangeListener = OnFocusChangeListener { _, b ->
+
+ if (b) {
+ txtScan!!.setText("")
+
+ }else{}
+ }
+
+ listView!!.setOnFocusChangeListener { _, _ ->
+ txtScan!!.requestFocus()
+
+ }*/
}
@@ -342,7 +374,7 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
txtScan!!.setText("")
- txtScan!!.requestFocus()
+ txtScan!!.requestFocus()
}
@@ -372,14 +404,20 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
- private fun expeditionState_addByExpeditionMulti(expeditions: List, state: String) {
+ private fun expeditionState_addByExpeditionMulti(
+ expeditions: List,
+ state: String
+ ) {
val stateData: Array = arrayOfNulls(2)
stateData[0] = expeditions
stateData[1] = state
- restClient!!.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this), stateData)
+ restClient!!.expeditionState_addByExpeditionMulti(
+ Utils.getMapWhitUser(this),
+ stateData
+ )
.enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
Utils.progressBar.dialog.dismiss()
@@ -424,17 +462,21 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
private fun checkNextAddress(totalSendSuccessful: Int) {
+ if (listExpeditionSummary.size > positionSelected!! + 1) {
+ textAddressSelected!!.text =
+ if (checked == totalChecks) {
+ listExpeditionSummary.get(positionSelected!! + 1).address
+ } else {
+ listExpeditionSummary.get(positionSelected!!).address
- if (listExpeditionSummary.size >= positionSelected!! + 1) {
- textAddressSelected!!.text = listExpeditionSummary.get(positionSelected!! + 1).address
- positionSelected = positionSelected!! + 1
+ }
+ //positionSelected = positionSelected!! + 1
}
onResume()
}
-
fun Activity.hideKeyboard() {
hideKeyboard(currentFocus ?: View(this))
}
@@ -456,7 +498,6 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
}
-
fun exit(view: View) {
if (itemScanned && textAddressSelected!!.text.isNotEmpty()) {
@@ -467,13 +508,20 @@ class ExpeditionSummaryActivity : AppCompatActivity() {
.filter { it.routeFk == textViewRoute!!.text }
.filter { it.code == "ON DELIVERY" }, "ON DELIVERY"
)
+ if (listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code != "ON DELIVERY" }.isNotEmpty()
+ ) {
- expeditionState_addByExpeditionMulti(listCheck
- .filter { it.addressFk == textAddressSelected!!.text }
- .filter { it.routeFk == textViewRoute!!.text }
- .filter { it.code != "ON DELIVERY" }, "LOST"
- )
-
+ expeditionState_addByExpeditionMulti(listCheck
+ .filter { it.addressFk == textAddressSelected!!.text }
+ .filter { it.routeFk == textViewRoute!!.text }
+ .filter { it.code != "ON DELIVERY" }, "LOST"
+ )
+ } else {
+ totalSend = 1
+ }
itemScanned = false
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java b/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
index fc46d2f..b6474d0 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
@@ -9,11 +9,11 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
+import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,14 +30,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import okhttp3.Route;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import verdnatura.es.repartoverdnatura.ADAPTERS.ClientAdapter;
import verdnatura.es.repartoverdnatura.ADAPTERS.PhonesAdapter;
import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
-import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.MODELS.ClientTickets;
import verdnatura.es.repartoverdnatura.MODELS.Cliente;
import verdnatura.es.repartoverdnatura.MODELS.Ruta;
@@ -49,18 +47,20 @@ import verdnatura.es.repartoverdnatura.UTILS.Utils;
public class Tickets extends AppCompatActivity {
public String tlf;
+ private int positionOnScreen = 0;
private ListView listViewClients;
private ArrayList listClientesTickets = new ArrayList<>();
private ArrayList listClientesTicketsFirmados = new ArrayList<>();
private ClientAdapter adapter;
public Ruta route;
private RestClient restClient;
- private TextView txtZona, txtLines,btnVolver,txtClientsToSign,btnShowSigned;
+ private TextView txtZona, txtLines, btnVolver, txtClientsToSign, btnShowSigned;
private boolean isSignedShowed = false;
private ListView dialogListView;
public String uri = "";
private int posForNote = 0;
public ArrayList listData = new ArrayList<>();
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -77,20 +77,22 @@ public class Tickets extends AppCompatActivity {
@Override
protected void onRestart() {
+
super.onRestart();
- setViews();
+ // setViews();
checkPendingSigns();
+
}
- public void checkPendingSigns(){
+ public void checkPendingSigns() {
Set pendingSigns = LocalStorage.getPendingSigns(this);
- if (pendingSigns.size() == 0){
+ if (pendingSigns.size() == 0) {
getData(-1);
- }else{
+ } else {
Gson gson = new Gson();
listData = new ArrayList<>();
- for (String s : pendingSigns){
- listData.add(gson.fromJson(s,SignDataUpload.class));
+ for (String s : pendingSigns) {
+ listData.add(gson.fromJson(s, SignDataUpload.class));
}
confirmSave(0);
@@ -98,7 +100,7 @@ public class Tickets extends AppCompatActivity {
}
}
- public void confirmSave(final int pos){
+ public void confirmSave(final int pos) {
if (pos < listData.size()) {
Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
final Tickets that = this;
@@ -110,8 +112,8 @@ public class Tickets extends AppCompatActivity {
Utils.progressBar.getDialog().dismiss();
if (response.isSuccessful()) {
- // if (response.body().equals("OK")) {*/
- confirmSave(pos+1);
+ // if (response.body().equals("OK")) {*/
+ confirmSave(pos + 1);
/* }else{
getData(pos);
}*/
@@ -129,27 +131,28 @@ public class Tickets extends AppCompatActivity {
getData(pos);
}
});
- }else{
+ } else {
Utils.progressBar.getDialog().dismiss();
getData(pos);
}
}
- private void setViews(){
+ private void setViews() {
listViewClients = this.findViewById(R.id.listClientes);
//Tarea 4659
- /* listViewClients.setOnScrollListener(new AbsListView.OnScrollListener() {
+ listViewClients.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
- Log.d("VERDNATURA::","has changed");
+ //Log.d("VERDNATURA::","has changed");
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- Log.d("VERDNATURA::","has scroll"+firstVisibleItem);
+ // Log.d("VERDNATURA::","has scroll"+firstVisibleItem);
+ positionOnScreen = firstVisibleItem;
}
- });*/
+ });
txtZona = this.findViewById(R.id.textView19);
txtLines = this.findViewById(R.id.textView35);
@@ -161,17 +164,17 @@ public class Tickets extends AppCompatActivity {
}
- private void getData(int pos){
+ private void getData(int pos) {
//han quedado firmas por subir
ArrayList listAux = new ArrayList<>();
- if(pos < listData.size() && pos != -1){
+ if (pos < listData.size() && pos != -1) {
- for(int i = pos; i < listData.size(); i++){
+ for (int i = pos; i < listData.size(); i++) {
listAux.add(listData.get(i));
}
- LocalStorage.udpatePendingSigns(this,listAux,route.getId());
- }else{
- LocalStorage.udpatePendingSigns(this,listAux,route.getId());
+ LocalStorage.udpatePendingSigns(this, listAux, route.getId());
+ } else {
+ LocalStorage.udpatePendingSigns(this, listAux, route.getId());
}
txtLines.setText("");
@@ -179,64 +182,63 @@ public class Tickets extends AppCompatActivity {
listClientesTickets = new ArrayList<>();
listClientesTicketsFirmados = new ArrayList<>();
listViewClients.setVisibility(View.VISIBLE);
- Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
+ Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
String idR = route.getId();
String[] routeData = new String[1];
routeData[0] = idR;
- restClient.getClients(Utils.getMapWhitUser(this),routeData).enqueue(new Callback>() {
+ restClient.getClients(Utils.getMapWhitUser(this), routeData).enqueue(new Callback>() {
@Override
public void onResponse(Call> call, Response> response) {
Utils.progressBar.getDialog().dismiss();
- Log.i("VERDNATURA","Vamos a por los clientes o tickets");
+ Log.i("VERDNATURA", "Vamos a por los clientes o tickets");
Boolean exists = false;
- if(response.isSuccessful()){
- for(Cliente cliente : response.body()){
+ if (response.isSuccessful()) {
+ for (Cliente cliente : response.body()) {
exists = false;
- for (ClientTickets c : listClientesTicketsFirmados){
- if(c.getAddress().equals(cliente.getAddress())){
- Map values = new HashMap<>();
- values.put("Packages",cliente.getPackages());
- values.put("Warehouse",cliente.getWarehouse());
- values.put("Id",cliente.getId());
- values.put("Polizon",cliente.getPolizon());
- values.put("PackingType",cliente.getPackingType());
+ for (ClientTickets c : listClientesTicketsFirmados) {
+ if (c.getAddress().equals(cliente.getAddress())) {
+ Map values = new HashMap<>();
+ values.put("Packages", cliente.getPackages());
+ values.put("Warehouse", cliente.getWarehouse());
+ values.put("Id", cliente.getId());
+ values.put("Polizon", cliente.getPolizon());
+ values.put("PackingType", cliente.getPackingType());
c.addTicket(values);
- c.setNote(c.getNote()+" - "+ cliente.getNote());
+ c.setNote(c.getNote() + " - " + cliente.getNote());
exists = true;
break;
}
}
- for (ClientTickets c : listClientesTickets){
- if(c.getAddress().equals(cliente.getAddress())){
- Map values = new HashMap<>();
- values.put("Packages",cliente.getPackages());
- values.put("Warehouse",cliente.getWarehouse());
- values.put("Id",cliente.getId());
- values.put("Polizon",cliente.getPolizon());
- values.put("PackingType",cliente.getPackingType());
+ for (ClientTickets c : listClientesTickets) {
+ if (c.getAddress().equals(cliente.getAddress())) {
+ Map values = new HashMap<>();
+ values.put("Packages", cliente.getPackages());
+ values.put("Warehouse", cliente.getWarehouse());
+ values.put("Id", cliente.getId());
+ values.put("Polizon", cliente.getPolizon());
+ values.put("PackingType", cliente.getPackingType());
c.addTicket(values);
- c.setNote(c.getNote()+" - "+ cliente.getNote());
+ c.setNote(c.getNote() + " - " + cliente.getNote());
exists = true;
break;
}
}
-
- if(!exists){
- Map values = new HashMap<>();
- values.put("Packages",cliente.getPackages());
- values.put("Warehouse",cliente.getWarehouse());
- values.put("Id",cliente.getId());
- values.put("Polizon",cliente.getPolizon());
- values.put("PackingType",cliente.getPackingType());
- ArrayList