Skip to content

Commit

Permalink
update hasil activity, add hasil adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
anprimordi committed Nov 20, 2019
1 parent 564dee8 commit 6ff61c7
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 203 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,35 @@ package com.makaryostudio.lovebird.feature.hasil

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.makaryostudio.lovebird.R
import com.makaryostudio.lovebird.repository.model.Gejala

class HasilActivity : AppCompatActivity() {

private lateinit var textNamaBurung: TextView
private lateinit var adapter: RecyclerView
private lateinit var textHasilDiagnosis: TextView
private lateinit var textSolusi: TextView

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

val gejala = intent.getParcelableExtra<Gejala>("gejala")
val checked = intent.getBooleanArrayExtra("checked")
val namaBurung = intent.getStringExtra("namaBurung")

textNamaBurung.text = namaBurung

bindView()
}

private fun bindView() {
textNamaBurung = findViewById(R.id.text_nama_burung)
adapter = findViewById(R.id.rv_gejala_dialami)
textHasilDiagnosis = findViewById(R.id.text_hasil_diagnosis)
textSolusi = findViewById(R.id.text_solusi)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.makaryostudio.lovebird.feature.hasil

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.makaryostudio.lovebird.R
import com.makaryostudio.lovebird.repository.model.Gejala
import com.makaryostudio.lovebird.repository.model.Penyakit
import kotlinx.android.synthetic.main.item_hasil.view.*

class HasilAdapter internal constructor(private val context: Context) :
RecyclerView.Adapter<HasilAdapter.ViewHolder>() {

private var mListData: List<Penyakit>

init {
mListData = ArrayList()
notifyDataSetChanged()
}

//constructor mListData
fun loadListData(mListData: List<Penyakit>) {
this.mListData = mListData
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_hasil, parent, false)
return ViewHolder(view)
}

override fun getItemCount(): Int {
return mListData.size
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val penyakit = mListData[position]

// val gejala = Intent()
// gejala.getParcelableExtra<Gejala>("gejala")
holder.textGejalaDialami.text = penyakit.gejalaDialami
}

class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var textGejalaDialami: TextView = itemView.findViewById(R.id.text_hasil_gejala)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ import android.os.Parcelable
data class Penyakit(
var kodePenyakit: Int,
var namaPenyakit: String?,
var gejalaDialami: String?,
var deskripsiPenyakit: String?
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readInt(),
parcel.readString(),
parcel.readString(),
parcel.readString()
) {
}

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(kodePenyakit)
parcel.writeString(namaPenyakit)
parcel.writeString(gejalaDialami)
parcel.writeString(deskripsiPenyakit)
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_circle_green_8dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="8dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="8dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#22E863" android:pathData="M256,0C114.837,0 0,114.837 0,256s114.837,256 256,256s256,-114.837 256,-256S397.163,0 256,0z"/>
</vector>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_hasil.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/diagnosis_isi_form_text"
android:text="@string/hasil_diagnosis_text"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@color/primary_text"
app:layout_constraintBottom_toTopOf="@id/guideline_horizontal_top"
Expand Down Expand Up @@ -94,7 +94,7 @@
app:layout_constraintEnd_toEndOf="@id/text_nama_burung"
app:layout_constraintStart_toStartOf="@id/text_nama_burung"
app:layout_constraintTop_toBottomOf="@id/text_gejala_dialami"
tools:listitem="@layout/item_gejala" />
tools:listitem="@layout/item_hasil" />

<TextView
android:id="@+id/text_diagnosis_penyakit"
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/layout/item_hasil.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_gejala"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:layout_marginStart="4dp"
android:layout_gravity="center"
android:src="@drawable/ic_circle_green_8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/hasil_green_dot_img" />

<TextView
android:layout_marginStart="4dp"
android:id="@+id/text_hasil_gejala"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
tools:text="@tools:sample/lorem/random" />
</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<string name="hasil_gejala_dialami_text">Gejala yang dialami</string>
<string name="hasil_diagnosis_penyakit_text">Diagnosis penyakit</string>
<string name="hasil_solusi_text">Solusi</string>
<string name="hasil_diagnosis_text">Hasil Diagnosis</string>
<string name="hasil_green_dot_img">Gambar titik hijau pada item hasil</string>

<!-- nama penyakit -->
<array name="array_nama_penyakit">
Expand Down

0 comments on commit 6ff61c7

Please sign in to comment.