From 5455fef624c8f4758ebe3421739dea82fc5987f6 Mon Sep 17 00:00:00 2001 From: Azat Sagutdinov Date: Thu, 6 Jun 2024 16:48:12 +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.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tele2med/mobile/domain/entity/DataTech.kt | 1 + .../menu/items/tech/list/TechListAdapter.kt | 2 +- .../menu/items/tech/list/TechListFragment.kt | 22 +++++ .../menu/items/tech/list/TechListPresenter.kt | 8 ++ .../ui/menu/items/tech/list/TechListView.kt | 6 ++ .../info/TechCheckupInfoFragment.kt | 2 +- .../tests/TechCheckupTestsFragment.kt | 4 +- .../tests/TechCheckupTestsPresenter.kt | 2 + .../techCheckup/tests/test/TestFragment.kt | 30 +++++- .../techCheckup/tests/test/TestPresenter.kt | 95 +++++++++++++++++-- .../main/res/layout/fragment_checkup_test.xml | 4 +- .../main/res/layout/fragment_tech_checkup.xml | 33 ++++--- .../main/res/layout/fragment_tech_list.xml | 7 ++ 13 files changed, 181 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTech.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTech.kt index 66b4845..fd282d2 100644 --- a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTech.kt +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataTech.kt @@ -9,6 +9,7 @@ data class DataTech( val waybill_uuid: String, val waybill_name: String, val organization_id: String, + val organization_name: String, val mechanic_id: String, val mechanic_name: String, val result_id: String, diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListAdapter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListAdapter.kt index 23d1052..ec0bec2 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListAdapter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListAdapter.kt @@ -53,7 +53,7 @@ class TechListAdapter( fun bind(list: DataTechCheckup) { carName.text = list.vehicle_name - time.text = list.datetime + time.text = list.datetime_ //fio.text = list.fio status.text = list.exam_state_name /* eye.setImageDrawable( diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListFragment.kt index 009b891..96f9683 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListFragment.kt @@ -5,7 +5,10 @@ import android.view.View import androidx.recyclerview.widget.LinearLayoutManager import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.ProvidePresenter +import com.google.gson.Gson +import kotlinx.android.synthetic.main.fragment_medical_checkup.* import kotlinx.android.synthetic.main.fragment_tech_list.* +import kotlinx.android.synthetic.main.fragment_tech_list.refresh import ru.tele2med.mobile.R import ru.tele2med.mobile.presentation.ui.auth.AuthActivity import ru.tele2med.mobile.presentation.ui.base.BasePresenter @@ -19,7 +22,9 @@ import kotlinx.android.synthetic.main.toolbar_with_help.* import org.jetbrains.anko.clearTask import org.jetbrains.anko.intentFor import org.jetbrains.anko.newTask +import ru.tele2med.mobile.domain.entity.DataTech import ru.tele2med.mobile.domain.entity.DataTechCheckup +import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsFragment class TechListFragment : BaseMenuFragment(), TechListView { @@ -92,12 +97,29 @@ class TechListFragment : BaseMenuFragment(), TechListView { } recyclerView.addOnScrollListener(scrollListener) + initRecycler() //setName() setClickListeners() } + override fun setRefreshing(flag: Boolean) { + println("setRefreshing = $flag") + refresh.isRefreshing = flag + } + + private fun initRecycler() { + println("initRecycler") + + refresh.setOnRefreshListener { + println("setOnRefreshListener") + + presenter.getCheckups() + } + + } + override fun showCheckups(list: List) { adapter.submitList(list) 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 e93e43e..251da00 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 @@ -63,6 +63,14 @@ class TechListPresenter( ) .map(uiConverter::toUiTechCheckups) .ioToMain() + .doOnSubscribe { + viewState.showLoading() + } + .doAfterTerminate { + viewState.hideLoading() + viewState.setRefreshing(false) + + } .baseLoadingHandle() .baseHandleErrorSubscribe { currentCheckups.addAll(it.data) diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListView.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListView.kt index 8d0ff29..54d60d3 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListView.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/TechListView.kt @@ -1,5 +1,7 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list +import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy +import com.arellomobile.mvp.viewstate.strategy.StateStrategyType import ru.tele2med.mobile.domain.entity.DataCheckup import ru.tele2med.mobile.domain.entity.DataTechCheckup import ru.tele2med.mobile.presentation.ui.base.BaseView @@ -7,4 +9,8 @@ import ru.tele2med.mobile.presentation.ui.base.BaseView interface TechListView : BaseView { fun showCheckups(list: List) + + + @StateStrategyType(AddToEndSingleStrategy::class) + fun setRefreshing(flag: Boolean) } \ No newline at end of file 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 aa4a153..fd36d38 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 @@ -169,7 +169,7 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { tvDriverNumber.text = dataTech.vehicle_name tvDrivers.text = dataTech.mechanic_name - tvOrgName.text = dataTech.organization_id + tvOrgName.text = dataTech.organization_name tvNumberPL.text = dataTech.waybill_name tvDatePL.text = dataTech.datetime 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 3d805da..393492f 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,7 +15,6 @@ import com.arellomobile.mvp.presenter.ProvidePresenter import com.bumptech.glide.Glide import com.google.gson.Gson import com.squareup.picasso.Picasso -import kotlinx.android.synthetic.main.fragment_tech_list.* import ru.tele2med.mobile.R import ru.tele2med.mobile.presentation.ui.base.BasePresenter import ru.tele2med.mobile.presentation.ui.drawer.entity.ScreenType @@ -30,7 +29,6 @@ import org.jetbrains.anko.clearTask import org.jetbrains.anko.intentFor import org.jetbrains.anko.newTask import ru.tele2med.mobile.domain.entity.* -import ru.tele2med.mobile.presentation.router.NavScreens import ru.tele2med.mobile.presentation.ui.common.EndlessRecyclerViewScrollListener @@ -128,7 +126,7 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { override fun setRefreshing(flag: Boolean) { println("setRefreshing = $flag") - // refresh.isRefreshing = flag + refresh.isRefreshing = flag } private fun initRecycler() { 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 ddbf846..8082d12 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 @@ -47,6 +47,8 @@ class TechCheckupTestsPresenter( Log.v("LOG", "it = $it ${it.data.data}") viewState.showCheckups(it.data.data) + viewState.setRefreshing(false) + }, { if (it is ApiException) { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestFragment.kt index b885e9c..33d7c02 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestFragment.kt @@ -10,6 +10,9 @@ import com.arellomobile.mvp.presenter.ProvidePresenter import com.google.gson.Gson import kotlinx.android.synthetic.main.fragment_checkup_test.* import kotlinx.android.synthetic.main.toolbar_with_help.* +import org.jetbrains.anko.clearTask +import org.jetbrains.anko.intentFor +import org.jetbrains.anko.newTask import ru.tele2med.mobile.R import ru.tele2med.mobile.domain.entity.CheckupShowList import ru.tele2med.mobile.domain.entity.DataShow @@ -42,6 +45,9 @@ class TestFragment : BaseMenuFragment(), TestView { addDrawerToggle() title = getString(R.string.test_toolbar) close.visibility = View.VISIBLE + close.setOnClickListener { + activity?.onBackPressed() + } } // val args = arguments @@ -75,7 +81,7 @@ class TestFragment : BaseMenuFragment(), TestView { fillData(data, datacheckupShowList) - actions(data, uniq_id ?: "", dataTech) + actions(data, uniq_id ?: "", dataTech, datacheckupShowList) } } @@ -85,7 +91,8 @@ class TestFragment : BaseMenuFragment(), TestView { tvTestName.text = data.name tvComment.text = data.comment - tvStatusName.text = checkupShowList?.data?.exam_state_description?: "Вопрос №${data.order+1}" + tvStatusName.text = + checkupShowList?.data?.exam_state_description ?: "Вопрос №${data.order.toInt() + 1}" } @@ -95,7 +102,17 @@ class TestFragment : BaseMenuFragment(), TestView { } - private fun actions(data: DataShow, uniq_id: String, dataTech: DataTech) { + private fun actions( + data: DataShow, + uniq_id: String, + dataTech: DataTech, + checkupShowList: CheckupShowList? + ) { + skipBtn.setOnClickListener { + presenter.skipTech(uniq_id, dataTech, checkupShowList, data) + + } + trueBtn.setOnClickListener { presenter.setValue(uniq_id, data.uniq_id, data, "1", dataTech) } @@ -116,7 +133,12 @@ class TestFragment : BaseMenuFragment(), TestView { private var CHECKUP = "CHECKUP" - fun getInstance(test: DataShow, uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList?): TestFragment { + fun getInstance( + test: DataShow, + uniq_id: String, + dataTech: DataTech, + checkupShowList: CheckupShowList? + ): TestFragment { val gson = Gson() val string: String = gson.toJson(test) this.TEST = string diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestPresenter.kt index 4948c96..ec63cb9 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestPresenter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestPresenter.kt @@ -29,7 +29,13 @@ class TestPresenter( } - fun setValue(uniq_id: String, id: String, dataShow: DataShow, value: String, dataTech: DataTech) { + fun setValue( + uniq_id: String, + id: String, + dataShow: DataShow, + value: String, + dataTech: DataTech + ) { var checkup = CheckupData(id, dataShow.name ?: "", value, dataShow.type_id ?: "") var data: List = listOf(checkup) Log.v("LOG", "it checkup = $uniq_id, data = $data") @@ -39,7 +45,7 @@ class TestPresenter( .ioToMain() .doOnSubscribe { Log.v("LOG", "it 2 = $it") - // viewState.showLoading() + // viewState.showLoading() } .doAfterTerminate { viewState.hideLoading() @@ -48,9 +54,8 @@ class TestPresenter( .subscribe({ Log.v("LOG", "it = $it ${it.data}") if (it.data.count_checked != it.data.count_all.toInt()) { - showTech(uniq_id, dataTech, it) - } - else { + showTech(uniq_id, dataTech, it, dataShow) + } else { viewState.toBack() } @@ -70,7 +75,12 @@ class TestPresenter( //router.openPhoneEnterScreen() } - fun showTech(uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList) { + fun showTech( + uniq_id: String, + dataTech: DataTech, + checkupShowList: CheckupShowList?, + dataShow: DataShow + ) { Log.v( "LOG", "showTech uniq_id = $uniq_id," @@ -94,13 +104,18 @@ class TestPresenter( it.data.data.forEach { Log.v("LOG", "showTech forEach ${it}") - if ((it.value != "1") && (it.value != "0")) { + if ((it.value != "1") && (it.value != "0") && (it.id != dataShow.id)) { newShowTech.add(it) Log.v("LOG", "showTech openTestCheckupScreen ${newShowTech}") } } if (newShowTech.isNotEmpty()) { - navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech, checkupShowList) + navRouter.openTestCheckupScreen( + newShowTech.first(), + uniq_id, + dataTech, + checkupShowList + ) } else { viewState.toBack() } @@ -121,4 +136,68 @@ class TestPresenter( } + fun skipTech( + uniq_id: String, + dataTech: DataTech, + checkupShowList: CheckupShowList?, + dataShow: DataShow + ) { + Log.v( + "LOG", + "skipTech uniq_id = $uniq_id," + ) + + disposable += techInteractor + .showTech(uniq_id) + .ioToMain() + .doOnSubscribe { + Log.v("LOG", "it 2 = $it") + // viewState.showLoading() + } + .doAfterTerminate { + viewState.hideLoading() + + } + .subscribe({ it -> + Log.v("LOG", "skipTech ${it.data.data}") + val newShowTech = mutableListOf() + + + for (i in 0 until it.data.data.size) { + if (it.data.data[i] == dataShow) { + if (i+1 != it.data.data.size) { + navRouter.openTestCheckupScreen( + it.data.data[i + 1], + uniq_id, + dataTech, + null + ) + } + else { + navRouter.openTestCheckupScreen( + it.data.data[0], + uniq_id, + dataTech, + null + ) + } + } + + } + + + + }, { + if (it is ApiException) { + if (it.code == RestApiCodes.NotFound.code) { + } else { + this.handleError(it) + } + } else { + this.handleError(it) + } + }) + } + + } diff --git a/app/src/main/res/layout/fragment_checkup_test.xml b/app/src/main/res/layout/fragment_checkup_test.xml index bf0a8cb..ea63362 100644 --- a/app/src/main/res/layout/fragment_checkup_test.xml +++ b/app/src/main/res/layout/fragment_checkup_test.xml @@ -213,10 +213,12 @@ diff --git a/app/src/main/res/layout/fragment_tech_checkup.xml b/app/src/main/res/layout/fragment_tech_checkup.xml index 19fd850..9e67608 100644 --- a/app/src/main/res/layout/fragment_tech_checkup.xml +++ b/app/src/main/res/layout/fragment_tech_checkup.xml @@ -76,7 +76,6 @@ app:layout_constraintTop_toTopOf="@id/checkupsBody"> - @@ -90,6 +89,7 @@ android:focusable="true" android:focusableInTouchMode="true" android:text="Путевой лист:" + android:visibility="gone" app:layout_constraintTop_toTopOf="parent" /> @@ -171,6 +171,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Номер ПЛ" + android:visibility="gone" app:layout_constraintTop_toBottomOf="@+id/divider4" /> @@ -186,6 +188,7 @@ style="@style/BlockValueDividerStyle" android:layout_width="match_parent" android:layout_height="1dp" + android:visibility="gone" app:layout_constraintTop_toBottomOf="@id/tvNumberPL" /> @@ -212,9 +217,6 @@ app:layout_constraintTop_toBottomOf="@id/tvDatePL" /> - - - @@ -224,11 +226,11 @@ android:id="@+id/startTest" android:layout_width="200dp" android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:background="@drawable/btn_rounded_blue" android:text="Начать проверки" android:textColor="@color/white" android:textSize="12sp" - android:background="@drawable/btn_rounded_blue" - android:layout_marginTop="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/cvMainInfoContainer" /> @@ -237,11 +239,11 @@ android:id="@+id/signButton" android:layout_width="200dp" android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:background="@drawable/btn_rounded_blue" android:text="Допустить и подписать" android:textColor="@color/white" android:textSize="12sp" - android:background="@drawable/btn_rounded_blue" - android:layout_marginTop="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/startTest" /> @@ -251,19 +253,16 @@ android:id="@+id/notTest" android:layout_width="200dp" android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:background="@drawable/btn_rounded_blue" android:text="Не допустить и подписать" android:textColor="@color/white" android:textSize="12sp" - android:background="@drawable/btn_rounded_blue" - android:layout_marginTop="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/signButton" /> - - - - @@ -292,7 +290,7 @@ @@ -316,7 +316,6 @@ - diff --git a/app/src/main/res/layout/fragment_tech_list.xml b/app/src/main/res/layout/fragment_tech_list.xml index 9ea4b07..4a24342 100644 --- a/app/src/main/res/layout/fragment_tech_list.xml +++ b/app/src/main/res/layout/fragment_tech_list.xml @@ -7,6 +7,12 @@ android:orientation="vertical"> + + + + \ No newline at end of file