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

Fix#2356 Guarantor Type Selection Fixed #2360

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
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
@@ -1,5 +1,6 @@
package org.mifos.mobile.ui.fragments

import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -39,20 +40,27 @@ class AddGuarantorFragment : BaseFragment() {

private val viewModel: AddGuarantorViewModel by viewModels()

var guarantorTypeAdapter: ArrayAdapter<String?>? = null
private var guarantorTypeAdapter: ArrayAdapter<String?>? = null
var template: GuarantorTemplatePayload? = null
var payload: GuarantorPayload? = null
private var guarantorState: GuarantorState? = null
private var guarantorApplicationPayload: GuarantorApplicationPayload? = null
var loanId: Long? = 0
var index: Int? = 0
private var index: Int? = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (arguments != null) {
loanId = arguments?.getLong(Constants.LOAN_ID)
guarantorState = requireArguments()
.getSerializable(Constants.GUARANTOR_STATE) as GuarantorState
payload = arguments?.getParcelable(Constants.PAYLOAD)
guarantorState = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
arguments?.getSerializable(Constants.GUARANTOR_STATE, GuarantorState::class.java)
}else{
arguments?.getSerializable(Constants.GUARANTOR_STATE) as GuarantorState?
}
payload = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
arguments?.getParcelable(Constants.PAYLOAD, GuarantorPayload::class.java)
}else{
arguments?.getParcelable(Constants.PAYLOAD) as GuarantorPayload?
}
index = arguments?.getInt(Constants.INDEX)
}
}
Expand Down Expand Up @@ -115,7 +123,7 @@ class AddGuarantorFragment : BaseFragment() {
viewModel.getGuarantorTemplate(guarantorState, loanId)
}

fun onSubmit() {
private fun onSubmit() {
with(binding) {
tilFirstName.isErrorEnabled = false
tilLastName.isErrorEnabled = false
Expand Down Expand Up @@ -199,12 +207,12 @@ class AddGuarantorFragment : BaseFragment() {
_binding = null
}

fun showGuarantorApplication(template: GuarantorTemplatePayload?) {
private fun showGuarantorApplication(template: GuarantorTemplatePayload?) {
this.template = template
setUpSpinner()
}

fun showGuarantorUpdation(template: GuarantorTemplatePayload?) {
private fun showGuarantorUpdation(template: GuarantorTemplatePayload?) {
this.template = template
setUpSpinner()
with(binding) {
Expand All @@ -217,7 +225,6 @@ class AddGuarantorFragment : BaseFragment() {

private fun setUpSpinner() {
val options: MutableList<String?> = ArrayList()
options.addAll(listOf("choicea", "choiceB"))
for (option in template?.guarantorTypeOptions!!) {
options.add(option.value)
}
Expand All @@ -231,13 +238,13 @@ class AddGuarantorFragment : BaseFragment() {
}
}

fun updatedSuccessfully(message: String?) {
private fun updatedSuccessfully(message: String?) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
publish(UpdateGuarantorEvent(guarantorApplicationPayload, index))
activity?.supportFragmentManager?.popBackStack()
}

fun submittedSuccessfully(message: String?, payload: GuarantorApplicationPayload?) {
private fun submittedSuccessfully(message: String?, payload: GuarantorApplicationPayload?) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
publish(AddGuarantorEvent(payload, index))
activity?.supportFragmentManager?.popBackStack()
Expand Down