File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
app/src/main/java/devmike/jade/com/jadesharedpreference
binder/src/main/java/devmike/jade/com/binder Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ class MainActivity @SharedPref("key") constructor(): AppCompatActivity() {
3939 public fun btnTestOne (v : View ){
4040 val ed: String = ed_1.text.toString()
4141 when (v) {
42- save_btn1 -> jsp.insert(" string" , ed)git
42+ save_btn1 -> jsp.insert(" string" , ed)
4343 save_btn2 -> jsp.insert(" integer_anything" , ed_2.text.toString().toInt())
4444 save_btn3 -> jsp.insert(" float_key" , ed_3.text.toString().toFloat())
45- save_btn5 -> jsp.insert(" stringset__" , mutableSetOf (ed_5.text.toString().split( " , " )))
45+ save_btn5 -> jsp.insert(" stringset__" , setOf (ed_5.text.toString()))
4646 save_btn4 -> jsp.insert(" long_" , ed_4.text.toString().toLong())
4747 }
4848 }
Original file line number Diff line number Diff line change @@ -30,19 +30,20 @@ public object JadeSharedPreference {
3030 return this
3131 }
3232
33- fun insert (key : String , value : Any ){
33+ fun <T : Any > insert (key : String , value : T ){
34+ Log .d(" TAGGGG" , value::class .simpleName)
3435 if (value is String ) {
3536 val insertStringFunc = bindingClass?.getMethod(" insertValue" , String ::class .java,
3637 String ::class .java)
3738 insertStringFunc?.invoke(this .bindingClassNewInstance, value, key)
3839 }else if (value is Int ) {
3940 val insertIntFunc = bindingClass?.getMethod(" insertValue" , Int ::class .java, String ::class .java)
4041 insertIntFunc?.invoke(this .bindingClassNewInstance, value, key)
41- }else if (value is MutableSet <* >) {
42+ }else if (value is LinkedHashSet <* >) {
4243 if (! value.isEmpty()){
4344 if (value.elementAt(0 ) is String ){
4445 val insertStringSetFunc = bindingClass?.getMethod(" insertValue" , Set ::class .java, String ::class .java)
45- insertStringSetFunc?.invoke(this .bindingClassNewInstance)
46+ insertStringSetFunc?.invoke(this .bindingClassNewInstance, value, key )
4647 return
4748 }
4849
You can’t perform that action at this time.
0 commit comments