Skip to content

Commit

Permalink
add checkbox selection logic in diagnosis adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
anprimordi committed Nov 15, 2019
1 parent 0d284ea commit 282bb8f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
holder.mCbGejala.text = gejala.gejalaDialami
holder.mCbGejala.isChecked = gejala.checked

if (holder.mCbGejala.isChecked) {
val intent = Intent()
// intent.putExtra("checked", holder.mCbGejala.isChecked)
intent.putExtra("gejala", gejala)
context.startActivity(intent)
holder.mCbGejala.setOnClickListener {
if (!gejala.checked) {
holder.mCbGejala.isChecked = true
gejala.checked = true
} else {
holder.mCbGejala.isChecked = false
gejala.checked = false
}
}

// if (holder.mCbGejala.isChecked) {
// val intent = Intent()
// intent.putExtra("checked", holder.mCbGejala.isChecked)
// intent.putExtra("gejala", gejala)
// }
}

class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import com.makaryostudio.lovebird.base.BaseView
import com.makaryostudio.lovebird.repository.model.Gejala

interface DiagnosisContract {
interface Presenter: BasePresenter{
interface Presenter : BasePresenter {
fun loadListGejala()
fun getSelectedItems(isSelected: Boolean): ArrayList<Gejala>
}

interface View: BaseView<Presenter>{
interface View : BaseView<Presenter> {
fun onLoadListGejalaSucceed(listGejala: List<Gejala>)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package com.makaryostudio.lovebird.feature.diagnosis

class DiagnosisPresenter internal constructor(private val view: DiagnosisContract.View) : DiagnosisContract.Presenter{
import com.makaryostudio.lovebird.repository.model.Gejala

class DiagnosisPresenter internal constructor(private val view: DiagnosisContract.View) :
DiagnosisContract.Presenter {
override fun getSelectedItems(isSelected: Boolean): ArrayList<Gejala> {
TODO("mengambil list yang dipilih")
// val list: ArrayList<Gejala>
// for (i in 0..18 ) {
//
//
// }
// return list
}

override fun loadListGejala() {

TODO("what kind of database are we going to use?")
Expand Down
27 changes: 26 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@
</item>
</array>

<!-- kode gejala -->
<array name="array_kode_gejala">
<item>G001</item>
<item>G002</item>
<item>G003</item>
<item>G004</item>
<item>G005</item>

<item>G006</item>
<item>G007</item>
<item>G008</item>
<item>G009</item>
<item>G010</item>

<item>G011</item>
<item>G012</item>
<item>G013</item>
<item>G014</item>
<item>G015</item>

<item>G016</item>
<item>G017</item>
<item>G018</item>
</array>

<!-- nama gejala -->
<array name="array_nama_gejala">
<item>Nafsu makan menurun</item>
Expand All @@ -84,7 +109,7 @@
</array>

<!-- bobot -->
<array name="array_bobot">
<array name="array_bobot_gejala">
<item>5</item>
<item>4</item>
<item>3</item>
Expand Down

0 comments on commit 282bb8f

Please sign in to comment.