Skip to content

Commit

Permalink
fix #1075: ui layout for loan application fragment
Browse files Browse the repository at this point in the history
fix #1075: ui layout for loan application fragment
  • Loading branch information
kmanikanta335 authored and therajanmaurya committed Dec 28, 2023
1 parent 71a2aab commit 938f833
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.github.therajanmaurya.sweeterror.SweetUIErrorHandler
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.mifos.mobile.R
Expand Down Expand Up @@ -61,7 +62,7 @@ class LoanApplicationFragment : BaseFragment() {
private var submittedDate: String? = null
private var isDisbursementDate = false
private var isLoanUpdatePurposesInitialization = true

private var sweetUIErrorHandler: SweetUIErrorHandler? = null
/**
* Used when we want to apply for a Loan
*
Expand Down Expand Up @@ -114,6 +115,7 @@ class LoanApplicationFragment : BaseFragment() {
savedInstanceState: Bundle?,
): View {
_binding = FragmentAddLoanApplicationBinding.inflate(inflater, container, false)
sweetUIErrorHandler = SweetUIErrorHandler(activity, binding.root)
showUserInterface()
if (savedInstanceState == null) {
loadLoanTemplate()
Expand Down Expand Up @@ -197,7 +199,7 @@ class LoanApplicationFragment : BaseFragment() {
setTvDisbursementOnDate()
}

llError.ivStatus.setOnClickListener {
binding.layoutError.btnTryAgain.setOnClickListener {
onRetry()
}
}
Expand Down Expand Up @@ -322,11 +324,16 @@ class LoanApplicationFragment : BaseFragment() {
* Retries to fetch [LoanTemplate] by calling `loadLoanTemplate()`
*/
private fun onRetry() {
binding.apply {
llError.root.visibility = View.GONE
llAddLoan.visibility = View.VISIBLE
if (Network.isConnected(context)) {
sweetUIErrorHandler?.hideSweetErrorLayoutUI(
binding.viewFlipper,
binding.layoutError.root,
)
loadLoanTemplate()
} else {
Toaster.show(binding.viewFlipper, getString(R.string.internet_not_connected))
}
loadLoanTemplate()

}

/**
Expand Down Expand Up @@ -546,16 +553,17 @@ class LoanApplicationFragment : BaseFragment() {
* @param message Error message that tells the user about the problem.
*/
fun showError(message: String?) {
with(binding) {
if (!Network.isConnected(activity)) {
llError.ivStatus.setImageResource(R.drawable.ic_error_black_24dp)
llError.tvStatus.text = getString(R.string.internet_not_connected)
llAddLoan.visibility = View.GONE
llError.root.visibility = View.VISIBLE
} else {
Toaster.show(root, message)
}
if (!Network.isConnected(context)) {
sweetUIErrorHandler?.showSweetNoInternetUI(binding.viewFlipper, binding.layoutError.root)
} else {
sweetUIErrorHandler?.showSweetErrorUI(
message,
binding.viewFlipper,
binding.layoutError.root,
)
Toaster.show(binding.viewFlipper, message)
}
hideProgress()
}

fun showProgress() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_add_loan_application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@
</androidx.core.widget.NestedScrollView>

<include
android:id="@+id/ll_error"
layout="@layout/layout_error"
android:id="@+id/layout_error"
layout="@layout/error_layout"
android:visibility="gone" />

</RelativeLayout>

0 comments on commit 938f833

Please sign in to comment.