diff --git a/app/src/dev/res/values/strings.xml b/app/src/dev/res/values/strings.xml index 5557e55..f205316 100644 --- a/app/src/dev/res/values/strings.xml +++ b/app/src/dev/res/values/strings.xml @@ -290,6 +290,7 @@ Номер задания Статус Проведение измерения + Проведение Тех. осмотра Выберите путевой лист или задание diff --git a/app/src/jooli/res/values/strings.xml b/app/src/jooli/res/values/strings.xml index eca5c8e..8fa88d3 100644 --- a/app/src/jooli/res/values/strings.xml +++ b/app/src/jooli/res/values/strings.xml @@ -285,6 +285,7 @@ Номер задания Статус Проведение измерения + Проведение Тех. осмотра Выберите путевой лист или задание diff --git a/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/CheckupShowListResponse.kt b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/CheckupShowListResponse.kt index 414acb3..c9de827 100644 --- a/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/CheckupShowListResponse.kt +++ b/app/src/main/java/ru/tele2med/mobile/data/api/entity/response/CheckupShowListResponse.kt @@ -1 +1 @@ -package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.* data class CheckupShowListResponse( val af: String, val status: String, val message: String, val data: List ) \ No newline at end of file +package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.* data class CheckupShowListResponse( val af: String, val status: String, val message: String, val data: DataCheckListUpdate ) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/di/module/presenterModule.kt b/app/src/main/java/ru/tele2med/mobile/di/module/presenterModule.kt index cc4d545..c2b795a 100644 --- a/app/src/main/java/ru/tele2med/mobile/di/module/presenterModule.kt +++ b/app/src/main/java/ru/tele2med/mobile/di/module/presenterModule.kt @@ -51,6 +51,7 @@ import ru.tele2med.mobile.presentation.ui.menu.items.tech.TechPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.TechListPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoPresenter +import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign.SignPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.park.ParkPresenter @@ -84,6 +85,11 @@ fun presenterModule() = Kodein.Module(name = "presenterModule") { TestPresenter(instance(), instance()) } + bind() from provider { + SignPresenter(instance(), instance()) + } + + bind() from provider { TechPresenter() } @@ -93,9 +99,6 @@ fun presenterModule() = Kodein.Module(name = "presenterModule") { } - - - bind() from provider { QrReviewPresenter(instance(), instance(), instance()) } diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/CheckupShowList.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/CheckupShowList.kt index ce9cf16..1633c38 100644 --- a/app/src/main/java/ru/tele2med/mobile/domain/entity/CheckupShowList.kt +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/CheckupShowList.kt @@ -4,5 +4,5 @@ data class CheckupShowList( val af: String, val status: String, val message: String, - val data: List + val data: DataCheckListUpdate ) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/domain/entity/DataCheckListUpdate.kt b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataCheckListUpdate.kt new file mode 100644 index 0000000..f19f7ed --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/domain/entity/DataCheckListUpdate.kt @@ -0,0 +1,13 @@ +package ru.tele2med.mobile.domain.entity + +data class DataCheckListUpdate( + val count_all: String, + val count_checked: Int?, + val check_positive: Int?, + val check_negative: Int?, + val exam_state_description: String?, + val exam_state: Int?, + val exam_state_name: String? + + +) \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/router/NavRouter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/router/NavRouter.kt index 670bda6..538d53f 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/router/NavRouter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/router/NavRouter.kt @@ -1,5 +1,6 @@ package ru.tele2med.mobile.presentation.router +import ru.tele2med.mobile.domain.entity.CheckupShowList import ru.tele2med.mobile.domain.entity.DataQR import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataTech @@ -124,8 +125,12 @@ class NavRouter : Router() { navigateTo(NavScreens.getTechCheckup(dataTech)) } - fun openTestCheckupScreen(test: DataShow, uniq_id: String, dataTech: DataTech) { - navigateTo(NavScreens.getTestCheckup(test, uniq_id, dataTech)) + fun openTestCheckupScreen(test: DataShow, uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList?) { + navigateTo(NavScreens.getTestCheckup(test, uniq_id, dataTech, checkupShowList?: null)) + } + + fun openSignScreen(dataTech: DataTech) { + navigateTo(NavScreens.getSign(dataTech)) } fun openMedicalCheckupsScreen() { 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 f409c06..260c01d 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 @@ -1,5 +1,6 @@ package ru.tele2med.mobile.presentation.router +import ru.tele2med.mobile.domain.entity.CheckupShowList import ru.tele2med.mobile.domain.entity.DataQR import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataTech @@ -41,6 +42,7 @@ import ru.tele2med.mobile.presentation.ui.menu.items.stats.StatsScreen import ru.tele2med.mobile.presentation.ui.menu.items.status.StatusesScreen import ru.tele2med.mobile.presentation.ui.menu.items.tech.TechScreen import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupScreen +import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign.SignScreen import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestScreen import ru.tele2med.mobile.presentation.ui.menu.items.tonometr.TonScreen @@ -95,7 +97,9 @@ object NavScreens { fun getTechCheckup(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) - fun getTestCheckup(test: DataShow, uniq_id: String, dataTech: DataTech): TestScreen = TestScreen(test, uniq_id, dataTech) + fun getTestCheckup(test: DataShow, uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList?): TestScreen = TestScreen(test, uniq_id, dataTech, checkupShowList) + + fun getSign(dataTech: DataTech): SignScreen = SignScreen(dataTech) fun getTechCheckupInfo(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/base/BaseFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/base/BaseFragment.kt index 779908d..489a0b8 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/base/BaseFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/base/BaseFragment.kt @@ -47,6 +47,7 @@ abstract class BaseFragment : MvpAppCompatFragment(), BaseView, KodeinAware { override fun showLoading() { progressDialog?.dismiss() + progressDialog = null progressDialog = ProgressDialog.show(activity, null, getString(R.string.loading), true) } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerAdapter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerAdapter.kt index e083254..fa5d5c4 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerAdapter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerAdapter.kt @@ -240,6 +240,7 @@ class DrawerAdapter( ScreenType.TASKS_FOR_TODAY -> image.setImageResource(R.drawable.ic_rectangle) ScreenType.NOTIFICATIONS -> image.setImageResource(R.drawable.ic_rectangle) ScreenType.MAIN -> image.setImageResource(R.drawable.ic_rectangle) + ScreenType.TECH -> image.setImageResource(R.drawable.ic_rectangle) ScreenType.STATUS -> image.setImageResource(R.drawable.ic_rectangle) ScreenType.HISTORY -> image.setImageResource(R.drawable.ic_rectangle) ScreenType.CHAT -> image.setImageResource(R.drawable.ic_rectangle) diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerPresenter.kt index f6d8bc3..f320d2f 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerPresenter.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/DrawerPresenter.kt @@ -363,11 +363,42 @@ class DrawerPresenter( listOf( defaultHeader, - ListItem( + /* ListItem( ScreenType.MAIN, true, R.string.main, header = true + ), */ + + + ListItem( + ScreenType.REVIEW, + false, + R.string.review_toolbar, + header = true + ), + + ListItem( + ScreenType.SETTING, + false, + R.string.settings_toolbar, + header = true + ) + + // ButtonItem + + // ButtonItem + ) + + private var listTechCheckup: List = + listOf( + defaultHeader, + + ListItem( + ScreenType.TECH, + true, + R.string.tech, + header = true ), @@ -391,6 +422,7 @@ class DrawerPresenter( ) + override fun onFirstViewAttach() { super.onFirstViewAttach() disposable += changes @@ -416,7 +448,12 @@ class DrawerPresenter( } else { viewState.showList(listB) } - } else { + } + if (screenType == ScreenType.MAIN) { + viewState.showList(listTechCheckup) + + } + else { if (prefs.getLcMenu() == "true") { viewState.showList(listCoordinatesA) } else { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/entity/ScreenType.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/entity/ScreenType.kt index f773492..65ba316 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/entity/ScreenType.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/drawer/entity/ScreenType.kt @@ -14,6 +14,7 @@ enum class ScreenType { WITHOUT_BORDER, SELECT_ROUTE, QR, + TECH, PRINT, DASHBOARD, SELECT_TASK, diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/MenuActivity.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/MenuActivity.kt index 7557c23..2dd1523 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/MenuActivity.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/MenuActivity.kt @@ -230,7 +230,12 @@ class MenuActivity : BaseDrawerActivity(), MenuView { override fun onResumeFragments() { navigationHolder.setNavigator(navigator) if (webSocketClient.isClosed) { - webSocketClient.connect() + try { + webSocketClient.connect() + } + catch (e: Exception) { + Log.v("LOG", "e = ${e.message}") + } } super.onResumeFragments() @@ -330,6 +335,7 @@ class MenuActivity : BaseDrawerActivity(), MenuView { settings.setOnClickListener { presenter.onSettingsClick() } + } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/TechFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/TechFragment.kt index 76f3109..50a2c6d 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/TechFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/TechFragment.kt @@ -16,7 +16,7 @@ import ru.tele2med.mobile.presentation.util.providePresenter class TechFragment : BaseMenuFragment(), TechView { override val screenType: ScreenType - get() = ScreenType.TASKS_FOR_TODAY + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: TechPresenter 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 558ed6b..009b891 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 @@ -25,7 +25,7 @@ import ru.tele2med.mobile.domain.entity.DataTechCheckup class TechListFragment : BaseMenuFragment(), TechListView { override val screenType: ScreenType - get() = ScreenType.HELLO + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: TechListPresenter diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupFragment.kt index bdb2cf3..2e0d1aa 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/TechCheckupFragment.kt @@ -7,6 +7,10 @@ import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.ProvidePresenter import com.google.gson.Gson import kotlinx.android.synthetic.main.fragment_tasks.* +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.DataTech import ru.tele2med.mobile.presentation.ui.base.BasePresenter @@ -19,7 +23,7 @@ import ru.tele2med.mobile.presentation.util.providePresenter class TechCheckupFragment : BaseMenuFragment(), TechCheckupView { override val screenType: ScreenType - get() = ScreenType.TASKS_FOR_TODAY + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: TechCheckupPresenter @@ -38,6 +42,12 @@ class TechCheckupFragment : BaseMenuFragment(), TechCheckupView { super.onViewCreated(view, savedInstanceState) (activity as MenuActivity).apply { var dataString = arguments?.getString(DATA_QR) + close.visibility = View.VISIBLE + close.setOnClickListener { + startActivity(intentFor().newTask().clearTask()) + } + phone.visibility = View.GONE + settings.visibility = View.GONE val gson = Gson() val data = gson.fromJson(dataString, DataTech::class.java) 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 7e40bbd..aa4a153 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 @@ -24,6 +24,9 @@ import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuFragment import ru.tele2med.mobile.presentation.util.providePresenter import kotlinx.android.synthetic.main.fragment_tech_checkup.* 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.presentation.ui.menu.items.medicalCheckup.MedicalCheckupFragment @@ -31,7 +34,7 @@ import ru.tele2med.mobile.presentation.ui.menu.items.medicalCheckup.MedicalCheck class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { override val screenType: ScreenType - get() = ScreenType.QR + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: TechCheckupInfoPresenter @@ -63,6 +66,12 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { is MenuActivity -> { (activity as MenuActivity).apply { // addDrawerToggle() + close.visibility = View.VISIBLE + close.setOnClickListener { + startActivity(intentFor().newTask().clearTask()) + } + phone.visibility = View.GONE + settings.visibility = View.GONE showOrHideHelpButton(false) title = "" } @@ -74,16 +83,25 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { Log.v("DATA", "data 32 = $DATA_QR") val gson = Gson() - val data = gson.fromJson(dataString, DataTech::class.java) + val data = gson.fromJson(DATA_QR, DataTech::class.java) + + signButton.setOnClickListener { + presenter.goToSign(data) + } + + notTest.setOnClickListener { + presenter.goToSign(data) + } + startTest.setOnClickListener { - presenter.updateTech(, data.uniq_id, data) + presenter.updateTech(data.uniq_id, data) } // tvDriverTitle.focusable // tvDriverTitle.requestFocus() - presenter.showCheckUp() + presenter.showCheckUp(data.uniq_id) initRecycler() @@ -97,20 +115,18 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { private fun initRecycler() { println("initRecycler") - val args = arguments - val index = args?.toString() // getString("data", "") + val args = requireArguments().getString(DATA_QR) Log.v( - "TechCheckupInfoFragment", "data = $index ${args?.getString("data")}" + "TechCheckupInfoFragment", "Z $DATA_QR" ) - 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") - presenter.showCheckUp() + presenter.showCheckUp(data.uniq_id) } @@ -120,6 +136,29 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { @SuppressLint("StringFormatInvalid") override fun fillData(dataTech: DataTech) { + when (dataTech.exam_state) { + "1" -> { + notTest.visibility = View.GONE + signButton.visibility = View.GONE + startTest.text = "Начать проверки" + } + "2" -> { + notTest.visibility = View.GONE + signButton.visibility = View.GONE + startTest.text = "Продолжить проверки" + } + "3" -> { + startTest.visibility = View.GONE + } + "4" -> { + startTest.visibility = View.GONE + notTest.visibility = View.GONE + signButton.visibility = View.GONE + } + else -> startTest.text = "Начать проверки" + } + + println("СЕРВЕР = ${dataTech.mechanic_name}") var profilePhoto: String var profilePhotoUrl: Uri @@ -148,21 +187,22 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView { private var DATA_QR = "DATA_QR" fun getInstance(data: DataTech): TechCheckupInfoFragment { + Log.v("getInstance", "data DataTech = $data") + val gson = Gson() val string: String = gson.toJson(data) - Log.v("COMP", "data = $data") - this.DATA_QR = string + DATA_QR = string return TechCheckupInfoFragment().also { - Log.v("COMP", "data2 = $data") - + DATA_QR = string it.arguments = Bundle().apply { - Log.v("COMP", "data3 = $data") - putString(DATA_QR, string) + } - Log.v("COMP", "data4 = ${it.requireArguments().getString(DATA_QR)}") + Log.v("getInstance", "data DataTech = ${it.requireArguments().getString(DATA_QR)}") } + + } 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 de36e38..b483ab5 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 @@ -5,11 +5,9 @@ import com.arellomobile.mvp.InjectViewState import com.google.gson.Gson import ru.tele2med.mobile.presentation.ui.base.BasePresenter import ru.tele2med.mobile.presentation.ui.base.entity.RestApiCodes -import ru.tele2med.mobile.presentation.util.Prefs import ru.tele2med.mobile.presentation.util.ioToMain import io.reactivex.rxkotlin.plusAssign import ru.tele2med.mobile.data.api.entity.exception.ApiException -import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataTech import ru.tele2med.mobile.domain.interactor.TechInteractor import ru.tele2med.mobile.presentation.router.NavRouter @@ -21,22 +19,69 @@ class TechCheckupInfoPresenter( private val stringId: String ) : BasePresenter() { - fun onRefresh() { + override fun onFirstViewAttach() { + super.onFirstViewAttach() + Log.v( + "LOG", + "onFirstViewAttach in TechCheckupInfoPresenter" + ) + } - fun updateTech(test: DataShow, uniq_id: String, dataTech: DataTech) { - navRouter.openTestCheckupScreen(test, uniq_id, dataTech) + fun goToSign(dataTech: DataTech) { + Log.v( + "LOG", + "goToSign carName = ${dataTech.vehicle_name}" + ) + navRouter.openSignScreen(dataTech) + + } + + fun updateTech(uniq_id: String, dataTech: DataTech) { + Log.v( + "LOG", + "showTech uniq_id = $uniq_id," + ) + + disposable += techInteractor + .showTech(uniq_id) + .ioToMain() + .doOnSubscribe { + Log.v("LOG", "it 2 = $it") + viewState.showLoading() + } + .doAfterTerminate { + viewState.hideLoading() + + } + .subscribe({ it -> + var test = it.data.data.first() + navRouter.openTestCheckupScreen(test, uniq_id, dataTech, null) + + + }, { + if (it is ApiException) { + if (it.code == RestApiCodes.NotFound.code) { + } else { + this.handleError(it) + } + } else { + this.handleError(it) + } + }) + } - fun showCheckUp() { + fun showCheckUp(id: String) { val gson = Gson() val data = gson.fromJson(stringId, DataTech::class.java) - println("data RoleName = ${data}") + println("data RoleName = ${id}") + get(id) // viewState.fillData(data) - viewState.setRefreshing(false) + //viewState.setRefreshing(false) } fun get(code: String) { @@ -52,7 +97,7 @@ class TechCheckupInfoPresenter( viewState.hideLoading() } .subscribe({ - + viewState.fillData(it.data) }, { if (it is ApiException) { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignFragment.kt new file mode 100644 index 0000000..1fc1f70 --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignFragment.kt @@ -0,0 +1,118 @@ +package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign + +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.util.Log +import android.view.View +import com.arellomobile.mvp.presenter.InjectPresenter +import com.arellomobile.mvp.presenter.ProvidePresenter +import com.google.gson.Gson +import kotlinx.android.synthetic.main.fragment_checkup_test.* +import kotlinx.android.synthetic.main.fragment_checkup_test.falseBtn +import kotlinx.android.synthetic.main.fragment_checkup_test.trueBtn +import kotlinx.android.synthetic.main.fragment_checkup_test.tvComment +import kotlinx.android.synthetic.main.fragment_checkup_test.tvStatusName +import kotlinx.android.synthetic.main.fragment_checkup_test.tvTestName +import kotlinx.android.synthetic.main.fragment_sign.* +import ru.tele2med.mobile.R +import ru.tele2med.mobile.domain.entity.DataShow +import ru.tele2med.mobile.domain.entity.DataTech +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.base.BaseMenuFragment +import ru.tele2med.mobile.presentation.util.providePresenter + +class SignFragment : BaseMenuFragment(), SignView { + + override val screenType: ScreenType + get() = ScreenType.TECH + + @InjectPresenter + lateinit var presenter: SignPresenter + + private var errorDialog: androidx.appcompat.app.AlertDialog? = null + + + @ProvidePresenter + fun initPresenter(): SignPresenter = providePresenter() + + override fun getPresenter(): BasePresenter<*>? = presenter + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + (activity as MenuActivity).apply { + addDrawerToggle() + title = getString(R.string.test_toolbar) + } + + // val args = arguments + // val data = args?.toString() // getString("data", "") + + + Log.v("TestFragment", "args = ${arguments?.getString(TEST)}") + val gson = Gson() + + var stringTech = arguments?.getString(TECH) + val dataTech = gson.fromJson(stringTech, DataTech::class.java) + fillData(dataTech) + } + + + private fun fillData(data: DataTech) { + Log.v("TestFragment", "data = data.name = ${data.vehicle_name}") + + tvCarName.text = data.vehicle_name + tvResult.text = data.result_name?: "" + + signBtn.setOnClickListener { + presenter.sign(data) + } + + + } + + override fun toBack() { + activity?.onBackPressed() + } + + + private fun actions(data: DataShow, uniq_id: String, dataTech: DataTech) { + trueBtn.setOnClickListener { + presenter.setValue(uniq_id, data.uniq_id, data, "1", dataTech) + } + + falseBtn.setOnClickListener { + presenter.setValue(uniq_id, data.uniq_id, data, "0", dataTech) + } + } + + + override val layoutId: Int + get() = R.layout.fragment_sign + + companion object { + private var TEST = "TEST" + private var UNIQ_ID = "UNIQ_ID" + private var TECH = "TECH" + + + fun getInstance(dataTech: DataTech): SignFragment { + val gson = Gson() + val stringTech: String = gson.toJson(dataTech) + TECH = stringTech + + + + return SignFragment().also { + it.arguments = Bundle().apply { + putString(TECH, stringTech) + } + } + + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignPresenter.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignPresenter.kt new file mode 100644 index 0000000..830e97b --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignPresenter.kt @@ -0,0 +1,125 @@ +package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign + +import android.util.Log +import com.arellomobile.mvp.InjectViewState +import io.reactivex.rxkotlin.plusAssign +import ru.tele2med.mobile.data.api.entity.exception.ApiException +import ru.tele2med.mobile.domain.entity.CheckupData +import ru.tele2med.mobile.domain.entity.DataShow +import ru.tele2med.mobile.domain.entity.DataTech +import ru.tele2med.mobile.domain.entity.Position +import ru.tele2med.mobile.domain.interactor.TechInteractor +import ru.tele2med.mobile.presentation.router.NavRouter +import ru.tele2med.mobile.presentation.ui.base.entity.RestApiCodes +import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuPresenter +import ru.tele2med.mobile.presentation.util.ioToMain + + +@InjectViewState +class SignPresenter( + private val techInteractor: TechInteractor, + private val navRouter: NavRouter, +) : BaseMenuPresenter() { + + private var position: Position? = null + + override fun onFirstViewAttach() { + super.onFirstViewAttach() + } + + fun sign(dataTech: DataTech) { + Log.v("SIGN", "Подписание с данными ${dataTech.vehicle_name}") + } + + 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") + + disposable += techInteractor + .updateCheckList(uniq_id, id, data) + .ioToMain() + .doOnSubscribe { + Log.v("LOG", "it 2 = $it") + viewState.showLoading() + } + .doAfterTerminate { + viewState.hideLoading() + // viewState.toBack() + } + .subscribe({ + Log.v("LOG", "it = $it ${it.data}") + showTech(uniq_id, dataTech) + + }, { + if (it is ApiException) { + if (it.code == RestApiCodes.NotFound.code) { + } else { + this.handleError(it) + } + } else { + this.handleError(it) + } + }) + + //router.openPhoneEnterScreen() + } + + fun showTech(uniq_id: String, dataTech: DataTech) { + Log.v( + "LOG", + "showTech 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", "showTech ${it.data.data}") + val newShowTech = mutableListOf() + + it.data.data.forEach { + Log.v("LOG", "showTech forEach ${it}") + + if ((it.value != "1") && (it.value != "0")) { + newShowTech.add(it) + Log.v("LOG", "showTech openTestCheckupScreen ${newShowTech}") + } + } + if (newShowTech.isNotEmpty()) { + navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech, null) + } else { + viewState.toBack() + } + + + // viewState.showCheckups(it.data.data) + + }, { + if (it is ApiException) { + if (it.code == RestApiCodes.NotFound.code) { + } else { + this.handleError(it) + } + } else { + this.handleError(it) + } + }) + } + + +} diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignScreen.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignScreen.kt new file mode 100644 index 0000000..7c0839a --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignScreen.kt @@ -0,0 +1,19 @@ +package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign + +import androidx.fragment.app.Fragment +import ru.tele2med.mobile.domain.entity.DataShow +import ru.tele2med.mobile.domain.entity.DataTech +import ru.terrakok.cicerone.android.support.SupportAppScreen + +class SignScreen(val dataTech: DataTech) : SupportAppScreen() { + + override fun getFragment(): Fragment { + return SignFragment.getInstance( + dataTech + ) + } + + override fun getScreenKey(): String { + return SignFragment::class.java.name + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignView.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignView.kt new file mode 100644 index 0000000..1126e2c --- /dev/null +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/info/sign/SignView.kt @@ -0,0 +1,18 @@ +package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.sign + +import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy +import com.arellomobile.mvp.viewstate.strategy.SkipStrategy +import com.arellomobile.mvp.viewstate.strategy.StateStrategyType +import ru.tele2med.mobile.domain.entity.DataShow +import ru.tele2med.mobile.presentation.ui.base.BaseView + +interface SignView : BaseView { + + fun bindTest(test: DataShow) { + } + + @StateStrategyType(OneExecutionStateStrategy::class) + fun toBack() + + +} \ No newline at end of file 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 5c5dca0..3d805da 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 @@ -26,7 +26,11 @@ import ru.tele2med.mobile.presentation.util.providePresenter import kotlinx.android.synthetic.main.fragment_test_list.* import kotlinx.android.synthetic.main.fragment_test_list.recyclerView 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.* +import ru.tele2med.mobile.presentation.router.NavScreens import ru.tele2med.mobile.presentation.ui.common.EndlessRecyclerViewScrollListener @@ -79,6 +83,12 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView { } is MenuActivity -> { (activity as MenuActivity).apply { + close.visibility = View.VISIBLE + close.setOnClickListener { + startActivity(intentFor().newTask().clearTask()) + } + phone.visibility = View.GONE + settings.visibility = View.GONE // addDrawerToggle() showOrHideHelpButton(false) title = "" @@ -118,7 +128,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 9c2f2c0..ddbf846 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 @@ -40,10 +40,11 @@ class TechCheckupTestsPresenter( } .doAfterTerminate { viewState.hideLoading() - viewState.setRefreshing(false) } .subscribe({ + viewState.hideLoading() + Log.v("LOG", "it = $it ${it.data.data}") viewState.showCheckups(it.data.data) @@ -61,7 +62,7 @@ class TechCheckupTestsPresenter( fun get(test: DataShow, uniq_id: String, dataTech: DataTech) { println("TechCheckupTestsPresenter ${test.uniq_id}") - navRouter.openTestCheckupScreen(test, uniq_id, dataTech) + navRouter.openTestCheckupScreen(test, uniq_id, dataTech, null) } 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 ffae9ca..b885e9c 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 @@ -9,25 +9,21 @@ import com.arellomobile.mvp.presenter.InjectPresenter 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 ru.tele2med.mobile.R -import ru.tele2med.mobile.di.module.navigationModule -import ru.tele2med.mobile.domain.entity.Data +import ru.tele2med.mobile.domain.entity.CheckupShowList import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataTech 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.base.BaseMenuFragment -import ru.tele2med.mobile.presentation.ui.menu.items.result.ResFragment -import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupFragment -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 import ru.tele2med.mobile.presentation.util.providePresenter class TestFragment : BaseMenuFragment(), TestView { override val screenType: ScreenType - get() = ScreenType.WITHOUT_BORDER + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: TestPresenter @@ -45,6 +41,7 @@ class TestFragment : BaseMenuFragment(), TestView { (activity as MenuActivity).apply { addDrawerToggle() title = getString(R.string.test_toolbar) + close.visibility = View.VISIBLE } // val args = arguments @@ -67,6 +64,9 @@ class TestFragment : BaseMenuFragment(), TestView { var dataString = arguments?.getString(TEST) val data = gson.fromJson(dataString, DataShow::class.java) + var checkupShowList = arguments?.getString(CHECKUP) + val datacheckupShowList = gson.fromJson(checkupShowList, CheckupShowList::class.java) + var uniq_id = arguments?.getString(UNIQ_ID) @@ -74,18 +74,19 @@ class TestFragment : BaseMenuFragment(), TestView { // val dataTest = gson.fromJson(TEST, DataShow::class.java) - fillData(data) + fillData(data, datacheckupShowList) actions(data, uniq_id ?: "", dataTech) } } - private fun fillData(data: DataShow) { + private fun fillData(data: DataShow, checkupShowList: CheckupShowList?) { Log.v("TestFragment", "data = data.name = ${data.name}") tvTestName.text = data.name tvComment.text = data.comment - tvStatusName.text = "Проверка ${data.order}" + tvStatusName.text = checkupShowList?.data?.exam_state_description?: "Вопрос №${data.order+1}" + } @@ -112,15 +113,19 @@ class TestFragment : BaseMenuFragment(), TestView { private var TEST = "TEST" private var UNIQ_ID = "UNIQ_ID" private var TECH = "TECH" + private var CHECKUP = "CHECKUP" - fun getInstance(test: DataShow, uniq_id: String, dataTech: DataTech): 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 val stringTech: String = gson.toJson(dataTech) this.TECH = stringTech + val checkupShowListCommon: String = gson.toJson(checkupShowList) + this.CHECKUP = checkupShowListCommon + return TestFragment().also { @@ -128,6 +133,7 @@ class TestFragment : BaseMenuFragment(), TestView { putString(TEST, string) putString(UNIQ_ID, uniq_id) putString(TECH, stringTech) + putString(CHECKUP, checkupShowListCommon) } } 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 b62261b..4948c96 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 @@ -4,10 +4,7 @@ import android.util.Log import com.arellomobile.mvp.InjectViewState import io.reactivex.rxkotlin.plusAssign import ru.tele2med.mobile.data.api.entity.exception.ApiException -import ru.tele2med.mobile.domain.entity.CheckupData -import ru.tele2med.mobile.domain.entity.DataShow -import ru.tele2med.mobile.domain.entity.DataTech -import ru.tele2med.mobile.domain.entity.Position +import ru.tele2med.mobile.domain.entity.* import ru.tele2med.mobile.domain.interactor.TechInteractor import ru.tele2med.mobile.presentation.router.NavRouter import ru.tele2med.mobile.presentation.ui.base.entity.RestApiCodes @@ -42,7 +39,7 @@ class TestPresenter( .ioToMain() .doOnSubscribe { Log.v("LOG", "it 2 = $it") - viewState.showLoading() + // viewState.showLoading() } .doAfterTerminate { viewState.hideLoading() @@ -50,7 +47,14 @@ class TestPresenter( } .subscribe({ Log.v("LOG", "it = $it ${it.data}") - showTech(uniq_id, dataTech) + if (it.data.count_checked != it.data.count_all.toInt()) { + showTech(uniq_id, dataTech, it) + } + else { + viewState.toBack() + + } + }, { if (it is ApiException) { @@ -66,7 +70,7 @@ class TestPresenter( //router.openPhoneEnterScreen() } - fun showTech(uniq_id: String, dataTech: DataTech) { + fun showTech(uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList) { Log.v( "LOG", "showTech uniq_id = $uniq_id," @@ -96,7 +100,7 @@ class TestPresenter( } } if (newShowTech.isNotEmpty()) { - navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech) + navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech, checkupShowList) } else { viewState.toBack() } diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestScreen.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestScreen.kt index be499a6..5ebab65 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestScreen.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/list/techCheckup/tests/test/TestScreen.kt @@ -1,14 +1,15 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test import androidx.fragment.app.Fragment +import ru.tele2med.mobile.domain.entity.CheckupShowList import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataTech import ru.terrakok.cicerone.android.support.SupportAppScreen -class TestScreen(val test: DataShow, val uniq_id: String, val dataTech: DataTech) : SupportAppScreen() { +class TestScreen(val test: DataShow, val uniq_id: String, val dataTech: DataTech, val checkupShowList: CheckupShowList?) : SupportAppScreen() { override fun getFragment(): Fragment { - return TestFragment.getInstance(test, uniq_id, dataTech) + return TestFragment.getInstance(test, uniq_id, dataTech, checkupShowList) } override fun getScreenKey(): String { diff --git a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/park/ParkFragment.kt b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/park/ParkFragment.kt index 6cc30db..98dec1a 100644 --- a/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/park/ParkFragment.kt +++ b/app/src/main/java/ru/tele2med/mobile/presentation/ui/menu/items/tech/park/ParkFragment.kt @@ -14,7 +14,7 @@ import ru.tele2med.mobile.presentation.util.providePresenter class ParkFragment : BaseMenuFragment(), ParkView { override val screenType: ScreenType - get() = ScreenType.WITHOUT_BORDER + get() = ScreenType.TECH @InjectPresenter lateinit var presenter: ParkPresenter diff --git a/app/src/main/res/layout-land/toolbar_with_help.xml b/app/src/main/res/layout-land/toolbar_with_help.xml index 40d4001..6eea22b 100644 --- a/app/src/main/res/layout-land/toolbar_with_help.xml +++ b/app/src/main/res/layout-land/toolbar_with_help.xml @@ -36,6 +36,18 @@ android:layout_marginEnd="20dp" tools:visibility="visible" android:layout_marginTop="10dp" + app:layout_constraintEnd_toStartOf="@+id/close" + app:layout_constraintTop_toTopOf="parent" /> + + @@ -51,6 +63,8 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + +