Merge branch 'master' into test
This commit is contained in:
commit
78ef7c144f
|
@ -0,0 +1,14 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
|
@ -0,0 +1 @@
|
||||||
|
Gestor Almacén
|
|
@ -0,0 +1,122 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
|
<option name="disableWrapperSourceDistributionNotification" value="true" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useQualifiedModuleNames" value="true" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
/build
|
|
@ -0,0 +1,91 @@
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
apply plugin: 'com.google.firebase.crashlytics'
|
||||||
|
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "es.verdnatura"
|
||||||
|
minSdkVersion 21
|
||||||
|
targetSdkVersion 29
|
||||||
|
versionCode 60
|
||||||
|
// versionName "5.4.4"
|
||||||
|
versionName "6.1.3"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataBinding {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar'])
|
||||||
|
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar'])
|
||||||
|
|
||||||
|
// Kotlin and Android
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.core:core-ktx:1.2.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
|
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
|
||||||
|
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
|
||||||
|
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
|
||||||
|
implementation "com.airbnb.android:lottie:$lottieVersion"
|
||||||
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
|
||||||
|
|
||||||
|
|
||||||
|
// Architecture components
|
||||||
|
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle"
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
|
||||||
|
// Koin for DI
|
||||||
|
implementation "org.koin:koin-core:$koin"
|
||||||
|
implementation "org.koin:koin-android:$koin"
|
||||||
|
implementation "org.koin:koin-androidx-scope:$koin"
|
||||||
|
implementation "org.koin:koin-androidx-viewmodel:$koin"
|
||||||
|
|
||||||
|
|
||||||
|
// Image libraries
|
||||||
|
implementation "io.coil-kt:coil:$coil"
|
||||||
|
implementation "com.github.bumptech.glide:glide:$glide"
|
||||||
|
implementation "com.github.bumptech.glide:okhttp3-integration:$glide"
|
||||||
|
kapt "com.github.bumptech.glide:compiler:$glide"
|
||||||
|
|
||||||
|
// Add the Firebase Crashlytics SDK.
|
||||||
|
implementation 'com.google.firebase:firebase-analytics:17.5.0'
|
||||||
|
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
|
||||||
|
|
||||||
|
//search
|
||||||
|
implementation 'com.github.mirrajabi:search-dialog:1.1'
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "519813071137",
|
||||||
|
"firebase_url": "https://gestoralmacen-bfa2a.firebaseio.com",
|
||||||
|
"project_id": "gestoralmacen-bfa2a",
|
||||||
|
"storage_bucket": "gestoralmacen-bfa2a.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:519813071137:android:3de54686c580a6f79dfe60",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "es.verdnatura"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "519813071137-5099s9mme9juufnrkm88ajt5n7cmluqh.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyA74wQCwDCpCjWs49lCX5m2SsdqcYb_J8s"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "519813071137-5099s9mme9juufnrkm88ajt5n7cmluqh.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"artifactType": {
|
||||||
|
"type": "APK",
|
||||||
|
"kind": "Directory"
|
||||||
|
},
|
||||||
|
"applicationId": "es.verdnatura",
|
||||||
|
"variantName": "processReleaseResources",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "SINGLE",
|
||||||
|
"filters": [],
|
||||||
|
"versionCode": 60,
|
||||||
|
"versionName": "6.1.3",
|
||||||
|
"outputFile": "app-release.apk"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"5.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
||||||
|
package es.verdnatura
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("es.verdnatura", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="es.verdnatura">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".MobileApplication"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
|
<activity android:name=".presentation.view.feature.imageview.activity.ImageViewActivity" android:configChanges="orientation"
|
||||||
|
android:screenOrientation="portrait"/>
|
||||||
|
<activity
|
||||||
|
android:name=".presentation.view.feature.main.activity.MainActivity"
|
||||||
|
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||||
|
android:configChanges="orientation"
|
||||||
|
android:screenOrientation="portrait"/>
|
||||||
|
<activity
|
||||||
|
android:name=".presentation.view.feature.login.activity.LoginActivity"
|
||||||
|
android:configChanges="orientation"
|
||||||
|
android:screenOrientation="portrait">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
|
@ -0,0 +1,20 @@
|
||||||
|
package es.verdnatura
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import es.verdnatura.di.viewModelModule
|
||||||
|
import org.koin.android.ext.koin.androidContext
|
||||||
|
import org.koin.core.context.loadKoinModules
|
||||||
|
import org.koin.core.context.startKoin
|
||||||
|
|
||||||
|
class MobileApplication: Application() {
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
|
||||||
|
startKoin { androidContext(this@MobileApplication)
|
||||||
|
val moduleList = listOf(viewModelModule)
|
||||||
|
loadKoinModules(moduleList)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
package es.verdnatura.di
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.fragment.BuscarItemAllViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.fragment.BuyersViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.fragment.QaualityViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletDetailViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
|
||||||
|
import org.koin.android.ext.koin.androidContext
|
||||||
|
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
val viewModelModule = module{
|
||||||
|
// Login
|
||||||
|
viewModel {
|
||||||
|
LoginViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros
|
||||||
|
viewModel {
|
||||||
|
PasilleroViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros / Item Card
|
||||||
|
viewModel {
|
||||||
|
ItemCardViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros / Item Card / Historico
|
||||||
|
viewModel {
|
||||||
|
HistoricoViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros / Buscar Item
|
||||||
|
viewModel {
|
||||||
|
BuscarItemViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros / Buscar Item 2
|
||||||
|
viewModel {
|
||||||
|
BuscarItemAllViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pasilleros / Inventario
|
||||||
|
viewModel {
|
||||||
|
InventaryViewModel(androidContext())
|
||||||
|
}
|
||||||
|
// Pasilleros / Faltas
|
||||||
|
viewModel {
|
||||||
|
FaltasViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShelvingParking
|
||||||
|
viewModel {
|
||||||
|
ShelvingParkingViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ubicador
|
||||||
|
viewModel {
|
||||||
|
UbicadorViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ubicador // Automatic
|
||||||
|
viewModel {
|
||||||
|
AutomaticAddItemViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajustes
|
||||||
|
viewModel {
|
||||||
|
AjustesViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// PALETIZADOR
|
||||||
|
viewModel {
|
||||||
|
ExpeditionTruckListViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ExpeditionPalletViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ExpeditionPalletDetailViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ExpeditionScanViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
// SACADOR
|
||||||
|
viewModel {
|
||||||
|
SacadorViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
CollectionViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ControladorViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ParkingViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
PreSacadorViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ReposicionViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
BuyersViewModel(androidContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
QaualityViewModel(androidContext())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
class ApiSalixUtils {
|
||||||
|
companion object {
|
||||||
|
//const val BASE_URL:String = "http://192.168.1.108:8000/"
|
||||||
|
const val BASE_URL:String = "https://salix.verdnatura.es/api/"
|
||||||
|
fun getApiService():SalixService{
|
||||||
|
val salixRetrofit = Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(
|
||||||
|
GsonConverterFactory.create()).build()
|
||||||
|
return salixRetrofit.create(SalixService::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.preference.PreferenceManager
|
||||||
|
import android.util.Log
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
|
class ApiUtils {
|
||||||
|
companion object {
|
||||||
|
//const val BASE_URL:String = "http://192.168.1.54:8009/"
|
||||||
|
const val BASE_URL:String = "https://app.verdnatura.es/"
|
||||||
|
//const val BASE_URL:String = "https://test-app.verdnatura.es/"
|
||||||
|
//const val BASE_URL:String = "http://10.1.4.186/"
|
||||||
|
|
||||||
|
fun getApiService(context: Context):VerdnaturaService{
|
||||||
|
val retrofit = Retrofit.Builder()
|
||||||
|
.baseUrl(getBaseUrlLocal(context))
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.client(getRequestHeader())
|
||||||
|
.build()
|
||||||
|
return retrofit.create(VerdnaturaService::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBaseUrlLocal(context: Context): String {
|
||||||
|
var url = this.getDefaults("base_url",context)
|
||||||
|
if (url.isNullOrEmpty()){
|
||||||
|
setDefaults("base_url", BASE_URL,context)
|
||||||
|
}else{
|
||||||
|
if (!url.contains("http")){
|
||||||
|
url = "https://"+url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (url.isNullOrEmpty()) BASE_URL else url
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRequestHeader(): OkHttpClient? {
|
||||||
|
val client = OkHttpClient.Builder()
|
||||||
|
.connectTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(40, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDefaults(key: String?, value: String?, context: Context?) {
|
||||||
|
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
val editor = preferences.edit()
|
||||||
|
editor.putString(key, value)
|
||||||
|
editor.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDefaults(key: String?, context: Context?): String? {
|
||||||
|
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
return preferences.getString(key, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
object ConstAndValues {
|
||||||
|
const val SACADOR = "PREPARED"
|
||||||
|
const val CONTROLADOR = "CHECKED"
|
||||||
|
const val OK = "OK"
|
||||||
|
const val PREPARED = "PREPARED"
|
||||||
|
const val ON_PREPARATION = "ON_PREPARATION"
|
||||||
|
const val CHECKED = "CHECKED"
|
||||||
|
const val PRESACADOR = "PRESACADOR"
|
||||||
|
const val ON_CHECKING = "ON_CHECKING"
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.widget.Toast
|
||||||
|
|
||||||
|
fun Any.toast(context: Context?, duration: Int = Toast.LENGTH_SHORT): Toast {
|
||||||
|
return Toast.makeText(context, this.toString(), duration).apply { show() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : Any> T?.notNull(f: (it: T) -> Unit) {
|
||||||
|
if (this != null) f(this)
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetAjustesUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun getSectors(usuario:String,password:String) : Call<List<SectorItemVO>> {
|
||||||
|
return restClient!!.getSectors("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetBuscarItemAllUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun searchItemsUbicadorAll(usuario:String,password:String,itemFk:String) : Call<List<ItemLocationAll>> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(itemFk)
|
||||||
|
return restClient!!.searchItemsUbicadorAll("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetBuscarItemUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun searchItemsUbicador(usuario:String,password:String,itemFk:String) : Call<List<ItemLocationVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
return restClient!!.searchItemsUbicador("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetInventaryUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun itemShelvingRadar(usuario:String,password:String,sectorFk:String) : Call<List<ItemInventaryVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(sectorFk)
|
||||||
|
return restClient!!.itemShelvingRadar("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingRadarFilterBuyer(usuario:String,password:String,buyerFk:String,warehouseFk: String) : Call<List<ItemInventaryVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(buyerFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.itemShelvingRadarFilterBuyer("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun faultsReview(usuario:String,password:String,warehouseFk:String) : Call<List<ItemFaltasVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.faultsReview("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun faultsReview_isChecked(usuario:String,password:String,itemFk:String,warehouseFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.faultsReview_isChecked("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun itemShelvingBuyerGet(usuario:String,password:String) : Call<List<BuyerVO>> {
|
||||||
|
return restClient!!.itemShelvingBuyerGet("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
|
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetItemCardUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun getItemCard(usuario:String,password:String,itemFk:String,warehouseFk:String) : Call<ItemCardVO> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.getItemCard("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getItemPackingType(usuario:String,password:String) : Call<List<ItemPackingType>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
return restClient!!.getItemPackingType("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemStockUpdate(usuario:String,password:String,itemFk:String,warehouseFk:String,newVisible:String,isTrash:String ) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
params.add(newVisible)
|
||||||
|
params.add(isTrash)
|
||||||
|
return restClient!!.itemStockUpdate("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemTrash(usuario:String,password:String,itemFk:String,warehouseFk:String,newVisible:String,isTrash:String ) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
params.add(newVisible)
|
||||||
|
params.add(isTrash)
|
||||||
|
return restClient!!.itemTrash("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSave(usuario:String,password:String,itemFk:String,warehouseFk:String,value:String ) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
params.add(value)
|
||||||
|
return restClient!!.itemPlacementSave("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateGrouping(usuario:String,password:String,itemFk:String,value:String ,warehouseFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(value)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.updateGrouping("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updatePacking(usuario:String,password:String,itemFk:String,value:String ,warehouseFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(value)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.updatePacking("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updatePackingType(usuario:String,password:String,itemFk:String,ItemPackingType:String) : Call<Boolean> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(ItemPackingType)
|
||||||
|
return restClient!!.updatePackingType("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun itemSaveMin(usuario:String,password:String,itemFk:String,value:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(value)
|
||||||
|
return restClient!!.itemSaveMin("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun barcodes_edit(usuario:String,password:String,itemFk:String,value:String, delete:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(value)
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(delete)
|
||||||
|
return restClient!!.barcodes_edit("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemDiary(usuario:String,password:String,itemFk:String,warehouseFk: String) : Call<List<ItemHistoricoVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.itemDiary("json","1",usuario,password,"application/json",params = params)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.versionApp
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetLoginUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun login(usuario:String,password:String) : Call<String>{
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(usuario)
|
||||||
|
params.add(password)
|
||||||
|
return restClient!!.login("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun salixLogin(usuario:String,password:String) : Call<LoginSalixVO>{
|
||||||
|
return salixClient!!.login("application/json", LoginSalixVO(usuario,password))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkVersion_old(usuario:String,password:String,version:String) : Call<Boolean> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(version)
|
||||||
|
return restClient!!.version("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendChekingPresence(token:String,workerId:Int,message:String) : Call<Boolean>{
|
||||||
|
return salixClient!!.sendChekingPresence(content_type = "application/json", authorization = token, params = SalixMessageVO(workerId = workerId,message = message))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkVersion(usuario:String,password:String,nameApp:String) : Call<versionApp> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(nameApp)
|
||||||
|
return restClient!!.version2("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.model.*
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetPaletizadoresUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun expeditionTruckList(usuario:String,password:String) : Call<List<ItemExpeditionTruckVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
return restClient!!.expeditionTruckList("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionTruckAdd(usuario:String,password:String,vHour:String,vDescription:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vHour)
|
||||||
|
params.add(vDescription)
|
||||||
|
// ////Log.i("VERDNATURA"," La hora es $vHour y descrip $vDescription")
|
||||||
|
return restClient!!.expeditionTruckAdd("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionPallet_List(usuario:String,password:String,vTruckFk:String) : Call<List<ItemPalletVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vTruckFk)
|
||||||
|
return restClient!!.expeditionPallet_List("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionScanAdd(usuario:String,password:String,vPalletFk:String,vTruckFk:String) : Call<List<ItemScanVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
params.add(vTruckFk)
|
||||||
|
return restClient!!.expeditionScanAdd("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
params.add(vExpeditionFk)
|
||||||
|
return restClient!!.expeditionScanPut("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
params.add(vExpeditionFk)
|
||||||
|
return restClient!!.checkRouteExpeditionScanPut("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun expeditionPalletView(usuario:String,password:String,vPalletFk:String) : Call<List<ItemPalletViewVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
return restClient!!.expeditionPalletView("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionPalletDel(usuario:String,password:String,vPalletFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
return restClient!!.expeditionPalletDel("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionScanList(usuario:String,password:String,vPalletFk:String) : Call<List<ItemExpeditionScanVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vPalletFk)
|
||||||
|
return restClient!!.expeditionScanList("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionScanDel(usuario:String,password:String,vScanFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vScanFk)
|
||||||
|
return restClient!!.expeditionScanDel("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun expeditionPalletPrintSet(
|
||||||
|
usuario: String,
|
||||||
|
password: String,
|
||||||
|
vPalletFk: String,
|
||||||
|
vSectorFk: String
|
||||||
|
) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(vPalletFk)
|
||||||
|
params.add(vSectorFk)
|
||||||
|
return restClient!!.expeditionPalletPrintSet("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetPreSacadorUseCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String) : Call<List<PreSacadorItemVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(ticketFk)
|
||||||
|
params.add(sectorFk)
|
||||||
|
return restClient!!.ticketToPrePrepare("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String) : Call<List<PreSacadorItemVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(sectorFk)
|
||||||
|
return restClient!!.itemPlacementSupplyGetOrder("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(id)
|
||||||
|
params.add(quantity)
|
||||||
|
return restClient!!.itemPlacementSupplyCloseOrder("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetQualityUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun itemShelvingBuyerGet(usuario:String,password:String) : Call<List<BuyerVO>> {
|
||||||
|
return restClient!!.itemShelvingBuyerGet("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingBuyerTask(usuario:String,password:String, userFk: String) : Call<List<ItemBuyerVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(userFk)
|
||||||
|
return restClient!!.itemShelvingBuyerTask("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(vId)
|
||||||
|
params.add(vStars)
|
||||||
|
return restClient!!.itemShelvingStarsUpdate("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetSacadorControladorUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,print:String) : Call<CollectionVO> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(collectionFk)
|
||||||
|
params.add(sectorFk)
|
||||||
|
params.add(print)
|
||||||
|
return restClient!!.collectionTicketGet("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionNew(usuario:String,password:String,sectorFk:String,carros:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(sectorFk)
|
||||||
|
params.add(carros)
|
||||||
|
return restClient!!.collectionNew("json","1",usuario,password,"application/json",params)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun collectionGet(usuario:String,password:String) : Call<List<CollectionVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
return restClient!!.collectionGet("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(saleFk)
|
||||||
|
params.add(vOriginalQuantity)
|
||||||
|
params.add(vStateFk)
|
||||||
|
params.add(vIsChecked)
|
||||||
|
params.add(vBuyFk)
|
||||||
|
return restClient!!.saleTrackingReplace("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String) : Call<List<PlacementSupplyVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(shelvingFk)
|
||||||
|
params.add(quantity)
|
||||||
|
params.add(itemFk)
|
||||||
|
return restClient!!.itemPlacementSupplyAiming("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemShelvingFk)
|
||||||
|
params.add(saleFk)
|
||||||
|
params.add(quantity)
|
||||||
|
return restClient!!.itemShelvingSaleSupplyAdd("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemShelvingFk)
|
||||||
|
params.add(itemPlacementSupplyFk)
|
||||||
|
params.add(quantity)
|
||||||
|
return restClient!!.itemShelvingPlacementSupplyAdd("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(collectionFk)
|
||||||
|
params.add(sectorFk)
|
||||||
|
return restClient!!.collectionStickerPrint("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String) : Call<ItemVO> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.itemGetAvailable("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(quantityFk)
|
||||||
|
params.add(ticketFk)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
return restClient!!.collectionAddItem("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(saleFk)
|
||||||
|
params.add(quantity)
|
||||||
|
params.add(originalQuantity)
|
||||||
|
return restClient!!.saleMove("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(saleFk)
|
||||||
|
params.add(quantity)
|
||||||
|
params.add(type)
|
||||||
|
params.add(warehouseFk)
|
||||||
|
params.add(originalQuantity)
|
||||||
|
return restClient!!.collectionMissingTrash("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleTrackingDel(usuario:String,password:String,saleFk: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(saleFk)
|
||||||
|
return restClient!!.saleTrackingDel("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionUpdateState(usuario:String,password:String,collectionFk: String,state : String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(collectionFk)
|
||||||
|
params.add(state)
|
||||||
|
return restClient!!.collectionUpdateState("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getIdFromCode(usuario:String,password:String,code: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(code)
|
||||||
|
return restClient!!.getIdFromCode("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String, quantity: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(saleFk)
|
||||||
|
params.add(quantity)
|
||||||
|
return restClient!!.collectionIncreaseQuantity("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList()
|
||||||
|
params.add(vSaleFk)
|
||||||
|
params.add(vUserFk)
|
||||||
|
params.add(vTypeFk)
|
||||||
|
return restClient!!.saleMistakeAdd("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun mistakeType(usuario:String,password:String) : Call<List<MistakeTypeVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
return restClient!!.mistakeType("json","1",usuario,password,"application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetShelvingParkingUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String) : Call<List<ItemShelvingParkingVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(vShelvingFk)
|
||||||
|
params.add(vWarehouseFk)
|
||||||
|
params.add(vDayRange)
|
||||||
|
return restClient!!.shelvingParking_get("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetUbicadorUserCase(context: Context) : RestClient(context) {
|
||||||
|
|
||||||
|
fun itemShelvingList(usuario:String,password:String,vShelvingFk:String) : Call<List<ItemUbicadorVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(vShelvingFk)
|
||||||
|
return restClient!!.itemShelvingList("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(shelving)
|
||||||
|
params.add(item)
|
||||||
|
params.add(deep)
|
||||||
|
params.add(quantity)
|
||||||
|
params.add(packing)
|
||||||
|
params.add(warehouse)
|
||||||
|
params.add(level)
|
||||||
|
return restClient!!.itemShelvingMake("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(shelving)
|
||||||
|
params.add(item)
|
||||||
|
params.add(deep)
|
||||||
|
params.add(quantity)
|
||||||
|
params.add(packing)
|
||||||
|
params.add(warehouse)
|
||||||
|
params.add(level)
|
||||||
|
params.add(itemShelvingFk)
|
||||||
|
return restClient!!.itemShelvingMakeEdit("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingMake_multi(usuario:String,password:String,shelving:String,items:List<String>,deep:String,warehouse:String,level:String) : Call<String> {
|
||||||
|
val params:ArrayList<Any> = ArrayList();
|
||||||
|
params.add(shelving)
|
||||||
|
params.add(items)
|
||||||
|
params.add(deep)
|
||||||
|
params.add(warehouse)
|
||||||
|
params.add(level)
|
||||||
|
return restClient!!.itemShelvingMake_multi("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(priority)
|
||||||
|
params.add(shelving)
|
||||||
|
return restClient!!.shelvingPriorityUpdate("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shelvingPark(usuario:String,password:String,shelving:String,parking:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(shelving)
|
||||||
|
params.add(parking)
|
||||||
|
return restClient!!.shelvingPark("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shelvingChange(usuario:String,password:String,origen:String,destino:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(origen)
|
||||||
|
params.add(destino)
|
||||||
|
return restClient!!.shelvingChange("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearShelvingList(usuario:String,password:String,shelvingFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(shelvingFk)
|
||||||
|
return restClient!!.clearShelvingList("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
params.add(shelvingFk)
|
||||||
|
return restClient!!.itemShelvingTransfer("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingDelete(usuario:String,password:String,itemFk:String) : Call<String> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(itemFk)
|
||||||
|
return restClient!!.itemShelvingDelete("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
open class RestClient(context:Context) {
|
||||||
|
var restClient:VerdnaturaService? = null
|
||||||
|
var salixClient:SalixService? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
restClient = ApiUtils.getApiService(context)
|
||||||
|
salixClient = ApiSalixUtils.getApiService()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.Header
|
||||||
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
interface SalixService {
|
||||||
|
|
||||||
|
@POST("Accounts/login")
|
||||||
|
fun login(@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: LoginSalixVO):
|
||||||
|
Call<LoginSalixVO>
|
||||||
|
|
||||||
|
@POST("chats/sendCheckingPresence")
|
||||||
|
fun sendChekingPresence(
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Header("Authorization") authorization: String,
|
||||||
|
@Body params: SalixMessageVO):
|
||||||
|
Call<Boolean>
|
||||||
|
}
|
|
@ -0,0 +1,666 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.versionApp
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.model.*
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||||
|
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.Header
|
||||||
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
|
||||||
|
@JvmSuppressWildcards
|
||||||
|
interface VerdnaturaService {
|
||||||
|
|
||||||
|
//LOGIN ========================================================================>
|
||||||
|
@POST("security/login")
|
||||||
|
fun login(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/version")
|
||||||
|
fun version(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<Boolean>
|
||||||
|
|
||||||
|
@POST("/security/getVersion")
|
||||||
|
fun version2(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<versionApp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//AJUSTES ========================================================================>
|
||||||
|
@POST("almacennew/sector_get")
|
||||||
|
fun getSectors(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String):
|
||||||
|
Call<List<SectorItemVO>>
|
||||||
|
|
||||||
|
|
||||||
|
//PRESACADORES ========================================================================>
|
||||||
|
|
||||||
|
@POST("almacennew/ticketToPrePrepare")
|
||||||
|
fun ticketToPrePrepare(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<PreSacadorItemVO>>
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/itemPlacementSupplyGetOrder")
|
||||||
|
fun itemPlacementSupplyGetOrder(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<PreSacadorItemVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/itemPlacementSupplyCloseOrder")
|
||||||
|
fun itemPlacementSupplyCloseOrder(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//SACADORES / CONTROLADORES ========================================================================>
|
||||||
|
@POST("almacennew/collectionGet")
|
||||||
|
fun collectionGet(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String):
|
||||||
|
Call<List<CollectionVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionNew")
|
||||||
|
fun collectionNew(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionTicketGet")
|
||||||
|
fun collectionTicketGet(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<CollectionVO>
|
||||||
|
|
||||||
|
@POST("almacennew/saleTrackingReplace")
|
||||||
|
fun saleTrackingReplace(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemPlacementSupplyAiming")
|
||||||
|
fun itemPlacementSupplyAiming(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<PlacementSupplyVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingSaleSupplyAdd")
|
||||||
|
fun itemShelvingSaleSupplyAdd(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingPlacementSupplyAdd")
|
||||||
|
fun itemShelvingPlacementSupplyAdd(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionStickerPrint")
|
||||||
|
fun collectionStickerPrint(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemGetAvailable")
|
||||||
|
fun itemGetAvailable(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<ItemVO>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionAddItem")
|
||||||
|
fun collectionAddItem(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/saleMove")
|
||||||
|
fun saleMove(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionMissingTrash")
|
||||||
|
fun collectionMissingTrash(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/saleTrackingDel")
|
||||||
|
fun saleTrackingDel(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionUpdateState")
|
||||||
|
fun collectionUpdateState(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/barcodeToItem")
|
||||||
|
fun getIdFromCode(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/collectionIncreaseQuantity")
|
||||||
|
fun collectionIncreaseQuantity(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/saleMistakeAdd")
|
||||||
|
fun saleMistakeAdd(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/mistakeType")
|
||||||
|
fun mistakeType(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String):
|
||||||
|
Call<List<MistakeTypeVO>>
|
||||||
|
|
||||||
|
//PASILLEROS ========================================================================>
|
||||||
|
|
||||||
|
//CONSULTAR ARTICULO ========================================================================>
|
||||||
|
@POST("almacennew/itemDiary")
|
||||||
|
fun itemDiary(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemHistoricoVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/item_card")
|
||||||
|
fun getItemCard(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<ItemCardVO>
|
||||||
|
|
||||||
|
@POST("almacennew/get_ItemPackingType")
|
||||||
|
fun getItemPackingType(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemPackingType>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/itemStockUpdate")
|
||||||
|
fun itemStockUpdate(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemTrash")
|
||||||
|
fun itemTrash(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/item_placement_save")
|
||||||
|
fun itemPlacementSave(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/buy_updateGrouping")
|
||||||
|
fun updateGrouping(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/buy_updatePacking")
|
||||||
|
fun updatePacking(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/update_ItemPackingType")
|
||||||
|
fun updatePackingType(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<Boolean>
|
||||||
|
|
||||||
|
@POST("almacennew/itemSaveMin")
|
||||||
|
fun itemSaveMin(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/barcodes_edit")
|
||||||
|
fun barcodes_edit(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
//BUSCAR ITEM ========================================================================>
|
||||||
|
@POST("almacennew/getItemUbication")
|
||||||
|
fun searchItemsUbicador(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemLocationVO>>
|
||||||
|
|
||||||
|
// BUSCAR ITEM ALL
|
||||||
|
@POST("almacennew/getItemUbication")
|
||||||
|
fun searchItemsUbicadorAll(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemLocationAll>>
|
||||||
|
|
||||||
|
//INVENTARIO ========================================================================>
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingRadar")
|
||||||
|
fun itemShelvingRadar(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemInventaryVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelving_filterBuyer")
|
||||||
|
fun itemShelvingRadarFilterBuyer(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemInventaryVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/faultsReview")
|
||||||
|
fun faultsReview(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemFaltasVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/faultsReview_isChecked")
|
||||||
|
fun faultsReview_isChecked(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
//SHELVING PARKING ========================================================================>
|
||||||
|
@POST("almacennew/shelvingParking_get")
|
||||||
|
fun shelvingParking_get(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemShelvingParkingVO>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//UBICADOR ========================================================================>
|
||||||
|
@POST("almacennew/itemShelvingList")
|
||||||
|
fun itemShelvingList(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemUbicadorVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/shelvingPriorityUpdate")
|
||||||
|
fun shelvingPriorityUpdate(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingMake")
|
||||||
|
fun itemShelvingMake(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingMakeEdit")
|
||||||
|
fun itemShelvingMakeEdit(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingMake_multi")
|
||||||
|
fun itemShelvingMake_multi(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<Any>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/shelvingPark")
|
||||||
|
fun shelvingPark(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/shelvingChange")
|
||||||
|
fun shelvingChange(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/clearShelvingList")
|
||||||
|
fun clearShelvingList(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingTransfer")
|
||||||
|
fun itemShelvingTransfer(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingDelete")
|
||||||
|
fun itemShelvingDelete(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
//PALETIZADORES ========================================================================>
|
||||||
|
@POST("almacennew/expeditionTruckList")
|
||||||
|
fun expeditionTruckList(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String):
|
||||||
|
Call<List<ItemExpeditionTruckVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionTruckAdd")
|
||||||
|
fun expeditionTruckAdd(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionPalletList")
|
||||||
|
fun expeditionPallet_List(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemPalletVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionScanAdd")
|
||||||
|
fun expeditionScanAdd(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemScanVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionScanPut")
|
||||||
|
fun expeditionScanPut(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/checkRouteExpeditionScanPut")
|
||||||
|
fun checkRouteExpeditionScanPut(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionPalletView")
|
||||||
|
fun expeditionPalletView(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemPalletViewVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionPalletDel")
|
||||||
|
fun expeditionPalletDel(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionScanList")
|
||||||
|
fun expeditionScanList(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemExpeditionScanVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionScanDel")
|
||||||
|
fun expeditionScanDel(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
@POST("almacennew/expeditionPalletPrintSet")
|
||||||
|
fun expeditionPalletPrintSet(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
//CALIDAD
|
||||||
|
@POST("almacennew/itemShelvingBuyerGet")
|
||||||
|
fun itemShelvingBuyerGet(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String):
|
||||||
|
Call<List<BuyerVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingBuyerTask")
|
||||||
|
fun itemShelvingBuyerTask(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<List<ItemBuyerVO>>
|
||||||
|
|
||||||
|
@POST("almacennew/itemShelvingStarsUpdate")
|
||||||
|
fun itemShelvingStarsUpdate(@Header("aplicacion") aplicacion: String,
|
||||||
|
@Header("version") version: String,
|
||||||
|
@Header("user") user: String,
|
||||||
|
@Header("pass") pass: String,
|
||||||
|
@Header("Content-Type") content_type: String,
|
||||||
|
@Body params: List<String>):
|
||||||
|
Call<String>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package es.verdnatura.presentation.base
|
||||||
|
|
||||||
|
object BR {
|
||||||
|
const val _all = 0
|
||||||
|
const val focused = 1
|
||||||
|
const val rating = 2
|
||||||
|
const val resumePosition = 3
|
||||||
|
const val favorite = 4
|
||||||
|
const val selected = 5
|
||||||
|
const val toolBarItem = 6
|
||||||
|
const val item = 7
|
||||||
|
const val loadingInfo = 8
|
||||||
|
const val color = 9
|
||||||
|
const val icon = 10
|
||||||
|
const val episode = 11
|
||||||
|
const val title = 12
|
||||||
|
const val content = 13
|
||||||
|
const val onOptionsItemSelected = 14
|
||||||
|
const val vpsActionListener = 15
|
||||||
|
const val numberEpisodes = 16
|
||||||
|
const val seasonColor = 17
|
||||||
|
const val viewModel = 18
|
||||||
|
const val action = 19
|
||||||
|
const val liveProgram = 20
|
||||||
|
const val loadingEpisodes = 21
|
||||||
|
const val ratio = 22
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package es.verdnatura.presentation.base
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.databinding.DataBindingUtil
|
||||||
|
import androidx.databinding.ViewDataBinding
|
||||||
|
|
||||||
|
abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {
|
||||||
|
|
||||||
|
|
||||||
|
protected lateinit var binding: T
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(getLayoutId())
|
||||||
|
initDataBinding()
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
@LayoutRes
|
||||||
|
abstract fun getLayoutId(): Int
|
||||||
|
open fun addBindingVariables() {}
|
||||||
|
abstract fun init()
|
||||||
|
|
||||||
|
|
||||||
|
private fun initDataBinding() {
|
||||||
|
binding = DataBindingUtil.setContentView(this, getLayoutId())
|
||||||
|
binding.lifecycleOwner = this
|
||||||
|
addBindingVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideKeyboard(view: View){
|
||||||
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,446 @@
|
||||||
|
package es.verdnatura.presentation.base
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.app.AlarmManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.media.AudioManager
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.speech.RecognitionListener
|
||||||
|
import android.speech.RecognizerIntent
|
||||||
|
import android.speech.SpeechRecognizer
|
||||||
|
import android.speech.tts.TextToSpeech
|
||||||
|
import android.speech.tts.UtteranceProgressListener
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
|
import androidx.databinding.DataBindingUtil
|
||||||
|
import androidx.databinding.ViewDataBinding
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.common.mediaCurrentVolume
|
||||||
|
import es.verdnatura.presentation.common.mediaMaxVolume
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelClass: KClass<V>) :
|
||||||
|
Fragment(), TextToSpeech.OnInitListener , RecognitionListener{
|
||||||
|
|
||||||
|
protected val TAG="VERDNATURA"
|
||||||
|
protected val PREFS_USER = "es.verdnatura.user.prefs"
|
||||||
|
protected val USERFK = "userFk"
|
||||||
|
protected val USER = "user"
|
||||||
|
protected val PASSWORD = "password"
|
||||||
|
protected val TOKEN = "token"
|
||||||
|
protected val SECTORDESCRIP = "sectordescrip"
|
||||||
|
protected val SECTORFK = "sectorFk"
|
||||||
|
protected val WAREHOUSEFK = "warehouseFk"
|
||||||
|
protected val RECORDAR = "recordar"
|
||||||
|
protected val VOZ = "voz"
|
||||||
|
//nuevo campo número carros ajustes y campos para guardar el buyerid y buyernickname
|
||||||
|
protected val BUYER = "buyernickname"
|
||||||
|
protected val BUYERID="buyerid"
|
||||||
|
protected val CARRO="carro"
|
||||||
|
protected val WAREHOUSEFK_DEFAULT=60
|
||||||
|
|
||||||
|
protected val viewModel: V by viewModel(viewModelClass)
|
||||||
|
protected lateinit var binding: T
|
||||||
|
private var isOnReadyForSpeech = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var textToSpeech: TextToSpeech? = null
|
||||||
|
private var mAudioManager:AudioManager? = null
|
||||||
|
protected var mSpeechRecognizer: SpeechRecognizer? = null
|
||||||
|
private var mSpeechRecognizerIntent: Intent? = null
|
||||||
|
|
||||||
|
protected val NEW_COLLECTION = 0
|
||||||
|
protected val LISTO = 1
|
||||||
|
protected val CANCEL = 2
|
||||||
|
protected val VOLVER = 3
|
||||||
|
protected val REPITE = 4
|
||||||
|
protected val OTRO = 5
|
||||||
|
protected val FALTA = 6
|
||||||
|
protected val ERROR = -1
|
||||||
|
|
||||||
|
val allowedStrings =
|
||||||
|
Arrays.asList(
|
||||||
|
"cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete",
|
||||||
|
"ocho", "nueve", "diez", "once", "doce", "trece", "catorce",
|
||||||
|
"quince", "dieziseis", "diezisiete", "dieziocho", "diezinueve", "veinte",
|
||||||
|
"treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa",
|
||||||
|
"cien", "mil"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? = inflater.inflate(getLayoutId(), container, false)
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
initDataBinding()
|
||||||
|
getBundleArguments()
|
||||||
|
observeViewModel()
|
||||||
|
runSound()
|
||||||
|
requestRecordAudioPermission()
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
@LayoutRes
|
||||||
|
abstract fun getLayoutId(): Int
|
||||||
|
open fun init() {}
|
||||||
|
open fun observeViewModel() {}
|
||||||
|
open fun getBundleArguments() {}
|
||||||
|
open fun addBindingVariables() {}
|
||||||
|
|
||||||
|
open fun setSpeak() {
|
||||||
|
//VOZ
|
||||||
|
textToSpeech = TextToSpeech(requireContext(),this)
|
||||||
|
mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun restartapp(f : Fragment){
|
||||||
|
val mStartActivity = Intent(context, f::class.java)
|
||||||
|
val mPendingIntentId = 123456
|
||||||
|
val mPendingIntent = PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
mPendingIntentId,
|
||||||
|
mStartActivity,
|
||||||
|
PendingIntent.FLAG_CANCEL_CURRENT
|
||||||
|
)
|
||||||
|
val mgr = context!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
|
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] = mPendingIntent
|
||||||
|
System.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
open fun initialize(){
|
||||||
|
//ESCUCHA
|
||||||
|
try {
|
||||||
|
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext())
|
||||||
|
mSpeechRecognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
|
||||||
|
mSpeechRecognizerIntent!!.putExtra(
|
||||||
|
RecognizerIntent.EXTRA_LANGUAGE_MODEL,
|
||||||
|
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
|
||||||
|
)
|
||||||
|
mSpeechRecognizerIntent!!.putExtra(
|
||||||
|
RecognizerIntent.EXTRA_LANGUAGE,
|
||||||
|
Locale.getDefault()
|
||||||
|
)
|
||||||
|
mSpeechRecognizerIntent!!.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, false)
|
||||||
|
mSpeechRecognizer?.setRecognitionListener(this)
|
||||||
|
isOnReadyForSpeech = false;
|
||||||
|
startListening()
|
||||||
|
}catch (e:Exception){
|
||||||
|
cancelSpeech()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initDataBinding() {
|
||||||
|
binding = DataBindingUtil.bind<T>(view!!)!!
|
||||||
|
binding.lifecycleOwner = viewLifecycleOwner
|
||||||
|
binding.setVariable(BR.viewModel, this@BaseFragment.viewModel)
|
||||||
|
lifecycle.addObserver(this@BaseFragment.viewModel)
|
||||||
|
addBindingVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onInit(status: Int) {
|
||||||
|
if (status == TextToSpeech.SUCCESS) {
|
||||||
|
val spanish = Locale("es", "ES")
|
||||||
|
textToSpeech!!.language = spanish
|
||||||
|
textToSpeech!!.setOnUtteranceProgressListener(object: UtteranceProgressListener() {
|
||||||
|
override fun onDone(utteranceId: String?) {
|
||||||
|
Log.i("SPEEAK","on done")
|
||||||
|
requireActivity().runOnUiThread(Runnable {
|
||||||
|
if (mSpeechRecognizer != null){
|
||||||
|
mSpeechRecognizer!!.destroy()
|
||||||
|
mSpeechRecognizer = null
|
||||||
|
}
|
||||||
|
initialize()
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(utteranceId: String?) {
|
||||||
|
"Error to speak".toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart(utteranceId: String?) {
|
||||||
|
Log.i("SPEEAK","on start")
|
||||||
|
runSound()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
"La voz no se ha podido iniciar".toast(requireContext())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun runSound(){
|
||||||
|
// Get the maximum media/music volume
|
||||||
|
val maxVolume = mAudioManager?.mediaMaxVolume
|
||||||
|
// mAudioManager?.setMediaVolume(maxVolume!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun muteSound() {
|
||||||
|
if (mAudioManager?.mediaCurrentVolume != 0){
|
||||||
|
// mAudioManager?.setMediaVolume(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun speak(frase:String) {
|
||||||
|
textToSpeech!!.speak(frase, TextToSpeech.QUEUE_FLUSH, null, "frase")
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun startListening() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
muteSound()
|
||||||
|
}
|
||||||
|
mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onReadyForSpeech(params: Bundle?) {
|
||||||
|
isOnReadyForSpeech = true;
|
||||||
|
Log.i("Speech", "onReadyForSpeech")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBeginningOfSpeech() {
|
||||||
|
Log.i("Speech", "onBeginningOfSpeech")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRmsChanged(rmsdB: Float) {}
|
||||||
|
|
||||||
|
override fun onBufferReceived(buffer: ByteArray?) {
|
||||||
|
Log.i("Speech", "onBufferReceived")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEndOfSpeech() {
|
||||||
|
Log.i("Speech", "onEndOfSpeech")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(error: Int) {
|
||||||
|
if (!isOnReadyForSpeech && error == SpeechRecognizer.ERROR_NO_MATCH) {
|
||||||
|
("Problemas con la velocidad de internet. No se puede usar la voz").toast(requireContext())
|
||||||
|
return
|
||||||
|
}else{
|
||||||
|
Log.i("Speech", "onError "+error)
|
||||||
|
if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy()
|
||||||
|
mSpeechRecognizer = null
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResults(results: Bundle) {}
|
||||||
|
|
||||||
|
override fun onPartialResults(partialResults: Bundle?) {
|
||||||
|
Log.i("Speech", "onPartialResults")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEvent(eventType: Int, params: Bundle?) {
|
||||||
|
Log.i("Speech", "onEvent")
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkText(text: String): Int {
|
||||||
|
|
||||||
|
//check for nuevo
|
||||||
|
val nuevo = getMatch(text, "nuevo")
|
||||||
|
|
||||||
|
//check for listo
|
||||||
|
val listo = getMatch(text, "listo")
|
||||||
|
|
||||||
|
//check for cancelar
|
||||||
|
val cancelar = getMatch(text, "cancelar")
|
||||||
|
|
||||||
|
//check for volver
|
||||||
|
val volver = getMatch(text, "volver")
|
||||||
|
|
||||||
|
//check for repite
|
||||||
|
val repite = getMatch(text, "repite")
|
||||||
|
|
||||||
|
//check for siguiente
|
||||||
|
val otro = getMatch(text, "otro")
|
||||||
|
|
||||||
|
//check for FALTA
|
||||||
|
val falta = getMatch(text, "falta")
|
||||||
|
val words = IntArray(7)
|
||||||
|
words[0] = nuevo
|
||||||
|
words[1] = listo
|
||||||
|
words[2] = cancelar
|
||||||
|
words[3] = volver
|
||||||
|
words[4] = repite
|
||||||
|
words[5] = otro
|
||||||
|
words[6] = falta
|
||||||
|
return getMax(words)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMax(a: IntArray): Int {
|
||||||
|
var max = a[0]
|
||||||
|
var pos = 0
|
||||||
|
for (i in a.indices) {
|
||||||
|
if (a[i] > max) {
|
||||||
|
max = a[i]
|
||||||
|
pos = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return if (max < 80) {
|
||||||
|
-1
|
||||||
|
} else pos
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMatch(a: String, b: String): Int {
|
||||||
|
var count = 0
|
||||||
|
val cha = a.toCharArray()
|
||||||
|
val chb = b.toCharArray()
|
||||||
|
for (i in cha) {
|
||||||
|
for (x in chb) {
|
||||||
|
if (x == i) {
|
||||||
|
count += 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val numChar = a.length
|
||||||
|
if (numChar != 0)
|
||||||
|
return count * 100 / numChar
|
||||||
|
else
|
||||||
|
return 100
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestRecordAudioPermission() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
val requiredPermission: String = Manifest.permission.RECORD_AUDIO
|
||||||
|
val res = context!!.checkCallingOrSelfPermission(requiredPermission)
|
||||||
|
// If the user previously denied this permission then show a message explaining why
|
||||||
|
// this permission is needed
|
||||||
|
if (res == PackageManager.PERMISSION_DENIED) {
|
||||||
|
requestPermissions(arrayOf(requiredPermission), 101)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cancelSpeech(){
|
||||||
|
if (mSpeechRecognizer != null){
|
||||||
|
mSpeechRecognizer!!.destroy()
|
||||||
|
mSpeechRecognizer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun saveBuyer(buyernickname: String) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0)
|
||||||
|
val editor = prefs.edit()
|
||||||
|
editor.putString(BUYER, buyernickname)
|
||||||
|
editor.apply()
|
||||||
|
}
|
||||||
|
fun saveBuyerId(buyerid: String) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0)
|
||||||
|
val editor = prefs.edit()
|
||||||
|
editor.putString(BUYERID, buyerid)
|
||||||
|
editor.apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*open fun wordToNumber(input: String?): Int {
|
||||||
|
var input = input
|
||||||
|
var isValidInput = true
|
||||||
|
var result = 0
|
||||||
|
var finalResult = 0
|
||||||
|
if (input != null && input.length > 0) {
|
||||||
|
input = input.replace("-".toRegex(), " ")
|
||||||
|
input = input.toLowerCase().replace(" and".toRegex(), " ")
|
||||||
|
val splittedParts =
|
||||||
|
input.trim { it <= ' ' }.split("\\s+".toRegex()).toTypedArray()
|
||||||
|
for (str in splittedParts) {
|
||||||
|
if (!es.verdnatura.warehouse.UTILS.Utils.allowedStrings.contains(str)) {
|
||||||
|
isValidInput = false
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isValidInput) {
|
||||||
|
for (str in splittedParts) {
|
||||||
|
if (str.equals("cero", ignoreCase = true)) {
|
||||||
|
result += 0
|
||||||
|
} else if (str.equals("uno", ignoreCase = true)) {
|
||||||
|
result += 1
|
||||||
|
} else if (str.equals("dos", ignoreCase = true)) {
|
||||||
|
result += 2
|
||||||
|
} else if (str.equals("tres", ignoreCase = true)) {
|
||||||
|
result += 3
|
||||||
|
} else if (str.equals("cuatro", ignoreCase = true)) {
|
||||||
|
result += 4
|
||||||
|
} else if (str.equals("cinco", ignoreCase = true)) {
|
||||||
|
result += 5
|
||||||
|
} else if (str.equals("seis", ignoreCase = true)) {
|
||||||
|
result += 6
|
||||||
|
} else if (str.equals("siete", ignoreCase = true)) {
|
||||||
|
result += 7
|
||||||
|
} else if (str.equals("ocho", ignoreCase = true)) {
|
||||||
|
result += 8
|
||||||
|
} else if (str.equals("nueve", ignoreCase = true)) {
|
||||||
|
result += 9
|
||||||
|
} else if (str.equals("diez", ignoreCase = true)) {
|
||||||
|
result += 10
|
||||||
|
} else if (str.equals("once", ignoreCase = true)) {
|
||||||
|
result += 11
|
||||||
|
} else if (str.equals("doce", ignoreCase = true)) {
|
||||||
|
result += 12
|
||||||
|
} else if (str.equals("trece", ignoreCase = true)) {
|
||||||
|
result += 13
|
||||||
|
} else if (str.equals("catorce", ignoreCase = true)) {
|
||||||
|
result += 14
|
||||||
|
} else if (str.equals("quince", ignoreCase = true)) {
|
||||||
|
result += 15
|
||||||
|
} else if (str.equals("dieziseis", ignoreCase = true)) {
|
||||||
|
result += 16
|
||||||
|
} else if (str.equals("diezisiete", ignoreCase = true)) {
|
||||||
|
result += 17
|
||||||
|
} else if (str.equals("dieziocho", ignoreCase = true)) {
|
||||||
|
result += 18
|
||||||
|
} else if (str.equals("diezinueve", ignoreCase = true)) {
|
||||||
|
result += 19
|
||||||
|
} else if (str.equals("veinte", ignoreCase = true)) {
|
||||||
|
result += 20
|
||||||
|
} else if (str.equals("treinta", ignoreCase = true)) {
|
||||||
|
result += 30
|
||||||
|
} else if (str.equals("cuarenta", ignoreCase = true)) {
|
||||||
|
result += 40
|
||||||
|
} else if (str.equals("cincuenta", ignoreCase = true)) {
|
||||||
|
result += 50
|
||||||
|
} else if (str.equals("sesenta", ignoreCase = true)) {
|
||||||
|
result += 60
|
||||||
|
} else if (str.equals("setenta", ignoreCase = true)) {
|
||||||
|
result += 70
|
||||||
|
} else if (str.equals("ochenta", ignoreCase = true)) {
|
||||||
|
result += 80
|
||||||
|
} else if (str.equals("noventa", ignoreCase = true)) {
|
||||||
|
result += 90
|
||||||
|
} else if (str.equals("cien", ignoreCase = true)) {
|
||||||
|
result *= 100
|
||||||
|
} else if (str.equals("mil", ignoreCase = true)) {
|
||||||
|
result *= 1000
|
||||||
|
finalResult += result
|
||||||
|
result = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalResult += result
|
||||||
|
return finalResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finalResult
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package es.verdnatura.presentation.base
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleObserver
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
abstract class BaseViewModel : ViewModel(), LifecycleObserver
|
|
@ -0,0 +1,22 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
|
import androidx.databinding.BindingAdapter
|
||||||
|
import org.koin.core.KoinComponent
|
||||||
|
|
||||||
|
object BindingAdapter : KoinComponent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set view visibility depending boolean
|
||||||
|
*
|
||||||
|
* @param isVisible - If true, set view to VISIBLE, else set view to GONE
|
||||||
|
*/
|
||||||
|
@BindingAdapter("isVisible")
|
||||||
|
@JvmStatic
|
||||||
|
fun View.isVisible(isVisible: Boolean) {
|
||||||
|
visibility = if (isVisible) VISIBLE else GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
open class Event<out T>(private val content: T) {
|
||||||
|
|
||||||
|
var hasBeenHandled = false
|
||||||
|
private set // Allow external read but not write
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the content and prevents its use again.
|
||||||
|
*/
|
||||||
|
fun getContentIfNotHandled(): T? {
|
||||||
|
return if (hasBeenHandled) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
hasBeenHandled = true
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the content, even if it's already been handled.
|
||||||
|
*/
|
||||||
|
fun peekContent(): T = content
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
class ResponseItemVO (
|
||||||
|
var response:String = "",
|
||||||
|
var isError: Boolean = false,
|
||||||
|
var errorMessage: String = ""
|
||||||
|
)
|
|
@ -0,0 +1,105 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionScanVO
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
|
||||||
|
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||||
|
|
||||||
|
interface OnOptionsSelectedListener {
|
||||||
|
fun onOptionsItemSelected(item: Drawable)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnPasillerosItemClickListener {
|
||||||
|
fun onPasillerosItemClickListener(item: PasillerosItemVO,entryPoint:String)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnAjustesItemClickListener {
|
||||||
|
fun onAjustesItemClickListener(item: AjustesItemVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface OnItemCardRowClickListener {
|
||||||
|
fun onItemCardRowClickListener(item: ItemCardRowVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnBarcodeRowClickListener {
|
||||||
|
fun onBarcodeRowClickListener(item: BarcodeVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnLocationRowClickListener {
|
||||||
|
fun onLocationRowClickListener(item: ItemLocationVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnInvetoryNichoClickListener {
|
||||||
|
fun onInvetoryNichoClickListener(item: ItemInventaryVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnFaltasNichoClickListener {
|
||||||
|
fun onFaltasNichoClickListener(item: ItemFaltasVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnFaltasReviewClickListener {
|
||||||
|
fun onFaltasReviewClickListener(item: ItemFaltasVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnAutomaticItemClickListener {
|
||||||
|
fun onAutomaticItemClickListener(position: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnVisibleClickListener {
|
||||||
|
fun onVisibleClickListener(item: ItemUbicadorVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnMoreClickListener {
|
||||||
|
fun onMoreClickListener(item: ItemUbicadorVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnTruckClickListener {
|
||||||
|
fun onTruckClickListener(item: ItemExpeditionTruckVO,entryPoint: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnPalletClickListener {
|
||||||
|
fun onPalletClickListener(itemTruck: ItemExpeditionTruckVO,itemPallet: ItemPalletVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnComprobarPalletViewClickListener {
|
||||||
|
fun onComprobarPalletViewClickListener(itemTruck: ItemExpeditionTruckVO,itemPallet: ItemPalletVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnScanLongClickListener {
|
||||||
|
fun onScanLongClickListener(ItemExpeditionScanVO: ItemExpeditionScanVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnCollectionSelectedListener {
|
||||||
|
fun onCollectionSelected(collection: CollectionVO,type:String)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnQuantityClickListener {
|
||||||
|
fun onQuantityClick(sale: SaleVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnSaleClickListener {
|
||||||
|
fun onSaleClick(sale: SaleVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnMistakeClickListener {
|
||||||
|
fun onMistakeClickListener(sale:SaleVO)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnBuyerSelectedListener {
|
||||||
|
fun onBuyerSelected(userFk:String)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnStarSelectedListener {
|
||||||
|
fun onStarSelected(vId:String, vStars:String)
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.media.AudioManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.request.target.CustomTarget
|
||||||
|
import com.bumptech.glide.request.transition.Transition
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
|
inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) =
|
||||||
|
beginTransaction().func().commit()
|
||||||
|
|
||||||
|
|
||||||
|
fun <T> Context.openActivity(it: Class<T>, extras: Bundle.() -> Unit = {}) {
|
||||||
|
val intent = Intent(this, it)
|
||||||
|
intent.putExtras(Bundle().apply(extras))
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FragmentActivity.replaceFragment(
|
||||||
|
fragment: Fragment,
|
||||||
|
frameId: Int,
|
||||||
|
tag: String,
|
||||||
|
addToBackStack: Boolean = false
|
||||||
|
) {
|
||||||
|
supportFragmentManager.inTransaction {
|
||||||
|
replace(frameId, fragment, tag)
|
||||||
|
if (addToBackStack) addToBackStack(tag)
|
||||||
|
setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FragmentActivity.addFragment(
|
||||||
|
fragment: Fragment,
|
||||||
|
frameId: Int,
|
||||||
|
tag: String = "",
|
||||||
|
addToBackStack: Boolean = false
|
||||||
|
) {
|
||||||
|
supportFragmentManager.inTransaction {
|
||||||
|
add(frameId, fragment, tag)
|
||||||
|
if (addToBackStack) addToBackStack(tag)
|
||||||
|
setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun View.setDimensions(width: Int, height: Int) {
|
||||||
|
val layoutParams = this.layoutParams
|
||||||
|
layoutParams?.width = width
|
||||||
|
layoutParams?.height = height
|
||||||
|
this.layoutParams = layoutParams
|
||||||
|
}
|
||||||
|
fun View.setMargins(left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
|
val mlp = this.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
mlp.setMargins(left, top, right, bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ImageView.loadUrl(url: String) {
|
||||||
|
Glide.with(context)
|
||||||
|
.asBitmap()
|
||||||
|
.load(url)
|
||||||
|
.into(object : CustomTarget<Bitmap>() {
|
||||||
|
|
||||||
|
override fun onLoadCleared(placeholder: Drawable?) {}
|
||||||
|
|
||||||
|
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||||
|
setImageBitmap(resource)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
inline val <reified T> T.TAG: String
|
||||||
|
get() = T::class.java.canonicalName ?: T::class.simpleName ?: T::class.java.simpleName
|
||||||
|
|
||||||
|
fun Calendar.convertToDateString(): String {
|
||||||
|
var dayOfWeek = ""
|
||||||
|
var dayOfMonth = ""
|
||||||
|
val day = this[Calendar.DATE]
|
||||||
|
|
||||||
|
when (this[Calendar.DAY_OF_WEEK]) {
|
||||||
|
1 -> dayOfWeek = "Dom"
|
||||||
|
2 -> dayOfWeek = "Lun"
|
||||||
|
3 -> dayOfWeek = "Mar"
|
||||||
|
4 -> dayOfWeek = "Mie"
|
||||||
|
5 -> dayOfWeek = "Jue"
|
||||||
|
6 -> dayOfWeek = "Vie"
|
||||||
|
7 -> dayOfWeek = "Sab"
|
||||||
|
}
|
||||||
|
|
||||||
|
when (this[Calendar.MONTH]) {
|
||||||
|
0 -> dayOfMonth = "Ene"
|
||||||
|
1 -> dayOfMonth = "Feb"
|
||||||
|
2 -> dayOfMonth = "Mar"
|
||||||
|
3 -> dayOfMonth = "Abr"
|
||||||
|
4 -> dayOfMonth = "May"
|
||||||
|
5 -> dayOfMonth = "Jun"
|
||||||
|
6 -> dayOfMonth = "Jul"
|
||||||
|
7 -> dayOfMonth = "Ago"
|
||||||
|
8 -> dayOfMonth = "Sep"
|
||||||
|
9 -> dayOfMonth = "Oct"
|
||||||
|
10 -> dayOfMonth = "Nov"
|
||||||
|
11 -> dayOfMonth = "Dic"
|
||||||
|
}
|
||||||
|
|
||||||
|
return dayOfWeek + " " + day + " " + dayOfMonth
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RecyclerView.addViewObserver(function: () -> Unit) {
|
||||||
|
val view = this
|
||||||
|
view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
view.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
function.invoke()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Fragment.hideKeyboard() {
|
||||||
|
view?.let { activity?.hideKeyboard(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Activity.hideKeyboard() {
|
||||||
|
hideKeyboard(currentFocus ?: View(this))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.hideKeyboard(view: View) {
|
||||||
|
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
val hideSoftInputFromWindow = inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension function to change media volume programmatically
|
||||||
|
fun AudioManager.setMediaVolume(volumeIndex:Int) {
|
||||||
|
// Set media volume level
|
||||||
|
this.setStreamVolume(
|
||||||
|
AudioManager.STREAM_MUSIC, // Stream type
|
||||||
|
volumeIndex, // Volume index
|
||||||
|
AudioManager.FLAG_SHOW_UI// Flags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Extension property to get media maximum volume index
|
||||||
|
val AudioManager.mediaMaxVolume:Int
|
||||||
|
get() = this.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||||
|
|
||||||
|
|
||||||
|
// Extension property to get media/music current volume index
|
||||||
|
val AudioManager.mediaCurrentVolume:Int
|
||||||
|
get() = this.getStreamVolume(AudioManager.STREAM_MUSIC)
|
|
@ -0,0 +1,42 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_dialog.*
|
||||||
|
|
||||||
|
class CustomDialog(context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialog {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(description: String): CustomDialog {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialog {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialog {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.app.TimePickerDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_hour.*
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
|
class CustomDialogHour(context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_hour)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDestinoEditText(): TextInputEditText {
|
||||||
|
return custom_dialog_destino_value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDestinoValue(): String {
|
||||||
|
return custom_dialog_destino_value.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDestinoValue(value: String): CustomDialogHour {
|
||||||
|
custom_dialog_destino_value.setText(value)
|
||||||
|
custom_dialog_destino_value.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getHoraEditText(): TextInputEditText {
|
||||||
|
return custom_dialog_hour_value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getHoraValue(): String {
|
||||||
|
return custom_dialog_hour_value.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setHoraValue(value: String): CustomDialogHour {
|
||||||
|
custom_dialog_hour_value.setText(value)
|
||||||
|
custom_dialog_hour_value.visibility = View.VISIBLE
|
||||||
|
ib_obtener_hora.setOnClickListener {
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
val timeSetListener = TimePickerDialog.OnTimeSetListener { timePicker, hour, minute ->
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, hour)
|
||||||
|
cal.set(Calendar.MINUTE, minute)
|
||||||
|
custom_dialog_hour_value.setText(SimpleDateFormat("HH:mm").format(cal.time))
|
||||||
|
}
|
||||||
|
TimePickerDialog(context, timeSetListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true).show()
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogHour {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(description: String): CustomDialogHour {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogHour {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogHour {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_dialog.custom_dialog_button_ko
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_dialog.custom_dialog_button_ok
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_dialog.custom_dialog_description
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_dialog.custom_dialog_title
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_edit_dialog.*
|
||||||
|
|
||||||
|
class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_edit_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEditText() : TextInputEditText {
|
||||||
|
return custom_dialog_value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getValue() : String {
|
||||||
|
return custom_dialog_value.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setValue(value : String): CustomDialogInput{
|
||||||
|
custom_dialog_value.setText(value)
|
||||||
|
custom_dialog_value.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogInput {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(description: String): CustomDialogInput {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogInput {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogInput {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_list_dialog.*
|
||||||
|
|
||||||
|
|
||||||
|
class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_list_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRecyclerView() : RecyclerView {
|
||||||
|
return item_recyclerview
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEditText() : TextInputEditText {
|
||||||
|
return custom_dialog_value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEditTextTwo() : TextInputEditText {
|
||||||
|
return custom_dialog_value_two
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getValue() : String {
|
||||||
|
return custom_dialog_value.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setValue(value : String): CustomDialogList{
|
||||||
|
custom_dialog_value.setText(value)
|
||||||
|
textinputlayout_username.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getValueTwo() : String {
|
||||||
|
return custom_dialog_value_two.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setValueTwo(value : String): CustomDialogList{
|
||||||
|
custom_dialog_value_two.setText(value)
|
||||||
|
textinputlayout_two.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogList {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(title: String): CustomDialogList {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setHintValue(text:String): CustomDialogList{
|
||||||
|
custom_dialog_value.hint = text
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setHintValueTwo(text:String): CustomDialogList{
|
||||||
|
custom_dialog_value_two.hint = text
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTextTwoGone():CustomDialogList{
|
||||||
|
textinputlayout_two.visibility = View.GONE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideDialog():CustomDialogList{
|
||||||
|
custom_dialog_value.visibility = View.GONE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_three_dialog.*
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.custom_dialog_button_ko
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.custom_dialog_button_ok
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.custom_dialog_button_ok_two
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.custom_dialog_description
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.custom_dialog_title
|
||||||
|
|
||||||
|
class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_three_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(description: String): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getValue() : String {
|
||||||
|
return custom_dialog_value.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEditText() : TextInputEditText {
|
||||||
|
return custom_dialog_value
|
||||||
|
}
|
||||||
|
fun setValue(value : String): CustomDialogThreeButtons{
|
||||||
|
custom_dialog_value.setText(value)
|
||||||
|
textinputlayout.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButtonTwo(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_ok_two.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok_two.text = text
|
||||||
|
custom_dialog_button_ok_two.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButtonThree(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_ok_three.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok_three.text = text
|
||||||
|
custom_dialog_button_ok_three.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButtonFour(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_ok_four.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok_four.text = text
|
||||||
|
custom_dialog_button_ok_four.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButtonAdd(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_add.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_add.text = text
|
||||||
|
custom_dialog_button_add.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_two_dialog.*
|
||||||
|
|
||||||
|
class CustomDialogTwoButtons (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_two_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogTwoButtons {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDescription(description: String): CustomDialogTwoButtons {
|
||||||
|
custom_dialog_description.visibility = View.VISIBLE
|
||||||
|
custom_dialog_description.text = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogTwoButtons {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOkButtonTwo(text: String, onButtonClicked: () -> Unit): CustomDialogTwoButtons {
|
||||||
|
custom_dialog_button_ok_two.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok_two.text = text
|
||||||
|
custom_dialog_button_ok_two.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogTwoButtons {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package es.verdnatura.presentation.view.component
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import es.verdnatura.R
|
||||||
|
import kotlinx.android.synthetic.main.component_custom_ubicador_dialog.*
|
||||||
|
|
||||||
|
class CustomDialogUbicador (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setContentView(R.layout.component_custom_ubicador_dialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setTitle(title: String): CustomDialogUbicador {
|
||||||
|
custom_dialog_title.visibility = View.VISIBLE
|
||||||
|
custom_dialog_title.text = title
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setItemValue(value : String) : CustomDialogUbicador{
|
||||||
|
custom_dialog_item.setText(value)
|
||||||
|
custom_dialog_item.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getItemValue() : String{
|
||||||
|
return custom_dialog_item.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEditItem() : TextInputEditText {
|
||||||
|
return custom_dialog_item
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setEtiquetaValue(value : String) : CustomDialogUbicador{
|
||||||
|
custom_dialog_etiquetas.setText(value)
|
||||||
|
custom_dialog_etiquetas.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEtiquetaValue() : String{
|
||||||
|
return custom_dialog_etiquetas.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEtiquetaItem() : TextInputEditText {
|
||||||
|
return custom_dialog_etiquetas
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setPackingValue(value : String) : CustomDialogUbicador{
|
||||||
|
custom_dialog_packing.setText(value)
|
||||||
|
custom_dialog_packing.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getPackingValue() : String{
|
||||||
|
return custom_dialog_packing.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getPackingItem() : TextInputEditText {
|
||||||
|
return custom_dialog_packing
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setVisibleValue(value : String) : CustomDialogUbicador{
|
||||||
|
custom_dialog_visible.setText(value)
|
||||||
|
custom_dialog_visible.visibility = View.VISIBLE
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getVisibleValue() : String{
|
||||||
|
return custom_dialog_visible.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getVisibleItem() : TextInputEditText {
|
||||||
|
return custom_dialog_visible
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicador {
|
||||||
|
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ok.text = text
|
||||||
|
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicador {
|
||||||
|
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||||
|
custom_dialog_button_ko.text = text
|
||||||
|
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ajustes.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemAjustesRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnAjustesItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||||
|
|
||||||
|
class AjustesAdapter (
|
||||||
|
private val items: List<AjustesItemVO>,
|
||||||
|
private val onAjustesItemClickListener: OnAjustesItemClickListener
|
||||||
|
): RecyclerView.Adapter<AjustesAdapter.AjustesItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||||
|
return AjustesItemHolder(
|
||||||
|
ItemAjustesRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onAjustesItemClickListener.onAjustesItemClickListener(items[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class AjustesItemHolder(
|
||||||
|
val binding: ItemAjustesRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(item: AjustesItemVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,260 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||||
|
|
||||||
|
import android.app.AlarmManager
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.preference.PreferenceManager
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import android.view.View
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentAjustesBinding
|
||||||
|
import es.verdnatura.domain.notNull
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnAjustesItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.hideKeyboard
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.activity.LoginActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.login.fragment.LoginFragment
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_ajustes.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_ajustes.splash_progress
|
||||||
|
import kotlinx.android.synthetic.main.fragment_login.*
|
||||||
|
|
||||||
|
class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(AjustesViewModel::class) {
|
||||||
|
|
||||||
|
private var user:String? = ""
|
||||||
|
private var password:String? = ""
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var sectorListVO:List<SectorItemVO> = listOf()
|
||||||
|
private var vozList:List<String> = listOf()
|
||||||
|
private var prefs: SharedPreferences? = null
|
||||||
|
private var ajustesAdapter: AjustesAdapter? = null
|
||||||
|
//añadido
|
||||||
|
private var carroList:List<String> = listOf()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = AjustesFragment()
|
||||||
|
}
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_ajustes
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
prefs = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
|
||||||
|
//modificat el InitilializeAjusts
|
||||||
|
viewModel.inititializeDefaultAjusts(prefs!!.getString(SECTORDESCRIP,getString(R.string.Sinsector)).toString(),prefs!!.getInt(SECTORFK,0),prefs!!.getInt(WAREHOUSEFK,0),prefs!!.getString(VOZ,"NO").toString(),prefs!!.getString(CARRO,"2").toString())
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.VISIBLE
|
||||||
|
user_text.setText(prefs!!.getString(USERFK,""))
|
||||||
|
val versionName = activity!!.packageManager.getPackageInfo(activity!!.packageName,0).versionName
|
||||||
|
item_version.setText(versionName)
|
||||||
|
user = prefs!!.getString(USER,"")
|
||||||
|
password = prefs!!.getString(PASSWORD,"")
|
||||||
|
|
||||||
|
|
||||||
|
txtserver.setText(this.getDefaults("base_url",this.requireContext()))
|
||||||
|
txtserver.setOnKeyListener(View.OnKeyListener { v, keyCode, event ->
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
|
||||||
|
this.setDefaults("base_url",txtserver.text.toString(),this.requireContext())
|
||||||
|
// sergio: se comenta línea de abajo porque da fallo en la app//
|
||||||
|
// this.setDefaults("base_url", edittext_server.text.toString(), this.requireContext())
|
||||||
|
this.hideKeyboard()
|
||||||
|
//sergio:creada restartapp en BaseFragment por si es necesario utilizarla de nuevo.
|
||||||
|
// se hace un restart por si se cambia el servidor para que tome nuevos valores
|
||||||
|
|
||||||
|
restartapp(this)
|
||||||
|
|
||||||
|
return@OnKeyListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
})
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
ajustesAdapter = AjustesAdapter(ajustesitem,object: OnAjustesItemClickListener{
|
||||||
|
override fun onAjustesItemClickListener(item: AjustesItemVO) {
|
||||||
|
if (item.id == 0){
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getSectors(user!!,password!!)
|
||||||
|
} else if (item.id == 1){
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}else if (item.id == 2){
|
||||||
|
// ////Log.i("VERDNATURA","Carros pulsados")
|
||||||
|
val listCarros : ArrayList<String> = ArrayList()
|
||||||
|
listCarros.add("1")
|
||||||
|
listCarros.add("2")
|
||||||
|
listCarros.add("3")
|
||||||
|
listCarros.add("4")
|
||||||
|
listCarros.add("5")
|
||||||
|
listCarros.add("6")
|
||||||
|
carroList = listCarros
|
||||||
|
|
||||||
|
val array= arrayOfNulls<String>(listCarros.size)
|
||||||
|
|
||||||
|
showDialogCarros(array=listCarros.toArray(array))
|
||||||
|
|
||||||
|
// getString(R.string.Nodisponibleenestaversión).toast(requireContext())
|
||||||
|
// getString(R.string.enbreveDisponible).toast(requireContext())
|
||||||
|
}else if (item.id == 3){
|
||||||
|
val listVoz : ArrayList<String> = ArrayList()
|
||||||
|
listVoz.add("NO")
|
||||||
|
listVoz.add("YES")
|
||||||
|
vozList = listVoz
|
||||||
|
val array = arrayOfNulls<String>(listVoz.size)
|
||||||
|
showDialogVoz(array = listVoz.toArray(array))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ajustess_items.adapter = ajustesAdapter
|
||||||
|
ajustess_items.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
loadSectorList.observe(viewLifecycleOwner, Observer { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
splash_progress.visibility = View.INVISIBLE
|
||||||
|
if (it.list != null && it.list.size > 0 && it.list.get(0).isError){
|
||||||
|
customDialog.setTitle("Error").setDescription(it.list.get(0).errorMessage).setOkButton(getString(R.string.Cerrar)){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if (it.list != null && it.list.size > 0){
|
||||||
|
val listSectores : ArrayList<String> = ArrayList()
|
||||||
|
it.list.forEach {
|
||||||
|
listSectores.add(it.description)
|
||||||
|
}
|
||||||
|
val array = arrayOfNulls<String>(listSectores.size)
|
||||||
|
sectorListVO = it.list
|
||||||
|
showDialogSector(listSectores.toArray(array))
|
||||||
|
|
||||||
|
}else{
|
||||||
|
customDialog.setTitle("Sectores").setDescription(getString(R.string.Noexistessectores)).setOkButton(getString(R.string.Cerrar)){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
super.observeViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDialogSector(array:Array<String>){
|
||||||
|
val builder = AlertDialog.Builder(this.context)
|
||||||
|
|
||||||
|
|
||||||
|
builder.setTitle(getString(R.string.Seleccionaunsector))
|
||||||
|
builder.setItems(array) { _, which ->
|
||||||
|
val selected = array[which]
|
||||||
|
sectorListVO.forEach {
|
||||||
|
if (it.description.equals(selected)){
|
||||||
|
val editor = prefs!!.edit()
|
||||||
|
editor.putString(SECTORDESCRIP,it.description)
|
||||||
|
editor.putInt(SECTORFK,it.id)
|
||||||
|
it.warehouseFk?.let { it1 -> editor.putInt(WAREHOUSEFK, it1) }
|
||||||
|
editor.apply()
|
||||||
|
|
||||||
|
viewModel.ajustesitem.get(0).sectorFk = it.id
|
||||||
|
viewModel.ajustesitem.get(0).warehouse = it.warehouseFk
|
||||||
|
viewModel.ajustesitem.get(0).selected = it.description
|
||||||
|
ajustesAdapter!!.notifyDataSetChanged()
|
||||||
|
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
val dialog = builder.create()
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDialogVoz(array:Array<String>){
|
||||||
|
val builder = AlertDialog.Builder(this.context)
|
||||||
|
|
||||||
|
|
||||||
|
builder.setTitle(getString(R.string.Seleccionaunsector))
|
||||||
|
builder.setItems(array) { _, which ->
|
||||||
|
val selected = array[which]
|
||||||
|
vozList.forEach {
|
||||||
|
if (it.equals(selected)){
|
||||||
|
val editor = prefs!!.edit()
|
||||||
|
editor.putString(VOZ,it)
|
||||||
|
editor.apply()
|
||||||
|
viewModel.ajustesitem.get(3).selected = it
|
||||||
|
ajustesAdapter!!.notifyDataSetChanged()
|
||||||
|
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialog = builder.create()
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//sergio : guardar datos
|
||||||
|
private fun showDialogCarros(array:Array<String>){
|
||||||
|
val builder = AlertDialog.Builder(this.context)
|
||||||
|
|
||||||
|
|
||||||
|
builder.setTitle(getString(R.string.Seleccionauncarro))
|
||||||
|
builder.setItems(array) { _, which ->
|
||||||
|
val selected = array[which]
|
||||||
|
carroList.forEach {
|
||||||
|
if (it.equals(selected)){
|
||||||
|
val editor = prefs!!.edit()
|
||||||
|
editor.putString(CARRO,it)
|
||||||
|
editor.apply()
|
||||||
|
|
||||||
|
viewModel.ajustesitem.get(2).selected = it
|
||||||
|
ajustesAdapter!!.notifyDataSetChanged()
|
||||||
|
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialog = builder.create()
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun setDefaults(key: String?, value: String?, context: Context?) {
|
||||||
|
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
val editor = preferences.edit()
|
||||||
|
editor.putString(key, value)
|
||||||
|
editor.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDefaults(key: String?, context: Context?): String? {
|
||||||
|
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
return preferences.getString(key, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.Transformations
|
||||||
|
import es.verdnatura.domain.GetAjustesUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.Event
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.SectorListVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
|
||||||
|
class AjustesViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
private val getAjustesUserCase:GetAjustesUserCase = GetAjustesUserCase(context)
|
||||||
|
val version : String = "5.0.0";
|
||||||
|
|
||||||
|
private val _ajustesitem by lazy { ArrayList<AjustesItemVO>() }
|
||||||
|
val ajustesitem: List<AjustesItemVO>
|
||||||
|
get() = _ajustesitem
|
||||||
|
|
||||||
|
private val _sectorList by lazy { MutableLiveData<SectorListVO>() }
|
||||||
|
val sectorList: LiveData<SectorListVO>
|
||||||
|
get() = _sectorList
|
||||||
|
|
||||||
|
|
||||||
|
val loadSectorList = Transformations.map(_sectorList) {Event(it)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun inititializeDefaultAjusts(sectorDescrip: String,sectorFk : Int, warehouseFk : Int,vozDescrip:String,carroDescrip:String) {
|
||||||
|
_ajustesitem.add(
|
||||||
|
AjustesItemVO(0,
|
||||||
|
"Sector",
|
||||||
|
sectorDescrip,
|
||||||
|
sectorFk,
|
||||||
|
warehouseFk)
|
||||||
|
)
|
||||||
|
|
||||||
|
_ajustesitem.add(
|
||||||
|
AjustesItemVO(1,
|
||||||
|
"Cerrar Sesión",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
)
|
||||||
|
_ajustesitem.add(
|
||||||
|
AjustesItemVO(2,
|
||||||
|
"Carros",
|
||||||
|
carroDescrip,
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
)
|
||||||
|
_ajustesitem.add(
|
||||||
|
AjustesItemVO(3,
|
||||||
|
"Voz",
|
||||||
|
vozDescrip,
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSectors(user:String,password:String){
|
||||||
|
getAjustesUserCase.getSectors(user,password).enqueue(object : Callback<List<SectorItemVO>>{
|
||||||
|
override fun onFailure(call: Call<List<SectorItemVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<SectorItemVO> = ArrayList()
|
||||||
|
listError.add(SectorItemVO(0,"",0,true,t.message!!))
|
||||||
|
_sectorList.value = SectorListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<SectorItemVO>>,
|
||||||
|
response: Response<List<SectorItemVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_sectorList.value = response.body()?.let { SectorListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<SectorItemVO> = ArrayList()
|
||||||
|
listError.add(SectorItemVO(0,"",0,true,"Error en la llamada sector_get"))
|
||||||
|
_sectorList.value = SectorListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ajustes.model
|
||||||
|
|
||||||
|
class AjustesItemVO (
|
||||||
|
var id: Int,
|
||||||
|
var title: String = "",
|
||||||
|
var selected: String = "",
|
||||||
|
var sectorFk : Int?,
|
||||||
|
var warehouse: Int?
|
||||||
|
)
|
||||||
|
|
||||||
|
class SectorItemVO (
|
||||||
|
var id: Int,
|
||||||
|
var description:String = "",
|
||||||
|
val warehouseFk:Int?,
|
||||||
|
val isError : Boolean = false,
|
||||||
|
var errorMessage : String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
class SectorListVO (
|
||||||
|
var list: List<SectorItemVO> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,48 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemBarcodeRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
|
||||||
|
class BarcodeAdapter(
|
||||||
|
private val items: List<BarcodeVO>,
|
||||||
|
private val onBarcodeRowClickListener: OnBarcodeRowClickListener,
|
||||||
|
private var showDelete: Boolean = true
|
||||||
|
): RecyclerView.Adapter<BarcodeAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemBarcodeRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onBarcodeRowClickListener.onBarcodeRowClickListener(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inner class ItemHolder(
|
||||||
|
val binding: ItemBarcodeRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: BarcodeVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
if (showDelete) itemImage.visibility = View.VISIBLE
|
||||||
|
else itemImage.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.ItemCardRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnItemCardRowClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||||
|
|
||||||
|
class ItemCardAdapter (
|
||||||
|
private val items: List<ItemCardRowVO>,
|
||||||
|
private val onItemCardRowClickListener: OnItemCardRowClickListener
|
||||||
|
): RecyclerView.Adapter<ItemCardAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemCardRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
if (items[position].isEditable){
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onItemCardRowClickListener.onItemCardRowClickListener(items[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ItemHolder(
|
||||||
|
val binding: ItemCardRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: ItemCardRowVO) {
|
||||||
|
binding.apply {
|
||||||
|
if (item.barcodes.isNotEmpty()){
|
||||||
|
item.value = ""
|
||||||
|
item.barcodes.forEach {
|
||||||
|
item.value = item.value + it.code + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.item = item
|
||||||
|
if (item.isEditable){
|
||||||
|
itemImage.visibility = View.VISIBLE
|
||||||
|
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_5))
|
||||||
|
}else{
|
||||||
|
itemImage.visibility = View.INVISIBLE
|
||||||
|
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_9))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,517 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.fragment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentItemCardBinding
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnItemCardRowClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.loadUrl
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.adapter.ItemCardAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.imageview.activity.ImageViewActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.fragment.SearchBuyerModel
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.buyers_fragment.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_item_card.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_item_card.splash_progress
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class ItemCardFragment(
|
||||||
|
var itemFk:String = ""
|
||||||
|
) : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>(ItemCardViewModel::class) {
|
||||||
|
|
||||||
|
private var urlLarge:String = ""
|
||||||
|
private var titleImage:String = ""
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private var adapter : ItemCardAdapter? = null
|
||||||
|
private var barcodeAdapter : BarcodeAdapter? = null
|
||||||
|
private var listItemsRow:ArrayList<ItemCardRowVO> = ArrayList()
|
||||||
|
private var listBarcodes:ArrayList<BarcodeVO> = ArrayList()
|
||||||
|
private var itemsPackingType:ArrayList<ItemPackingType> = ArrayList()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var itemInfoG:ItemCardVO? = null
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(entryPoint:String) = ItemCardFragment(entryPoint)
|
||||||
|
}
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private lateinit var customDialogInput: CustomDialogInput
|
||||||
|
private lateinit var customDialogList: CustomDialogList
|
||||||
|
private lateinit var customDialogTwo: CustomDialogTwoButtons
|
||||||
|
|
||||||
|
private val _buyersList by lazy { MutableLiveData<BuyerListVO>() }
|
||||||
|
val buyersList: LiveData<BuyerListVO>
|
||||||
|
get() = _buyersList
|
||||||
|
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_item_card
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
itemcard_layout.visibility = View.GONE
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
setEvents()
|
||||||
|
toolbar_title.text = getString(R.string.ConsultarArticulo)
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
|
customDialogList = CustomDialogList(requireContext())
|
||||||
|
customDialogTwo = CustomDialogTwoButtons(requireContext())
|
||||||
|
//sergio: se le pasa el item desde otros fragments
|
||||||
|
if (!itemFk.isNullOrEmpty()){
|
||||||
|
getItemCard(itemFk)
|
||||||
|
}
|
||||||
|
setToolBar()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun setToolBar(){
|
||||||
|
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||||
|
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
|
||||||
|
val iconHistory : Drawable = resources.getDrawable(R.drawable.ic_history_black_24dp,resources.newTheme())
|
||||||
|
listIcons.add(iconReload)
|
||||||
|
listIcons.add(iconHistory)
|
||||||
|
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
if (item == iconReload){
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
getItemCard(itemFk)
|
||||||
|
}
|
||||||
|
if (item == iconHistory){
|
||||||
|
if (itemFk.isNullOrEmpty()){
|
||||||
|
"Escanea un item".toast(activity!!)
|
||||||
|
}else{
|
||||||
|
(activity as MainActivity).onPasillerosItemClickListener( PasillerosItemVO(title = "Historico"),itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
edit_itemFk.requestFocus()
|
||||||
|
edit_itemFk.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!edit_itemFk.text.toString().isNullOrEmpty())
|
||||||
|
getItemCard(edit_itemFk.text.toString())
|
||||||
|
edit_itemFk.setText("")
|
||||||
|
(activity as MainActivity).hideKeyboard(edit_itemFk)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
itemcard_image.setOnClickListener {
|
||||||
|
val i:Intent = Intent(activity,ImageViewActivity::class.java)
|
||||||
|
i.putExtra("url",urlLarge)
|
||||||
|
i.putExtra("title",titleImage)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getItemCard(itemFk:String){
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
this.itemFk = itemFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getItemCard(itemFk,warehouseFk,user!!,password!!)
|
||||||
|
viewModel.getItemPackingType(user!!,password!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
itemcard.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (it.isError){
|
||||||
|
itemcard_layout.visibility = View.GONE
|
||||||
|
toolbar_title.text = "ItemCard"
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
if (it.id != "0"){
|
||||||
|
itemcard_layout.visibility = View.VISIBLE
|
||||||
|
setItemCard(it)
|
||||||
|
}else{
|
||||||
|
itemcard_layout.visibility = View.GONE
|
||||||
|
toolbar_title.text = "ItemCard"
|
||||||
|
customDialog.setTitle("Sin resultados").setDescription("No hemos podido encontrar el articulo. Revisa el sector.").setOkButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
itemspackinglist.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
// Log.i("VERDNATURA","el code es $it.code")
|
||||||
|
// Log.i("VERDNATURA","la descrip es $it.description")
|
||||||
|
createItemTypeTypeList(it.list)
|
||||||
|
})
|
||||||
|
|
||||||
|
response.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (it.isError){
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
getItemCard(itemFk)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createItemTypeTypeList(list: List<ItemPackingType>) {
|
||||||
|
itemsPackingType.clear()
|
||||||
|
list.forEach { item ->
|
||||||
|
if (!item.isError){
|
||||||
|
try {
|
||||||
|
itemsPackingType.add(ItemPackingType(item.code,item.description));
|
||||||
|
// Log.i("VERDNATURA","Nombre encajado ${item.code} : ${item.description}")
|
||||||
|
}catch (e:Exception){}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun setItemCard(itemInfo:ItemCardVO){
|
||||||
|
itemInfoG = itemInfo
|
||||||
|
toolbar_title.text = itemInfo.id+"-"+itemInfo.longName
|
||||||
|
titleImage = itemInfo.id+"-"+itemInfo.longName
|
||||||
|
itemcard_image.setImageDrawable(resources.getDrawable(R.drawable.loadphoto,resources.newTheme()))
|
||||||
|
itemcard_image.loadUrl(itemInfo.urlImage200)
|
||||||
|
urlLarge = itemInfo.urlImage
|
||||||
|
itemcard_tag1.text = itemInfo.size
|
||||||
|
itemcard_tag2.text = itemInfo.value5
|
||||||
|
itemcard_tag3.text = itemInfo.value6
|
||||||
|
itemcard_tag4.text = itemInfo.value7 + " " + itemInfo.origin
|
||||||
|
listItemsRow = ArrayList()
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.total),value = itemInfo.total,isEditable = false))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Disponible),value = itemInfo.available,isEditable = false))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Ubicado),value = itemInfo.enAltillo,isEditable = false))
|
||||||
|
|
||||||
|
//EDITABLES
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.SINUBICAR),value = itemInfo.enNicho,isEditable = false, action = "itemStockUpdate"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.DARALTA),value = "",isEditable = true, action = "itemStockUpdateAdd"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.DARBAJA),value = "",isEditable = true, action = "itemStockUpdateRemove"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.BUSCARITEM),value = "",isEditable = true, action = "buscarItem"))
|
||||||
|
//listItemsRow.add(ItemCardRowVO(title = "NICHO",value = itemInfo.nicho,isEditable = true, action = "itemPlacementSave"))
|
||||||
|
// listItemsRow.add(ItemCardRowVO(title = "RESERVA",value = itemInfo.reserva,isEditable = true, action = "itemPlacementSave"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Grouping),value = itemInfo.grouping,isEditable = true, action = "updateGrouping"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Packing),value = itemInfo.packing,isEditable = true, action = "updatePacking"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.MINIMO),value = itemInfo.min,isEditable = true, action = "itemSaveMin"))
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Barcode),barcodes = itemInfo.barcodes,isEditable = true, action = "toBarcode"))
|
||||||
|
//sergio para itemTypePacking
|
||||||
|
listItemsRow.add(ItemCardRowVO(title = getString(R.string.tipodeencajado),value = itemInfo.itemPackingTypeFk,isEditable = true, action = "updateSector"))
|
||||||
|
|
||||||
|
listBarcodes = itemInfo.barcodes as ArrayList<BarcodeVO>
|
||||||
|
|
||||||
|
adapter = ItemCardAdapter(listItemsRow,object: OnItemCardRowClickListener{
|
||||||
|
override fun onItemCardRowClickListener(item: ItemCardRowVO) {
|
||||||
|
|
||||||
|
if (item.action=="updateSector"){ showDialogSelectItemTypePacking()
|
||||||
|
}else{
|
||||||
|
if(item.action != "toBarcode" && item.action != "buscarItem" && item.action != "itemStockUpdateAdd" && item.action != "itemStockUpdateRemove"){
|
||||||
|
customDialogInput.setTitle(item.title!!).setDescription("Valor actual: "+item.value!!).setOkButton("Guardar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!customDialogInput.getValue().isNullOrEmpty())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}else if(item.action == "toBarcode"){
|
||||||
|
//BARCODE ROW
|
||||||
|
prepareBarcodeDialog(item)
|
||||||
|
}else if(item.action == "buscarItem"){
|
||||||
|
(activity as MainActivity).onPasillerosItemClickListener( PasillerosItemVO(title = "Buscar item"),itemFk)
|
||||||
|
}else if(item.action == "itemStockUpdateAdd"){
|
||||||
|
customDialogInput.setTitle(item.title!!).setDescription("Indica la cantidad a dar de alta").setOkButton("Guardar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!customDialogInput.getValue().isNullOrEmpty())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}else if(item.action == "itemStockUpdateRemove"){
|
||||||
|
customDialogInput.setTitle(item.title!!).setDescription("Indica la cantidad a dar de baja ").setOkButton("Guardar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!customDialogInput.getValue().isNullOrEmpty())
|
||||||
|
editItemCardRow(item,customDialogInput.getValue())
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
itemcard_recyclerview.adapter = adapter
|
||||||
|
itemcard_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
scroll_view.post(Runnable {
|
||||||
|
val position = IntArray(2)
|
||||||
|
if (itemcard_image != null){
|
||||||
|
itemcard_image.getLocationInWindow(position)
|
||||||
|
scroll_view.scrollTo(0, position[1])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun editItemCardRow(item:ItemCardRowVO,value:String){
|
||||||
|
|
||||||
|
when (item.action){
|
||||||
|
"itemStockUpdate" -> prepareItemStockUpdate(item,value)
|
||||||
|
"itemStockUpdateAdd" -> prepareItemStockUpdate2(item,value)
|
||||||
|
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item,value)
|
||||||
|
"itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value)
|
||||||
|
"updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk)
|
||||||
|
"updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk)
|
||||||
|
"itemSaveMin" -> viewModel.itemSaveMin(itemFk = itemFk, user = user, password = password, value = value)
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.action != "itemStockUpdate")
|
||||||
|
changeOfflineValue(item,value, listBarcodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeOfflineValue(item:ItemCardRowVO,newValue:String, barcodes:List<BarcodeVO>){
|
||||||
|
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
/*var i = 0
|
||||||
|
var position = 0
|
||||||
|
listItemsRow.forEach {
|
||||||
|
if (it.title == item.title) {
|
||||||
|
position = i
|
||||||
|
}
|
||||||
|
i = i.plus(1)
|
||||||
|
}
|
||||||
|
if (listItemsRow.get(position).title != "BARCODE") listItemsRow.get(position).value = newValue
|
||||||
|
else listItemsRow.get(position).barcodes = barcodes
|
||||||
|
adapter?.notifyDataSetChanged()*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareItemStockUpdate(itemB:ItemCardRowVO,value:String){
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (itemB.value!!.toInt() > value.toInt()) {
|
||||||
|
customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){
|
||||||
|
viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
|
||||||
|
}.setOkButtonTwo("Basura"){
|
||||||
|
viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1")
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
|
||||||
|
}
|
||||||
|
}catch (e:Exception){
|
||||||
|
itemcard_layout.visibility = View.GONE
|
||||||
|
customDialog.setTitle("Error").setDescription("El elemento introducido no es un número").setKoButton("Cancelar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareItemStockUpdate2(itemB:ItemCardRowVO,value:String){
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (itemB.action == "itemStockUpdateRemove") {
|
||||||
|
customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){
|
||||||
|
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
|
||||||
|
}.setOkButtonTwo("Basura"){
|
||||||
|
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1")
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
|
||||||
|
customDialogTwo.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
changeOfflineValue(itemB,value, listBarcodes)
|
||||||
|
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0")
|
||||||
|
}
|
||||||
|
}catch (e:Exception){
|
||||||
|
itemcard_layout.visibility = View.GONE
|
||||||
|
customDialog.setTitle("Error").setDescription("El elemento introducido no es un número").setKoButton("Cancelar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareBarcodeDialog(itemB:ItemCardRowVO){
|
||||||
|
|
||||||
|
customDialogList.setTitle("Barcodes").setOkButton("Guardar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
|
||||||
|
if (!customDialogList.getValue().isNullOrEmpty())
|
||||||
|
updateBarcode(customDialogList.getValue(),"0",itemB)
|
||||||
|
customDialogList.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton("Cerrar"){
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
|
||||||
|
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
|
||||||
|
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!customDialogList.getValue().isNullOrEmpty())
|
||||||
|
updateBarcode(customDialogList.getValue(),"0",itemB)
|
||||||
|
customDialogList.setValue("")
|
||||||
|
customDialogList.dismiss()
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
barcodeAdapter = BarcodeAdapter(listBarcodes,object: OnBarcodeRowClickListener{
|
||||||
|
override fun onBarcodeRowClickListener(item: BarcodeVO) {
|
||||||
|
updateBarcode(item.code!!,"1",itemB)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
customDialogList.getRecyclerView().adapter = barcodeAdapter
|
||||||
|
|
||||||
|
customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateBarcode(code:String,delete:String,item:ItemCardRowVO){
|
||||||
|
if (delete == "1"){
|
||||||
|
var i = 0
|
||||||
|
var posDelete = 0
|
||||||
|
listBarcodes.forEach {
|
||||||
|
if (it.code == code)
|
||||||
|
posDelete = i
|
||||||
|
i+=1
|
||||||
|
}
|
||||||
|
listBarcodes.removeAt(posDelete)
|
||||||
|
}else{
|
||||||
|
listBarcodes.add(BarcodeVO(code))
|
||||||
|
}
|
||||||
|
viewModel.barcodesEdit(itemFk = itemFk, user = user, password = password, value = code, delete = delete)
|
||||||
|
barcodeAdapter!!.notifyDataSetChanged()
|
||||||
|
changeOfflineValue(item,"", listBarcodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDialogSelectItemTypePacking(){
|
||||||
|
|
||||||
|
var array= arrayOfNulls<String>(itemsPackingType.size)
|
||||||
|
for (indice in array.indices){
|
||||||
|
array[indice]=itemsPackingType[indice].code + " : "+itemsPackingType[indice].description
|
||||||
|
}
|
||||||
|
val builder = AlertDialog.Builder(this.context)
|
||||||
|
builder.setTitle(getString(R.string.mensajeseleccionencajado))
|
||||||
|
.setItems(array
|
||||||
|
) { dialog, position ->
|
||||||
|
updateItemPackingType(itemsPackingType[position].code.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.create().show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateItemPackingType(itemPackingType:String) {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.updatePackingType(this.itemFk,user,password,itemPackingType)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,226 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.fragment
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetItemCardUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerListVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class ItemCardViewModel(context: Context) : BaseViewModel() {
|
||||||
|
private val getItemCardUserCase:GetItemCardUserCase = GetItemCardUserCase(context)
|
||||||
|
val version : String = "5.0.0";
|
||||||
|
|
||||||
|
private val _itemcard by lazy { MutableLiveData<ItemCardVO>() }
|
||||||
|
val itemcard: LiveData<ItemCardVO>
|
||||||
|
get() = _itemcard
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
private val _itemspackinglist by lazy { MutableLiveData<ItemPackingTypeList>() }
|
||||||
|
val itemspackinglist: LiveData<ItemPackingTypeList>
|
||||||
|
get() = _itemspackinglist
|
||||||
|
|
||||||
|
|
||||||
|
fun getItemCard(itemFk:String,warehouseFk:String,user:String,password:String) {
|
||||||
|
getItemCardUserCase.getItemCard(user,password,itemFk,warehouseFk).enqueue(object :Callback<ItemCardVO>{
|
||||||
|
override fun onFailure(call: Call<ItemCardVO>, t: Throwable) {
|
||||||
|
_itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al OBTENER "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<ItemCardVO>, response: Response<ItemCardVO>) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_itemcard.value = response.body()!!
|
||||||
|
}else{
|
||||||
|
_itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al llamar a vn.itemCard")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getItemPackingType(user:String,password:String) {
|
||||||
|
getItemCardUserCase.getItemPackingType(user,password).enqueue(object :
|
||||||
|
Callback<List<ItemPackingType>>{
|
||||||
|
override fun onFailure(call: Call<List<ItemPackingType>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<ItemPackingType> = ArrayList()
|
||||||
|
listError.add(ItemPackingType(isError = true,errorMessage = t.message!!))
|
||||||
|
_itemspackinglist.value = ItemPackingTypeList(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<List<ItemPackingType>>, response: Response<List<ItemPackingType>>) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_itemspackinglist.value = response.body()?.let { ItemPackingTypeList(it) }
|
||||||
|
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<ItemPackingType> = ArrayList()
|
||||||
|
listError.add(ItemPackingType(isError = true,errorMessage = "Error en la llamada de getItemPackingType"))
|
||||||
|
_itemspackinglist.value = ItemPackingTypeList(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){
|
||||||
|
getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){
|
||||||
|
getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemTrash")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String){
|
||||||
|
getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar NICHO "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSave")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String){
|
||||||
|
getItemCardUserCase.updateGrouping(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar GROUPING "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updateGrouping")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updatePacking(itemFk:String,user:String,password:String,value:String,warehouseFk: String){
|
||||||
|
getItemCardUserCase.updatePacking(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PACKING "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//sergio ver como solucionar el tema del "Finish"
|
||||||
|
fun updatePackingType(itemFk:String,user:String,password:String,itemPackingType:String){
|
||||||
|
getItemCardUserCase.updatePackingType(user,password,itemFk,itemPackingType).enqueue(object : Callback<Boolean>{
|
||||||
|
override fun onFailure(call: Call<Boolean>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PackingType "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePackingType")
|
||||||
|
}else{
|
||||||
|
//if (response.body()=="Finish"){
|
||||||
|
// Log.i("VERDNATURA","Fisnih encontrado")}
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemSaveMin(itemFk:String,user:String,password:String,value:String){
|
||||||
|
getItemCardUserCase.itemSaveMin(user,password,itemFk,value).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar MIN "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun barcodesEdit(itemFk:String,user:String,password:String,value:String,delete:String){
|
||||||
|
getItemCardUserCase.barcodes_edit(user,password,itemFk,value,delete).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar BARCODES "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemBarcode_update")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.model
|
||||||
|
|
||||||
|
class ItemCardVO (
|
||||||
|
var id:String = "0",
|
||||||
|
var longName:String = "0",
|
||||||
|
var value5:String = "",
|
||||||
|
var value6:String = "0",
|
||||||
|
var value7:String = "0",
|
||||||
|
var image:String = "0",
|
||||||
|
var size:String = "0",
|
||||||
|
var stems:String = "0",
|
||||||
|
var category:String = "0",
|
||||||
|
var producer:String = "0",
|
||||||
|
var origin:String = "0",
|
||||||
|
var nicho:String = "0",
|
||||||
|
var reserva:String = "0",
|
||||||
|
var enNicho:String = "0",
|
||||||
|
var available:String = "0",
|
||||||
|
var enAltillo:String = "0",
|
||||||
|
var repo:String = "0",
|
||||||
|
var total:String = "0",
|
||||||
|
var min:String = "0",
|
||||||
|
var grouping:String = "0",
|
||||||
|
var packing:String = "0",
|
||||||
|
var barcodes:List<BarcodeVO> = listOf(),
|
||||||
|
var tag5:String = "",
|
||||||
|
var tag6:String = "",
|
||||||
|
var tag7:String = "",
|
||||||
|
var isError: Boolean = false,
|
||||||
|
var errorMessage:String = "",
|
||||||
|
var urlImage200:String = "",
|
||||||
|
var urlImage:String = "",
|
||||||
|
var itemPackingTypeFk:String =" "
|
||||||
|
)
|
||||||
|
|
||||||
|
class ItemCardRowVO (
|
||||||
|
var title:String? = "",
|
||||||
|
var value:String? = "",
|
||||||
|
var isEditable:Boolean = true,
|
||||||
|
var action:String = "",
|
||||||
|
var barcodes: List<BarcodeVO> = listOf()
|
||||||
|
)
|
||||||
|
|
||||||
|
class BarcodeVO(
|
||||||
|
var code:String? = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.articulo.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ItemPackingType (
|
||||||
|
|
||||||
|
var code:String= "",
|
||||||
|
var description:String = "",
|
||||||
|
var isError: Boolean = false,
|
||||||
|
var errorMessage:String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
class ItemPackingTypeList (
|
||||||
|
var list: List<ItemPackingType> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,43 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritem.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemLocationRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
|
||||||
|
class LocationAdapter (
|
||||||
|
private val items: List<ItemLocationVO>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||||
|
): RecyclerView.Adapter<LocationAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemLocationRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Ubicador"),items[position].Matricula)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ItemHolder(
|
||||||
|
val binding: ItemLocationRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: ItemLocationVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentBuscarItemBinding
|
||||||
|
import es.verdnatura.domain.notNull
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.adapter.LocationAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class BuscarItemFragment(
|
||||||
|
var itemFk:String = ""
|
||||||
|
) : BaseFragment<FragmentBuscarItemBinding,BuscarItemViewModel>(BuscarItemViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private var adapter : LocationAdapter? = null
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(entryPoint:String) = BuscarItemFragment(entryPoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_buscar_item
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
toolbar_title.text = getString(R.string.getubicaition)
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
setEvents()
|
||||||
|
if (!itemFk.isNullOrEmpty()){
|
||||||
|
getLocations(itemFk)
|
||||||
|
}
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
edit_itemFk.requestFocus()
|
||||||
|
edit_itemFk.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!edit_itemFk.text.toString().isNullOrEmpty())
|
||||||
|
getLocations(edit_itemFk.text.toString())
|
||||||
|
edit_itemFk.setText("")
|
||||||
|
(activity as MainActivity).hideKeyboard(edit_itemFk)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getLocations(itemFk:String){
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
this.itemFk = itemFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getLocations(user,password,itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
loadLocationList.observe(viewLifecycleOwner, Observer { event ->
|
||||||
|
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
adapter = LocationAdapter(it.list,pasillerosItemClickListener!!)
|
||||||
|
|
||||||
|
location_recyclerview.adapter = adapter
|
||||||
|
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
var totalVisible:Int = 0
|
||||||
|
it.list.forEach {
|
||||||
|
if (!it.visible.isNullOrEmpty())
|
||||||
|
totalVisible += it.visible.toInt()
|
||||||
|
}
|
||||||
|
toolbar_title.text = "Item: "+itemFk+ " Total visible: "+totalVisible
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.Transformations
|
||||||
|
import es.verdnatura.domain.GetBuscarItemUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.Event
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class BuscarItemViewModel(context: Context) : BaseViewModel() {
|
||||||
|
private val getBuscarItemUserCase: GetBuscarItemUserCase = GetBuscarItemUserCase(context)
|
||||||
|
|
||||||
|
|
||||||
|
private val _locationList by lazy { MutableLiveData<LocationListVO>() }
|
||||||
|
val locationList: LiveData<LocationListVO>
|
||||||
|
get() = _locationList
|
||||||
|
|
||||||
|
|
||||||
|
val loadLocationList = Transformations.map(_locationList) { Event(it) }
|
||||||
|
|
||||||
|
|
||||||
|
fun getLocations(user:String,password:String,itemFk:String){
|
||||||
|
getBuscarItemUserCase.searchItemsUbicador(user,password,itemFk).enqueue(object : Callback<List<ItemLocationVO>> {
|
||||||
|
override fun onFailure(call: Call<List<ItemLocationVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<ItemLocationVO> = ArrayList()
|
||||||
|
listError.add(ItemLocationVO(isError = true,errorMessage = t.message!!))
|
||||||
|
_locationList.value = LocationListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<ItemLocationVO>>,
|
||||||
|
response: Response<List<ItemLocationVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_locationList.value = response.body()?.let { LocationListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<ItemLocationVO> = ArrayList()
|
||||||
|
listError.add(ItemLocationVO(isError = true,errorMessage = "Error en la llamada de searchItemsUbicador"))
|
||||||
|
_locationList.value = LocationListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritem.model
|
||||||
|
|
||||||
|
|
||||||
|
class ItemLocationVO (
|
||||||
|
var Parking:String = "",
|
||||||
|
var Matricula:String = "",
|
||||||
|
var visible:String = "",
|
||||||
|
var Disponible:String = "",
|
||||||
|
var level:String = "",
|
||||||
|
var created:String = "",
|
||||||
|
var itemFk:String = "",
|
||||||
|
val isError : Boolean = false,
|
||||||
|
var errorMessage : String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
class LocationListVO (
|
||||||
|
var list: List<ItemLocationVO> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,44 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritemall.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemLocationAllRowBinding
|
||||||
|
import es.verdnatura.databinding.ItemLocationRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
|
||||||
|
class LocationAdapterAll (
|
||||||
|
private val items: List<ItemLocationAll>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||||
|
): RecyclerView.Adapter<LocationAdapterAll.ItemHolderAll> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolderAll{
|
||||||
|
return ItemHolderAll(
|
||||||
|
ItemLocationAllRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolderAll, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Ubicador"),items[position].Matricula)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ItemHolderAll(
|
||||||
|
val binding: ItemLocationAllRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: ItemLocationAll) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentBuscarItemAllBinding
|
||||||
|
import es.verdnatura.domain.notNull
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.adapter.LocationAdapterAll
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.fragment.BuscarItemAllViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item.edit_itemFk
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item.location_recyclerview
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item.splash_progress
|
||||||
|
import kotlinx.android.synthetic.main.fragment_buscar_item_all.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_inventary.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class BuscarItemAllFragment(
|
||||||
|
var itemFk:String = ""
|
||||||
|
) : BaseFragment<FragmentBuscarItemAllBinding, BuscarItemAllViewModel>(BuscarItemAllViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private var adapter : LocationAdapterAll? = null
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(entryPoint:String) = BuscarItemAllFragment(entryPoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_buscar_item_all
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
toolbar_title.text = getString(R.string.getubicaition)
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
setEvents()
|
||||||
|
if (!itemFk.isNullOrEmpty()){
|
||||||
|
getLocations(itemFk)
|
||||||
|
}
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
edit_itemFk.requestFocus()
|
||||||
|
edit_itemFk.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!edit_itemFk.text.toString().isNullOrEmpty())
|
||||||
|
getLocations(edit_itemFk.text.toString())
|
||||||
|
edit_itemFk.setText("")
|
||||||
|
(activity as MainActivity).hideKeyboard(edit_itemFk)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_itemFk.setOnKeyListener { v, keyCode, event ->
|
||||||
|
Log.i("VERDNATURA","text")
|
||||||
|
return@setOnKeyListener false}
|
||||||
|
/*if (filter_itemFk.text.toString().isNullOrEmpty()){
|
||||||
|
if (listInvetory.size != listInvetoryAux.size){
|
||||||
|
listInvetory.removeAll(listInvetoryAux)
|
||||||
|
listInvetoryAux.forEach {
|
||||||
|
listInvetory.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
listInvetory.removeAll(listInvetoryAux)
|
||||||
|
listInvetoryAux.forEach {
|
||||||
|
if ((it.itemFk.contains(filter_itemFk.text.toString(),true)) || (it.producer?.contains(filter_itemFk.text.toString(),true))){
|
||||||
|
listInvetory.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
LocationAdapterAll!!.notifyDataSetChanged()
|
||||||
|
return@setOnKeyListener false
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getLocations(itemFk:String){
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
this.itemFk = itemFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getLocationsAll(user,password,itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
loadLocationListAll.observe(viewLifecycleOwner, Observer { event ->
|
||||||
|
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
adapter = LocationAdapterAll(it.list,pasillerosItemClickListener!!)
|
||||||
|
|
||||||
|
location_all_recyclerview.adapter = adapter
|
||||||
|
location_all_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
var totalVisible:Int = 0
|
||||||
|
it.list.forEach {
|
||||||
|
if (!it.visible.isNullOrEmpty())
|
||||||
|
totalVisible += it.visible.toInt()
|
||||||
|
}
|
||||||
|
toolbar_title.text = "Item: "+itemFk+ " Total visible: "+totalVisible
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritemall.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.Transformations
|
||||||
|
import es.verdnatura.domain.GetBuscarItemAllUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.Event
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll
|
||||||
|
import es.verdnatura.presentation.view.feature.buscaritemall.model.LocationListAll
|
||||||
|
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class BuscarItemAllViewModel(context: Context) : BaseViewModel() {
|
||||||
|
private val getBuscarItemAllUserCase: GetBuscarItemAllUserCase = GetBuscarItemAllUserCase(context)
|
||||||
|
|
||||||
|
|
||||||
|
private val _locationListAll by lazy { MutableLiveData<LocationListAll>() }
|
||||||
|
val locationListAll: LiveData<LocationListAll>
|
||||||
|
get() = _locationListAll
|
||||||
|
|
||||||
|
|
||||||
|
val loadLocationListAll = Transformations.map(_locationListAll) { Event(it) }
|
||||||
|
|
||||||
|
|
||||||
|
fun getLocationsAll(user:String,password:String,itemFk:String){
|
||||||
|
getBuscarItemAllUserCase.searchItemsUbicadorAll(user,password,itemFk).enqueue(object : Callback<List<ItemLocationAll>> {
|
||||||
|
override fun onFailure(call: Call<List<ItemLocationAll>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<ItemLocationAll> = ArrayList()
|
||||||
|
listError.add(ItemLocationAll(isError = true,errorMessage = t.message!!))
|
||||||
|
_locationListAll.value = LocationListAll(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<ItemLocationAll>>,
|
||||||
|
response: Response<List<ItemLocationAll>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_locationListAll.value = response.body()?.let { LocationListAll(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<ItemLocationAll> = ArrayList()
|
||||||
|
listError.add(ItemLocationAll(isError = true,errorMessage = "Error en la llamada de searchItemsUbicadorAll"))
|
||||||
|
_locationListAll.value = LocationListAll(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.buscaritemall.model
|
||||||
|
|
||||||
|
|
||||||
|
class ItemLocationAll (
|
||||||
|
var Parking:String = "",
|
||||||
|
var Matricula:String = "",
|
||||||
|
var visible:String = "",
|
||||||
|
var Disponible:String = "",
|
||||||
|
var level:String = "",
|
||||||
|
var created:String = "",
|
||||||
|
var itemFk:String = "",
|
||||||
|
val isError : Boolean = false,
|
||||||
|
var errorMessage : String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
class LocationListAll (
|
||||||
|
var list: List<ItemLocationAll> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,124 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemBuyerRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnStarSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.convertToDateString
|
||||||
|
import es.verdnatura.presentation.common.loadUrl
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ItemBuyersAdapter (
|
||||||
|
private val items: List<ItemBuyerVO>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||||
|
private val onStarSelectedListener: OnStarSelectedListener
|
||||||
|
): RecyclerView.Adapter<ItemBuyersAdapter.BuyersItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BuyersItemHolder {
|
||||||
|
return BuyersItemHolder(
|
||||||
|
ItemBuyerRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: BuyersItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inner class BuyersItemHolder(
|
||||||
|
val binding: ItemBuyerRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(item: ItemBuyerVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.itemBuyer = item
|
||||||
|
if (item != null && item.image != "")
|
||||||
|
imgItem.loadUrl("https://verdnatura.es/vn-image-data/catalog/200x200/"+item.image);
|
||||||
|
else
|
||||||
|
imgItem.loadUrl("https://verdnatura.es/vn-image-data/catalog/200x200/"+item.itemFk);
|
||||||
|
|
||||||
|
imgItem.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.showStars) layoutStars.visibility = View.VISIBLE
|
||||||
|
else layoutStars.visibility = View.GONE
|
||||||
|
|
||||||
|
|
||||||
|
s1.setOnClickListener {
|
||||||
|
onStarSelectedListener.onStarSelected(item.id,"1")
|
||||||
|
}
|
||||||
|
|
||||||
|
s2.setOnClickListener {
|
||||||
|
onStarSelectedListener.onStarSelected(item.id,"2")
|
||||||
|
}
|
||||||
|
|
||||||
|
s3.setOnClickListener {
|
||||||
|
onStarSelectedListener.onStarSelected(item.id,"3")
|
||||||
|
}
|
||||||
|
|
||||||
|
s4.setOnClickListener {
|
||||||
|
onStarSelectedListener.onStarSelected(item.id,"4")
|
||||||
|
}
|
||||||
|
|
||||||
|
s5.setOnClickListener {
|
||||||
|
onStarSelectedListener.onStarSelected(item.id,"5")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.stars != null && item.stars != ""){
|
||||||
|
try {
|
||||||
|
val punt = item.stars.toInt()
|
||||||
|
if (punt == 1){
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceKo)
|
||||||
|
s3.setImageResource(item.iconResourceKo)
|
||||||
|
s4.setImageResource(item.iconResourceKo)
|
||||||
|
s5.setImageResource(item.iconResourceKo)
|
||||||
|
}else if (punt == 2){
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceOk)
|
||||||
|
s3.setImageResource(item.iconResourceKo)
|
||||||
|
s4.setImageResource(item.iconResourceKo)
|
||||||
|
s5.setImageResource(item.iconResourceKo)
|
||||||
|
}else if (punt == 3){
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceOk)
|
||||||
|
s3.setImageResource(item.iconResourceOk)
|
||||||
|
s4.setImageResource(item.iconResourceKo)
|
||||||
|
s5.setImageResource(item.iconResourceKo)
|
||||||
|
}else if (punt == 4){
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceOk)
|
||||||
|
s3.setImageResource(item.iconResourceOk)
|
||||||
|
s4.setImageResource(item.iconResourceOk)
|
||||||
|
s5.setImageResource(item.iconResourceKo)
|
||||||
|
}else if (punt == 5){
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceOk)
|
||||||
|
s3.setImageResource(item.iconResourceOk)
|
||||||
|
s4.setImageResource(item.iconResourceOk)
|
||||||
|
s5.setImageResource(item.iconResourceOk)
|
||||||
|
}else{
|
||||||
|
s1.setImageResource(item.iconResourceOk)
|
||||||
|
s2.setImageResource(item.iconResourceOk)
|
||||||
|
s3.setImageResource(item.iconResourceOk)
|
||||||
|
s4.setImageResource(item.iconResourceOk)
|
||||||
|
s5.setImageResource(item.iconResourceOk)
|
||||||
|
}
|
||||||
|
}catch (e:Exception){}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.BuyersFragmentBinding
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnAjustesItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnBuyerSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.buyers_fragment.*
|
||||||
|
import kotlinx.android.synthetic.main.buyers_fragment.splash_progress
|
||||||
|
import kotlinx.android.synthetic.main.fragment_ajustes.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(BuyersViewModel::class) {
|
||||||
|
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var onBuyerSelectedListener : OnBuyerSelectedListener? = null
|
||||||
|
private var buyersAdapter: AjustesAdapter? = null
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = BuyersFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.buyers_fragment
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnBuyerSelectedListener) onBuyerSelectedListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
sectorFk = prefs.getInt(SECTORFK,1).toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
viewModel.itemShelvingBuyerGet(user = user,password = password)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
toolbar_title.text = getString(R.string.quality)
|
||||||
|
setToolBar()
|
||||||
|
setEvents()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToolBar(){
|
||||||
|
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||||
|
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
|
||||||
|
listIcons.add(iconReload)
|
||||||
|
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
if (item == iconReload){
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.itemShelvingBuyerGet(user = user,password = password)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel) {
|
||||||
|
buyersList.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
createBuyerList(it.list)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createBuyerList(list:List<BuyerVO>){
|
||||||
|
var buyers = ArrayList<AjustesItemVO>()
|
||||||
|
list.forEach { buyer ->
|
||||||
|
if (!buyer.isError){
|
||||||
|
try {
|
||||||
|
buyers.add(
|
||||||
|
AjustesItemVO(
|
||||||
|
id = buyer.userFk.toInt(),
|
||||||
|
title = buyer.nickname,
|
||||||
|
sectorFk = 0,
|
||||||
|
warehouse = 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}catch (e:Exception){}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buyersAdapter = AjustesAdapter(buyers,object: OnAjustesItemClickListener {
|
||||||
|
override fun onAjustesItemClickListener(item: AjustesItemVO) {
|
||||||
|
onBuyerSelectedListener?.onBuyerSelected(item.id.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
buyers_items.adapter = buyersAdapter
|
||||||
|
buyers_items.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetQualityUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class BuyersViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase(context)
|
||||||
|
|
||||||
|
private val _buyersList by lazy { MutableLiveData<BuyerListVO>() }
|
||||||
|
val buyersList: LiveData<BuyerListVO>
|
||||||
|
get() = _buyersList
|
||||||
|
|
||||||
|
fun itemShelvingBuyerGet(user:String,password:String){
|
||||||
|
getQualityUserCase.itemShelvingBuyerGet(user,password).enqueue(object :
|
||||||
|
Callback<List<BuyerVO>> {
|
||||||
|
override fun onFailure(call: Call<List<BuyerVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<BuyerVO> = ArrayList()
|
||||||
|
listError.add(BuyerVO(isError = true,errorMessage = t.message!!))
|
||||||
|
_buyersList.value = BuyerListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<BuyerVO>>,
|
||||||
|
response: Response<List<BuyerVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_buyersList.value = response.body()?.let { BuyerListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<BuyerVO> = ArrayList()
|
||||||
|
listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet"))
|
||||||
|
_buyersList.value = BuyerListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.QaualityFragmentBinding
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.*
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.adapter.ItemBuyersAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_collection.*
|
||||||
|
import kotlinx.android.synthetic.main.qauality_fragment.*
|
||||||
|
import kotlinx.android.synthetic.main.qauality_fragment.scan_input
|
||||||
|
import kotlinx.android.synthetic.main.qauality_fragment.splash_progress
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
class QaualityFragment(
|
||||||
|
var userFk : String = "0"
|
||||||
|
) : BaseFragment<QaualityFragmentBinding,QaualityViewModel>(QaualityViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var buyersAdapter: ItemBuyersAdapter? = null
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
private var onStarSelectedListener : OnStarSelectedListener? = null
|
||||||
|
private var listItems:List<ItemBuyerVO> = listOf()
|
||||||
|
private var lm : LinearLayoutManager? = null
|
||||||
|
private var storedPosition: Int = 0
|
||||||
|
private var goBack:Boolean = false
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(userFk:String) = QaualityFragment(userFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.qauality_fragment
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
sectorFk = prefs.getInt(SECTORFK,1).toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
toolbar_title.text = "itemShelving_BuyerTask"
|
||||||
|
setToolBar()
|
||||||
|
setEvents()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
goBack = true
|
||||||
|
storedPosition = lm?.findFirstVisibleItemPosition() ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToolBar(){
|
||||||
|
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||||
|
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
|
||||||
|
listIcons.add(iconReload)
|
||||||
|
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
if (item == iconReload){
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
//ESCANER =========
|
||||||
|
hideKeyboards()
|
||||||
|
scan_input.requestFocus()
|
||||||
|
scan_input.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!scan_input.text.toString().isNullOrEmpty()){
|
||||||
|
findSale(scan_input.text.toString())
|
||||||
|
}
|
||||||
|
scan_input.setText("")
|
||||||
|
hideKeyboards()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun hideKeyboards(){
|
||||||
|
try{
|
||||||
|
requireActivity().hideKeyboard()
|
||||||
|
}catch (e:Exception){}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel) {
|
||||||
|
buyersList.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
createBuyerList(it.list)
|
||||||
|
})
|
||||||
|
|
||||||
|
response.observe(viewLifecycleOwner, Observer {
|
||||||
|
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createBuyerList(list:List<ItemBuyerVO>){
|
||||||
|
list.forEach { item ->
|
||||||
|
if (!goBack){
|
||||||
|
if (item.created != null && item.created != ""){
|
||||||
|
item.created = getCalendarFromDate(item.created).convertToDateString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.visible.contains("Visible:",ignoreCase = true)){
|
||||||
|
item.visible = item.visible
|
||||||
|
}else{
|
||||||
|
item.visible = "Visible: "+item.visible
|
||||||
|
}
|
||||||
|
|
||||||
|
item.iconResourceOk = R.drawable.ic_start_ok
|
||||||
|
item.iconResourceKo = R.drawable.ic_star_ko
|
||||||
|
}
|
||||||
|
goBack = false
|
||||||
|
listItems = list
|
||||||
|
buyersAdapter = ItemBuyersAdapter(listItems,pasillerosItemClickListener!!,object: OnStarSelectedListener{
|
||||||
|
override fun onStarSelected(vId: String, vStars: String) {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.itemShelvingStarsUpdate(user,password,vId,vStars)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
shelving_buyers_items.adapter = buyersAdapter
|
||||||
|
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
shelving_buyers_items.layoutManager = lm
|
||||||
|
|
||||||
|
if (storedPosition < listItems.size)
|
||||||
|
goToPosition(storedPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCalendarFromDate(date:String): Calendar {
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd")
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
cal.setTime(sdf.parse(date))
|
||||||
|
return cal
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findSale(matricula:String){
|
||||||
|
var isSearch = false
|
||||||
|
var index = 0
|
||||||
|
var position = 0
|
||||||
|
listItems.forEach { item ->
|
||||||
|
if (item.shelvingFk.toUpperCase() == matricula.toUpperCase()){
|
||||||
|
item.showStars = true
|
||||||
|
if (!isSearch){
|
||||||
|
position = index
|
||||||
|
isSearch = true
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
item.showStars = false
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
storedPosition = position
|
||||||
|
goToPosition(position)
|
||||||
|
|
||||||
|
buyersAdapter?.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun goToPosition(position:Int){
|
||||||
|
if (shelving_buyers_items != null){
|
||||||
|
shelving_buyers_items.addViewObserver {
|
||||||
|
lm!!.scrollToPositionWithOffset(position,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetQualityUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class QaualityViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase(context)
|
||||||
|
|
||||||
|
private val _buyersList by lazy { MutableLiveData<ItemBuyerListVO>() }
|
||||||
|
val buyersList: LiveData<ItemBuyerListVO>
|
||||||
|
get() = _buyersList
|
||||||
|
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
|
||||||
|
fun itemShelvingBuyerTask(user:String,password:String,userFk:String){
|
||||||
|
getQualityUserCase.itemShelvingBuyerTask(user,password,userFk).enqueue(object :
|
||||||
|
Callback<List<ItemBuyerVO>> {
|
||||||
|
override fun onFailure(call: Call<List<ItemBuyerVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<ItemBuyerVO> = ArrayList()
|
||||||
|
listError.add(ItemBuyerVO(isError = true,errorMessage = t.message!!))
|
||||||
|
_buyersList.value = ItemBuyerListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<ItemBuyerVO>>,
|
||||||
|
response: Response<List<ItemBuyerVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_buyersList.value = response.body()?.let { ItemBuyerListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<ItemBuyerVO> = ArrayList()
|
||||||
|
listError.add(ItemBuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelvingBuyerTask"))
|
||||||
|
_buyersList.value = ItemBuyerListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) {
|
||||||
|
getQualityUserCase.itemShelvingStarsUpdate(usuario,password,vId,vStars).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingStarsUpdate")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.calidad.model
|
||||||
|
|
||||||
|
//import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
|
|
||||||
|
class BuyerVO (
|
||||||
|
var userFk:String = "",
|
||||||
|
var nickname:String= "",
|
||||||
|
var isError:Boolean = false,
|
||||||
|
var errorMessage:String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class BuyerListVO (
|
||||||
|
var list: List<BuyerVO> = listOf()
|
||||||
|
)
|
||||||
|
|
||||||
|
class ItemBuyerVO (
|
||||||
|
var id:String = "",
|
||||||
|
var itemFk:String = "",
|
||||||
|
var longName:String = "",
|
||||||
|
var image:String = "",
|
||||||
|
var parking:String = "",
|
||||||
|
var shelvingFk:String = "",
|
||||||
|
var visible:String = "",
|
||||||
|
var created:String = "",
|
||||||
|
var stars:String = "",
|
||||||
|
var isError:Boolean = false,
|
||||||
|
var errorMessage:String = "",
|
||||||
|
var showStars:Boolean = false,
|
||||||
|
var iconResourceOk: Int = 0,
|
||||||
|
var iconResourceKo: Int = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
class ItemBuyerListVO(
|
||||||
|
var list: List<ItemBuyerVO> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,10 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.collection
|
||||||
|
|
||||||
|
class ItemVO(
|
||||||
|
var id : String = "",
|
||||||
|
var longName : String = "",
|
||||||
|
var visible : String = "",
|
||||||
|
var available : String = "",
|
||||||
|
var isError: Boolean = false,
|
||||||
|
var errorMessage: String = ""
|
||||||
|
)
|
|
@ -0,0 +1,46 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemPlacementRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
||||||
|
|
||||||
|
class PlacementAdapter (
|
||||||
|
private val items: List<PlacementVO>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||||
|
): RecyclerView.Adapter<PlacementAdapter.AjustesItemHolder> () {
|
||||||
|
var context: Context? = null
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||||
|
this.context = parent.context
|
||||||
|
return AjustesItemHolder(
|
||||||
|
ItemPlacementRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class AjustesItemHolder(
|
||||||
|
val binding: ItemPlacementRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(placement: PlacementVO) {
|
||||||
|
binding.apply {
|
||||||
|
if (placement.placement.isNullOrEmpty())
|
||||||
|
placement.placement = placement.parking
|
||||||
|
if (placement.visible.isNullOrEmpty())
|
||||||
|
placement.visible = "("+placement.stockTotal+")"
|
||||||
|
this.item = placement
|
||||||
|
itemRootLayout.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Ubicador"),placement.shelving)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.ItemArticleRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnQuantityClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnSaleClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||||
|
|
||||||
|
class SaleAdapter (
|
||||||
|
private val items: List<SaleVO>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||||
|
private val onQuantityClick: OnQuantityClickListener,
|
||||||
|
private val onSaleClickListener: OnSaleClickListener,
|
||||||
|
private val onMistakeClickListener: OnMistakeClickListener
|
||||||
|
): RecyclerView.Adapter<SaleAdapter.AjustesItemHolder> () {
|
||||||
|
var context:Context? = null
|
||||||
|
var position:Int = 0
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||||
|
this.context = parent.context
|
||||||
|
return AjustesItemHolder(
|
||||||
|
ItemArticleRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||||
|
this.position = position
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class AjustesItemHolder(
|
||||||
|
val binding: ItemArticleRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(sale: SaleVO) {
|
||||||
|
binding.apply {
|
||||||
|
if (sale.pickedQuantity.isNullOrEmpty())
|
||||||
|
sale.pickedQuantity = "0"
|
||||||
|
|
||||||
|
val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
|
||||||
|
|
||||||
|
itemArticlePlacements.apply {
|
||||||
|
layoutManager = childLayoutManager
|
||||||
|
adapter = PlacementAdapter(sale.placements,onPasillerosItemClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
//CLICK EVENTS
|
||||||
|
contentLayout.setOnClickListener {
|
||||||
|
onSaleClickListener.onSaleClick(sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemArticleItemFk.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),sale.itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
itemArticleQuantity.setOnClickListener {
|
||||||
|
onQuantityClick.onQuantityClick(sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemArticleQuantityPicked.setOnClickListener {
|
||||||
|
onQuantityClick.onQuantityClick(sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
txtde.setOnClickListener {
|
||||||
|
onQuantityClick.onQuantityClick(sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentLayout.setOnLongClickListener {
|
||||||
|
onMistakeClickListener.onMistakeClickListener(sale)
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
//ERROR
|
||||||
|
if (sale.originalQuantity != sale.quantity){
|
||||||
|
layoutError.visibility = View.VISIBLE
|
||||||
|
txtError.text = "Cantidad original: "+sale.originalQuantity
|
||||||
|
if (sale.isPrepared == "1" || sale.isControlled == "1")
|
||||||
|
sale.pickedQuantity = sale.quantity
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sale.isNew){
|
||||||
|
layoutError.visibility = View.VISIBLE
|
||||||
|
txtError.text = "Artículo nuevo"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sale.isNew && sale.originalQuantity == sale.quantity){
|
||||||
|
layoutError.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//SEMAFORO
|
||||||
|
if (sale.isPreviousPrepared == "1"){
|
||||||
|
itemArticleRowSemaforoPre.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_sky_blue))
|
||||||
|
}else{
|
||||||
|
itemArticleRowSemaforoPre.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sale.isPrepared == "1"){
|
||||||
|
itemArticleRowSemaforoSac.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_pumpkin_orange))
|
||||||
|
}else{
|
||||||
|
itemArticleRowSemaforoSac.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sale.isControlled == "1"){
|
||||||
|
itemArticleRowSemaforoCon.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_mint))
|
||||||
|
}else{
|
||||||
|
itemArticleRowSemaforoCon.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sale.isControlled == "1"){
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_mint))
|
||||||
|
}else if (sale.isPrepared == "1"){
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_pumpkin_orange))
|
||||||
|
}else if (sale.isPreviousPrepared == "1"){
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_sky_blue))
|
||||||
|
}else{
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_black))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//ASIGNAMOS VALOR A LA VSITA
|
||||||
|
this.sale = sale
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,354 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.collection.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetLoginUserCase
|
||||||
|
import es.verdnatura.domain.GetSacadorControladorUserCase
|
||||||
|
import es.verdnatura.domain.GetUbicadorUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.*
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class CollectionViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
val emptyMessage = "La colección no tiene tickets";
|
||||||
|
|
||||||
|
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context)
|
||||||
|
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context)
|
||||||
|
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context)
|
||||||
|
|
||||||
|
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
|
||||||
|
val collectionTicketList: LiveData<CollectionVO>
|
||||||
|
get() = _collectionTicketList
|
||||||
|
|
||||||
|
private val _placementSuppleyList by lazy { MutableLiveData<PlacementSupplyListVO>() }
|
||||||
|
val placementSuppleyList: LiveData<PlacementSupplyListVO>
|
||||||
|
get() = _placementSuppleyList
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
private val _responseNew by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val responseNew: LiveData<ResponseItemVO>
|
||||||
|
get() = _responseNew
|
||||||
|
|
||||||
|
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val responseCode: LiveData<ResponseItemVO>
|
||||||
|
get() = _responseCode
|
||||||
|
|
||||||
|
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val responseIncQuantity: LiveData<ResponseItemVO>
|
||||||
|
get() = _responseIncQuantity
|
||||||
|
|
||||||
|
private val _mistakeList by lazy { MutableLiveData<MistakeTypeListVO>() }
|
||||||
|
val mistakeList: LiveData<MistakeTypeListVO>
|
||||||
|
get() = _mistakeList
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private val _item by lazy { MutableLiveData<ItemVO>() }
|
||||||
|
val item: LiveData<ItemVO>
|
||||||
|
get() = _item
|
||||||
|
|
||||||
|
|
||||||
|
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
|
||||||
|
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0").enqueue(object :
|
||||||
|
Callback<CollectionVO> {
|
||||||
|
override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
|
||||||
|
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!)
|
||||||
|
}
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<CollectionVO>,
|
||||||
|
response: Response<CollectionVO>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_collectionTicketList.value = response.body()?.let { it.map() }
|
||||||
|
}else{
|
||||||
|
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String){
|
||||||
|
getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,vBuyFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){
|
||||||
|
getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object :
|
||||||
|
Callback<List<PlacementSupplyVO>> {
|
||||||
|
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<PlacementSupplyVO> = ArrayList()
|
||||||
|
listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!))
|
||||||
|
_placementSuppleyList.value = PlacementSupplyListVO(listError)
|
||||||
|
}
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<PlacementSupplyVO>>,
|
||||||
|
response: Response<List<PlacementSupplyVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<PlacementSupplyVO> = ArrayList()
|
||||||
|
listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming"))
|
||||||
|
_placementSuppleyList.value = PlacementSupplyListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){
|
||||||
|
getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){
|
||||||
|
getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String){
|
||||||
|
getSacadorControladorUserCase.itemGetAvailable(usuario,password,itemFk,warehouseFk).enqueue(object : Callback<ItemVO>{
|
||||||
|
override fun onFailure(call: Call<ItemVO>, t: Throwable) {
|
||||||
|
_item.value = ItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<ItemVO>, response: Response<ItemVO>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_item.value = ItemVO(isError = true,errorMessage = "Error en la llamada item_GetVisibleAvailable")
|
||||||
|
}else{
|
||||||
|
_item.value = response.body()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String){
|
||||||
|
getSacadorControladorUserCase.collectionAddItem(usuario,password,itemFk,quantityFk,ticketFk,warehouseFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_responseNew.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_responseNew.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionAddItem")
|
||||||
|
}else{
|
||||||
|
_responseNew.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){
|
||||||
|
getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMove")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){
|
||||||
|
getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun saleTrackingDel(usuario:String,password:String,saleFk: String){
|
||||||
|
getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun parking(usuario: String,password: String,ticketFk: String,parking:String){
|
||||||
|
getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionUpdateState(usuario:String,password:String,collectionFk: String,state : String){
|
||||||
|
getSacadorControladorUserCase.collectionUpdateState(usuario,password,collectionFk,state).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionUpdateState")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getIdFromCode(usuario:String,password:String,code: String){
|
||||||
|
getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem")
|
||||||
|
}else{
|
||||||
|
_responseCode.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){
|
||||||
|
getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity")
|
||||||
|
}else{
|
||||||
|
_responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendChekingPresence(token:String,workerId:String,message:String){
|
||||||
|
try{
|
||||||
|
getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback<Boolean>{
|
||||||
|
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
|
||||||
|
Log.i("Salix","Mensaje enviado a salix")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(call: Call<Boolean>, t: Throwable) {
|
||||||
|
Log.i("Salix Error",""+t.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}catch (e:Exception){}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String){
|
||||||
|
getSacadorControladorUserCase.saleMistakeAdd(usuario,password,vSaleFk,vUserFk,vTypeFk).enqueue(object :
|
||||||
|
Callback<String> {
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<String>,
|
||||||
|
response: Response<String>
|
||||||
|
) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMistakeAdd")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun mistakeType(usuario:String,password:String){
|
||||||
|
getSacadorControladorUserCase.mistakeType(usuario,password).enqueue(object : Callback<List<MistakeTypeVO>>{
|
||||||
|
override fun onFailure(call: Call<List<MistakeTypeVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<MistakeTypeVO> = ArrayList()
|
||||||
|
listError.add(MistakeTypeVO("0",""))
|
||||||
|
_mistakeList.value = MistakeTypeListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<MistakeTypeVO>>,
|
||||||
|
response: Response<List<MistakeTypeVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<MistakeTypeVO> = ArrayList()
|
||||||
|
listError.add(MistakeTypeVO("0",""))
|
||||||
|
_mistakeList.value = MistakeTypeListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.collection.mapper
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.common.convertToDateString
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun CollectionVO.map() : CollectionVO{
|
||||||
|
try {
|
||||||
|
this.tickets.forEach { ticket ->
|
||||||
|
ticket.sales.forEach {
|
||||||
|
it.ticketFk = ticket.ticketFk
|
||||||
|
it.level = ticket.level
|
||||||
|
it.salePersonFk = ticket.salesPersonFk
|
||||||
|
it.agencyName = ticket.agencyName
|
||||||
|
it.quantity = it.quantity.substring(0, it.quantity.indexOf("."))
|
||||||
|
it.isNew = it.isAdded == "1"
|
||||||
|
it.originalQuantity =
|
||||||
|
if (it.originalQuantity != "-1") it.originalQuantity.substring(
|
||||||
|
0,
|
||||||
|
it.originalQuantity.indexOf(".")
|
||||||
|
) else it.quantity
|
||||||
|
it.pickedQuantity =
|
||||||
|
if (it.isPrepared == "1" || it.isPreviousPrepared == "1" || it.isControlled == "1") it.quantity else it.pickedQuantity
|
||||||
|
if (!it.placements.isNullOrEmpty()) {
|
||||||
|
it.placements.forEachIndexed { index, placement ->
|
||||||
|
if (index == 0) {
|
||||||
|
try {
|
||||||
|
it.saleOrder = placement.saleOrder.toInt()
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
it.saleOrder = 9999
|
||||||
|
}
|
||||||
|
}
|
||||||
|
placement.created =
|
||||||
|
getCalendarFromDate(placement.created).convertToDateString()
|
||||||
|
placement.visible = "(" + (if(placement.visible.toInt() > 0) placement.visible else "0") + ")"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
it.placements = listOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (e:Exception){
|
||||||
|
this.isError = true
|
||||||
|
if (this.tickets == null || this.tickets.isEmpty()){
|
||||||
|
this.errorMessage = "La colección no tiene tickets"
|
||||||
|
}else{
|
||||||
|
this.errorMessage = "Error al construir la colección"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCalendarFromDate(date:String): Calendar {
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd")
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
cal.setTime(sdf.parse(date))
|
||||||
|
return cal
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.controlador.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentControladorBinding
|
||||||
|
import es.verdnatura.domain.ConstAndValues
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnCollectionSelectedListener
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import kotlinx.android.synthetic.main.fragment_controlador.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class ControladorFragment : BaseFragment<FragmentControladorBinding,ControladorViewModel>(ControladorViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private var goBack:Boolean = false
|
||||||
|
private var onCollectionSelectedListener : OnCollectionSelectedListener? = null
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_controlador
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = ControladorFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
super.onAttach(context)
|
||||||
|
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
|
||||||
|
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
toolbar_title.text = getString(R.string.getcollection)
|
||||||
|
setEvents()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
goBack = true
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
sectorFk = prefs.getInt(SECTORFK,1).toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
|
||||||
|
scan_input.requestFocus()
|
||||||
|
scan_input.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!scan_input.text.isNullOrEmpty()) {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.collectionTicketGet(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
sectorFk = sectorFk,
|
||||||
|
collectionFk = scan_input.text.toString()
|
||||||
|
)
|
||||||
|
Log.i("VERDNATURA","La collection es ${scan_input.text.toString()}")
|
||||||
|
}
|
||||||
|
scan_input.setText("")
|
||||||
|
(activity as MainActivity).hideKeyboard(scan_input)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
collectionTicketList.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (it.isError){
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
if (!goBack)navigateToCollectionList(it)
|
||||||
|
goBack = false
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToCollectionList(collection: CollectionVO){
|
||||||
|
onCollectionSelectedListener?.onCollectionSelected(collection, ConstAndValues.CONTROLADOR)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.controlador.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetSacadorControladorUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class ControladorViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
|
||||||
|
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context)
|
||||||
|
|
||||||
|
val collectionTicketList: LiveData<CollectionVO>
|
||||||
|
get() = _collectionTicketList
|
||||||
|
|
||||||
|
|
||||||
|
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
|
||||||
|
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0").enqueue(object :
|
||||||
|
Callback<CollectionVO> {
|
||||||
|
override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
|
||||||
|
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!)
|
||||||
|
}
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<CollectionVO>,
|
||||||
|
response: Response<CollectionVO>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_collectionTicketList.value = response.body()?.let { it.map() }
|
||||||
|
}else{
|
||||||
|
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.faltas.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemFaltasRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnFaltasNichoClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnFaltasReviewClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
|
||||||
|
class FaltasAdapter (
|
||||||
|
private val items: List<ItemFaltasVO>,
|
||||||
|
private val onFaltasNichoClickListener: OnFaltasNichoClickListener,
|
||||||
|
private val onFaltasReviewClickListener:OnFaltasReviewClickListener,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||||
|
): RecyclerView.Adapter<FaltasAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemFaltasRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ItemHolder(
|
||||||
|
val binding: ItemFaltasRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: ItemFaltasVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
if(item.producer.isNullOrEmpty()){
|
||||||
|
itemProducer.visibility = View.GONE
|
||||||
|
}else{
|
||||||
|
itemProducer.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
itemNicho.setOnClickListener {
|
||||||
|
onFaltasNichoClickListener.onFaltasNichoClickListener(item)
|
||||||
|
}
|
||||||
|
itemFaltas.setOnClickListener {
|
||||||
|
onFaltasReviewClickListener.onFaltasReviewClickListener(item)
|
||||||
|
}
|
||||||
|
itemFk.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk)
|
||||||
|
}
|
||||||
|
itemUp.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
|
||||||
|
}
|
||||||
|
itemDown.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.faltas.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentFaltasBinding
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnFaltasNichoClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnFaltasReviewClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.adapter.FaltasAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_faltas.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(FaltasViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private var adapter : FaltasAdapter? = null
|
||||||
|
private lateinit var customDialogInput: CustomDialogInput
|
||||||
|
private var listInvetory:ArrayList<ItemFaltasVO> = ArrayList()
|
||||||
|
private var listInvetoryAux:ArrayList<ItemFaltasVO> = ArrayList()
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
private var reload = false
|
||||||
|
private var hideLoad = true
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = FaltasFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_faltas
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
password = prefs.getString(PASSWORD,"").toString()
|
||||||
|
sectorFk = prefs.getInt(SECTORFK,1).toString()
|
||||||
|
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||||
|
viewModel.getFaltas(user,password,warehouseFk)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
toolbar_title.text = getString(R.string.faultsReview)
|
||||||
|
setToolBar()
|
||||||
|
|
||||||
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
setEvents()
|
||||||
|
if (reload){
|
||||||
|
reload = false
|
||||||
|
hideLoad = false
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getFaltas(user,password,warehouseFk)
|
||||||
|
}
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setToolBar(){
|
||||||
|
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||||
|
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
|
||||||
|
listIcons.add(iconReload)
|
||||||
|
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
if (item == iconReload){
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getFaltas(user,password,warehouseFk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
filter_itemFk.setOnKeyListener { v, keyCode, event ->
|
||||||
|
if (filter_itemFk.text.toString().isNullOrEmpty()){
|
||||||
|
if (listInvetory.size != listInvetoryAux.size){
|
||||||
|
listInvetory.removeAll(listInvetoryAux)
|
||||||
|
listInvetoryAux.forEach {
|
||||||
|
listInvetory.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
listInvetory.removeAll(listInvetoryAux)
|
||||||
|
listInvetoryAux.forEach {
|
||||||
|
if (it.itemFk.contains(filter_itemFk.text.toString(),true)){
|
||||||
|
listInvetory.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
return@setOnKeyListener false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
faltasList.observe(viewLifecycleOwner, Observer {
|
||||||
|
if (hideLoad){
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
}else{
|
||||||
|
hideLoad = true
|
||||||
|
}
|
||||||
|
listInvetory = ArrayList()
|
||||||
|
listInvetoryAux = ArrayList()
|
||||||
|
it.list.forEach {
|
||||||
|
listInvetory.add(it)
|
||||||
|
listInvetoryAux.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter = FaltasAdapter(listInvetory,object: OnFaltasNichoClickListener {
|
||||||
|
override fun onFaltasNichoClickListener(item: ItemFaltasVO) {
|
||||||
|
customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){
|
||||||
|
viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0")
|
||||||
|
changeOfflineValue(item)
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("0").show()
|
||||||
|
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!customDialogInput.getValue().isNullOrEmpty()){
|
||||||
|
viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0")
|
||||||
|
changeOfflineValue(item)
|
||||||
|
}
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},object: OnFaltasReviewClickListener{
|
||||||
|
override fun onFaltasReviewClickListener(item: ItemFaltasVO) {
|
||||||
|
viewModel.faultsReview_isChecked(user,password,item.itemFk,warehouseFk)
|
||||||
|
changeOfflineValue(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
},pasillerosItemClickListener!!)
|
||||||
|
location_recyclerview.adapter = adapter
|
||||||
|
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
response.observe(viewLifecycleOwner, Observer {
|
||||||
|
if (it.isError){
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeOfflineValue(item: ItemFaltasVO){
|
||||||
|
var i = 0
|
||||||
|
var position = 0
|
||||||
|
listInvetory.forEach {
|
||||||
|
if (it.itemFk == item.itemFk) {
|
||||||
|
position = i
|
||||||
|
}
|
||||||
|
i = i.plus(1)
|
||||||
|
}
|
||||||
|
listInvetory.removeAt(position)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
position = 0
|
||||||
|
listInvetoryAux.forEach {
|
||||||
|
if (it.itemFk == item.itemFk) {
|
||||||
|
position = i
|
||||||
|
}
|
||||||
|
i = i.plus(1)
|
||||||
|
}
|
||||||
|
listInvetoryAux.removeAt(position)
|
||||||
|
adapter?.notifyDataSetChanged()
|
||||||
|
|
||||||
|
reload = true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.faltas.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.Transformations
|
||||||
|
import es.verdnatura.domain.GetInventaryUserCase
|
||||||
|
import es.verdnatura.domain.GetItemCardUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.Event
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO
|
||||||
|
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class FaltasViewModel(context: Context) : BaseViewModel() {
|
||||||
|
|
||||||
|
|
||||||
|
private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase(context)
|
||||||
|
private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context)
|
||||||
|
|
||||||
|
|
||||||
|
private val _faltasList by lazy { MutableLiveData<ItemFaltasListVO>() }
|
||||||
|
val faltasList: LiveData<ItemFaltasListVO>
|
||||||
|
get() = _faltasList
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
|
||||||
|
val loadFaltasList = Transformations.map(_faltasList) { Event(it) }
|
||||||
|
|
||||||
|
|
||||||
|
fun getFaltas(user:String,password:String,warehouseFk:String){
|
||||||
|
getInventaryUserCase.faultsReview(user,password,warehouseFk).enqueue(object :
|
||||||
|
Callback<List<ItemFaltasVO>> {
|
||||||
|
override fun onFailure(call: Call<List<ItemFaltasVO>>, t: Throwable) {
|
||||||
|
val listError:ArrayList<ItemFaltasVO> = ArrayList()
|
||||||
|
listError.add(ItemFaltasVO(isError = true,errorMessage = t.message!!))
|
||||||
|
_faltasList.value = ItemFaltasListVO(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<ItemFaltasVO>>,
|
||||||
|
response: Response<List<ItemFaltasVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_faltasList.value = response.body()?.let { ItemFaltasListVO(it) }
|
||||||
|
}else{
|
||||||
|
val listError:ArrayList<ItemFaltasVO> = ArrayList()
|
||||||
|
listError.add(ItemFaltasVO(isError = true,errorMessage = "Error en la llamada de faultsReview"))
|
||||||
|
_faltasList.value = ItemFaltasListVO(listError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){
|
||||||
|
getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object :
|
||||||
|
Callback<String> {
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun faultsReview_isChecked(user:String,password:String,itemFk:String,warehouseFk:String){
|
||||||
|
getInventaryUserCase.faultsReview_isChecked(user,password,itemFk,warehouseFk).enqueue(object :
|
||||||
|
Callback<String> {
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error faultsReview_isChecked "+itemFk+ " Respuesta:"+t.message!!)
|
||||||
|
}
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada faultsReview_isChecked")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.faltas.model
|
||||||
|
|
||||||
|
class ItemFaltasVO (
|
||||||
|
var itemFk:String = "",
|
||||||
|
var longName:String= "",
|
||||||
|
var size:String= "",
|
||||||
|
var producer:String= "",
|
||||||
|
var downstairs:String= "",
|
||||||
|
var upstairs:String= "",
|
||||||
|
var nicho:String= "",
|
||||||
|
var faltas:String= "",
|
||||||
|
var isError:Boolean = false,
|
||||||
|
var errorMessage:String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ItemFaltasListVO (
|
||||||
|
var list: List<ItemFaltasVO> = listOf()
|
||||||
|
)
|
|
@ -0,0 +1,46 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.historico.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.ItemHistoricoRowBinding
|
||||||
|
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class HistoricoAdapter (
|
||||||
|
private val items: List<ItemHistoricoVO>
|
||||||
|
): RecyclerView.Adapter<HistoricoAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemHistoricoRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ItemHolder(
|
||||||
|
val binding: ItemHistoricoRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
fun bind(item: ItemHistoricoVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd")
|
||||||
|
val currentDate = sdf.format(Date())
|
||||||
|
if (currentDate == item.shipped){
|
||||||
|
historicoDate.setBackgroundColor(res.getColor(R.color.verdnatura_pumpkin_orange))
|
||||||
|
}else{
|
||||||
|
historicoDate.setBackgroundColor(res.getColor(R.color.verdnatura_black_5))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue