Skip to content

Commit

Permalink
[ADD] #3 : Add askList Item at home view
Browse files Browse the repository at this point in the history
  • Loading branch information
Haeeul committed Jan 11, 2021
1 parent 2909c11 commit 82d0fba
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 147 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android {
}

dependencies {
def navigation_ktx_version = '2.2.2'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
Expand All @@ -50,4 +51,7 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// cardview
implementation "androidx.cardview:cardview:1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.teamhousing.housing.ui.home.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.teamhousing.housing.R
import com.teamhousing.housing.databinding.RvItemHomeAskListBinding
import com.teamhousing.housing.vo.HomeAskListData

class HomeAskListAdapter(private val context: Context) : RecyclerView.Adapter<HomeAskListViewHolder>() {
var data = mutableListOf<HomeAskListData>()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeAskListViewHolder {
val binding : RvItemHomeAskListBinding = DataBindingUtil.inflate(
LayoutInflater.from(parent.context),
R.layout.rv_item_home_ask_list,
parent,
false
)

return HomeAskListViewHolder(
binding
)
}

override fun onBindViewHolder(holder: HomeAskListViewHolder, position: Int) {
data[position].let{
holder.bind(it)
}
}

override fun getItemCount(): Int = data.size

}

class HomeAskListViewHolder(val binding:RvItemHomeAskListBinding) : RecyclerView.ViewHolder(binding.root){
fun bind(item : HomeAskListData){
binding.item = item
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/teamhousing/housing/util/BindingAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.teamhousing.housing.util


import android.widget.TextView
import androidx.databinding.BindingAdapter

object BindingAdapter {

@JvmStatic
@BindingAdapter("setProgress")
fun TextView.setProgress(progress: Int) {
text = when (progress) {
0 -> {
"확인 μ „"
}
1 -> {
"확인 쀑"
}
else -> {
"ν•΄κ²° μ™„λ£Œ"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.teamhousing.housing.vo

data class HomeAskListData (
val category : String,
val title : String,
val contents : String,
val progress : Int
)
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/border_black_fill_1000.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/primary_black"/>
<corners android:radius="1000dp"/>
</shape>
Loading

0 comments on commit 82d0fba

Please sign in to comment.