Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0.0-b6] Crash ClassCastException on addItem (with sticky headers) #79

Closed
francescopedronomnys opened this issue May 9, 2016 · 25 comments

Comments

@francescopedronomnys
Copy link

Hi,
thanks in advance for the library.

I'm using v 5.0.0-b6 to implement a list with multiple sections (different AbstractFlexibleItem classes for each section) and sticky headers.
At first I initialize the list with data from the DB (done using addItem() on the FlexibleAdapter).
Then as soon as updated data come from my network layer I proceed doing removeItemsOfType() and addItem() again.

I often get this exception that do not happen if I disable the network layer and so no further removeItemsOfType() and addItem() is performed before the first one.

This is the method I call when data is available:

public void setOtherArticles(List<Article> otherArticles) {
        removeItemsOfType(Constants.MainContent.ViewType.BOTTOM_PADDING);
        removeItemsOfType(Constants.MainContent.ViewType.OTHER_ARTICLES_ITEM);

        if (otherArticles.size() > 0) {
            List<AbstractFlexibleItem> items = new ArrayList<>();
            for (Article article : otherArticles) {
                items.add(new OtherArticleItem(mOtherArticlesHeader, article));
            }

            int adapterPos = getItemCountOfTypes(
                    Constants.MainContent.ViewType.CAT_HEADER, Constants.MainContent.ViewType.CAT_ARTICLE, Constants.MainContent.ViewType.CAT_NO_ARTICLES,
                    Constants.MainContent.ViewType.VIDEO_ARTICLE, Constants.MainContent.ViewType.VIDEO_HEADER,
                    Constants.MainContent.ViewType.BLOG_ARTICLE, Constants.MainContent.ViewType.BLOG_HEADER,
                    Constants.MainContent.ViewType.OTHER_ARTICLES_HEADER);
            addItems(adapterPos, items);
        }

        addItem(getItemCount(), new BottomPaddingItem(mOtherArticlesHeader));
    }

Sometimes (rarely) I've seen the same exception as reported by tprochazka on issue #78, I don't know if they're related.

I don't know if I'm doing something wrong or it is a library issue.
Let me know if I can provide further info.

Here's the exception stacktrace:

java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v7.widget.RecyclerView$LayoutParams
at android.support.v7.widget.RecyclerView.getChildViewHolderInt(RecyclerView.java:3661)
at android.support.v7.widget.RecyclerView$5.getChildViewHolder(RecyclerView.java:645)
at android.support.v7.widget.ChildHelper.findHiddenNonRemovedView(ChildHelper.java:210)
at android.support.v7.widget.RecyclerView$Recycler.getScrapViewForPosition(RecyclerView.java:5075)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4634)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:528)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:122)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1170)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:814)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)

Thanks,
Francesco

@francescopedronomnys francescopedronomnys changed the title [5.0.0-b6] Crash [5.0.0-b6] Crash ClassCastException on addItem May 9, 2016
@tprochazka
Copy link

Yes. It looks like related to my problem.
For me it also happen during I'm trying to refresh old data with new one.

I'm using this code

setPermanentDelete(true);
removeRange(0, getItemCount());
setPermanentDelete(false);
addItems(Integer.MAX_VALUE, ...);

It doesn't happen every time but very very often.

@tprochazka
Copy link

But it works OK when I turn off sticky headers support.
It looks that problem is caused when header is inserted to headers holder, it change the LayoutParams defined by RecyclerView LayoutManager to FrameLayout.LayoutParams

@LuckHard
Copy link

I have the same problem,but not every time.
Hope to have a way to solve this problem……
Thanks.

@EpariNigam
Copy link

EpariNigam commented May 12, 2016

I also, faced the problem , but not every time.
Sometimes, when scrolling this issue arises.
I hope it will be solved.
I am just testing the sample given by you peoples.

@davideas davideas added the bug label May 13, 2016
@davideas davideas changed the title [5.0.0-b6] Crash ClassCastException on addItem [5.0.0-b6] Crash ClassCastException on addItem (with sticky headers) May 13, 2016
davideas added a commit that referenced this issue May 13, 2016
@davideas
Copy link
Owner

