diff --git a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupLeaderStepFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupLeaderStepFragment.kt
index 55c2e4d6..f8bd2a95 100644
--- a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupLeaderStepFragment.kt
+++ b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupLeaderStepFragment.kt
@@ -1,5 +1,6 @@
package org.apache.fineract.ui.online.groups.creategroup
+import android.app.AlertDialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
@@ -12,10 +13,9 @@ import butterknife.Optional
import com.stepstone.stepper.Step
import com.stepstone.stepper.VerificationError
import com.wajahatkarim3.easyvalidation.core.view_ktx.validator
-import kotlinx.android.synthetic.main.fragment_step_add_group_leader.*
import kotlinx.android.synthetic.main.fragment_step_add_group_leader.view.*
-import kotlinx.android.synthetic.main.fragment_step_add_group_member.view.*
import kotlinx.android.synthetic.main.fragment_step_add_group_member.view.rv_name
+import kotlinx.android.synthetic.main.member_leader_layout.view.*
import org.apache.fineract.R
import org.apache.fineract.ui.adapters.NameListAdapter
import org.apache.fineract.ui.base.FineractBaseActivity
@@ -89,36 +89,7 @@ class AddGroupLeaderStepFragment : FineractBaseFragment(), Step, NameListAdapter
private fun showAddLeaderView(action: GroupAction, name: String?) {
currentAction = action
- llAddLeader.visibility = View.VISIBLE
- when (action) {
- GroupAction.CREATE -> {
- btnAddLeader.text = getString(R.string.add)
- }
- GroupAction.EDIT -> {
- etNewLeader.setText(name)
- btnAddLeader.text = getString(R.string.update)
- }
- }
- }
-
- @Optional
- @OnClick(R.id.btnAddLeader)
- fun addLeader() {
- if (etNewLeader.validator()
- .nonEmpty()
- .noNumbers()
- .addErrorCallback { etNewLeader.error = it }.check()) {
- if (currentAction == GroupAction.CREATE) {
- leaders.add(etNewLeader.text.toString())
- } else {
- leaders[editItemPosition] = etNewLeader.text.toString()
- }
- etNewLeader.text.clear()
- llAddLeader.visibility = View.GONE
- Utils.hideKeyboard(context, etNewLeader)
- showRecyclerView(true)
- nameLisAdapter.submitList(leaders)
- }
+ showAddEditDialog(action, name)
}
fun showRecyclerView(isShow: Boolean) {
@@ -132,13 +103,6 @@ class AddGroupLeaderStepFragment : FineractBaseFragment(), Step, NameListAdapter
}
- @Optional
- @OnClick(R.id.btnCancelAddLeader)
- fun cancelLeaderAddition() {
- etNewLeader.text.clear()
- llAddLeader.visibility = View.GONE
- }
-
override fun onSelected() {
}
@@ -178,4 +142,40 @@ class AddGroupLeaderStepFragment : FineractBaseFragment(), Step, NameListAdapter
}.run { show() }
}
+ private fun showAddEditDialog(action: GroupAction, name: String?) {
+ val layout = layoutInflater.inflate(R.layout.member_leader_layout, null)
+ val dialog = AlertDialog.Builder(context)
+ .setView(layout)
+ .create()
+ dialog.show()
+
+ if (action == GroupAction.CREATE) {
+ layout.btnAddMember.text = getString(R.string.add)
+ layout.tv_member_head.text = getString(R.string.add_new_leader)
+ }
+ else if (action == GroupAction.EDIT) {
+ layout.etNewMember.setText(name)
+ layout.btnAddMember.text = getString(R.string.update)
+ layout.tv_member_head.text = getString(R.string.edit_leader)
+ }
+
+ layout.btnAddMember.setOnClickListener {
+ if (layout.etNewMember.validator()
+ .nonEmpty()
+ .noNumbers()
+ .addErrorCallback { layout.etNewMember.error = it }.check()) {
+ if (currentAction == GroupAction.CREATE) {
+ leaders.add(layout.etNewMember.text.toString())
+ } else {
+ leaders[editItemPosition] = layout.etNewMember.text.toString()
+ }
+ Utils.hideKeyboard(context, layout.etNewMember)
+ showRecyclerView(true)
+ nameLisAdapter.submitList(leaders)
+ dialog.dismiss()
+ }
+ }
+
+ layout.btnCancelAddMember.setOnClickListener { dialog.dismiss() }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupMemberStepFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupMemberStepFragment.kt
index b7fe562e..33ae353d 100644
--- a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupMemberStepFragment.kt
+++ b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/AddGroupMemberStepFragment.kt
@@ -1,5 +1,6 @@
package org.apache.fineract.ui.online.groups.creategroup
+import android.app.AlertDialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
@@ -12,8 +13,8 @@ import butterknife.Optional
import com.stepstone.stepper.Step
import com.stepstone.stepper.VerificationError
import com.wajahatkarim3.easyvalidation.core.view_ktx.validator
-import kotlinx.android.synthetic.main.fragment_step_add_group_member.*
import kotlinx.android.synthetic.main.fragment_step_add_group_member.view.*
+import kotlinx.android.synthetic.main.member_leader_layout.view.*
import org.apache.fineract.R
import org.apache.fineract.ui.adapters.NameListAdapter
import org.apache.fineract.ui.base.FineractBaseActivity
@@ -87,36 +88,7 @@ class AddGroupMemberStepFragment : FineractBaseFragment(), Step, NameListAdapter
private fun showAddMemberView(action: GroupAction, name: String?) {
currentAction = action
- llAddMember.visibility = View.VISIBLE
- when (action) {
- GroupAction.CREATE -> {
- btnAddMember.text = getString(R.string.add)
- }
- GroupAction.EDIT -> {
- etNewMember.setText(name)
- btnAddMember.text = getString(R.string.update)
- }
- }
- }
-
- @Optional
- @OnClick(R.id.btnAddMember)
- fun addMember() {
- if (etNewMember.validator()
- .nonEmpty()
- .noNumbers()
- .addErrorCallback { etNewMember.error = it }.check()) {
- if (currentAction == GroupAction.CREATE) {
- members.add(etNewMember.text.toString())
- } else {
- members[editItemPosition] = etNewMember.text.toString()
- }
- etNewMember.text.clear()
- llAddMember.visibility = View.GONE
- Utils.hideKeyboard(context, etNewMember)
- showRecyclerView(true)
- nameLisAdapter.submitList(members)
- }
+ showAddEditDialog(action, name)
}
fun showRecyclerView(isShow: Boolean) {
@@ -127,14 +99,6 @@ class AddGroupMemberStepFragment : FineractBaseFragment(), Step, NameListAdapter
rootView.rv_name.visibility = View.GONE
rootView.tvAddedMember.visibility = View.VISIBLE
}
-
- }
-
- @Optional
- @OnClick(R.id.btnCancelAddMember)
- fun cancelMemberAddition() {
- etNewMember.text.clear()
- llAddMember.visibility = View.GONE
}
override fun onSelected() {
@@ -175,4 +139,41 @@ class AddGroupMemberStepFragment : FineractBaseFragment(), Step, NameListAdapter
createMaterialDialog()
}.run { show() }
}
+
+ private fun showAddEditDialog(action: GroupAction, name: String?) {
+ val layout = layoutInflater.inflate(R.layout.member_leader_layout, null)
+ val dialog = AlertDialog.Builder(context)
+ .setView(layout)
+ .create()
+ dialog.show()
+
+ if (action == GroupAction.CREATE) {
+ layout.btnAddMember.text = getString(R.string.add)
+ layout.tv_member_head.text = getString(R.string.add_new_member)
+ }
+ else if (action == GroupAction.EDIT) {
+ layout.etNewMember.setText(name)
+ layout.btnAddMember.text = getString(R.string.update)
+ layout.tv_member_head.text = getString(R.string.edit_member)
+ }
+
+ layout.btnAddMember.setOnClickListener {
+ if (layout.etNewMember.validator()
+ .nonEmpty()
+ .noNumbers()
+ .addErrorCallback { layout.etNewMember.error = it }.check()) {
+ if (currentAction == GroupAction.CREATE) {
+ members.add(layout.etNewMember.text.toString())
+ } else {
+ members[editItemPosition] = layout.etNewMember.text.toString()
+ }
+ Utils.hideKeyboard(context, layout.etNewMember)
+ showRecyclerView(true)
+ nameLisAdapter.submitList(members)
+ dialog.dismiss()
+ }
+ }
+
+ layout.btnCancelAddMember.setOnClickListener { dialog.dismiss() }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_step_add_group_leader.xml b/app/src/main/res/layout/fragment_step_add_group_leader.xml
index b49c067c..164b54c1 100644
--- a/app/src/main/res/layout/fragment_step_add_group_leader.xml
+++ b/app/src/main/res/layout/fragment_step_add_group_leader.xml
@@ -61,53 +61,6 @@
android:text="@string/no_group_leader_added"
android:visibility="visible" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index af22aaa1..3af1958c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -542,4 +542,9 @@
"Updating group status, please wait... "
Error while updating group status
Error while creating group
+
+ Add New Member
+ Edit Member
+ Add New Leader
+ Edit Leader