Git Product home page Git Product logo

Comments (10)

oubowu avatar oubowu commented on September 22, 2024

我去把它demo拿来试试

from pinnedsectionitemdecoration.

oubowu avatar oubowu commented on September 22, 2024

问题知道了,他实际设的是包装后的adapter,所以adapter instanceof PinnedHeaderNotifyer就是false
@Override public void setAdapter(Adapter adapter) { mWrapAdapter = new WrapAdapter(adapter); super.setAdapter(mWrapAdapter); adapter.registerAdapterDataObserver(mDataObserver); mDataObserver.onChanged(); }

from pinnedsectionitemdecoration.

gaoyl87 avatar gaoyl87 commented on September 22, 2024

好的 我再试试 谢谢

from pinnedsectionitemdecoration.

oubowu avatar oubowu commented on September 22, 2024

我改了代码,不报错了,结果还是兼容不了

from pinnedsectionitemdecoration.

gaoyl87 avatar gaoyl87 commented on September 22, 2024

嗯 我还是不用那个库了

from pinnedsectionitemdecoration.

oubowu avatar oubowu commented on September 22, 2024

新的版本去掉那个实现PinnedHeaderNotifyer接口了,该用构建的时候就传递头部对应的type,所以包装后的adapter也是可以用了,只是这个库的type会在你原adapter的基础下加个260多的值(我打印出来看到的),所以传值的时候原值+263即可实现粘性头部了 @13588823551

from pinnedsectionitemdecoration.

gaoyl87 avatar gaoyl87 commented on September 22, 2024

你好,新版本出现错误。
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.oushangfeng.pinnedsectionitemdecoration.entity.ClickBounds.getLeft()' on a null object reference
at com.oushangfeng.pinnedsectionitemdecoration.callback.OnItemTouchListener$GestureListener.onDown(OnItemTouchListener.java:130)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:559)
at com.oushangfeng.pinnedsectionitemdecoration.callback.OnItemTouchListener.onInterceptTouchEvent(OnItemTouchListener.java:84)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouchIntercept(RecyclerView.java:2394)
at android.support.v7.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:2440)

我是在你的demo上改的,StockActivity,我把
mHeaderItemDecoration = new PinnedHeaderItemDecoration.Builder(StockEntity.StockInfo.TYPE_HEADER)
.setDividerId(R.drawable.divider).enableDivider(true)
.setClickIds(R.id.iv_more,R.id.fl,R.id.checkbox).disableHeaderClick(true)
.setHeaderClickListener(clickAdapter).create();
这段代码改为
mHeaderItemDecoration = new PinnedHeaderItemDecoration.Builder(StockEntity.StockInfo.TYPE_HEADER)
.disableHeaderClick(true).create();
就会报错。
mBoundsArray这个对象是空的。
是不是HeaderItemDecoration必须绑定一个ClickAdapter?

from pinnedsectionitemdecoration.

oubowu avatar oubowu commented on September 22, 2024

我看看,待会给你答复 @13588823551

from pinnedsectionitemdecoration.

oubowu avatar oubowu commented on September 22, 2024

更新下即可,我的失误 @13588823551

from pinnedsectionitemdecoration.

gaoyl87 avatar gaoyl87 commented on September 22, 2024

刚才的问题解决了,你的demo可以跑通,但是我自己写的会报错...
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getLeft()' on a null object reference
at com.oushangfeng.pinnedsectionitemdecoration.PinnedHeaderItemDecoration.createPinnedHeader(PinnedHeaderItemDecoration.java:376)
at com.oushangfeng.pinnedsectionitemdecoration.PinnedHeaderItemDecoration.onDraw(PinnedHeaderItemDecoration.java:143)
at android.support.v7.widget.RecyclerView.onDraw(RecyclerView.java:3608)

这是我写的Decoration部分
OnHeaderClickAdapter clickAdapter = new OnHeaderClickAdapter() {

        @Override
        public void onHeaderClick(View view, int id, int position) {
            switch (id) {
                case R.id.item_tag:
                    ToastUtil.show(getActivity(), "click tag " + mAdapter.getData().get(position).getLabel());
                    break;
                case R.id.item_data:
                    ToastUtil.show(getActivity(), "click " + mAdapter.getData().get(position).getName());
                    break;
            }
        }

    };

    PinnedHeaderItemDecoration decoration = new PinnedHeaderItemDecoration.Builder(ItemEntity.TYPE_HEADER)
            .setClickIds(R.id.item_tag, R.id.item_data).setHeaderClickListener(clickAdapter).create();
    mRecyclerView.addItemDecoration(decoration);

mAdapter = new MyAdapter(null);
mRecyclerView.setAdapter(mAdapter);

adapter是异步加载数据的。

from pinnedsectionitemdecoration.

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.