davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.55k stars 553 forks source link

Java.lang.ClassCastException casting issue while implementing in TabLayout with ViewPagerAdapter #174

Closed Shamik07 closed 8 years ago

Shamik07 commented 8 years ago

Hey .. Hi .. I am Shamik from India, First of all thank you for for such an excellent library. I have been using this library for over 3 months now. Went through a lot of libraries for Recyclerview Sticky Headers before finding this.. really appreciate your work.

1) For Bugs / Support I don't know if this is a bug or I haven't properly implemented your library. I trying to implement stickyheaders in a TabView/Tablayout with Viewpager. Each view/tab has an fragment with FlexibleAdapter .. all the data is loaded from a DatabaseService which uses volley to load data via models. Now the problem is if I have only one tab implementing FlexibleAdapter .. everything works fine. But if I have two tabs back to back ( for eg tab 1 and tab 2 ) implementing FlexibleAdapter it gives me an error ( mentioned below ) .. but if I implement it on alternate tabs ( for eg tab 1 and tab 3 ) ..everything works.

The error -

09-24 02:24:33.973 3746-3746/in.thinktek.aayaa E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: in.thinktek.aayaa, PID: 3746
                                                                 java.lang.ClassCastException: in.thinktek.aayaa.viewholder.ContactsExpandableHeaderItem$ContactsExpandableHeaderViewHolder cannot be cast to in.thinktek.aayaa.viewholder.AssignTaskExpandableHeaderItem$AssignTaskExpandableHeaderViewHolder
at in.thinktek.aayaa.viewholder.AssignTaskExpandableHeaderItem.bindViewHolder(AssignTaskExpandableHeaderItem.java:28)
at eu.davidea.flexibleadapter.FlexibleAdapter.onBindViewHolder(FlexibleAdapter.java:1396)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5858)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5094)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1549)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:305)

How I have implemented your library ... My code -

AssignFragment - Fragment that loads up via viewpageradapter

public class AssignFragment extends Fragment {

    public static final String TAG = AssignFragment.class.getSimpleName();

    private AssignAdapter mAdapter;
    public SwipeRefreshLayout swipeRefreshLayout;
    RecyclerView mRecyclerView;
    protected static final String ARG_COLUMN_COUNT = "column_count";

    protected OnFragmentInteractionListener mListener;
    protected int mColumnCount = 2;

