From ab2be51744966328850f3d9b637197f52291355a Mon Sep 17 00:00:00 2001 From: hunnihundert <47563806+hunnihundert@users.noreply.github.com> Date: Wed, 27 May 2020 14:49:25 +0900 Subject: [PATCH 1/3] loading indicator animation (bar at the top) implemented for all seeker fragments --- .../app/nexd/android/api/ArticlesApi.java | 2 +- .../ui/seeker/call/PhoneCallFragment.kt | 3 + ...ekerCreateRequestConfirmAddressFragment.kt | 3 + ...eekerCreateRequestEnterArticlesFragment.kt | 5 +- .../ui/seeker/detail/SeekerDetailFragment.kt | 7 +- .../seeker/overview/SeekerOverviewFragment.kt | 4 + .../main/res/layout/fragment_phone_call.xml | 35 +- ..._seeker_create_request_confirm_address.xml | 377 +++++++++--------- ...t_seeker_create_request_enter_articles.xml | 116 +++--- .../res/layout/fragment_seeker_detail.xml | 28 +- .../res/layout/fragment_seeker_overview.xml | 14 + 11 files changed, 350 insertions(+), 244 deletions(-) diff --git a/api/src/main/java/app/nexd/android/api/ArticlesApi.java b/api/src/main/java/app/nexd/android/api/ArticlesApi.java index fcea03a..8659be7 100644 --- a/api/src/main/java/app/nexd/android/api/ArticlesApi.java +++ b/api/src/main/java/app/nexd/android/api/ArticlesApi.java @@ -15,7 +15,7 @@ public interface ArticlesApi { * * @return Observable<List<Article>> */ - @GET("article/articles") + @GET("article/articles?language=de") Observable> articlesControllerFindAll(); diff --git a/app/src/main/java/app/nexd/android/ui/seeker/call/PhoneCallFragment.kt b/app/src/main/java/app/nexd/android/ui/seeker/call/PhoneCallFragment.kt index 2827d1a..4dd4a81 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/call/PhoneCallFragment.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/call/PhoneCallFragment.kt @@ -26,6 +26,7 @@ class PhoneCallFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + progressBar.visibility = View.VISIBLE vm.getPhoneNumber().observe(viewLifecycleOwner, Observer { phoneNumber -> textView_details.text = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -33,11 +34,13 @@ class PhoneCallFragment : Fragment() { getString(R.string.seeker_phone_call_text, phoneNumber), Html.FROM_HTML_MODE_LEGACY ) + } else { Html.fromHtml( getString(R.string.seeker_phone_call_text, phoneNumber) ) } + progressBar.visibility = View.GONE }) } 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..11799ea 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 @@ -51,6 +51,7 @@ class SeekerCreateRequestConfirmAddressFragment : Fragment() { } binding.buttonConfirm.setOnClickListener { + binding.progressBar.visibility = View.VISIBLE vm.sendRequest() } } @@ -65,11 +66,13 @@ class SeekerCreateRequestConfirmAddressFragment : Fragment() { // } is Error -> { + binding.progressBar.visibility = View.GONE it.message?.let { errorMessageId -> DefaultSnackbar(binding.root, errorMessageId, Snackbar.LENGTH_SHORT) } } is Finished -> { + binding.progressBar.visibility = View.GONE findNavController().navigate(SeekerCreateRequestConfirmAddressFragmentDirections.toSeekerOverviewFragment()) } else -> Log.d( 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..8b11368 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 @@ -76,13 +76,15 @@ class SeekerCreateRequestEnterArticlesFragment : Fragment() { articleListSection = ListSection() articleListSection!!.addAll(articles) adapter.addSection(articleListSection!!) + binding.progressBar.visibility = View.GONE } + }) vm.progress.observe(viewLifecycleOwner, Observer { when (it) { is Idle -> { - //nothing to do + binding.progressBar.visibility = View.VISIBLE } is Loading -> { findNavController().navigate(SeekerCreateRequestEnterArticlesFragmentDirections.toSeekerCreateRequestConfirmAddressFragment()) @@ -91,6 +93,7 @@ class SeekerCreateRequestEnterArticlesFragment : Fragment() { // state not reachable } is Error -> { + binding.progressBar.visibility = View.GONE it.message?.let { errorMessageId -> DefaultSnackbar(binding.root, errorMessageId, Snackbar.LENGTH_SHORT) } diff --git a/app/src/main/java/app/nexd/android/ui/seeker/detail/SeekerDetailFragment.kt b/app/src/main/java/app/nexd/android/ui/seeker/detail/SeekerDetailFragment.kt index 7cd59c8..f005f82 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/detail/SeekerDetailFragment.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/detail/SeekerDetailFragment.kt @@ -43,14 +43,18 @@ class SeekerDetailFragment : Fragment() { HelpRequestArticleBinder() ) + progressBar.visibility = View.VISIBLE + vm.progress.observe(viewLifecycleOwner) { when (it) { is SeekerDetailViewModel.Progress.Idle -> { } is SeekerDetailViewModel.Progress.Error -> { + progressBar.visibility = View.GONE Toast.makeText(requireContext(), getText(R.string.helper_request_detail_message_error_on_cancellation), Toast.LENGTH_LONG).show() } is SeekerDetailViewModel.Progress.Canceled -> { + progressBar.visibility = View.GONE // show information Toast.makeText(requireContext(), getText(R.string.helper_request_detail_message_cancelled), Toast.LENGTH_LONG).show() findNavController().navigateUp() @@ -67,8 +71,9 @@ class SeekerDetailFragment : Fragment() { textView_additionalRequest_label.visibility = if (request.additionalRequest.isNullOrBlank()) View.GONE else View.VISIBLE textView_additionalRequest.text = request.additionalRequest - + progressBar.visibility = View.GONE button_cancel.setOnClickListener { + progressBar.visibility = View.VISIBLE vm.cancelRequest(request) } } diff --git a/app/src/main/java/app/nexd/android/ui/seeker/overview/SeekerOverviewFragment.kt b/app/src/main/java/app/nexd/android/ui/seeker/overview/SeekerOverviewFragment.kt index 56a0579..4d09ed9 100644 --- a/app/src/main/java/app/nexd/android/ui/seeker/overview/SeekerOverviewFragment.kt +++ b/app/src/main/java/app/nexd/android/ui/seeker/overview/SeekerOverviewFragment.kt @@ -40,13 +40,17 @@ class SeekerOverviewFragment : Fragment() { SeekerOverviewHelpRequestBinder() ) + progressBar.visibility = View.VISIBLE + vm.getHelpRequests().observe(viewLifecycleOwner, Observer { requests -> adapter.removeAllSections() if (requests.isEmpty()) { + progressBar.visibility = View.GONE textView_empty.visibility = View.VISIBLE } else { textView_empty.visibility = View.GONE + progressBar.visibility = View.GONE val requestsSection = ListSection() requestsSection.addAll(requests) adapter.addSection(requestsSection) diff --git a/app/src/main/res/layout/fragment_phone_call.xml b/app/src/main/res/layout/fragment_phone_call.xml index c47815d..2d10293 100644 --- a/app/src/main/res/layout/fragment_phone_call.xml +++ b/app/src/main/res/layout/fragment_phone_call.xml @@ -1,16 +1,27 @@ - - + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_marginTop="-6dp" + android:layout_marginBottom="-8dp" + android:indeterminate="true" + android:indeterminateTint="@color/colorPrimaryDark" + android:max="100" + android:padding="0dp" + android:visibility="gone" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_margin="15dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_seeker_create_request_confirm_address.xml b/app/src/main/res/layout/fragment_seeker_create_request_confirm_address.xml index fef6a7b..d3ed9fa 100644 --- a/app/src/main/res/layout/fragment_seeker_create_request_confirm_address.xml +++ b/app/src/main/res/layout/fragment_seeker_create_request_confirm_address.xml @@ -1,7 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> @@ -10,214 +10,235 @@ type="app.nexd.android.ui.seeker.create.SeekerCreateRequestViewModel" /> - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_marginTop="-6dp" + android:layout_marginBottom="-8dp" + android:indeterminate="true" + android:indeterminateTint="@color/colorPrimaryDark" + android:max="100" + android:padding="0dp" + android:visibility="gone" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + - - - - - - - + android:paddingTop="@dimen/topPadding"> - + android:textSize="24sp" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/textView_enter_address" /> + android:textCursorDrawable="@android:color/white" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/editText_first_name" /> + + + + + + + + + + + + + + + - - + android:textColorHint="@color/grey_500" + android:textCursorDrawable="@android:color/white" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/linearLayout_zipCode_city" /> - - -