Hello, I confirm that this bug exists, the technique used is to have a FrameLayout on the top of the RV and so the itemView is moved from RV.ViewHolder to the FrameLayout.
Also when the

I got this exception in my tests, but only with expandables sections with sticky headers enabled.
The problem is that the LayoutManager is responsible to display the modifications from the Adapter notifications and when it comes to display the item, that is the same currently displayed in the FrameLayout, it complains that the LayoutParams are different.

Maybe I've found a solution, swapping the header in post so that LayoutManager can finish its elaboration. I'm having some improvements using the next 2 fixes:

private void swapHeader(final RecyclerView.ViewHolder newHeader) {
    mRecyclerView.post(new Runnable() {
        @Override
        public void run() {
            if (mStickyHeaderViewHolder != null) {
                resetHeader(mStickyHeaderViewHolder);
            }
            mStickyHeaderViewHolder = newHeader;
            if (mStickyHeaderViewHolder != null) {
                mStickyHeaderViewHolder.setIsRecyclable(false);
                ensureHeaderParent();
            }
            onStickyHeaderChange(mHeaderPosition);
        }
    });
}
private static void resetHeader(RecyclerView.ViewHolder header) {
    final View view = header.itemView;
    removeViewFromParent(view);
    //Reset transformation on removed header
    view.setTranslationX(0);
    view.setTranslationY(0);
    //Restore LayoutParams
    view.setLayoutParams(new RecyclerView.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    header.setIsRecyclable(true);
}

I commit these changes in dev branch and creating a new SNAPSHOT, if somebody want test it...
Thanks!

@davideas
Copy link
Owner

I'm now observing that, using this fix, a little glitch is unfortunately visible onSwap header item.

@EpariNigam
Copy link

EpariNigam commented May 14, 2016

@davideas
As you said, to change the methods. I changed the methods and tested, still the same error coming. It's coming in normal sticky header, with out expandable sticky. And also I faced a new issue,

E/AndroidRuntime: FATAL EXCEPTION: main Process: eu.davidea.examples.flexibleadapter, PID: 19214 java.lang.NullPointerException: Attempt to read from field 'boolean android.support.v7.widget.RecyclerView$ViewHolder.mInChangeScrap' on a null object reference at android.support.v7.widget.RecyclerView$ViewHolder.access$5100(RecyclerView.java:8829) at android.support.v7.widget.RecyclerView$Recycler.unscrapView(RecyclerView.java:4990) at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1126) at android.support.v7.widget.RecyclerView.access$6400(RecyclerView.java:147) at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:10294) at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:10794) at android.support.v7.widget.SimpleItemAnimator.dispatchMoveFinished(SimpleItemAnimator.java:279) at android.support.v7.widget.DefaultItemAnimator$6.onAnimationEnd(DefaultItemAnimator.java:303) at android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd(ViewPropertyAnimatorCompatJB.java:47) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:549) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

This error is not there previously.

@davideas
Copy link
Owner

davideas commented May 14, 2016

So the fix is not ok.
Can you tell me what are the steps when you add/remove items? and the positions of the those items, it's before the sticky header or after?

@EpariNigam
Copy link

EpariNigam commented May 14, 2016

Yes, this fix is not ok. I didn't changed anything in the sample you provided. At the time of scrolling it's crashing sometimes. I am not sure, when its crashing.

@davideas
Copy link
Owner

davideas commented May 14, 2016

@francescopedronomnys, to initialize the list not empty, you should use the constructor not addItems(). at the moment new items arrive you then add new items.
For bottom padding you can use the library decorator that adds padding between sections.

The new items seem to be added at the end, if so, how is possible you get exception on the sticky header?
And when you get exception, it's when you remove items or add items or when you scroll?

@tprochazka, Also when refreshing the full list, the method updateDataSet(new items) should be called, in order to animate correctly all items.

I'm now facing the issue of the class cast exception, but it's quite difficult to resolve.

@davideas
Copy link
Owner