    public static AssignFragment newInstance(int columnCount) {
        AssignFragment fragment = new AssignFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_COLUMN_COUNT, columnCount);
        fragment.setArguments(args);
        return fragment;
    }

    public AssignFragment() {
        // Required empty public constructor
    }

    public static Handler sAssignUpdateHandler;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sAssignUpdateHandler = new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                // call you update method here.
                // Activity to Fragment Communication
                Log.v(TAG, "Handler Received !");
                //mListener.setSnackbar("Handler Here", "warning");
            }
        };
        if (getArguments() != null) {
            mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
        }

        //Contribution for specific action buttons in the Toolbar
        setHasOptionsMenu(true);
    }

    @Override
    @SuppressWarnings("deprecation")
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) activity;
        } else {
            throw new RuntimeException(activity.toString()
                    + " must implement OnFragmentInteractionListener");
        }
    }

    protected LinearLayoutManager createNewLinearLayoutManager() {
        return new SmoothScrollLinearLayoutManager(getActivity());
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View layout = inflater.inflate(R.layout.fragment_assign, container, false);
        mRecyclerView = (RecyclerView) layout.findViewById(R.id.recycler_view);
        mAdapter = new AssignAdapter(getActivity());
        swipeRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeRefreshLayout);
        initializeRecyclerView();
        return layout;
    }

    @CallSuper
    public void showNewLayoutInfo(final MenuItem item) {
        item.setEnabled(false);
        mRecyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                item.setEnabled(true);
            }
        }, 2000L);
    }

    @SuppressWarnings({"ConstantConditions", "NullableProblems"})
    private void initializeRecyclerView() {
        if (isNetworkAvailable(getActivity())) {
            if (isOnline()) {
                DatabaseAssignService.getInstance().createAssignDatabase(getActivity(),mAdapter,mListener,true);
            } else {
                DatabaseAssignService.getInstance().createAssignDatabase(getActivity(),mAdapter,mListener,false);
                noInternetError();
            }
        } else {
            DatabaseAssignService.getInstance().createAssignDatabase(getActivity(),mAdapter,mListener,false);
            noInternetError();
        }

        //Experimenting NEW features (v5.0.0)
        mAdapter.expandItemsAtStartUp()
                .setAutoCollapseOnExpand(false)
                .setAutoScrollOnExpand(true)
                .setAnimateToLimit(Integer.MAX_VALUE)//Size limit = MAX_VALUE will always animate the changes
                .setNotifyMoveOfFilteredItems(false)//When true, filtering on big list is very slow!
                .setNotifyChangeOfUnfilteredItems(true)//We have highlighted text while filtering, so let's enable this feature to be consistent with the active filter
                .setRemoveOrphanHeaders(false)
                .setAnimationOnScrolling(true)
                .setAnimationOnReverseScrolling(true);
        //mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
        //mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));
        mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
        mAdapter.enableStickyHeaders();
        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.setHasFixedSize(true); //Size of RV will not change
        mRecyclerView.setItemAnimator(new DefaultItemAnimator() {
            @Override
            public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
                //NOTE: This allows to receive Payload objects when notifyItemChanged is called by the Adapter!!!
                return true;
            }
        });
        //mRecyclerView.setItemAnimator(new SlideInRightAnimator());
        mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
                R.drawable.line_divider, 0));//Increase to add gap between sections (Works only with LinearLayout!)

        mAdapter.setLongPressDragEnabled(false);//Enable long press to drag items

        //swipeRefreshLayout.setRefreshing(false);
        mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
        mListener.adapterSticky(mAdapter.areHeadersSticky());
    }

    public void noInternetError() {
        mListener.setSnackbar("Please check your internet connection", "alert");
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        Log.v(TAG, "onCreateOptionsMenu called!");
        inflater.inflate(R.menu.menu_assign_frag, menu);
        mListener.initSearchView(menu);
    }

    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // if (item.getItemId() == R.id.action_list_type)
        //     mAdapter.setAnimationOnScrolling(true);
        return super.onOptionsItemSelected(item);
    }

}

AssignAdapter :- Each fragment has its own seperate adapter

public class AssignAdapter extends FlexibleAdapter<AbstractFlexibleItem> {

    private static final String TAG = AssignAdapter.class.getSimpleName();

    public static final int EXAMPLE_VIEW_TYPE = 1;

    private int positionOld = -1;

    private AbstractFlexibleItem mUseCaseItem;

    public AssignAdapter(List<AbstractFlexibleItem> items, Object listeners) {
        //true = Items implement hashCode() and have stableIds!
        super(items, listeners, true);

    }

    public AssignAdapter(Activity activity) {
        super(DatabaseAssignService.getInstance().getDatabaseList(), activity);

        //NEW! We have highlighted text while filtering, so let's enable this feature
        //to be consistent with the active filter
        setNotifyChangeOfUnfilteredItems(true);
    }

    @Override
    public void updateDataSet(List<AbstractFlexibleItem> items, boolean animate) {
        //NOTE: To have views/items not changed, set them into "items" before passing the final
        // list to the Adapter, also pass animate=true in order to not delete those items.

        //Overwrite the list and fully notify the change, pass false to not animate changes.
        //Watch out! The original list must a copy
        super.updateDataSet(items, animate);
    }

    @Override
    public synchronized void filterItems(@NonNull List<AbstractFlexibleItem> unfilteredItems) {
        super.filterItems(unfilteredItems);
    }

    @Override
    public String onCreateBubbleText(int position) {
        if (!DatabaseAssignService.userLearnedSelection && position == 0) {//This 'if' is for my example only
            //TODO FOR YOU: This is the normal line you should use: Usually it's the first letter
            return Integer.toString(position);
        }
        return super.onCreateBubbleText(position);
    }

}

