신기성

favor func done

...@@ -3,6 +3,7 @@ package com.example.vip ...@@ -3,6 +3,7 @@ package com.example.vip
3 import android.content.Context 3 import android.content.Context
4 import android.content.Intent 4 import android.content.Intent
5 import android.content.SharedPreferences 5 import android.content.SharedPreferences
6 +import android.util.Log
6 import android.view.LayoutInflater 7 import android.view.LayoutInflater
7 import android.view.View 8 import android.view.View
8 import android.view.ViewGroup 9 import android.view.ViewGroup
...@@ -39,9 +40,6 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -39,9 +40,6 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
39 val prof: SharedPreferences = view.context.getSharedPreferences("profdata", Context.MODE_PRIVATE) 40 val prof: SharedPreferences = view.context.getSharedPreferences("profdata", Context.MODE_PRIVATE)
40 val editor: SharedPreferences.Editor=prof.edit() 41 val editor: SharedPreferences.Editor=prof.edit()
41 42
42 - var tempstring=prof.getString("favorstringlist","")
43 - var sepstr=tempstring!!.split("@")
44 - var sepstrset=sepstr.toMutableSet()
45 43
46 fun bind(item: PolicyItem) { 44 fun bind(item: PolicyItem) {
47 view.policyImage.setImageDrawable(item.policyItemImage) 45 view.policyImage.setImageDrawable(item.policyItemImage)
...@@ -52,11 +50,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -52,11 +50,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
52 view.policyFavor.text=item.policyItemFavor 50 view.policyFavor.text=item.policyItemFavor
53 51
54 52
55 - if(item.policyItemTitle in sepstrset){ 53 + if(item.policyItemTitle in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){
56 view.policyFavor.isChecked=true 54 view.policyFavor.isChecked=true
57 - } 55 + }else{
58 - else{ 56 + view.policyFavor.isChecked=false
59 -
60 } 57 }
61 view.setOnClickListener{ 58 view.setOnClickListener{
62 59
...@@ -68,6 +65,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -68,6 +65,10 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
68 } 65 }
69 66
70 view.policyFavor.setOnClickListener { 67 view.policyFavor.setOnClickListener {
68 + var tempstring=prof.getString("favorstringlist","")
69 + var sepstr=tempstring!!.split("@")
70 + var sepstrset=sepstr.toMutableSet()
71 +
71 if (view.policyFavor.isChecked) { 72 if (view.policyFavor.isChecked) {
72 tempstring = tempstring + view.policyTitle.text.toString() + "@" 73 tempstring = tempstring + view.policyTitle.text.toString() + "@"
73 editor.putString("favorstringlist", tempstring) 74 editor.putString("favorstringlist", tempstring)
...@@ -77,6 +78,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -77,6 +78,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
77 "찜목록 추가 완료! : " + view.policyTitle.text.toString(), 78 "찜목록 추가 완료! : " + view.policyTitle.text.toString(),
78 Toast.LENGTH_SHORT 79 Toast.LENGTH_SHORT
79 ).show() 80 ).show()
81 + Log.d("asdf1",prof.getString("favorstringlist","none"))
80 } else { 82 } else {
81 sepstrset.remove(view.policyTitle.text.toString()) 83 sepstrset.remove(view.policyTitle.text.toString())
82 editor.putString("favorstringlist", sepstrset.joinToString("@")) 84 editor.putString("favorstringlist", sepstrset.joinToString("@"))
...@@ -86,6 +88,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -86,6 +88,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
86 "찜목록 제거 완료! : " + view.policyTitle.text.toString(), 88 "찜목록 제거 완료! : " + view.policyTitle.text.toString(),
87 Toast.LENGTH_SHORT 89 Toast.LENGTH_SHORT
88 ).show() 90 ).show()
91 + Log.d("asdf2",prof.getString("favorstringlist","none"))
89 } 92 }
90 } 93 }
91 } 94 }
......