신기성

favor func done

......@@ -3,6 +3,7 @@ package com.example.vip
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -39,9 +40,6 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
val prof: SharedPreferences = view.context.getSharedPreferences("profdata", Context.MODE_PRIVATE)
val editor: SharedPreferences.Editor=prof.edit()
var tempstring=prof.getString("favorstringlist","")
var sepstr=tempstring!!.split("@")
var sepstrset=sepstr.toMutableSet()
fun bind(item: PolicyItem) {
view.policyImage.setImageDrawable(item.policyItemImage)
......@@ -52,11 +50,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
view.policyFavor.text=item.policyItemFavor
if(item.policyItemTitle in sepstrset){
if(item.policyItemTitle in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){
view.policyFavor.isChecked=true
}
else{
}else{
view.policyFavor.isChecked=false
}
view.setOnClickListener{
......@@ -68,6 +65,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
}
view.policyFavor.setOnClickListener {
var tempstring=prof.getString("favorstringlist","")
var sepstr=tempstring!!.split("@")
var sepstrset=sepstr.toMutableSet()
if (view.policyFavor.isChecked) {
tempstring = tempstring + view.policyTitle.text.toString() + "@"
editor.putString("favorstringlist", tempstring)
......@@ -77,6 +78,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
"찜목록 추가 완료! : " + view.policyTitle.text.toString(),
Toast.LENGTH_SHORT
).show()
Log.d("asdf1",prof.getString("favorstringlist","none"))
} else {
sepstrset.remove(view.policyTitle.text.toString())
editor.putString("favorstringlist", sepstrset.joinToString("@"))
......@@ -86,6 +88,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
"찜목록 제거 완료! : " + view.policyTitle.text.toString(),
Toast.LENGTH_SHORT
).show()
Log.d("asdf2",prof.getString("favorstringlist","none"))
}
}
}
......