As workaround, please disable sticky header before any deletion that has an impact of changing the current sticky header, meaning, any deletion that also implies an automatic swap header due to the layout change.
Simply scrolling in read only mode should be fine. Also adding items before or after the header sticky should be fine as my demo is doing.

@francescopedronomnys
Copy link
Author

@davideas I'm overriding FlexibleAdapter and providing to super() a new empty ArrayList in my constructor. Is it correct?

Here's the full adapter code, probably I'm doing something wrong: https://gist.github.com/francescopedronomnys/4ebea6da6e7b1070de21a0ada7b3fd83

I'm using addItems() because I have multiple callback from my db/network layer, each one for each section (a section is composed of one AbstractHeaderItem and many AbstractSectionableItem), so I do not have a single point when I can create my adapter with a list of items.

Actually I'm not adding items always at the end, I've multiple sections with different items (actually different header and item classes) that I should keep in a specific order, and so I'm using this code to get the correct insertion position:

int adapterPos = getItemCountOfTypes(
                    Constants.MainContent.ViewType.CAT_HEADER, Constants.MainContent.ViewType.CAT_ARTICLE, Constants.MainContent.ViewType.CAT_NO_ARTICLES,
                    Constants.MainContent.ViewType.VIDEO_ARTICLE, Constants.MainContent.ViewType.VIDEO_HEADER,
                    Constants.MainContent.ViewType.BLOG_ARTICLE, Constants.MainContent.ViewType.BLOG_HEADER,
                    Constants.MainContent.ViewType.OTHER_ARTICLES_HEADER);

I get the ClassCastException removing/adding items, but only when I do a second insert/remove iteration; this is because I get data from local DB on the first iteration and than from network on the second one.

Using the current dev SNAPSHOT I'm now getting this exception:

java.lang.ClassCastException: it.redacted.android.activities.main.adapter.items.CategoriesHeader$ViewHolder cannot be cast to it.redacted.android.activities.main.adapter.items.OtherArticlesHeader$ViewHolder
at it.redacted.android.activities.main.adapter.items.OtherArticlesHeader.bindViewHolder(OtherArticlesHeader.java:17)
at eu.davidea.flexibleadapter.FlexibleAdapter.onBindViewHolder(FlexibleAdapter.java:1054)
at eu.davidea.flexibleadapter.FlexibleAdapter.onBindViewHolder(FlexibleAdapter.java:1021)
at eu.davidea.flexibleadapter.helpers.StickyHeaderHelper.updateHeader(StickyHeaderHelper.java:151)
at eu.davidea.flexibleadapter.helpers.StickyHeaderHelper.updateOrClearHeader(StickyHeaderHelper.java:126)
at eu.davidea.flexibleadapter.FlexibleAdapter$AdapterDataObserver.updateOrClearHeader(FlexibleAdapter.java:3184)
at eu.davidea.flexibleadapter.FlexibleAdapter$AdapterDataObserver.onItemRangeChanged(FlexibleAdapter.java:3209)
at android.support.v7.widget.RecyclerView$AdapterDataObserver.onItemRangeChanged(RecyclerView.java:9504)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView.java:9959)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemChanged(RecyclerView.java:5791)
at eu.davidea.flexibleadapter.FlexibleAdapter.updateItem(FlexibleAdapter.java:1545)
at eu.davidea.flexibleadapter.FlexibleAdapter.updateItem(FlexibleAdapter.java:1523)
at it.redacted.android.activities.main.adapter.MainContentAdapter.updateCategoryArticles(MainContentAdapter.java:110)
[...]

Adding disableStickyHeaders() and enableStickyHeaders() I'm getting this exception:
http://pastebin.com/bxtMFJuS
I've added disable at the beginning of each method that removes/adds items and the enable at the end.

Thanks for the padding thing, I'll look into it.

Let me know if I can provide you more information, I understand that my usecase is not standard.

@davideas
Copy link
Owner

@francescopedronomnys, adding empty list at the start should be ok.

At first glance, the class cast on same ViewHolder it's because both holders use the same layout res id, which is used as key to return the item type mapped.

