GithubHelp home page GithubHelp logo

ve3344 / bindingadapter Goto Github PK

View Code? Open in Web Editor NEW
43.0 43.0 2.0 12.95 MB

❤ 一个使用ViewBinding 直接生成RecyclerView Adapter的库。

License: Other

Kotlin 100.00%
android databinding recyclerview recyclerview-adapter viewbinding

bindingadapter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

motouren

bindingadapter's Issues

多选这个功能,文档和代码有出入

image

看了代码,setupMultiSelectModuleByKey方法是MultiTypeBindingAdapter类的扩展方法,而不是示例里的那样写法...

fun <I : Any> MultiTypeBindingAdapter<I, *>.setupMultiSelectModuleByKey(identifier: (I) -> Any = { it }): MultiSelectModuleByKey<I> {
    return MultiSelectModuleByKey(adapter = this, selector = identifier)
}

能够单独使用空布局?

看了文档上使用空布局得结合分页模块才能使用空布局,且设置数据源的方法需要传入协程上下文或viewmodel

但app里目前没有用到这两个东西,能否提供一个就是单一的List对象作为数据源?

或者是能够将空布局单独出来使用(不结合分页模块) 提供一个新的(setupLoadMoreModule)类似的方法?

滚轮选择器如果动态设置字体大小会导致recyclerview直接显示全部选项(似乎是高度计算不正确)

如下图所示,当itemView设置了padding或marg,或者是修改了文字大小,会导致recyclerview显示的高度出现错误,直接显示出所有的item项了

主要是想实现选中的item的文字大小和未选中的item文字大小是不一样的效果

2023-08-21-15-10-25

itemView布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="#252935"
    android:layout_width="match_parent"
    android:gravity="center_horizontal"
    android:layout_height="wrap_content"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/tvItem"
        android:textColor="#50535E"
        android:textSize="22sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:text="Android"/>

</LinearLayout>

recyclerview的高度设置为wrap_content

Activity中的代码:

val list = (30..100).map { it.toString() }
        val adapter =
            BindingAdapter<String, RvItemPickerBinding>(RvItemPickerBinding::inflate) { position, item ->
                itemBinding.tvItem.text = item
                if (isWheelItemSelected) {
                    itemBinding.tvItem.setTextColor(Color.WHITE)
                    //修改字体大小也会出现计算高度错误
                    //itemBinding.tvItem.textSize = SizeUtils.sp2px(22f).toFloat()
                } else {
                    itemBinding.tvItem.setTextColor("#50535E".toColorInt())
                    //itemBinding.tvItem.textSize = SizeUtils.sp2px(14f).toFloat()
                }
            }

        binding.apply {
            rvPicker.adapter = adapter
            adapter.data.addAll(list)
            adapter.notifyDataSetChanged()

            val module = rvPicker.setupWheelModule()
            module.apply {
                offset = 1 //上下偏移多少
                orientation = RecyclerWheelViewModule.VERTICAL//方向
            }
            module.selectedPosition = list.indexOf("70")
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.