-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e2899c
commit 66a441c
Showing
6 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/example/publictoilet/SearchResultAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.example.publictoilet | ||
|
||
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 org.w3c.dom.Text | ||
|
||
class SearchResultAdapter(val mContext: Context, val searchResultList : MutableList<Toilet>) : RecyclerView.Adapter<SearchResultAdapter.CustomViewHolder>() { | ||
|
||
class CustomViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){ | ||
private val toiletName = itemView.findViewById<TextView>(R.id.toilet_name) | ||
private val distance = itemView.findViewById<TextView>(R.id.distance) | ||
|
||
fun bind(toilet : Toilet, position: Int){ | ||
toiletName.text = toilet.toiletName | ||
distance.text = toilet.distance.toString() | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.search_result_item, parent, false) | ||
return CustomViewHolder(view).apply{ | ||
itemView.setOnClickListener { | ||
val curPos = adapterPosition | ||
val toilet = searchResultList[curPos] | ||
// 누르면 화면 전환 | ||
val intent = Intent(mContext, ToiletInfoActivity::class.java) | ||
intent.putExtra("toiletName", toilet.toiletName) | ||
intent.putExtra("score_avg", toilet.score_avg) | ||
intent.putExtra("tel", toilet.tel) | ||
intent.putExtra("openTime", toilet.openTime) | ||
intent.putExtra("mw", toilet.mw) | ||
intent.putExtra("m1", toilet.m1) | ||
intent.putExtra("m2", toilet.m2) | ||
intent.putExtra("m3", toilet.m3) | ||
intent.putExtra("m4", toilet.m4) | ||
intent.putExtra("m5", toilet.m5) | ||
intent.putExtra("m6", toilet.m6) | ||
intent.putExtra("w1", toilet.w1) | ||
intent.putExtra("w2", toilet.w2) | ||
intent.putExtra("w3", toilet.w3) | ||
|
||
mContext.startActivity(intent) | ||
} | ||
} | ||
} | ||
|
||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { | ||
val toilet = searchResultList[position] | ||
holder.apply { | ||
bind(toilet, position) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return searchResultList.size | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.publictoilet | ||
|
||
data class Toilet ( | ||
val toiletName : String, | ||
val tel : String, | ||
val openTime : String, | ||
val mw : Boolean, | ||
val m1 : String, | ||
val m2 : String, | ||
val m3 : String, | ||
val m4 : String, | ||
val m5 : String, | ||
val m6 : String, | ||
val w1 : String, | ||
val w2 : String, | ||
val w3 : String, | ||
val distance : String, | ||
val score_avg : String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:background="@drawable/review_item_background" | ||
android:layout_width="match_parent" | ||
android:layout_height="60dp"> | ||
|
||
<TextView | ||
android:id="@+id/toilet_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="20dp" | ||
android:textColor="@color/black" | ||
android:textSize="18sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="솔샘 화장실" /> | ||
|
||
<TextView | ||
android:id="@+id/distance" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textColor="@color/black" | ||
android:textSize="18sp" | ||
android:layout_marginEnd="20dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="300m" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |