From 753b96e8fa8ed346de78de61d1c9f4a2e8fa6787 Mon Sep 17 00:00:00 2001 From: hunnihundert <47563806+hunnihundert@users.noreply.github.com> Date: Fri, 29 May 2020 16:52:28 +0900 Subject: [PATCH 1/2] changed input type for zip code input field in transcript info --- app/src/main/res/layout/fragment_transcript_info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/fragment_transcript_info.xml b/app/src/main/res/layout/fragment_transcript_info.xml index e9fce1b..4084895 100644 --- a/app/src/main/res/layout/fragment_transcript_info.xml +++ b/app/src/main/res/layout/fragment_transcript_info.xml @@ -192,7 +192,7 @@ android:autofillHints="postal-code" android:background="@drawable/rounded_white" android:error="@{viewModel.zipCodeError}" - android:inputType="number" + android:inputType="textPostalAddress" android:nextFocusDown="@id/editText_city_value" android:padding="10dp" android:text="@={viewModel.zipCode}" From a424412ae46a8a042f5f5d3317e29516b6a9708d Mon Sep 17 00:00:00 2001 From: hunnihundert <47563806+hunnihundert@users.noreply.github.com> Date: Sat, 6 Jun 2020 16:32:28 +0900 Subject: [PATCH 2/2] added SingleLiveEvent for navigation --- .../ui/seeker/create/SeekerCreateRequestViewModel.kt | 6 ++++-- .../address/SeekerCreateRequestConfirmAddressFragment.kt | 3 --- .../articles/SeekerCreateRequestEnterArticlesFragment.kt | 9 +++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/nexd/android/ui/seeker/create/SeekerCreateRequestViewModel.kt b/app/src/main/java/app/nexd/android/ui/seeker/create/SeekerCreateRequestViewModel.kt index 66ade17..ba8bb2c 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/create/SeekerCreateRequestViewModel.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/create/SeekerCreateRequestViewModel.kt @@ -10,6 +10,7 @@ import app.nexd.android.api.model.CreateHelpRequestArticleDto import app.nexd.android.api.model.HelpRequestCreateDto import app.nexd.android.api.model.User import app.nexd.android.ui.common.HelpRequestCreateArticleBinder +import app.nexd.android.ui.utils.SingleLiveEvent import io.reactivex.android.schedulers.AndroidSchedulers.mainThread import io.reactivex.disposables.CompositeDisposable @@ -17,11 +18,12 @@ class SeekerCreateRequestViewModel(private val api: Api) : ViewModel() { sealed class Progress { object Idle : Progress() - object Loading : Progress() class Error(@StringRes val message: Int? = null) : Progress() object Finished : Progress() } + val navigateToConfirmAddress = SingleLiveEvent() + val progress = MutableLiveData(Progress.Idle) val firstName = MutableLiveData() @@ -90,7 +92,7 @@ class SeekerCreateRequestViewModel(private val api: Api) : ViewModel() { selectedArticles.clear() setSelectedArticles() if (selectedArticles.isNotEmpty()) { - progress.value = Progress.Loading + navigateToConfirmAddress.call() } else { progress.value = Progress.Error(R.string.seeker_request_create_no_articles) } diff --git a/app/src/main/java/app/nexd/android/ui/seeker/create/address/SeekerCreateRequestConfirmAddressFragment.kt b/app/src/main/java/app/nexd/android/ui/seeker/create/address/SeekerCreateRequestConfirmAddressFragment.kt index d5bc41e..484ff64 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/create/address/SeekerCreateRequestConfirmAddressFragment.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/create/address/SeekerCreateRequestConfirmAddressFragment.kt @@ -61,9 +61,6 @@ class SeekerCreateRequestConfirmAddressFragment : Fragment() { is Idle -> { // nothing to do } - is Loading -> { - // - } is Error -> { it.message?.let { errorMessageId -> DefaultSnackbar(binding.root, errorMessageId, Snackbar.LENGTH_SHORT) diff --git a/app/src/main/java/app/nexd/android/ui/seeker/create/articles/SeekerCreateRequestEnterArticlesFragment.kt b/app/src/main/java/app/nexd/android/ui/seeker/create/articles/SeekerCreateRequestEnterArticlesFragment.kt index e05a574..67eb4ef 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/create/articles/SeekerCreateRequestEnterArticlesFragment.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/create/articles/SeekerCreateRequestEnterArticlesFragment.kt @@ -79,13 +79,14 @@ class SeekerCreateRequestEnterArticlesFragment : Fragment() { } }) + vm.navigateToConfirmAddress.observe(viewLifecycleOwner, Observer { + findNavController().navigate(SeekerCreateRequestEnterArticlesFragmentDirections.toSeekerCreateRequestConfirmAddressFragment()) + }) + vm.progress.observe(viewLifecycleOwner, Observer { when (it) { is Idle -> { - //nothing to do - } - is Loading -> { - findNavController().navigate(SeekerCreateRequestEnterArticlesFragmentDirections.toSeekerCreateRequestConfirmAddressFragment()) + // nothing to do } is Finished -> { // state not reachable