AssignTaskExpandableHeaderItem - Header Viewholder ( Each fragment has its own viewholder class )

public class AssignTaskExpandableHeaderItem extends AbstractModelItem<AssignTaskExpandableHeaderViewHolder>
        implements IExpandable<AssignTaskExpandableHeaderViewHolder, AssignTaskSubItem>,
        IHeader<AssignTaskExpandableHeaderViewHolder> {

    private static final long serialVersionUID = -1882711111814491061L;
    public static final String TAG = AssignTaskExpandableHeaderItem.class.getSimpleName();

    /* Flags for FlexibleAdapter */
    private boolean mExpanded = false;

    /* subItems list */
    private List<AssignTaskSubItem> mAssignTaskSubItems;

    public AssignTaskExpandableHeaderItem(String id) {
        super(id);
        setDraggable(true);
        //We start with header shown and expanded
        setHidden(false);
        setExpanded(true);
        //NOT selectable (otherwise ActionMode will be activated on long click)!
        setSelectable(false);
    }

    @Override
    public boolean isExpanded() {
        return mExpanded;
    }

    @Override
    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
    }

    @Override
    public int getExpansionLevel() {
        return 0;
    }

    @Override
    public List<AssignTaskSubItem> getSubItems() {
        return mAssignTaskSubItems;
    }

    public final boolean hasSubItems() {
        return mAssignTaskSubItems!= null && mAssignTaskSubItems.size() > 0;
    }

    public boolean removeSubItem(AssignTaskSubItem item) {
        return item != null && mAssignTaskSubItems.remove(item);
    }

    public boolean removeSubItem(int position) {
        if (mAssignTaskSubItems != null && position >= 0 && position < mAssignTaskSubItems.size()) {
            mAssignTaskSubItems.remove(position);
            return true;
        }
        return false;
    }

    public void addAssignTaskSubItem(AssignTaskSubItem assignTaskSubItem) {
        if (mAssignTaskSubItems == null)
            mAssignTaskSubItems = new ArrayList<AssignTaskSubItem>();
        mAssignTaskSubItems.add(assignTaskSubItem);
    }

    public void addSubItem(int position, AssignTaskSubItem subItem) {
        if (mAssignTaskSubItems != null && position >= 0 && position < mAssignTaskSubItems.size()) {
            mAssignTaskSubItems.add(position, subItem);
        } else
            addAssignTaskSubItem(subItem);
    }

    @Override
    public int getLayoutRes() {
        return R.layout.recycler_expandable_header_item;
    }

    @Override
    public AssignTaskExpandableHeaderViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater inflater, ViewGroup parent) {
        return new AssignTaskExpandableHeaderViewHolder(inflater.inflate(getLayoutRes(), parent, false), adapter);
    }

    @Override
    public void bindViewHolder(FlexibleAdapter adapter, AssignTaskExpandableHeaderViewHolder holder, int position, List payloads) {
        if (payloads.size() > 0) {
            Log.i(this.getClass().getSimpleName(), "AssignTaskExpandableHeaderItem Payload " + payloads);
        } else {
            holder.mTitle.setText(getTitle());
            //Log.d(TAG, "Response " + AppContants.USER_ACCOUNT_SUB_TYPE);

            //holder.mRoot.setBackgroundColor(ContextCompat.getColor(MyApplication.getAppContext(), ColorProvider.ColorPrimaryTransparent(AppContants.USER_ACCOUNT_SUB_TYPE)));
            holder.mRoot.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), ColorProvider.ColorPrimaryTransparent(AppContants.USER_ACCOUNT_SUB_TYPE)));
        }
    }

    /**
     * Provide a reference to the views for each data item.
     * Complex data labels may need more than one view per item, and
     * you provide access to all the views for a data item in a view holder.
     */
    static class AssignTaskExpandableHeaderViewHolder extends ExpandableViewHolder {

        public TextView mTitle;
        public RelativeLayout mRoot;
        //public TextView mSubtitle;
        //public ImageView mHandleView;

        public AssignTaskExpandableHeaderViewHolder(View view, FlexibleAdapter adapter) {
            super(view, adapter, true);//True for sticky
            mTitle = (TextView) view.findViewById(R.id.title);
            mRoot = (RelativeLayout) view.findViewById(R.id.root_layout);

            //Support for StaggeredGridLayoutManager
            if (itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
                ((StaggeredGridLayoutManager.LayoutParams) itemView.getLayoutParams()).setFullSpan(true);
            }
        }

        @Override
        protected boolean isViewExpandableOnClick() {
            return true;//true by default
        }

        @Override
        protected void expandView(int position) {
            super.expandView(position);
            //Let's notify the item has been expanded
            if (mAdapter.isExpanded(position)) mAdapter.notifyItemChanged(position, true);
        }

        @Override
        protected void collapseView(int position) {
            super.collapseView(position);
            //Let's notify the item has been collapsed
            if (!mAdapter.isExpanded(position)) mAdapter.notifyItemChanged(position, true);
        }

    }

    @Override
    public String toString() {
        return "AssignTaskExpandableHeaderItem[" + super.toString() + "//AssignTaskSubItems" + mAssignTaskSubItems + "]";
    }

}

