From bca3cd601b0751a579e419fdaae0b9e22d24d59d Mon Sep 17 00:00:00 2001 From: alamasrorul Date: Wed, 20 Nov 2019 07:50:48 +0700 Subject: [PATCH] Penambahan cekBox input --- .idea/vcs.xml | 2 +- .../feature/diagnosis/DiagnosisActivity.kt | 11 +++++----- .../feature/diagnosis/DiagnosisAdapter.kt | 4 ++++ .../feature/diagnosis/DiagnosisPresenter.kt | 22 ++++++++++++++++++- .../lovebird/repository/model/Gejala.kt | 8 +++---- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisActivity.kt b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisActivity.kt index 0ef5138..f95ff7c 100644 --- a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisActivity.kt +++ b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisActivity.kt @@ -1,5 +1,4 @@ package com.makaryostudio.lovebird.feature.diagnosis - import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle @@ -7,6 +6,7 @@ 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 @@ -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) { rvGejala.setHasFixedSize(true) @@ -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) } @@ -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) diff --git a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisAdapter.kt b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisAdapter.kt index c8a733c..55d067a 100644 --- a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisAdapter.kt +++ b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisAdapter.kt @@ -15,6 +15,7 @@ class DiagnosisAdapter internal constructor(private val context: Context) : RecyclerView.Adapter() { private var mCheckedGejala: ArrayList = ArrayList() + private var inputGejala : ArrayList = ArrayList() private var mListData: List init { @@ -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) diff --git a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisPresenter.kt b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisPresenter.kt index d1b5718..e68f72b 100644 --- a/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisPresenter.kt +++ b/app/src/main/java/com/makaryostudio/lovebird/feature/diagnosis/DiagnosisPresenter.kt @@ -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) diff --git a/app/src/main/java/com/makaryostudio/lovebird/repository/model/Gejala.kt b/app/src/main/java/com/makaryostudio/lovebird/repository/model/Gejala.kt index 9ea6432..d37587a 100644 --- a/app/src/main/java/com/makaryostudio/lovebird/repository/model/Gejala.kt +++ b/app/src/main/java/com/makaryostudio/lovebird/repository/model/Gejala.kt @@ -5,14 +5,15 @@ 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() @@ -20,7 +21,7 @@ data class Gejala( 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) } @@ -38,5 +39,4 @@ data class Gejala( return arrayOfNulls(size) } } - } \ No newline at end of file