-
Notifications
You must be signed in to change notification settings - Fork 591
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 -> { | ||
|
@@ -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) | ||
viewModel.loadGroupDetailsAndAccounts(groupId) | ||
|
||
} | ||
|
||
private fun showErrorLayout() { | ||
val errorMessage = getStringMessage(R.string.failed_to_load_group_details) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
There was a problem hiding this comment.
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()