AssignTaskSubItem - SubItem Viewholder ( Each fragment has its own viewholder class )

public class AssignTaskSubItem extends AbstractModelItem<AssignTaskSubItem.ChildViewHolder>
        implements ISectionable<AssignTaskSubItem.ChildViewHolder, IHeader>, IFilterable {

    public static final String TAG = AssignTaskSubItem.class.getSimpleName();

    /**
     * The header of this item
     */
    IHeader header;

    public AssignTaskSubItem(String id) {
        super(id);
        setDraggable(true);
    }

    @Override
    public IHeader getHeader() {
        return header;
    }

    @Override
    public void setHeader(IHeader header) {
        this.header = header;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.list_item_assign;
    }

    @Override
    public ChildViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater inflater, ViewGroup parent) {
        return new ChildViewHolder(inflater.inflate(getLayoutRes(), parent, false), adapter);
    }

    @SuppressWarnings("deprecation")
    @Override
    public void bindViewHolder(FlexibleAdapter adapter, ChildViewHolder holder, int position, List payloads) {
        // this will be highlighted
        if (adapter.hasSearchText()) {
            Context context = holder.itemView.getContext();
            Utils.highlightText(context, holder.mTitle, getTitle(), adapter.getSearchText(),
                    context.getResources().getColor(R.color.MainColorAccent));
            Utils.highlightText(context, holder.mName, getName(), adapter.getSearchText(),
                    context.getResources().getColor(R.color.MainColorAccent));
        } else {
            holder.mTitle.setText(getTitle());
            holder.mName.setText(getName());
            holder.mName.setTypeface(AppContants.mTypeface);
            holder.mProgressBar.setProgress(getProgressBar());
            holder.mLinearLayoutTask.setVisibility(getVisibilityLinearLayoutTask());
            holder.mLinearLayoutPeople.setVisibility(getVisibilityLinearLayoutPeople());
            holder.mUserAvailable.setText(getUserAvailable());

            holder.mTaskCreatedDate.setText(holder.itemView.getResources().getString(R.string.title_assign_date_created) + " " +getTaskCreatedDate());
            holder.mTaskExpiryDate.setText(holder.itemView.getResources().getString(R.string.title_assign_date_expiring) + " " +getTaskExpiryDate());

            Log.d("User", "messages" + getMessagesNumber());
            holder.mUserLastSeen.setText(getUserLastSeen());

            if(getUserOnline() == 1){
                holder.mUserOnline.setBackground(ContextCompat.getDrawable(holder.itemView.getContext(),R.drawable.circle_user_available));
            }else{
                holder.mUserOnline.setBackground(ContextCompat.getDrawable(holder.itemView.getContext(),R.drawable.circle_user_not_available));
            }

            holder.mAssignMessages.setText(String.valueOf(getMessagesNumber()));

            if(getUserAccountType()!= null) {
                holder.mName.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), ColorProvider.ColorPrimary(getUserAccountType())));
                holder.mUserLastSeen.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), ColorProvider.ColorPrimary(getUserAccountType())));
            }else{
                holder.mName.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.MainColorPrimary));
            }

            String imageLink = getImageLink();
            Log.d("JSON", "imageLink Pre " + imageLink);
            if (imageLink == null) {
                imageLink = "http:\\/\\/scontent-a-fra.cdninstagram.com\\/hphotos-xpf1\\/t51.2885-15\\/s306x306\\/e15\\/10665483_429615813855717_1490926670_n.jpg";
            }

            imageLink = getImageLink();
            Log.d("JSON", "imageLink Post " + imageLink);

            if (imageLink != null) {

                if (imageLink.endsWith("gif")) {
                    Glide.with(holder.itemView.getContext())
                            .load(imageLink)
                            .centerCrop()
                            .placeholder(R.mipmap.ic_launcher)
                            .into(holder.mImageView);
                } else {
                    Glide.with(holder.itemView.getContext())
                            .load(imageLink)
                            .asBitmap()
                            .centerCrop()
                            .placeholder(R.mipmap.ic_launcher)
                            .into(holder.mImageView);
                }
            } else {
                // make sure Glide doesn't load anything into this view until told otherwise
                Glide.clear(holder.mImageView);
                // remove the placeholder (optional); read comments below
                holder.mImageView.setImageResource(R.drawable.ic_account_circle_grey_400_24dp);
            }
            if(getUserAccountType()!= null) {
                holder.mImageView.setBorderColor(ContextCompat.getColor(holder.itemView.getContext(), ColorProvider.ColorPrimary(getUserAccountType())));
            }else{
                holder.mImageView.setBorderColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.MainColorPrimary));
            }
            holder.mImageView.setBorderWidth(12);

            Log.d(TAG, "User Account type is " + getUserAccountType());

            Log.d("Image", "Border image size is " + holder.mImageView.getWidth() + "x" + holder.mImageView.getHeight());
        }

        //This "if-else" is just an example of what you can do with item animation
        if (adapter.isSelected(position)) {
            adapter.animateView(holder.itemView, position);
        }
        //else {
        //    adapter.animateView(holder.itemView, position, false);
       // }
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //Toast.makeText(view.getContext(),"Clicked at "+String.valueOf(position),Toast.LENGTH_SHORT).show();
                Intent launchNewIntent = new Intent(view.getContext(), MainActivity.class);
                //view.getContext().startActivity(launchNewIntent);
            }
        });
    }

    @Override
    public boolean filter(String constraint) {
        // Log.v(TAG, "filter called! "+getTitle().toLowerCase().trim().contains(constraint));
        String title = "";
        String name ="";
        String userAccountType ="";
        if(getTitle() != null)
        {
            title = getTitle();
            Log.v(TAG, "filter called! "+getTitle().toLowerCase().trim().contains(constraint));
        }
        if(getName() != null)
        {
            name = getName();
            Log.v(TAG, "filter called! "+getName().toLowerCase().trim().contains(constraint));
        }
        if(getUserAccountType() != null)
        {
            userAccountType = getUserAccountType();
            Log.v(TAG, "filter called! "+getUserAccountType().toLowerCase().trim().contains(constraint));
        }
        return (getTitle() != null && title.toLowerCase().trim().contains(constraint)) || (getName() != null && name.toLowerCase().trim().contains(constraint)) || (getUserAccountType() != null && userAccountType.toLowerCase().trim().contains(constraint));
    }

    /**
     * Provide a reference to the views for each data item.
     * Complex data labels may need more than one view per item, and
     * you provide access to all the views for a data item in a view holder.
     */
    static final class ChildViewHolder extends FlexibleViewHolder {

        // public ImageView mHandleView;
        public AnimateHorizontalProgressBar mProgressBar;
        public TextView mTitle, mName, mUserAvailable, mAssignMessages, mTaskCreatedDate, mTaskExpiryDate, mUserLastSeen;
        public CircleImageView mImageView;
        public ImageView mUserOnline;
        public LinearLayout mLinearLayoutTask, mLinearLayoutPeople;

        public ChildViewHolder(View view, FlexibleAdapter adapter) {
            super(view, adapter);
            this.mTitle = (TextView) view.findViewById(R.id.text_view_assign_title);
            this.mName = (TextView) view.findViewById(R.id.text_view_assign_user_name);
            this.mAssignMessages = (TextView) view.findViewById(R.id.text_view_assign_messages);

            this.mTaskCreatedDate = (TextView) view.findViewById(R.id.text_view_date_created);
            this.mTaskExpiryDate = (TextView) view.findViewById(R.id.text_view_expiring_in);
            this.mUserLastSeen = (TextView) view.findViewById(R.id.text_view_user_last_seen);

            this.mUserAvailable = (TextView) view.findViewById(R.id.text_view_user_available);
            this.mProgressBar = (AnimateHorizontalProgressBar) view.findViewById(R.id.animate_progress_bar);
            this.mUserOnline = (ImageView) view.findViewById(R.id.image_view_user_online);
            mProgressBar.setMax(100);
            this.mLinearLayoutTask = (LinearLayout) view.findViewById(R.id.linear_layout_assign_task);
            this.mLinearLayoutPeople = (LinearLayout) view.findViewById(R.id.linear_layout_assign_people);
            mProgressBar.setMax(100);
            this.mImageView = (CircleImageView) view.findViewById(R.id.image_view_user_pic);
            /*
            this.mHandleView = (ImageView) view.findViewById(R.id.row_handle);
            if (adapter.isHandleDragEnabled()) {
                this.mHandleView.setVisibility(View.VISIBLE);
                setDragHandleView(mHandleView);
            } else {
                this.mHandleView.setVisibility(View.GONE);
            }
            */
        }

        @Override
        public float getActivationElevation() {
            return in.thinktek.aayaa.tools.Utils.dpToPx(itemView.getContext(), 4f);
        }

        @Override
        public void scrollAnimators(@NonNull List<Animator> animators, int position, boolean isForward) {
            AnimatorHelper.scaleAnimator(animators, itemView, 0f);
        }
    }

    @Override
    public String toString() {
        return "AssignTaskSubItem[" + super.toString() + "]";
    }

}