Try to use disable->remove->add->enable with beta6, if it is not enough add a delay of few milliseconds from the removal OR use the post to queue the operations (mRecyclerView is already available in the Adapter).
Maybe it's not nice to see from user perspective, but at the moment this is the best I can suggest.

Until I don't find a new technique, the current solution is that the itemView is moved from RV into a FrameLayout that simulate the sticky effect, unfortunately the deletion cause some unexpected issues to the LayoutManager of the RV not under our control... Instead, it works very well in read only mode.
This technique is the only that continues to receive click events on headers when sticky, because it is a real view not something drawn as with ItemDecorators.
A custom LayoutManager implementation should be the final solution, but it is very difficult also in terms of time.

PS. It might be easier to handle sections with expandables (with expansion disabled) and subItems.

@mdtuyen
Copy link

mdtuyen commented May 30, 2016

I think this is urgen issue, did you have solution or a
temporary solution for it ?

@davideas
Copy link
Owner

@mdtuyen, few days ago I found a new and good LayoutManager with sticky headers functionality, I will try to import and adapt based on my implementation. Unfortunately, it requires lot of time, and in this period it's really impossible for me to continue heavy development on this library.

The library I found is: StickyHeaders.
Already contacted for a possible collaboration.

@mdtuyen
Copy link

mdtuyen commented May 30, 2016

Thanks for your good news and your useful library. It is difficult to make a recycler with many feature as you see. I spend a lot of time to found a library combine many feature for recyclerview, there is some library but them have many and many bug. Your library is very best and easy to custom it. I'm making a fragment contain a recyclerview use your library to use it for many my projects.

Thanks for good lib again.

@mdtuyen
Copy link

mdtuyen commented Jun 1, 2016

I fixed this issue by change method animateTo in FlexibleAdapter to:

    public List<T> animateTo(List<T> models) {
        mItems.clear();
        mItems.addAll(models);
        notifyDataSetChanged();
        //applyAndAnimateRemovals(mItems, models);
        //applyAndAnimateAdditions(mItems, models);
        return mItems;
    }

@davideas
Copy link
Owner

davideas commented Jun 2, 2016

@mdtuyen, well, then animateTo() doesn't animate anymore :-)
animateTo() is called only in updateDataSet() and filterItems() so it doesn't resolve the scrolling issue with sticky headers. animateTo() is also public, so you can override it instead of rebuild the library only for that ;-)

However, I got an illumination now, I could create a sub-layout in the itemView at the moment of the creation and change the parent of this layout not the entire itemView, in this way the main view is unaltered and RV should not complain anymore with its internal processing.
As workaround, I hope it works, I will try to do it today (I have some free time)... otherwise the solution to create a new custom LayoutManager remains valid, but it is long to make it.

@davideas
Copy link
Owner

davideas commented Jun 2, 2016

So I think now I have resolved all these bugs by changing the constructor as following. But this is a temporary code and it should be adapted, because it must not interfere if one doesn't want sticky headers and it must easy to extend if one wants it instead.

Instead of using directly itemView I created stickyView. This view is then changing parent in the StickyHeaderHelper class that I have already adapted for this temporary code.

public View stickyView;

/**
 * Default constructor.
 *
 * @param view    The {@link View} being hosted in this ViewHolder
 * @param adapter Adapter instance of type {@link FlexibleAdapter}
 */
public FlexibleViewHolder(View view, FlexibleAdapter adapter) {
    super(new FrameLayout(view.getContext()));
    itemView.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            view.getLayoutParams().height));
    stickyView = view;
    ((ViewGroup) itemView).addView(stickyView);

    this.mAdapter = adapter;
    this.stickyView.setOnClickListener(this);
    this.stickyView.setOnLongClickListener(this);
}

Any suggestion to how extend/implement a new method/class considering the ExpandableViewHolder extends FlexibleViewHolder that extends RecyclerView.ViewHolder?
Pay attention:

  • itemView is declared final and so, once initialized cannot be modified.
  • super() must be called as first statement, etc...
  • the click listener have to be on the stickyView.
  • the height is necessary as I experimented that otherwise when scrolling up the parent view is compressed to 0 height (the child view is swapping parent) and the following items are also moved up, not nice.

