Giter Site home page Giter Site logo

Comments (8)

liangjingkanji avatar liangjingkanji commented on June 12, 2024

我即使仿造你代码也无法复现问题, 建议根据以下选项排查问题

  • 升级你的BRV版本至最新
  • 检查你PageRefreshLayout是否是rv的直接父容器
  • 请删除data.isEmpty判断, addData内部会自行判断

示例代码

binding.page.onRefresh {
    scope {
        val data = Get<List<UserModel>>("list") {
            param("page", index)
        }.await()
        addData(data) {
            index < 100 // 最多加载100个
        }
    }
}.showLoading()

from brv.

lexdev7 avatar lexdev7 commented on June 12, 2024

@liangjingkanji 感谢回复
我通过多次测试并复现了这个问题
BRV是最新的1.3.31,完整代码如下:

class MainFragment : Fragment() {

    lateinit var binding: FragmentMainBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        StateConfig.apply {
            emptyLayout = R.layout.layout_empty // 配置全局的空布局
            errorLayout = R.layout.layout_error // 配置全局的错误布局
            loadingLayout = R.layout.layout_loading // 配置全局的加载中布局
        }
        val view = layoutInflater.inflate(
            R.layout.fragment_main,
            container,
            false
        )
        binding = FragmentMainBinding.bind(
            view
        )
        return view
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.rv.setup {
            addType<String>(R.layout.item)
            onBind {

            }
        }
        binding.page.onRefresh {
            scope {
                addData(null) {
                    false
                }
            }
        }.showLoading()
    }
}

xml代码:

<?xml version="1.0" encoding="utf-8"?>
<com.drake.brv.PageRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/page"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</com.drake.brv.PageRefreshLayout>

from brv.

liangjingkanji avatar liangjingkanji commented on June 12, 2024

我再仔细查看

from brv.

liangjingkanji avatar liangjingkanji commented on June 12, 2024

还是没复现问题, 你fork本仓库直接在demo上复现然后通知我拉取你的仓库查看吧

from brv.

lexdev7 avatar lexdev7 commented on June 12, 2024

好的,感谢

from brv.

lexdev7 avatar lexdev7 commented on June 12, 2024

@liangjingkanji 问题已复现,请见 https://github.com/1115190769/BRV
需要向您说明的是:
1.使用的是viewBinding,非dataBinding
2.引入了Net联动

from brv.

liangjingkanji avatar liangjingkanji commented on June 12, 2024

好的, 我查看下

from brv.

liangjingkanji avatar liangjingkanji commented on June 12, 2024

你可以将布局文件xml使用layout包裹以解决此问题. 建议直接使用DataBinding取代ViewBinding

from brv.

Related Issues (20)

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.