Attaching screenshot screenshot_2016-09-24-02-24-12

Shamik07 commented 8 years ago

Upgraded from 'eu.davidea:flexible-adapter:5.0.0-b7' to 'eu.davidea:flexible-adapter:5.0.0-b8' and still facing the same issue

davideas commented 8 years ago

@Shamik07, is the following function in AssignTaskExpandableHeaderItem and ContactsExpandableHeaderItem returns different layout?

@Override
public int getLayoutRes() {
    return R.layout.recycler_expandable_header_item;
}
Shamik07 commented 8 years ago

No they return the same layout ie R.layout.recycler_expandable_header_item; ... I think i got it now .. I ll try making separate header layouts

Shamik07 commented 8 years ago

Its a little better .. I don't immediately get error .. but each time I switch to a new tab .. and then come back to the original one ( tab 1 to tab 2 to tab 1 ) .. I get the same error. Also initially Tab1's content are loaded in Tab2 and Tab2's content are loaded in Tab3 .. I ll keep working on it .. and try to figure it out. Thanks for the quick reply !

davideas commented 8 years ago

@Shamik07, with ViewPager things are more complicated, I still need to create a valid example in the demoApp. However, you can do it. Focus on layouts and read the issue #70, it can help.

davideas commented 8 years ago

@Shamik07, need more help? I will try to create a sample with ViewPager, when I have more time. It was planned already.

davideas commented 8 years ago

@Shamik07, see latest SNAPSHOT release.