@davideas
Copy link
Owner

davideas commented Jun 2, 2016

I've committed the changes in dev branch, please make some experiments for the definitive fix, I wait some suggestions :-)

@bornest
Copy link

bornest commented Jun 2, 2016

Alright, I've checked the example app - issue #92 is fixed.

It would be hard to test it in my app though,
can you please make a new snapshot, so we can import the fixed version with gradle?

@mdtuyen mdtuyen mentioned this issue Jun 3, 2016
@davideas
Copy link
Owner

davideas commented Jun 5, 2016

I tried some final solutions:

1 - Keep the above solution as final, means that, ALL ViewHolders have this extra layout created most of the time when not necessary. I can probably check adapter.areHeadersSticky() to reduce the impact, but still, it is not precise!
To resolve the issue, user has to do nothing.

public FlexibleViewHolder(View view, FlexibleAdapter adapter) {
    super(adapter.areHeadersSticky() ? new FrameLayout(view.getContext()) : view);
    this.mAdapter = adapter;
    if (adapter.areHeadersSticky()) {
        itemView.setLayoutParams(new FrameLayout.LayoutParams(
                view.getLayoutParams().width,
                view.getLayoutParams().height));
        contentView = view;
        ((FrameLayout) itemView).addView(contentView);//Add View after setLayoutParams
        contentView.setOnClickListener(this);
        contentView.setOnLongClickListener(this);
    } else {
        itemView.setOnClickListener(this);
        itemView.setOnLongClickListener(this);
    }
}

2 - I can add a new Constructor in FlexibleViewHolder accepting a new boolean parameter for stickyHeader and separate the logic to NOT insert another layout when not needed.
To resolve all issues, user has to adapt the call of constructor by adding true and to implement the proper IHeader interface.
No new classes.

public FlexibleViewHolder(View view, FlexibleAdapter adapter, boolean stickyHeader) {
    super(stickyHeader ? new FrameLayout(view.getContext()): view);
    this.mAdapter = adapter;
    if (stickyHeader) {
        itemView.setLayoutParams(new FrameLayout.LayoutParams(
                view.getLayoutParams().width,
                view.getLayoutParams().height));
        contentView = view;
        ((FrameLayout) itemView).addView(contentView);//Add View after setLayoutParams
        contentView.setOnClickListener(this);
        contentView.setOnLongClickListener(this);
    } else {
        itemView.setOnClickListener(this);
        itemView.setOnLongClickListener(this);
    }
}

3 - Create a new StickyHeaderViewHolder class that extends FlexibleViewHolder, but we also need to separate the 2 expandable ViewHolder one with sticky and one without ExpandableStickyHeaderViewHolder that extends directly FlexibleViewHolder.
To resolve all issues, user has to change the class extension to the proper one and to implement the proper IHeader interface..
We have 2 new classes and they creates more confusion.

4 - The new StickyHeaderViewHolder might extends ExpandableViewHolder, now the header inherits all the extension features for the VH, but cannot be used without the proper Item Interface IExpandable.
To resolve all issues, user has to change the class extension to the proper one and to implement the proper IHeader interface.
We have only 1 new class.

Suggestions?

@bornest
Copy link

bornest commented Jun 6, 2016

I'm not an expert on this, but I think that the second option with boolean parameter is the best way.

@davideas
Copy link
Owner

davideas commented Jun 7, 2016

The itemView with FrameLayout lost the elevation, how to show the shadow of the elevation??

I used android:clipToPadding="false" and also mStickyHolderLayout.setClipToPadding(false); but nothing.

@bornest
Copy link

bornest commented Jun 7, 2016

@davideas, I had a problem with no shadows under cardview items in my list when I switched to your lib,
I fixed it by wrapping cardview in FrameLayout like this:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    >

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view_news"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:foreground="?android:attr/selectableItemBackground"
        card_view:cardBackgroundColor="#fff"
        card_view:cardUseCompatPadding="true"
        card_view:cardElevation="2dp"
        card_view:cardCornerRadius="1dp"
        >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants