From cac9026c883a85607cd6055386af466afaccca04 Mon Sep 17 00:00:00 2001 From: Azat Sagutdinov Date: Sat, 27 Apr 2024 09:05:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=20=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=87.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 + .../ru/tele2med/mobile/data/api/ApiService.kt | 26 + .../entity/response/TechShowListResponse.kt | 1 + .../entity/response/TechUpdateListResponse.kt | 1 + .../mobile/data/repository/DataConverter.kt | 17 + .../data/repository/TechRepositoryImpl.kt | 48 +- .../ru/tele2med/mobile/di/module/netModule.kt | 66 +- .../tele2med/mobile/domain/entity/DataShow.kt | 23 + .../mobile/domain/entity/DataTechShow.kt | 19 + .../mobile/domain/entity/DataTechUpdate.kt | 16 + .../mobile/domain/entity/TechShowList.kt | 8 + .../mobile/domain/entity/TechUpdateList.kt | 8 + .../domain/interactor/TechInteractor.kt | 18 +- .../domain/repository/TechRepository.kt | 16 +- .../mobile/presentation/router/NavScreens.kt | 5 + .../menu/items/tech/list/TechListPresenter.kt | 1 - .../list/techCheckup/TechCheckupAdapter.kt | 8 +- .../list/techCheckup/TechCheckupScreen.kt | 3 + .../info/TechCheckupInfoFragment.kt | 186 ++--- .../info/TechCheckupInfoPresenter.kt | 36 +- .../tests/TechCheckupTestsFragment.kt | 205 ++---- .../tests/TechCheckupTestsPresenter.kt | 29 +- .../techCheckup/tests/TechCheckupTestsView.kt | 6 +- .../list/techCheckup/tests/TestListAdapter.kt | 60 ++ .../main/res/layout/fragment_tech_checkup.xml | 688 +++--------------- .../main/res/layout/fragment_test_list.xml | 27 + app/src/main/res/layout/item_test.xml | 44 ++ 27 files changed, 648 insertions(+), 921 deletions(-) create mode 100644 app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechShowListResponse.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechUpdateListResponse.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/domain/entity/DataShow.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechShow.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechUpdate.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/domain/entity/TechShowList.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/domain/entity/TechUpdateList.kt create mode 100644 app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TestListAdapter.kt create mode 100644 app/src/main/res/layout/fragment_test_list.xml create mode 100644 app/src/main/res/layout/item_test.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ec2e23d..2a1bc38 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -64,6 +64,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" + android:networkSecurityConfig="@xml/network_security_config" android:usesCleartextTraffic="true" tools:ignore="GoogleAppIndexingWarning"> @@ -78,6 +79,8 @@ @@ -100,6 +103,7 @@ + + @Multipart + @POST("${API_BASE_URL}waybills/tech_control/update/{uniq_id}") + fun updateTech( + @Path("uniq_id") uuid: String, + @Part("uniq_id") uuidPart: RequestBody, + @Part("vehicle_id") vehicleId: RequestBody?, + @Part("date_") date: RequestBody?, + @Part("time_") time: RequestBody?, + @Part("result_id") resultId: RequestBody?, + @Header("token") token: String? = "iddqd", + @Header("Authorization") tokenUser: String? + ): Single + + + @Multipart + @POST("${API_BASE_URL}waybills/checklist/show/{uniq_id}") + fun show( + @Path("uniq_id") uuid: String, + @Part("uniq_id") uuidPart: RequestBody, + @Header("token") token: String? = "iddqd", + @Header("Authorization") tokenUser: String? + ): Single + + + } /*-- Дальше OLD --*/ diff --git a/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechShowListResponse.kt b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechShowListResponse.kt new file mode 100644 index 0000000..6994f82 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechShowListResponse.kt @@ -0,0 +1 @@ +package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.DataCheckup import ru.tele2med.mobile.domain.entity.DataTechCheckup import ru.tele2med.mobile.domain.entity.DataTechShow import ru.tele2med.mobile.domain.entity.DataTechUpdate data class TechShowListResponse( val af: String, val status: String, val message: String, val data: DataTechShow ) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechUpdateListResponse.kt b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechUpdateListResponse.kt new file mode 100644 index 0000000..b3c6911 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/TechUpdateListResponse.kt @@ -0,0 +1 @@ +package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.DataCheckup import ru.tele2med.mobile.domain.entity.DataTechCheckup import ru.tele2med.mobile.domain.entity.DataTechUpdate data class TechUpdateListResponse( val af: String, val status: String, val message: String, val data: DataTechUpdate ) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/data/repository/DataConverter.kt b/app/src/main/java/ru/tele2med/mobile/data/repository/DataConverter.kt index e9b7e18..86f019e 100644 --- a/app/src/main/java/ru/tele2med/mobile/data/repository/DataConverter.kt +++ b/app/src/main/java/ru/tele2med/mobile/data/repository/DataConverter.kt @@ -79,6 +79,23 @@ class DataConverter { ) + fun toTechUpdate(list: TechUpdateListResponse): TechUpdateList = + TechUpdateList( + af = list.af, + status = list.status, + data = list.data, + message = list.message + ) + + fun toTechShow(list: TechShowListResponse): TechShowList = + TechShowList( + af = list.af, + status = list.status, + data = list.data, + message = list.message + ) + + fun toTech(tech: TechResponse): Tech = Tech( af = tech.af, diff --git a/app/src/main/java/ru/tele2med/mobile/data/repository/TechRepositoryImpl.kt b/app/src/main/java/ru/tele2med/mobile/data/repository/TechRepositoryImpl.kt index 477d225..8141508 100644 --- a/app/src/main/java/ru/tele2med/mobile/data/repository/TechRepositoryImpl.kt +++ b/app/src/main/java/ru/tele2med/mobile/data/repository/TechRepositoryImpl.kt @@ -1,15 +1,12 @@ package ru.tele2med.mobile.data.repository -import ru.tele2med.mobile.domain.entity.MedicalCheckupList -import ru.tele2med.mobile.domain.entity.QR import ru.tele2med.mobile.domain.repository.QRRepository import ru.tele2med.mobile.presentation.util.Prefs import io.reactivex.Single import okhttp3.MediaType import okhttp3.RequestBody import ru.tele2med.mobile.data.api.ApiService -import ru.tele2med.mobile.domain.entity.Tech -import ru.tele2med.mobile.domain.entity.TechCheckupList +import ru.tele2med.mobile.domain.entity.* import ru.tele2med.mobile.domain.repository.TechRepository @@ -69,4 +66,47 @@ class TechRepositoryImpl( .map(dataConverter::toTechCheckupListAll) + override fun updateTech( + id: String, + vehicleId: String, + date: String, + time: String, + resultId: String + ): Single = + apiService + .updateTech( + uuid = id, + uuidPart = RequestBody.create( + MediaType.parse("text/plain"), id + ), + vehicleId = RequestBody.create( + MediaType.parse("text/plain"), vehicleId + ), + date = RequestBody.create( + MediaType.parse("text/plain"), date + ), + time = RequestBody.create( + MediaType.parse("text/plain"), time + ), + resultId = RequestBody.create( + MediaType.parse("text/plain"), resultId + ), + tokenUser = "Bearer ${prefs.getTokenUser().toString()}" + ) + .map(dataConverter::toTechUpdate) + + override fun showTech( + id: String + ): Single = + apiService + .show( + uuid = id, + uuidPart = RequestBody.create( + MediaType.parse("text/plain"), id + ), + tokenUser = "Bearer ${prefs.getTokenUser().toString()}" + ) + .map(dataConverter::toTechShow) + + } \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/di/module/netModule.kt b/app/src/main/java/ru/tele2med/mobile/di/module/netModule.kt index 62dc184..dbece82 100644 --- a/app/src/main/java/ru/tele2med/mobile/di/module/netModule.kt +++ b/app/src/main/java/ru/tele2med/mobile/di/module/netModule.kt @@ -14,9 +14,13 @@ import org.kodein.di.generic.singleton import retrofit2.Retrofit import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory import retrofit2.converter.gson.GsonConverterFactory +import java.security.KeyStore +import java.security.SecureRandom +import java.security.cert.CertificateException +import java.security.cert.X509Certificate import java.util.* import java.util.concurrent.TimeUnit -import javax.net.ssl.SSLSession +import javax.net.ssl.* import kotlin.collections.ArrayList @@ -55,12 +59,11 @@ fun verify(hostname: String?, session: SSLSession?): Boolean { } - private fun provideOkHttpClient(network: Interceptor, query: Interceptor): OkHttpClient = OkHttpClient.Builder() .connectTimeout(TIMEOUT, TimeUnit.SECONDS) .readTimeout(TIMEOUT, TimeUnit.SECONDS) - // .cookieJar(SessionCookieJar()) + // .cookieJar(SessionCookieJar()) .addInterceptor(network) .addInterceptor(query) .hostnameVerifier { hostname, session -> verify(hostname, session) } @@ -68,17 +71,68 @@ private fun provideOkHttpClient(network: Interceptor, query: Interceptor): OkHtt .build() +private fun getUnsafeOkHttpClient(): OkHttpClient? { + return try { + // Create a trust manager that does not validate certificate chains + val trustAllCerts = arrayOf( + object : X509TrustManager { + @Throws(CertificateException::class) + override fun checkClientTrusted( + chain: Array?, + authType: String? + ) { + } + + @Throws(CertificateException::class) + override fun checkServerTrusted( + chain: Array?, + authType: String? + ) { + } + + override fun getAcceptedIssuers(): Array? { + return arrayOf() + } + } + ) + + // Install the all-trusting trust manager + val sslContext = SSLContext.getInstance("SSL") + sslContext.init(null, trustAllCerts, SecureRandom()) + // Create an ssl socket factory with our all-trusting manager + val sslSocketFactory = sslContext.socketFactory + val trustManagerFactory: TrustManagerFactory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()) + trustManagerFactory.init(null as KeyStore?) + val trustManagers: Array = + trustManagerFactory.trustManagers + check(!(trustManagers.size != 1 || trustManagers[0] !is X509TrustManager)) { + "Unexpected default trust managers:" + trustManagers.contentToString() + } + + val trustManager = + trustManagers[0] as X509TrustManager + + + val builder = OkHttpClient.Builder() + builder.sslSocketFactory(sslSocketFactory, trustManager) + builder.hostnameVerifier(HostnameVerifier { _, _ -> true }) + builder.build() + } catch (e: Exception) { + throw RuntimeException(e) + } +} + private fun provideRetrofit(client: OkHttpClient, gson: Gson): Retrofit = Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create(gson)) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) - .client(client) + .client(getUnsafeOkHttpClient()) + //.client(client) .baseUrl(serverUrl) .build() - - private class SessionCookieJar : CookieJar { private var cookies: List? = null override fun saveFromResponse(url: HttpUrl, cookies: List) { diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataShow.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataShow.kt new file mode 100644 index 0000000..b300f08 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataShow.kt @@ -0,0 +1,23 @@ +package ru.tele2med.mobile.domain.entity + +data class DataShow( + val id: String, + val uniq_id: String, + val template_checklist_uniq_id: String, + val name: String?, + val type_id: String?, + val type_name: String?, + val required_field: String?, + val need_photo_if_no: String?, + val order: String, + val comment: String, + val date_create: String, + val date_update: String, + val date_delete: String, + val enabled: String, + val tree: String?, + val clf_uniq_id: String, + val has_data: String, + val value: String + +) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechShow.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechShow.kt new file mode 100644 index 0000000..279a1f9 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechShow.kt @@ -0,0 +1,19 @@ +package ru.tele2med.mobile.domain.entity + +data class DataTechShow( + val id: String, + val uniq_id: String, + val template_checklist_uniq_id: String, + val waybill_uniq_id: String?, + val techcontrol_uuid: String?, + val organization_id: String?, + val name: String?, + val comment: String?, + val date_create: String, + val date_update: String, + val date_delete: String, + val enabled: String, + val data: List + + + ) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechUpdate.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechUpdate.kt new file mode 100644 index 0000000..4515512 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTechUpdate.kt @@ -0,0 +1,16 @@ +package ru.tele2med.mobile.domain.entity + +data class DataTechUpdate( + val id: String, + val uniq_id: String, + val user_uniq_id: String, + val tech_control_uniq_id: String, + val solution: String?, + val description: String?, + val tech: String, + val date_create: String, + val date_update: String, + val date_delete: String, + val enabled: String + +) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/TechShowList.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/TechShowList.kt new file mode 100644 index 0000000..b94e510 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/TechShowList.kt @@ -0,0 +1,8 @@ +package ru.tele2med.mobile.domain.entity + +data class TechShowList( + val af: String, + val status: String, + val message: String, + val data: DataTechShow +) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/TechUpdateList.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/TechUpdateList.kt new file mode 100644 index 0000000..ef8fcae --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/TechUpdateList.kt @@ -0,0 +1,8 @@ +package ru.tele2med.mobile.domain.entity + +data class TechUpdateList( + val af: String, + val status: String, + val message: String, + val data: DataTechUpdate +) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/interactor/TechInteractor.kt b/app/src/main/java/ru/tele2med/mobile/domain/interactor/TechInteractor.kt index d673b07..0bdc4e7 100644 --- a/app/src/main/java/ru/tele2med/mobile/domain/interactor/TechInteractor.kt +++ b/app/src/main/java/ru/tele2med/mobile/domain/interactor/TechInteractor.kt @@ -1,11 +1,8 @@ package ru.tele2med.mobile.domain.interactor -import ru.tele2med.mobile.domain.entity.MedicalCheckupList -import ru.tele2med.mobile.domain.entity.QR import ru.tele2med.mobile.domain.repository.QRRepository import io.reactivex.Single -import ru.tele2med.mobile.domain.entity.Tech -import ru.tele2med.mobile.domain.entity.TechCheckupList +import ru.tele2med.mobile.domain.entity.* import ru.tele2med.mobile.domain.repository.TechRepository class TechInteractor( @@ -17,5 +14,18 @@ class TechInteractor( fun getTechCheckupList(offset: Int, limit: Int): Single = techRepository.getTechCheckupAll(offset, limit) + fun updateTech( + id: String, + vehicleId: String, + date: String, + time: String, + resultId: String + ): Single = + techRepository.updateTech(id, vehicleId, date, time, resultId) + + fun showTech( + id: String, + ): Single = + techRepository.showTech(id) } \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/repository/TechRepository.kt b/app/src/main/java/ru/tele2med/mobile/domain/repository/TechRepository.kt index 428fdad..974cb7c 100644 --- a/app/src/main/java/ru/tele2med/mobile/domain/repository/TechRepository.kt +++ b/app/src/main/java/ru/tele2med/mobile/domain/repository/TechRepository.kt @@ -1,13 +1,21 @@ package ru.tele2med.mobile.domain.repository -import ru.tele2med.mobile.domain.entity.MedicalCheckupList -import ru.tele2med.mobile.domain.entity.QR import io.reactivex.Single -import ru.tele2med.mobile.domain.entity.Tech -import ru.tele2med.mobile.domain.entity.TechCheckupList +import ru.tele2med.mobile.domain.entity.* interface TechRepository { fun getTech(id: String): Single fun getTechCheckupAll(offset: Int, limit: Int): Single + fun updateTech( + id: String, + vehicleId: String, + date: String, + time: String, + resultId: String + ): Single + + fun showTech( + id: String, + ): Single } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/router/NavScreens.kt b/app/src/main/java/ru/tele2med/mobile/presentation/router/NavScreens.kt index f45e954..9b39b3f 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/router/NavScreens.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/router/NavScreens.kt @@ -93,6 +93,11 @@ object NavScreens { fun getTechCheckup(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) + fun getTechCheckupInfo(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) + + fun getTechCheckupTests(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) + + fun getMedicalCheckups(): CheckupsScreen = CheckupsScreen() fun getAlkoScreen(): AlkoScreen = AlkoScreen() diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListPresenter.kt index 7629428..e93e43e 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListPresenter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListPresenter.kt @@ -38,7 +38,6 @@ class TechListPresenter( viewState.hideLoading() } .subscribe({ - navRouter.openTechCheckupScreen(it.data) }, { if (it is ApiException) { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupAdapter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupAdapter.kt index 0c83c6b..cf24642 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupAdapter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupAdapter.kt @@ -5,7 +5,9 @@ import android.os.Bundle import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter +import com.google.gson.Gson import ru.tele2med.mobile.R +import ru.tele2med.mobile.domain.entity.DataTech import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsFragment @@ -14,9 +16,11 @@ class TechCheckupAdapter(val context: Context, fm: FragmentManager, private var private var fragments: MutableList = mutableListOf() override fun getItem(position: Int): Fragment { + val gson = Gson() + val data = gson.fromJson(dataTech, DataTech::class.java) return when (position) { 0 -> { - val fragment = TechCheckupInfoFragment.getInstance(dataTech) + val fragment = TechCheckupInfoFragment.getInstance(data) val arguments = Bundle() fragment.arguments = arguments @@ -24,7 +28,7 @@ class TechCheckupAdapter(val context: Context, fm: FragmentManager, private var fragment } 1 -> { - val fragment = TechCheckupTestsFragment.getInstance(dataTech) + val fragment = TechCheckupTestsFragment.getInstance(data) val arguments = Bundle() fragment.arguments = arguments fragments.add(fragment) diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupScreen.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupScreen.kt index 9e96c8a..4e90ea1 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupScreen.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupScreen.kt @@ -2,12 +2,15 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup import androidx.fragment.app.Fragment import ru.tele2med.mobile.domain.entity.DataTech +import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment import ru.terrakok.cicerone.android.support.SupportAppScreen class TechCheckupScreen(val dataTech: DataTech) : SupportAppScreen() { override fun getFragment(): Fragment { + // return TechCheckupInfoFragment.getInstance(dataTech) return TechCheckupFragment.getInstance(dataTech) + } override fun getScreenKey(): String { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoFragment.kt index 842e79e..2011a8b 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoFragment.kt @@ -22,13 +22,10 @@ import ru.tele2med.mobile.presentation.ui.menu.MenuActivity import ru.tele2med.mobile.presentation.ui.menu.ReviewActivity import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuFragment import ru.tele2med.mobile.presentation.util.providePresenter -import kotlinx.android.synthetic.main.fragment_medical_checkup.* +import kotlinx.android.synthetic.main.fragment_tech_checkup.* import kotlinx.android.synthetic.main.toolbar_with_help.* -import ru.tele2med.mobile.BuildConfig import ru.tele2med.mobile.domain.entity.DataTech -import ru.tele2med.mobile.presentation.ui.auth.number_enter.NumberEnterFragment -import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsFragment -import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsPresenter +import ru.tele2med.mobile.presentation.ui.menu.items.medicalCheckup.MedicalCheckupFragment class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { @@ -72,8 +69,16 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { } } - tvDriverTitle.focusable - tvDriverTitle.requestFocus() + var dataString = this.requireArguments().getString(DATA_QR) + + Log.v("DATA", "data 32 = $DATA_QR") + + val gson = Gson() + val data = gson.fromJson(dataString, DataTech::class.java) + + + // tvDriverTitle.focusable + // tvDriverTitle.requestFocus() presenter.showCheckUp() initRecycler() @@ -88,6 +93,16 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { private fun initRecycler() { println("initRecycler") + val args = arguments + val index = args?.toString() // getString("data", "") + Log.v( + "TechCheckupInfoFragment", "data = $index ${args?.getString("data")}" + ) + + Log.v("TechCheckupInfoFragment", "args = ${arguments?.getString("data")}") + val gson = Gson() + val data = gson.fromJson(DATA_QR, DataTech::class.java) + fillData(data) refresh.setOnRefreshListener { println("setOnRefreshListener") @@ -95,6 +110,16 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { } + startTest.setOnClickListener { + presenter.updateTech( + data.uniq_id, + data.vehicle_id, + data.date_, + data.time_, + data.result_id + ) + } + } @SuppressLint("StringFormatInvalid") @@ -108,122 +133,14 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { var checkupVideoString: String var checkupVideoUrl: Uri + tvDriverNumber.text = dataTech.vehicle_name + tvDrivers.text = dataTech.mechanic_name + tvOrgName.text = dataTech.organization_id + tvNumberPL.text = dataTech.waybill_name + tvDatePL.text = dataTech.datetime - - /* profilePhoto = "${BuildConfig.API_BASE_URL}${dataQR.profilePhoto}" - profilePhotoUrl = profilePhoto.toUri() - checkupPhoto = - "${BuildConfig.API_BASE_URL}${dataQR.checkupPhoto?.replace("/media", "media")}" - checkupPhotoUrl = checkupPhoto.toUri() - checkupVideoString = - "${BuildConfig.API_BASE_URL}${dataQR.checkupVideo?.replace("/media", "media")}" - checkupVideoUrl = checkupVideoString.toUri() - - - tvMainInfoTitle.requestFocus() - - tvMainInfoTitle.text = resources.getString(R.string.block_title_main_info, dataQR.idcheckup) - tvDriverNumber.text = dataQR.login - tvSex.text = dataQR.sex_name - tvSurname.text = dataQR.lastname - tvName.text = dataQR.name - tvPatronymic.text = dataQR.oldlastname - tvBirthday.text = dataQR.birthday - tvOrgName.text = dataQR.organization - tvCheckupDate.text = dataQR.exam_date - tvCheckupBeginTime.text = dataQR.exam_timestart - tvCheckupEndTime.text = dataQR.exam_timeend - tvCheckupType.text = dataQR.inspectiontype - tvCheckupTerminal.text = dataQR.terminal_name - tvCheckupStatus.text = dataQR.exam_state_name - tvCheckupMedic.text = dataQR.medic_fio - tvResultAuto.text = dataQR.exam_result_auto_txt - tvResultMedic.text = dataQR.exam_result_med_txt - tvMedicComment.text = dataQR.medic_comment - tvCheckupResultTime.text = dataQR.exam_result_datetime - // ivCheckupPhoto.setImageURI(checkupPhotoUrl) - - - val mediaController = MediaController(requireContext()) - checkupVideo.setMediaController(mediaController) - mediaController.setMediaPlayer(checkupVideo) - - println("гружу видео $checkupVideoUrl") - println("гружу фото $checkupPhotoUrl") - - checkupVideo.setVideoURI(checkupVideoUrl) - checkupVideo.start() - // checkupVideo.background = null - println("гружу видео start") - // checkupVideo.background = resources.getDrawable(R.drawable.arrow) - /*() checkupVideo.setOnClickListener { - checkupVideo.background = null - checkupVideo.start() - } - - checkupVideo.resume() - checkupVideo.pause() */ - - Glide.with(this).load(checkupPhoto).into(ivCheckupPhoto); - - - // Picasso.get().load(checkupPhotoUrl).rotate(0f).into(ivCheckupPhoto) - Picasso.get().load(profilePhotoUrl).into(ivDriverPhoto) - - - if (dataQR.exam_result_auto == 1) { - tvResultAuto.setBackgroundColor(resources.getColor(R.color.real_green)) - tvResultAuto.setTextColor(resources.getColor(R.color.white)) - } else { - tvResultAuto.setBackgroundColor(resources.getColor(R.color.dark_red)) - tvResultAuto.setTextColor(resources.getColor(R.color.white)) - - } - - if (dataQR.exam_result_auto == 1) { - tvResultMedic.setBackgroundColor(resources.getColor(R.color.real_green)) - tvResultMedic.setTextColor(resources.getColor(R.color.white)) - } else { - tvResultMedic.setBackgroundColor(resources.getColor(R.color.dark_red)) - tvResultMedic.setTextColor(resources.getColor(R.color.white)) - } - - - if (!dataQR.alcotest.isNullOrEmpty()) { - println("не нул") - tvAlkotest.text = dataQR.alcotest - tvSyspressure.text = dataQR.syspressure - tvDiapressure.text = dataQR.diapressure - tvPulse.text = dataQR.pulse - tvCheckupTemperature.text = dataQR.temperature - tvComplaints.text = dataQR.complaints - tvCheckupReference.text = dataQR.epicrisis - } else { - tvCheckupAlkotestTitle.visibility = View.GONE - tvCheckupSyspressureTitle.visibility = View.GONE - tvCheckupDiapressureTitle.visibility = View.GONE - tvCheckupPulseTitle.visibility = View.GONE - tvCheckupTemperatureTitle.visibility = View.GONE - tvComplaintsTitle.visibility = View.GONE - tvCheckupReferenceTitle.visibility = View.GONE - - tvAlkotest.visibility = View.GONE - tvSyspressure.visibility = View.GONE - tvDiapressure.visibility = View.GONE - tvPulse.visibility = View.GONE - tvCheckupTemperature.visibility = View.GONE - tvComplaints.visibility = View.GONE - tvCheckupReference.visibility = View.GONE - - - divider14_.visibility = View.GONE - divider15_.visibility = View.GONE - divider16_.visibility = View.GONE - divider17_.visibility = View.GONE - divider18_.visibility = View.GONE - divider19_.visibility = View.GONE - divider20_.visibility = View.GONE */ - + tvStatusName.text = dataTech.exam_state_name + tvStatusTest.text = dataTech.exam_state_description } @@ -233,20 +150,27 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { companion object { - private const val DATA_QR = "DATA_QR" - fun getInstance(dataTech: String?): TechCheckupInfoFragment { + private var DATA_QR = "DATA_QR" + + fun getInstance(data: DataTech): TechCheckupInfoFragment { val gson = Gson() - Log.v("TechCheckupInfoFragment", "dataTech = $dataTech") - - val string: String = gson.toJson(dataTech) + val string: String = gson.toJson(data) + Log.v("COMP", "data = $data") + this.DATA_QR = string return TechCheckupInfoFragment().also { - it.arguments = Bundle().apply { - putString(TechCheckupInfoFragment.DATA_QR, dataTech) - } - } + Log.v("COMP", "data2 = $data") + it.arguments = Bundle().apply { + Log.v("COMP", "data3 = $data") + + putString(DATA_QR, string) + } + Log.v("COMP", "data4 = ${it.requireArguments().getString(DATA_QR)}") + + } } + private const val PERMISSION_CAMERA_REQUEST = 1 private const val RATIO_4_3_VALUE = 4.0 / 3.0 private const val RATIO_16_9_VALUE = 16.0 / 9.0 diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoPresenter.kt index 926cd3d..034f8c5 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoPresenter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/TechCheckupInfoPresenter.kt @@ -1,5 +1,6 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info +import android.util.Log import com.arellomobile.mvp.InjectViewState import com.google.gson.Gson import ru.tele2med.mobile.presentation.ui.base.BasePresenter @@ -22,11 +23,44 @@ class TechCheckupInfoPresenter( } + fun updateTech(id: String, vehicleId: String, date: String, time: String, resultId: String) { + Log.v( + "LOG", + "it id = $id, vehicleId = $vehicleId date = $date, time = $time, resultId = $resultId" + ) + + disposable += techInteractor + .updateTech(id, vehicleId, date, time, resultId) + .ioToMain() + .doOnSubscribe { + Log.v("LOG", "it 2 = $it") + viewState.showLoading() + } + .doAfterTerminate { + viewState.hideLoading() + } + .subscribe({ + Log.v("LOG", "it = $it ${it.message}") + + }, { + if (it is ApiException) { + if (it.code == RestApiCodes.NotFound.code) { + } else { + this.handleError(it) + } + } else { + this.handleError(it) + } + }) + } + + + fun showCheckUp() { val gson = Gson() val data = gson.fromJson(stringId, DataTech::class.java) println("data RoleName = ${data}") - // viewState.fillData(data) + // viewState.fillData(data) viewState.setRefreshing(false) } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsFragment.kt index dab8690..e836b1e 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsFragment.kt @@ -15,20 +15,15 @@ import com.bumptech.glide.Glide import com.google.gson.Gson import com.squareup.picasso.Picasso import ru.tele2med.mobile.R -import ru.tele2med.mobile.domain.entity.DataQR import ru.tele2med.mobile.presentation.ui.base.BasePresenter import ru.tele2med.mobile.presentation.ui.drawer.entity.ScreenType import ru.tele2med.mobile.presentation.ui.menu.MenuActivity import ru.tele2med.mobile.presentation.ui.menu.ReviewActivity import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuFragment import ru.tele2med.mobile.presentation.util.providePresenter -import kotlinx.android.synthetic.main.fragment_medical_checkup.* +import kotlinx.android.synthetic.main.fragment_test_list.* import kotlinx.android.synthetic.main.toolbar_with_help.* -import ru.tele2med.mobile.BuildConfig -import ru.tele2med.mobile.domain.entity.DataTech -import ru.tele2med.mobile.presentation.ui.menu.items.medicalCheckup.MedicalCheckupFragment -import ru.tele2med.mobile.presentation.ui.menu.items.medicalCheckup.MedicalCheckupPresenter -import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment +import ru.tele2med.mobile.domain.entity.* class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { @@ -46,7 +41,13 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { override val layoutId: Int - get() = R.layout.fragment_tech_checkup + get() = R.layout.fragment_test_list + + private val adapter: TestListAdapter by lazy { + TestListAdapter { idcheckup -> + presenter.get(idcheckup) + } + } private var root: View? = null // create a global variable which will hold your layout @@ -72,15 +73,26 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { } } } + recyclerView.adapter = adapter - tvDriverTitle.focusable - tvDriverTitle.requestFocus() - presenter.showCheckUp() +// tvDriverTitle.focusable + // tvDriverTitle.requestFocus() + var dataString = DATA_QR + val gson = Gson() + val data = gson.fromJson(dataString, DataTech::class.java) + + presenter.showTech(data.uniq_id) initRecycler() } + override fun showCheckups(list: List) { + Log.v("SHOWCH", "data = $list") + adapter.submitList(list) + + } + override fun setRefreshing(flag: Boolean) { println("setRefreshing = $flag") refresh.isRefreshing = flag @@ -91,174 +103,39 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { refresh.setOnRefreshListener { println("setOnRefreshListener") + var dataString = DATA_QR + val gson = Gson() + val data = gson.fromJson(dataString, DataTech::class.java) - presenter.showCheckUp() + presenter.showTech(data.uniq_id) } } - @SuppressLint("StringFormatInvalid") - override fun fillData(dataTech: DataTech) { - - println("СЕРВЕР = ${prefs.getServer()}") - /* var profilePhoto: String - var profilePhotoUrl: Uri - var checkupPhoto: String - var checkupPhotoUrl: Uri - var checkupVideoString: String - var checkupVideoUrl: Uri - - profilePhoto = "${BuildConfig.API_BASE_URL}${dataQR.profilePhoto}" - profilePhotoUrl = profilePhoto.toUri() - checkupPhoto = - "${BuildConfig.API_BASE_URL}${dataQR.checkupPhoto?.replace("/media", "media")}" - checkupPhotoUrl = checkupPhoto.toUri() - checkupVideoString = - "${BuildConfig.API_BASE_URL}${dataQR.checkupVideo?.replace("/media", "media")}" - checkupVideoUrl = checkupVideoString.toUri() - - - tvMainInfoTitle.requestFocus() - - tvMainInfoTitle.text = resources.getString(R.string.block_title_main_info, dataQR.idcheckup) - tvDriverNumber.text = dataQR.login - tvSex.text = dataQR.sex_name - tvSurname.text = dataQR.lastname - tvName.text = dataQR.name - tvPatronymic.text = dataQR.oldlastname - tvBirthday.text = dataQR.birthday - tvOrgName.text = dataQR.organization - tvCheckupDate.text = dataQR.exam_date - tvCheckupBeginTime.text = dataQR.exam_timestart - tvCheckupEndTime.text = dataQR.exam_timeend - tvCheckupType.text = dataQR.inspectiontype - tvCheckupTerminal.text = dataQR.terminal_name - tvCheckupStatus.text = dataQR.exam_state_name - tvCheckupMedic.text = dataQR.medic_fio - tvResultAuto.text = dataQR.exam_result_auto_txt - tvResultMedic.text = dataQR.exam_result_med_txt - tvMedicComment.text = dataQR.medic_comment - tvCheckupResultTime.text = dataQR.exam_result_datetime - // ivCheckupPhoto.setImageURI(checkupPhotoUrl) - - - val mediaController = MediaController(requireContext()) - checkupVideo.setMediaController(mediaController) - mediaController.setMediaPlayer(checkupVideo) - - println("гружу видео $checkupVideoUrl") - println("гружу фото $checkupPhotoUrl") - - checkupVideo.setVideoURI(checkupVideoUrl) - checkupVideo.start() - // checkupVideo.background = null - println("гружу видео start") - // checkupVideo.background = resources.getDrawable(R.drawable.arrow) - /*() checkupVideo.setOnClickListener { - checkupVideo.background = null - checkupVideo.start() - } - - checkupVideo.resume() - checkupVideo.pause() */ - - Glide.with(this).load(checkupPhoto).into(ivCheckupPhoto); - - - // Picasso.get().load(checkupPhotoUrl).rotate(0f).into(ivCheckupPhoto) - Picasso.get().load(profilePhotoUrl).into(ivDriverPhoto) - - - if (dataQR.exam_result_auto == 1) { - tvResultAuto.setBackgroundColor(resources.getColor(R.color.real_green)) - tvResultAuto.setTextColor(resources.getColor(R.color.white)) - } else { - tvResultAuto.setBackgroundColor(resources.getColor(R.color.dark_red)) - tvResultAuto.setTextColor(resources.getColor(R.color.white)) - - } - - if (dataQR.exam_result_auto == 1) { - tvResultMedic.setBackgroundColor(resources.getColor(R.color.real_green)) - tvResultMedic.setTextColor(resources.getColor(R.color.white)) - } else { - tvResultMedic.setBackgroundColor(resources.getColor(R.color.dark_red)) - tvResultMedic.setTextColor(resources.getColor(R.color.white)) - } - - - if (!dataQR.alcotest.isNullOrEmpty()) { - println("не нул") - tvAlkotest.text = dataQR.alcotest - tvSyspressure.text = dataQR.syspressure - tvDiapressure.text = dataQR.diapressure - tvPulse.text = dataQR.pulse - tvCheckupTemperature.text = dataQR.temperature - tvComplaints.text = dataQR.complaints - tvCheckupReference.text = dataQR.epicrisis - } else { - tvCheckupAlkotestTitle.visibility = View.GONE - tvCheckupSyspressureTitle.visibility = View.GONE - tvCheckupDiapressureTitle.visibility = View.GONE - tvCheckupPulseTitle.visibility = View.GONE - tvCheckupTemperatureTitle.visibility = View.GONE - tvComplaintsTitle.visibility = View.GONE - tvCheckupReferenceTitle.visibility = View.GONE - - tvAlkotest.visibility = View.GONE - tvSyspressure.visibility = View.GONE - tvDiapressure.visibility = View.GONE - tvPulse.visibility = View.GONE - tvCheckupTemperature.visibility = View.GONE - tvComplaints.visibility = View.GONE - tvCheckupReference.visibility = View.GONE - - - divider14_.visibility = View.GONE - divider15_.visibility = View.GONE - divider16_.visibility = View.GONE - divider17_.visibility = View.GONE - divider18_.visibility = View.GONE - divider19_.visibility = View.GONE - divider20_.visibility = View.GONE - - - }*/ - - } - - fun play(view: View?) { - checkupVideo.start() - } - - fun pause(view: View?) { - checkupVideo.pause() - } - - fun stop(view: View?) { - checkupVideo.stopPlayback() - checkupVideo.resume() - } - override fun getPresenter(): BasePresenter<*>? = null companion object { - private const val DATA_QR = "DATA_QR" - fun getInstance(dataTech: String?): TechCheckupTestsFragment { + private var DATA_QR = "DATA_QR" + fun getInstance(data: DataTech): TechCheckupTestsFragment { val gson = Gson() - Log.v("TechCheckupTestsFragment", "dataTech = $dataTech") - - val string: String = gson.toJson(dataTech) + val string: String = gson.toJson(data) + Log.v("COMP", "data = $data") + this.DATA_QR = string return TechCheckupTestsFragment().also { - it.arguments = Bundle().apply { - putString(DATA_QR, dataTech) - } - } + Log.v("COMP", "data2 = $data") + it.arguments = Bundle().apply { + Log.v("COMP", "data3 = $data") + + putString(TechCheckupTestsFragment.DATA_QR, string) + } + Log.v("COMP", "data4 = ${it.requireArguments().getString(TechCheckupTestsFragment.DATA_QR)}") + + } } private const val PERMISSION_CAMERA_REQUEST = 1 diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsPresenter.kt index bd3744a..bdb53b6 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsPresenter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsPresenter.kt @@ -1,5 +1,6 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests +import android.util.Log import com.arellomobile.mvp.InjectViewState import com.google.gson.Gson import ru.tele2med.mobile.presentation.ui.base.BasePresenter @@ -22,28 +23,27 @@ class TechCheckupTestsPresenter( } - fun showCheckUp() { - val gson = Gson() - val data = gson.fromJson(stringId, DataTech::class.java) - println("data stringId = ${stringId}") - // viewState.fillData(data) - viewState.setRefreshing(false) - } - - fun get(code: String) { - println("qrcode4 $code") + fun showTech(id: String) { + Log.v( + "LOG", + "it id = $id," + ) disposable += techInteractor - .getTech(code) + .showTech(id) .ioToMain() .doOnSubscribe { + Log.v("LOG", "it 2 = $it") viewState.showLoading() } .doAfterTerminate { viewState.hideLoading() + viewState.setRefreshing(false) + } .subscribe({ - + Log.v("LOG", "it = $it ${it.message}") + viewState.showCheckups(it.data.data) }, { if (it is ApiException) { @@ -55,6 +55,11 @@ class TechCheckupTestsPresenter( this.handleError(it) } }) + } + + fun get(code: String) { + println("qrcode4 $code") + } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsView.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsView.kt index da041b2..23388bd 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsView.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TechCheckupTestsView.kt @@ -2,13 +2,13 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.test import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy import com.arellomobile.mvp.viewstate.strategy.StateStrategyType -import ru.tele2med.mobile.domain.entity.DataQR -import ru.tele2med.mobile.domain.entity.DataTech +import ru.tele2med.mobile.domain.entity.* import ru.tele2med.mobile.presentation.ui.base.BaseView interface TechCheckupTestsView : BaseView { - fun fillData(dataTech: DataTech) + fun showCheckups(list: List) + @StateStrategyType(AddToEndSingleStrategy::class) fun setRefreshing(flag: Boolean) diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TestListAdapter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TestListAdapter.kt new file mode 100644 index 0000000..5889488 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/TestListAdapter.kt @@ -0,0 +1,60 @@ +package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests + +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import ru.tele2med.mobile.R +import ru.tele2med.mobile.domain.entity.DataShow + +class TestListAdapter( + val onItemClick: (checkupId: String) -> Unit +) : ListAdapter( + DIFF_CALLBACK +) { + companion object { + private val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(p0: DataShow, p1: DataShow): Boolean = + p0.id == p1.id + + override fun areContentsTheSame(p0: DataShow, p1: DataShow): Boolean = + p0 == p1 + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + Log.v("BIND", "onCreateViewHolder") + val inflater = LayoutInflater.from(parent.context) + return ViewHolder(inflater.inflate(R.layout.item_test, parent, false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + Log.v("BIND", "override fun onBindViewHolder(holder: ViewHolder, position: Int) {\n") + holder.bind(getItem(position)) + } + + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + private val testName: TextView = view.findViewById(R.id.tvCheckupName) + private val testResult: TextView = view.findViewById(R.id.tvResult) + + + init { + view.setOnClickListener { + val list = getItem(adapterPosition) + onItemClick(list.uniq_id) + } + } + + fun bind(list: DataShow) { + Log.v("BIND", "list = $list") + testName.text = list.name + testResult.text = list.value + } + + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_tech_checkup.xml b/app/src/main/res/layout/fragment_tech_checkup.xml index 26d54b4..47b50d5 100644 --- a/app/src/main/res/layout/fragment_tech_checkup.xml +++ b/app/src/main/res/layout/fragment_tech_checkup.xml @@ -42,12 +42,13 @@ app:layout_constraintTop_toTopOf="parent" /> - - + app:layout_constraintTop_toBottomOf="@id/tvMainInfoTitle" /> + app:layout_constraintTop_toBottomOf="@id/tvDriversTitle" + tools:text="Иванов, Петров" /> - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/tvDrivers" /> + android:text="Организация" + app:layout_constraintTop_toBottomOf="@+id/divider3" /> + tools:text="Вектор-Нагибатор" /> - - + android:text="Номер ПЛ" + app:layout_constraintTop_toBottomOf="@+id/divider4" /> + app:layout_constraintTop_toBottomOf="@id/tvNumberPLTitle" + tools:text="23" /> + app:layout_constraintTop_toBottomOf="@id/tvNumberPL" /> + android:text="Дата ПЛ" + app:layout_constraintTop_toBottomOf="@+id/divider5" /> + app:layout_constraintTop_toBottomOf="@id/tvDatePLTitle" + tools:text="18.04.2024" /> + app:layout_constraintTop_toBottomOf="@id/tvDatePL" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +