From 3105de73801217e153711a9198853a1e8105ca24 Mon Sep 17 00:00:00 2001 From: kmanikanta335 <118070186+kmanikanta335@users.noreply.github.com> Date: Sat, 25 Nov 2023 18:09:33 +0530 Subject: [PATCH 1/5] fix:When Recent Transactions is opened without connection of internet App crashes --- .../fragments/RecentTransactionsFragment.kt | 2 +- .../viewModels/RecentTransactionViewModel.kt | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt index fa64eacc96..917da11d29 100644 --- a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt @@ -74,7 +74,7 @@ class RecentTransactionsFragment : BaseFragment(), OnRefreshListener { } is RecentTransactionUiState.Error -> { hideProgress() - showMessage(getString(it.message)) + showErrorFetchingRecentTransactions(getString(it.message)) } is RecentTransactionUiState.EmptyTransaction -> { hideProgress() diff --git a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt index 5c00319cb5..135cfe416d 100644 --- a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt +++ b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt @@ -28,22 +28,25 @@ class RecentTransactionViewModel @Inject constructor(private val recentTransacti private fun loadRecentTransactions(offset: Int, limit: Int) { viewModelScope.launch { - _recentTransactionUiState.value = RecentTransactionUiState.Loading - val response = recentTransactionRepositoryImp.recentTransactions(offset, limit) - if (response?.isSuccessful == true) { - if (response.body()?.totalFilteredRecords == 0) { - _recentTransactionUiState.value = RecentTransactionUiState.EmptyTransaction - } else if (loadmore && response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = - RecentTransactionUiState.LoadMoreRecentTransactions( - response.body()!!.pageItems - ) - } else if (response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = RecentTransactionUiState.RecentTransactions( - response.body()?.pageItems!! - ) + try { + _recentTransactionUiState.value = RecentTransactionUiState.Loading + val response = recentTransactionRepositoryImp.recentTransactions(offset, limit) + if (response?.isSuccessful == true) { + if (response.body()?.totalFilteredRecords == 0) { + _recentTransactionUiState.value = RecentTransactionUiState.EmptyTransaction + } else if (loadmore && response.body()?.pageItems?.isNotEmpty() == true) { + _recentTransactionUiState.value = + RecentTransactionUiState.LoadMoreRecentTransactions( + response.body()!!.pageItems + ) + } else if (response.body()?.pageItems?.isNotEmpty() == true) { + _recentTransactionUiState.value = + RecentTransactionUiState.RecentTransactions( + response.body()?.pageItems!! + ) + } } - } else { + } catch(e: Exception){ _recentTransactionUiState.value = RecentTransactionUiState.Error(R.string.recent_transactions) } From dd4aa5ab3f25a47380c0c827068f81eaf2ec8eb0 Mon Sep 17 00:00:00 2001 From: kmanikanta335 <118070186+kmanikanta335@users.noreply.github.com> Date: Sat, 25 Nov 2023 18:09:33 +0530 Subject: [PATCH 2/5] fix:When Recent Transactions is opened without connection of internet App crashes --- .../fragments/RecentTransactionsFragment.kt | 2 +- .../viewModels/RecentTransactionViewModel.kt | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt index fa64eacc96..917da11d29 100644 --- a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt @@ -74,7 +74,7 @@ class RecentTransactionsFragment : BaseFragment(), OnRefreshListener { } is RecentTransactionUiState.Error -> { hideProgress() - showMessage(getString(it.message)) + showErrorFetchingRecentTransactions(getString(it.message)) } is RecentTransactionUiState.EmptyTransaction -> { hideProgress() diff --git a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt index 5c00319cb5..135cfe416d 100644 --- a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt +++ b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt @@ -28,22 +28,25 @@ class RecentTransactionViewModel @Inject constructor(private val recentTransacti private fun loadRecentTransactions(offset: Int, limit: Int) { viewModelScope.launch { - _recentTransactionUiState.value = RecentTransactionUiState.Loading - val response = recentTransactionRepositoryImp.recentTransactions(offset, limit) - if (response?.isSuccessful == true) { - if (response.body()?.totalFilteredRecords == 0) { - _recentTransactionUiState.value = RecentTransactionUiState.EmptyTransaction - } else if (loadmore && response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = - RecentTransactionUiState.LoadMoreRecentTransactions( - response.body()!!.pageItems - ) - } else if (response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = RecentTransactionUiState.RecentTransactions( - response.body()?.pageItems!! - ) + try { + _recentTransactionUiState.value = RecentTransactionUiState.Loading + val response = recentTransactionRepositoryImp.recentTransactions(offset, limit) + if (response?.isSuccessful == true) { + if (response.body()?.totalFilteredRecords == 0) { + _recentTransactionUiState.value = RecentTransactionUiState.EmptyTransaction + } else if (loadmore && response.body()?.pageItems?.isNotEmpty() == true) { + _recentTransactionUiState.value = + RecentTransactionUiState.LoadMoreRecentTransactions( + response.body()!!.pageItems + ) + } else if (response.body()?.pageItems?.isNotEmpty() == true) { + _recentTransactionUiState.value = + RecentTransactionUiState.RecentTransactions( + response.body()?.pageItems!! + ) + } } - } else { + } catch(e: Exception){ _recentTransactionUiState.value = RecentTransactionUiState.Error(R.string.recent_transactions) } From 6fa1fdaf748d6774b7e2aa2f95a73106ede82bdb Mon Sep 17 00:00:00 2001 From: kmanikanta335 <118070186+kmanikanta335@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:00:27 +0530 Subject: [PATCH 3/5] =?UTF-8?q?Fixed=20#2442=20:When=20Recent=20Transactio?= =?UTF-8?q?ns=20is=20opened=20without=20connection=20of=20internet?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fragments/RecentTransactionsFragment.kt | 22 ----------------- .../viewModels/RecentTransactionViewModel.kt | 24 +------------------ 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt index c4c409e3b4..7a33878aa2 100644 --- a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt @@ -68,27 +68,6 @@ class RecentTransactionsFragment : BaseFragment(), OnRefreshListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - -<<<<<<< HEAD - recentTransactionViewModel.recentTransactionUiState.observe(viewLifecycleOwner) { - when (it) { - is RecentTransactionUiState.Loading -> showProgress() - is RecentTransactionUiState.RecentTransactions -> { - hideProgress() - showRecentTransactions(it.transactions) - } - is RecentTransactionUiState.Error -> { - hideProgress() - showErrorFetchingRecentTransactions(getString(it.message)) - } - is RecentTransactionUiState.EmptyTransaction -> { - hideProgress() - showEmptyTransaction() - } - is RecentTransactionUiState.LoadMoreRecentTransactions -> { - hideProgress() - showLoadMoreRecentTransactions(it.transactions) -======= viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { recentTransactionViewModel.recentTransactionUiState.collect{ @@ -113,7 +92,6 @@ class RecentTransactionsFragment : BaseFragment(), OnRefreshListener { RecentTransactionUiState.Initial -> {} } ->>>>>>> e6a6d7b05ee77dc5164d7f8d4abd6225b433b09c } } } diff --git a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt index ce4e117286..e6cf3a80c0 100644 --- a/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt +++ b/app/src/main/java/org/mifos/mobile/viewModels/RecentTransactionViewModel.kt @@ -29,31 +29,9 @@ class RecentTransactionViewModel @Inject constructor(private val recentTransacti } private fun loadRecentTransactions(offset: Int, limit: Int) { - viewModelScope.launch { <<<<<<< HEAD - try { - _recentTransactionUiState.value = RecentTransactionUiState.Loading - val response = recentTransactionRepositoryImp.recentTransactions(offset, limit) - if (response?.isSuccessful == true) { - if (response.body()?.totalFilteredRecords == 0) { - _recentTransactionUiState.value = RecentTransactionUiState.EmptyTransaction - } else if (loadmore && response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = - RecentTransactionUiState.LoadMoreRecentTransactions( - response.body()!!.pageItems - ) - } else if (response.body()?.pageItems?.isNotEmpty() == true) { - _recentTransactionUiState.value = - RecentTransactionUiState.RecentTransactions( - response.body()?.pageItems!! - ) - } - } - } catch(e: Exception){ -======= - + viewModelScope.launch { _recentTransactionUiState.value = RecentTransactionUiState.Loading recentTransactionRepositoryImp.recentTransactions(offset, limit).catch { ->>>>>>> e6a6d7b05ee77dc5164d7f8d4abd6225b433b09c _recentTransactionUiState.value = RecentTransactionUiState.Error(R.string.recent_transactions) }.collect { From d9d63d1780c9da560561242e4a798a0e0c4d5938 Mon Sep 17 00:00:00 2001 From: kmanikanta335 <118070186+kmanikanta335@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:02:40 +0530 Subject: [PATCH 4/5] =?UTF-8?q?Fixed=20#2442=20:When=20Recent=20Transactio?= =?UTF-8?q?ns=20is=20opened=20without=20connection=20of=20internet?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt index 7a33878aa2..e0870502c6 100644 --- a/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/fragments/RecentTransactionsFragment.kt @@ -68,6 +68,7 @@ class RecentTransactionsFragment : BaseFragment(), OnRefreshListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { recentTransactionViewModel.recentTransactionUiState.collect{ From d2e06a4728c7f8e90e280bbd728c57ddd2a8a89c Mon Sep 17 00:00:00 2001 From: kmanikanta335 <118070186+kmanikanta335@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:06:00 +0530 Subject: [PATCH 5/5] Fixed Feat: Implement Shimmer while user details are being loaded --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index e276955ac0..145fdb5dce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -204,6 +204,6 @@ dependencies { implementation "androidx.compose.material3:material3:$rootProject.materialVersion" implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$rootProject.lifecycleVersion" implementation "androidx.compose.material:material-icons-extended:$rootProject.composeVersion" - + implementation 'com.facebook.shimmer:shimmer:0.5.0' } apply plugin: 'com.google.gms.google-services'