Skip to content

Commit

Permalink
update recyclerview gejala item
Browse files Browse the repository at this point in the history
  • Loading branch information
anprimordi committed Nov 27, 2019
1 parent cb645dd commit 79ef148
Show file tree
Hide file tree
Showing 47 changed files with 402 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.makaryostudio.lovebird.feature.diagnosis
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
Expand Down Expand Up @@ -49,8 +50,8 @@ class DiagnosisActivity : AppCompatActivity(), DiagnosisContract.View {
}

private fun bindView() {
rvGejala = findViewById(R.id.rv_gejala)
rvGejala.layoutManager = LinearLayoutManager(this)
rvGejala = findViewById(R.id.rv_diagnosis_gejala)
rvGejala.layoutManager = GridLayoutManager(this, 2)
adapter = DiagnosisAdapter(this)
rvGejala.adapter = adapter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.makaryostudio.lovebird.R
Expand Down Expand Up @@ -55,13 +57,15 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val gejala = mListData[position]

holder.mCbGejala.text = gejala.gejalaDialami
holder.mCbGejala.isChecked = gejala.isChecked
holder.imgGejala.setImageResource(gejala.imageGejala)
holder.titleGejala.text = gejala.gejalaDialami
holder.textGejala.text = gejala.deskripsiGejala
holder.cbGejala.isChecked = gejala.isChecked

holder.mCbGejala.setOnClickListener {
holder.cbGejala.setOnClickListener {

if (!gejala.isChecked) {
holder.mCbGejala.isChecked = true
holder.cbGejala.isChecked = true
gejala.isChecked = true
mCheckedGejala.add(gejala)
inputGejala.add(gejala.kodeGejala)
Expand All @@ -72,7 +76,7 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
}

} else {
holder.mCbGejala.isChecked = false
holder.cbGejala.isChecked = false
gejala.isChecked = false
mCheckedGejala.remove(gejala)
inputGejala.remove(gejala.kodeGejala)
Expand All @@ -88,7 +92,10 @@ class DiagnosisAdapter internal constructor(private val context: Context) :
}

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var mCbGejala: CheckBox = itemView.findViewById(R.id.checkbox_gejala)
var cbGejala: CheckBox = itemView.findViewById(R.id.checkbox_item_gejala)
var imgGejala: ImageView = itemView.findViewById(R.id.image_item_gejala)
var titleGejala: TextView = itemView.findViewById(R.id.text_item_gejala_title)
var textGejala: TextView = itemView.findViewById(R.id.text_item_gejala_description)
}

fun cbr() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,139 @@
package com.makaryostudio.lovebird.feature.diagnosis

import com.makaryostudio.lovebird.R
import com.makaryostudio.lovebird.model.Gejala

class DiagnosisPresenter internal constructor(private val view: DiagnosisContract.View) :
DiagnosisContract.Presenter {

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

Gejala(
R.drawable.ic_gejala_nafsu_makan_turun,
0,
"Nafsu Makan Menurun",
"Burung cenderung tidak memakan makanan yang diberikan",
5f
),
Gejala(
R.drawable.ic_gejala_kotoran_cair,
1,
"Kotoran Cair",
"Kotoran burung lebih encer dari sebelumnya",
3f
),
Gejala(
R.drawable.ic_gejala_bulu_tidak_rapi,
2,
"Bulu Tidak Rapi",
"Bulu tidak rapi karena dipatuk oleh burung sendiri",
2f
),
Gejala(
R.drawable.ic_gejala_kurang_bergairah,
3,
"Kurang Bergairah/Lemas",
"Kurang aktif bergerak",
3f
),
Gejala(
R.drawable.ic_gejala_bobot_turun,
4,
"Bobot Burung Menurun",
"Berat badan burung menurun dibanding sebelumnya",
2f
),
Gejala(
R.drawable.ic_gejala_jarang_berkicau,
5,
"Jarang Berkicau",
"Burung tidak sering mengeluarkan suara atau berkicau",
2f
),
Gejala(
R.drawable.ic_gejala_sering_menggigit_bulu,
6,
"Sering Menggigit Bulu",
"Burung sering menggigit bulunya sendiri",
2f
),
Gejala(
R.drawable.ic_gejala_kotoran_keruh,
7,
"Kotoran Berwarna Keruh",
"Kotoran lebih berwarna gelap dari sebelumnya",
2f
),
Gejala(
R.drawable.ic_gejala_kotoran_busuk,
8,
"Kotoran Berbau Busuk",
"Bau kotoran burung tidak sedap berbeda dengan biasanya",
2f
),
Gejala(
R.drawable.ic_gejala_banyak_kutu,
9,
"Banyak Kutu",
"Terdapat banyak kutu pada bulu burung",
4f
),
Gejala(
R.drawable.ic_gejala_sayap_menggantung,
10,
"Sayap Menggantung",
"Sayap burung digantungkan kebawah",
5f
),
Gejala(
R.drawable.ic_gejala_mata_berair,
11,
"Mata Berair",
"Mata burung mengeluarkan cairan bening secara konstan",
4f
),
Gejala(
R.drawable.ic_gejala_mata_bengkak,
12,
"Mata Bengkak",
"Mata burung cenderung lebih besar dan membengkak",
3f
),
Gejala(
R.drawable.ic_gejala_kaki_bengkak,
13,
"Kaki Bengkak",
"Bengkak pada kaki burung",
3f
),
Gejala(
R.drawable.ic_gejala_kuku_memanjang,
14,
"Kuku Memanjang",
"Kuku lebih cepat memanjang",
2f
),
Gejala(
R.drawable.ic_gejala_lemah,
15,
"Lemah",
"Burung lemah kurang bersemangat",
3f
),
Gejala(
R.drawable.ic_gejala_kelumpuhan,
16,
"Kelumpuhan Anggota Badan",
"Anggota badan burung tidak dapat digerakkan",
4f
),
Gejala(
R.drawable.ic_gejala_kotoran_putih,
17,
"Kotoran Berwarna Putih",
"Warna kotoran burung putih seperti kapur",
3f
)
)

view.onLoadListGejalaSucceed(listGejala)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.makaryostudio.lovebird.feature.hasil

import android.content.Intent
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
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.diagnosis.DiagnosisActivity
import com.makaryostudio.lovebird.model.Gejala

class HasilActivity : AppCompatActivity() {
Expand All @@ -14,16 +17,18 @@ class HasilActivity : AppCompatActivity() {
private lateinit var textHasilDiagnosis: TextView
private lateinit var textSolusi: TextView
private lateinit var textPencegahan: TextView
private lateinit var fabSelesai: FloatingActionButton

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_hasil)

bindView()

textHasilDiagnosis = findViewById(R.id.text_hasil_diagnosis)
textSolusi = findViewById(R.id.text_solusi)
textPencegahan = findViewById(R.id.text_pencegahan)
textHasilDiagnosis = findViewById(R.id.text_hasil_diagnosis_penyakit)
textSolusi = findViewById(R.id.text_hasil_solusi_description)
textPencegahan = findViewById(R.id.text_hasil_pencegahan_description)
fabSelesai = findViewById(R.id.fab_hasil_selesai)

val checked = intent.getParcelableArrayListExtra<Gejala>("checked")
val penyakitBurung = intent.getStringExtra("penyakit")
Expand All @@ -37,10 +42,12 @@ class HasilActivity : AppCompatActivity() {
textHasilDiagnosis.text = penyakitBurung!!.toString()
textSolusi.text = solusi
textPencegahan.text = pencegahan

fabSelesai.setOnClickListener { startActivity(Intent(this, DiagnosisActivity::class.java)) }
}

private fun bindView() {
rvGejalaDialami = findViewById(R.id.rv_gejala_dialami)
rvGejalaDialami = findViewById(R.id.rv_hasil_gejala_dialami)
rvGejalaDialami.layoutManager = LinearLayoutManager(this)
adapter = HasilAdapter()
rvGejalaDialami.adapter = adapter
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/makaryostudio/lovebird/model/Gejala.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@ import android.os.Parcel
import android.os.Parcelable

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

constructor(parcel: Parcel) : this(

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

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(imageGejala)
parcel.writeInt(kodeGejala)
parcel.writeString(gejalaDialami)
parcel.writeString(deskripsiGejala)
parcel.writeFloat(bobot)
parcel.writeByte(if (isChecked) 1 else 0)
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_done_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_banyak_kutu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_banyak_kutu" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_bobot_turun.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_berat_turun" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_bulu_tidak_rapi.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_bulu_tidak_rapi" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_jarang_berkicau.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_jarang_berkicau" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_kaki_bengkak.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_kaki_bengkak" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_kelumpuhan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_kelumpuhan" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_kotoran_busuk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_kotoran_busuk" />
</item>
</layer-list>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_gejala_kotoran_cair.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/img_gejala_kotoran_cair" />
</item>
</layer-list>
Loading

0 comments on commit 79ef148

Please sign in to comment.