From 44a09220b5c92b8a809f59320dba9d0894d40723 Mon Sep 17 00:00:00 2001 From: Shankar Yadav Date: Thu, 7 Apr 2022 16:03:28 +0530 Subject: [PATCH] added shimmer --- app/build.gradle | 3 + .../naviapp/home/fragment/ProfileFragment.kt | 14 +-- .../com/naviapp/home/viewmodel/ProfileVM.kt | 6 +- .../main/res/drawable/bg_grey_8dp_radius.xml | 15 +++ .../main/res/layout/fragment_profile_ln.xml | 23 ++++ .../layout/shimmer_profile_header_layout.xml | 34 ++++++ .../layout/shimmer_profile_item_layout.xml | 103 ++++++++++++++++++ navi-design/src/main/res/values/dimens.xml | 3 + 8 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/bg_grey_8dp_radius.xml create mode 100644 app/src/main/res/layout/shimmer_profile_header_layout.xml create mode 100644 app/src/main/res/layout/shimmer_profile_item_layout.xml diff --git a/app/build.gradle b/app/build.gradle index 1eae657acf..9cef1bfcbf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -397,6 +397,9 @@ dependencies { //one tap sms verification implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1' + implementation 'com.facebook.shimmer:shimmer:0.5.0' + + } tasks.withType(Compiler) { diff --git a/app/src/main/java/com/naviapp/home/fragment/ProfileFragment.kt b/app/src/main/java/com/naviapp/home/fragment/ProfileFragment.kt index 99b69b2632..4888369005 100644 --- a/app/src/main/java/com/naviapp/home/fragment/ProfileFragment.kt +++ b/app/src/main/java/com/naviapp/home/fragment/ProfileFragment.kt @@ -81,9 +81,10 @@ class ProfileFragment : BaseFragment(), WidgetCallback { false ) initUI() + initError(viewModel) initObservers() setupFreshChatUnreadCount() - fetchProfileItems() + viewModel.fetchProfileItems() return binding.root } @@ -93,17 +94,14 @@ class ProfileFragment : BaseFragment(), WidgetCallback { } private fun initUI() { - - } - - private fun fetchProfileItems() { - showLoader() - viewModel.fetchProfileItems() + binding.shimmerLayout.startShimmer() } private fun initObservers() { viewModel.profileItems.observe(viewLifecycleOwner) { response -> - hideLoader() + binding.shimmerLayout.stopShimmer() + binding.shimmerLayout.visibility = View.GONE + binding.rvLAPContent.visibility = View.VISIBLE response?.contentWidget?.let { contentWidget -> updateStatusBar(contentWidget.firstOrNull()) binding.rvLAPContent.apply { diff --git a/app/src/main/java/com/naviapp/home/viewmodel/ProfileVM.kt b/app/src/main/java/com/naviapp/home/viewmodel/ProfileVM.kt index b8ccf6d63e..2c771f79f7 100644 --- a/app/src/main/java/com/naviapp/home/viewmodel/ProfileVM.kt +++ b/app/src/main/java/com/naviapp/home/viewmodel/ProfileVM.kt @@ -29,11 +29,7 @@ class ProfileVM @Inject constructor(private val repository: ProfileRepository) : fun fetchProfileItems() { coroutineScope.launch { val response = repository.fetchProfileItems() - if (response.error == null && response.errors.isNullOrEmpty()) { - _profileItems.value = response.data - } else { - setErrorData(response.errors, response.error) - } + _profileItems.value = response.data } } } \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_grey_8dp_radius.xml b/app/src/main/res/drawable/bg_grey_8dp_radius.xml new file mode 100644 index 0000000000..5d1f63687d --- /dev/null +++ b/app/src/main/res/drawable/bg_grey_8dp_radius.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile_ln.xml b/app/src/main/res/layout/fragment_profile_ln.xml index 4ecdb446cf..1dc7cc181b 100644 --- a/app/src/main/res/layout/fragment_profile_ln.xml +++ b/app/src/main/res/layout/fragment_profile_ln.xml @@ -12,10 +12,33 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/shimmer_profile_header_layout.xml b/app/src/main/res/layout/shimmer_profile_header_layout.xml new file mode 100644 index 0000000000..f14a5446c7 --- /dev/null +++ b/app/src/main/res/layout/shimmer_profile_header_layout.xml @@ -0,0 +1,34 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/shimmer_profile_item_layout.xml b/app/src/main/res/layout/shimmer_profile_item_layout.xml new file mode 100644 index 0000000000..115da29b40 --- /dev/null +++ b/app/src/main/res/layout/shimmer_profile_item_layout.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/navi-design/src/main/res/values/dimens.xml b/navi-design/src/main/res/values/dimens.xml index 0b523e88a8..6f36ec6eb7 100644 --- a/navi-design/src/main/res/values/dimens.xml +++ b/navi-design/src/main/res/values/dimens.xml @@ -37,6 +37,7 @@ 64dp 68dp 72dp + 76dp 80dp 82dp 90dp @@ -46,10 +47,12 @@ 126dp 128dp 130dp + 134dp 140dp 148dp 150dp 160dp + 190dp 220dp 250dp