LiveAdapter icon indicating copy to clipboard operation
LiveAdapter copied to clipboard

Can we use it without databinding ?

Open ahmadmssm opened this issue 4 years ago • 4 comments

ahmadmssm avatar Jan 30 '21 10:01 ahmadmssm

@ahmadmssm I will try to add it in the next version and release it soon.

RaviKoradiya avatar Feb 01 '21 07:02 RaviKoradiya

Thanks, I will wait for this feature.

ahmadmssm avatar Feb 01 '21 07:02 ahmadmssm

@ahmadmssm try version 1.3.4-alpha for implementation without data-binding.

    val dummyList = listOf<Any>(1, "Test Item 2", 4.5, 7, 5.8, "Dummy Item 3")

    LiveAdapter(dummyList)
            .map<Int>(R.layout.item_rv) {
                onBind {
                    it.binding.getViewById<TextView>(R.id.text_item_label)?.text = "Int Item ${it.binding.data}"
                }
            }
            .map<Double>(R.layout.item_rv) {
                onBind {
                    it.binding.getViewById<TextView>(R.id.text_item_label)?.text = "Float Item ${it.binding.data}"
                }
            }
            .map<String>(R.layout.item_rv) {
                onBind {
                    it.binding.getViewById<TextView>(R.id.text_item_label)?.text = it.binding.data
                }
            }
            .into(findViewById(R.id.rv_dummy))

If you are using kotlin, Don't forget to add apply plugin: 'kotlin-kapt' at the top section and kapt 'com.android.databinding:compiler:GRADLE_PLUGIN_VERSION' in dependencies block of the module's build.gradle file.

RaviKoradiya avatar Feb 03 '21 06:02 RaviKoradiya

@ahmadmssm let me know if you face any issues with it. I will move this version to stable and close this issue after a week from now.

RaviKoradiya avatar Feb 03 '21 06:02 RaviKoradiya