GithubHelp home page GithubHelp logo

wustor / gangedrecyclerview Goto Github PK

View Code? Open in Web Editor NEW
654.0 6.0 134.0 6.83 MB

Recyclerview实现双列表联动,列表悬停

Home Page: https://juejin.cn/post/6844903508882391047

Java 95.41% Kotlin 4.59%

gangedrecyclerview's Issues

小bug

点击左侧栏目,然后滑动右侧,发现只有滑动两个栏目左侧才会跳转,eg:点击保健品,滑动右侧,左侧只会跳转西药或者消毒品,不会跳转普通食品或医疗器械。

有快速引用的方法吗

代码封装的太好了不会在fragment中使用,可能是context传递的一些问题。那些类是必要的,为什么会用到fragment。好像是因为getAssetsData没有获取到数据,String assetsData = getAssetsData("sort.json")这个数据是怎么得到的。找到了,要在assets中放入模拟数据,谢谢大神,代码很好用。

你好

当右边的数据很多的时候,点击左边的菜单栏会有卡顿,有时超过了三秒才滑动到相应的位置,这个可以优化下么?
还有如果右边的数据展示改成一行只显示一个数据的时候,往上滑动的时候,当滑到这个列表倒数第二个的时候,头部的标题栏就被顶上去了,然后又回来的?直到这个分类滑完后标题栏才消失的,、。
麻烦解答下,谢谢

大佬 我又来提bug了

谢谢大佬对每个意见都回复
那个 我又发现一个bug,比如左侧我选了1 ,然后滑动至1不可见,滑动右边的会崩

发现一个小bug

楼主在吗,demo中发现一个小bug 点击选中左侧的某一项,然后缓慢滑动右侧的列表,当右侧列表滑动到下一项时,左侧的下一项并不会被选中,继续滑动到下一项,左侧选中状态才恢复正常。

有时候出现报空的情况

if (isTranslate) {
canvas.restore();
}
Log.d("tag--->", tag + "VS" + currentTag);
if (!TextUtils.equals(tag, currentTag)) {
currentTag = tag;
Integer integer = Integer.valueOf(tag);
mCheckListener.check(integer, false);
}

最下面一行 有时候出现报空的情况,这个我也无法复现,不知道什么时候会报,有时候是界面被覆盖时候太久时间时候出现的,

给你一个新思路

    private class SurplusListener extends RecyclerView.OnScrollListener {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            mSurplusHeight = mSurplusLayout.getHeight();
        }


        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            /**
             * 这块主要是比对当前的可见的第一个元素  之后的元素是否和其是同一组,如果不是
             * 即下一部分必为Title,所以即执行粘性头操作.
             */
            //TODO 这一块 实现的方式感觉还是太Low
            int pos = mLayoutManager.findFirstVisibleItemPosition();
            int spanSize = mLayoutManager.getSpanSizeLookup().getSpanSize(pos);
            //spanSize == 1代表的是当前Item只占1个格子,而每行有三个格子
            if (spanSize == 1) {
                String tag = contents.get(mCurrentPosition).getTag();
                String tag1 = contents.get(mCurrentPosition + 1).getTag();
                String tag2 = contents.get(mCurrentPosition + 2).getTag();
                String tag3 = contents.get(mCurrentPosition + 3).getTag();
                Log.d("比较值", "tag :  " + tag + "----tag1 : " + tag1 + "----tag2 : " + tag2 + "----tag3 : " + tag3);
                //因为1行有3个元素,这时候需要考虑不同的情况,然后确定位置.
                if (!TextUtils.equals(tag, tag1)) {
                    changeHeader(mCurrentPosition + 1);
                } else if (!TextUtils.equals(tag, tag2)) {
                    changeHeader(mCurrentPosition + 2);
                } else if (!TextUtils.equals(tag, tag3)) {
                    changeHeader(mCurrentPosition + 3);
                }
            }
            if (mCurrentPosition != mLayoutManager.findFirstVisibleItemPosition()) {
                mCurrentPosition = mLayoutManager.findFirstVisibleItemPosition();
                mSurplusLayout.setY(0);
                //更新假头的显示内容
                int tag = Integer.parseInt(contents.get(mCurrentPosition).getTag());
                updateSuspensionBar(tag);
            }
        }

        /**
         * 改变粘性头,使其滑动
         * 实现粘性头的核心
         */
        private void changeHeader(int position) {
            View view = mLayoutManager.findViewByPosition(position);
            if (view != null) {
                if (view.getTop() <= mSurplusHeight) {
                    mSurplusLayout.setY(-(mSurplusHeight - view.getTop()));
                } else {
                    mSurplusLayout.setY(0);
                }
            }
        }
    }

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.