Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed :#1772 Error handling missing in GroupDetails #2050

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.Button
import android.widget.ListAdapter
import android.widget.ListView
import android.widget.TextView
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.therajanmaurya.sweeterror.SweetUIErrorHandler
import com.joanzapata.iconify.fonts.MaterialIcons
import com.joanzapata.iconify.widget.IconTextView
import com.mifos.mifosxdroid.R
Expand Down Expand Up @@ -45,6 +48,7 @@ class GroupDetailsFragment : MifosBaseFragment() {
private lateinit var binding: FragmentGroupDetailsBinding

private lateinit var viewModel: GroupDetailsViewModel
private var sweetUIErrorHandler: SweetUIErrorHandler? = null

private var groupId = 0
private var accountAccordion: AccountAccordion? = null
Expand All @@ -65,11 +69,14 @@ class GroupDetailsFragment : MifosBaseFragment() {
viewModel = ViewModelProvider(this)[GroupDetailsViewModel::class.java]
viewModel.loadGroupDetailsAndAccounts(groupId)

showUserInterface()

viewModel.groupDetailsUiState.observe(viewLifecycleOwner) {
when (it) {
is GroupDetailsUiState.ShowFetchingError -> {
showProgressbar(false)
showFetchingError(it.message)
// showFetchingError(it.message)
showErrorLayout()
}

is GroupDetailsUiState.ShowGroup -> {
Expand Down Expand Up @@ -100,8 +107,29 @@ class GroupDetailsFragment : MifosBaseFragment() {
binding.btnActivateGroup.setOnClickListener {
onClickActivateGroup()
}
binding.layoutError.findViewById<Button>(R.id.btnTryAgain).setOnClickListener {
reloadOnError()
}
}

fun reloadOnError() {
sweetUIErrorHandler?.hideSweetErrorLayoutUI(binding.scrollGroupDetails, binding.layoutError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this line in groupDetailsUiState GroupDetailsUiState.ShowProgressbar state and rename the method loadGroupDetailsAndAccounts()

viewModel.loadGroupDetailsAndAccounts(groupId)

}

private fun showErrorLayout() {
val errorMessage = getStringMessage(R.string.failed_to_load_group_details)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have showFetchingError method, please remove this method and move this logic in showFetchingError method.

sweetUIErrorHandler?.showSweetErrorUI(
errorMessage, R.drawable.ic_error_black_24dp,
binding.scrollGroupDetails, binding.layoutError
)
}

private fun showUserInterface() {

sweetUIErrorHandler = SweetUIErrorHandler(requireActivity(), binding.root)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this method and initialize the sweetUIErrorHandler globally in onCreateView

}
private fun onClickActivateGroup() {
val action = GroupDetailsFragmentDirections.actionGroupDetailsFragmentToActivateFragment(
groupId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding">

<ScrollView style="@style/ScrollView.Base">
<ScrollView
android:id="@+id/scroll_group_details"
style="@style/ScrollView.Base">

<LinearLayout style="@style/LinearLayout.Base">

Expand Down Expand Up @@ -176,5 +178,9 @@
android:background="@color/accent"
android:text="@string/activate_group" />
</LinearLayout>
<include
android:id="@+id/layout_error"
layout="@layout/layout_sweet_exception_handler"
android:visibility="gone" />

</RelativeLayout>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,6 @@
<string name="dark_mode">mode fosc</string>

<string name="accounts">Comptes</string>
<string name="failed_to_load_group_details">No s\'han pogut carregar els detalls del grup</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<string name="valid">Valid</string>
<string name="surveyEmpty">This Survey is Empty</string>
<string name="accounts">Accounts</string>
<string name="failed_to_load_group_details">Failed To Load Group Details</string>


</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,6 @@
<string name="dark_mode">modo oscuro</string>

<string name="accounts">cuenta</string>
<string name="failed_to_load_group_details">Error al cargar los detalles del grupo</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -613,5 +613,6 @@
<string name="dark_mode">mode sombre</string>

<string name="accounts">Compte</string>
<string name="failed_to_load_group_details">Echec du chargement des détails du groupe</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,6 @@
<string name="lang_changed">भाषा बदली गए</string>
<string name="lang_change_description">उस भाषा का चयन करें जिसमें आप ऐप देखना चाहते हैं</string>
<string name="dark_mode">डार्क मोडं</string>
<string name="failed_to_load_group_details">समूह विवरण लोड करने में विफल</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-kn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,6 @@
<string name="dark_mode">ಡಾರ್ಕ್ ಮೋಡ್</string>

<string name="accounts">ಖಾತೆ</string>
<string name="failed_to_load_group_details">ಸಮೂಹ ವಿವರಗಳನ್ನು ಲೋಡ್ ಮಾಡಲು ವಿಫಲವಾಗಿದೆ</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-sw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -732,5 +732,6 @@
<string name="lang_changed">Lugha Imebadilishwa</string>
<string name="lang_change_description">Chagua lugha ambayo unataka kutazama programu</string>
<string name="dark_mode">hali ya giza</string>
<string name="failed_to_load_group_details">Imeshindwa Kupakia Maelezo ya Kikundi</string>

</resources>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@
<string name="lang_changed">语言已更改</string>
<string name="lang_change_description">选择您要查看应用程序的语言</string>
<string name="dark_mode">暗模式</string>
<string name="failed_to_load_group_details">无以加载组详细信息</string>


</resources>
2 changes: 2 additions & 0 deletions mifosng-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@
<string name="failed_to_sync_loan">Failed to Sync Loan</string>
<string name="failed_to_sync_loanrepayment">Failed to Sync LoanRepayment</string>
<string name="failed_to_load_client">Failed To Load Clients</string>
<string name="failed_to_group_details">Failed To Load Group Details</string>
<string name="failed_to_fetch_savingsaccount">Failed To Fetch SavingsAccount</string>
<string name="failed_to_fetch_datatable">Failed To Fetch DataTable</string>
<string name="failed_to_fetch_savings_template">Failed to load Saving Template</string>
Expand Down Expand Up @@ -916,5 +917,6 @@

<string name="instance_url">Instance Url</string>
<string name="no_check_inbox">Checker Inbox is empty</string>
<string name="failed_to_load_group_details">Failed To Load Group Details</string>

</resources>