Skip to content

Commit

Permalink
Penambahan cekBox input
Browse files Browse the repository at this point in the history
  • Loading branch information
alamasrorul committed Nov 20, 2019
1 parent 4680228 commit bca3cd6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.makaryostudio.lovebird.feature.diagnosis

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.makaryostudio.lovebird.R
import com.makaryostudio.lovebird.feature.hasil.HasilActivity
import com.makaryostudio.lovebird.repository.model.Gejala
Expand All @@ -19,8 +19,7 @@ class DiagnosisActivity : AppCompatActivity(), DiagnosisContract.View {
private lateinit var rvGejala: RecyclerView
private lateinit var adapter: DiagnosisAdapter
private lateinit var textNamaBurung: EditText
private lateinit var btnDiagnosis: Button

private lateinit var btnDiagnosis: FloatingActionButton

override fun onLoadListGejalaSucceed(listGejala: List<Gejala>) {
rvGejala.setHasFixedSize(true)
Expand All @@ -36,10 +35,11 @@ class DiagnosisActivity : AppCompatActivity(), DiagnosisContract.View {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_diagnosis)

btnDiagnosis = findViewById(R.id.button_diagnosis)

btnDiagnosis.setOnClickListener {
intent = Intent()
val intent = Intent(this, HasilActivity::class.java)
intent.putExtra("namaburung", textNamaBurung.toString())
intent = Intent(this, HasilActivity::class.java)
startActivity(intent)
}

Expand All @@ -48,7 +48,6 @@ class DiagnosisActivity : AppCompatActivity(), DiagnosisContract.View {

private fun bindView() {
textNamaBurung = findViewById(R.id.edit_nama_burung)
btnDiagnosis = findViewById(R.id.button_diagnosis)

rvGejala = findViewById(R.id.rv_gejala)
rvGejala.layoutManager = LinearLayoutManager(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
RecyclerView.Adapter<DiagnosisAdapter.ViewHolder>() {

private var mCheckedGejala: ArrayList<Gejala> = ArrayList()
private var inputGejala : ArrayList<Int> = ArrayList()
private var mListData: List<Gejala>

init {
Expand Down Expand Up @@ -51,10 +52,13 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
holder.mCbGejala.isChecked = true
gejala.isChecked = true
mCheckedGejala.add(gejala)
inputGejala.add(gejala.kodeGejala)

} else {
holder.mCbGejala.isChecked = false
gejala.isChecked = false
mCheckedGejala.remove(gejala)
inputGejala.remove(gejala.kodeGejala)
}

intent.putExtra("checked", mCheckedGejala)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,29 @@ class DiagnosisPresenter internal constructor(private val view: DiagnosisContrac
// gejala.checked
// }



override fun loadListGejala() {
val listGejala = arrayListOf(
Gejala(R.array.array_kode_gejala, R.array.array_nama_gejala, R.array.array_bobot_gejala)
Gejala(1, "Nafsu Makan Menurun", 5),
Gejala(2,"Kotoran Cair",3),
Gejala(3, "Bulu Tidak Rapi", 2),
Gejala(4, "Kurang Bergairah/Lemas", 3),
Gejala(5, "Bobot Burung Menurun", 2),
Gejala(6, "Jarang Berkicau", 2),
Gejala(7, "Sering Menggigit Bulu", 2),
Gejala(8, "Kotoran Berwarna Keruh", 2),
Gejala(9, "Kotoran Berbau Busuk", 2),
Gejala(10, "Banyak Kutu", 4),
Gejala(11, "Sayang Menggantung", 5),
Gejala(12, "Mata Berair", 4),
Gejala(13, "Mata Bengkak", 3),
Gejala(14, "Kaki Bengkak", 3),
Gejala(15, "Kuku Memanjang", 2),
Gejala(16, "Lemah", 3),
Gejala(17, "Kelumpuhan Anggota Badan", 4),
Gejala(18, "Kotoran Seperti Kapur", 3)

)

view.onLoadListGejalaSucceed(listGejala)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import android.os.Parcelable

data class Gejala(
var kodeGejala: Int,
var gejalaDialami: Int,
var gejalaDialami: String = "",
var bobot: Int
) : Parcelable {
var isChecked: Boolean = false

constructor(parcel: Parcel) : this(

parcel.readInt(),
parcel.readInt(),
parcel.readString().toString(),
parcel.readInt()
) {
isChecked = parcel.readByte() != 0.toByte()
}

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(kodeGejala)
parcel.writeInt(gejalaDialami)
parcel.writeString(gejalaDialami)
parcel.writeInt(bobot)
parcel.writeByte(if (isChecked) 1 else 0)
}
Expand All @@ -38,5 +39,4 @@ data class Gejala(
return arrayOfNulls(size)
}
}

}

0 comments on commit bca3cd6

Please sign in to comment.