{"action":"opened","issue":{"url":"https://api.github.com/repos/davideas/FlexibleAdapter/issues/59","repository_url":"https://api.github.com/repos/davideas/FlexibleAdapter","labels_url":"https://api.github.com/repos/davideas/FlexibleAdapter/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/davideas/FlexibleAdapter/issues/59/comments","events_url":"https://api.github.com/repos/davideas/FlexibleAdapter/issues/59/events","html_url":"https://github.com/davideas/FlexibleAdapter/issues/59","id":144427139,"number":59,"title":"Sticky Headers not working on 5.0.0-SNAPSHOT","user":{"login":"jonathanyee","id":79350,"avatar_url":"https://avatars.githubusercontent.com/u/79350?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanyee","html_url":"https://github.com/jonathanyee","followers_url":"https://api.github.com/users/jonathanyee/followers","following_url":"https://api.github.com/users/jonathanyee/following{/other_user}","gists_url":"https://api.github.com/users/jonathanyee/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanyee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanyee/subscriptions","organizations_url":"https://api.github.com/users/jonathanyee/orgs","repos_url":"https://api.github.com/users/jonathanyee/repos","events_url":"https://api.github.com/users/jonathanyee/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanyee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-30T00:38:48Z","updated_at":"2016-03-30T00:38:48Z","closed_at":null,"body":"I'm trying to follow what you have in the example app, but I can't get sticky headers to work with my app.\r\n\r\nAdapter\r\n```\r\npublic class RecentContactsAdapter extends FlexibleAdapter<AbstractFlexibleItem> {\r\n\r\n    private final Context context;\r\n\r\n    private List<GroupedRecentCall> groupedRecentCallList;\r\n    private Map<String, String> callLogToPhoneMap;\r\n    private List<AbstractFlexibleItem> recentCallsWithHeaders;\r\n    private Map<Integer, LocalDataForRecentCall> localMap;\r\n\r\n    public RecentContactsAdapter(Context context, List<AbstractFlexibleItem> recentCallsWithHeaders) {\r\n        super(recentCallsWithHeaders);\r\n\r\n        this.recentCallsWithHeaders = recentCallsWithHeaders;\r\n        this.context = context;\r\n\r\n        localMap = new HashMap<Integer, LocalDataForRecentCall>();\r\n\r\n        callLogToPhoneMap = new HashMap<String, String>();\r\n    }\r\n}\r\n```\r\n\r\nHeader\r\n```\r\npublic class RecentContactHeaderItem extends AbstractHeaderItem<RecentContactHeaderItem.ViewHolder> {\r\n\r\n    private String title;\r\n\r\n    public RecentContactHeaderItem(String title) {\r\n        super();\r\n        this.title = title;}\r\n\r\n    @Override\r\n    public boolean equals(Object o) {\r\n        if (o instanceof String) {\r\n            String oo = (String) o;\r\n            return oo.equals(this.title);\r\n        }\r\n        return false;\r\n    }\r\n\r\n    @Override\r\n    public int getLayoutRes() {\r\n        return R.layout.recent_contacts_header;\r\n    }\r\n\r\n    @Override\r\n    public ViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater inflater, ViewGroup parent) {\r\n        return new ViewHolder(inflater.inflate(getLayoutRes(), parent, false), adapter);\r\n    }\r\n\r\n    @Override\r\n    public void bindViewHolder(FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) {\r\n        holder.titleView.setText(title);\r\n    }\r\n\r\n    public static class ViewHolder extends FlexibleViewHolder {\r\n        public OpenSansTextView titleView;\r\n\r\n        public ViewHolder(View view, FlexibleAdapter adapter) {\r\n            super(view, adapter);\r\n            this.titleView = (OpenSansTextView) view.findViewById(R.id.title);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nSection item\r\n```\r\npublic class RecentContactItem extends AbstractSectionableItem<RecentContactItem.ViewHolder, RecentContactHeaderItem> {\r\n\r\n    private final String TAG = \"RecentContactItem\";\r\n\r\n    private Context context;\r\n    private SimpleDateFormat timeFormatter;\r\n    private SimpleDateFormat dateFormatter;\r\n    private GroupedRecentCall groupedRecentCall;\r\n\r\n    private Map<String, String> callLogToPhoneMap;\r\n    private Map<Integer, RecentContactsAdapter.LocalDataForRecentCall> localMap;\r\n\r\n    private RoundedTransformation roundedTransformer;\r\n    private Bitmap defaultAvatar;\r\n\r\n    public RecentContactItem(Context context, RecentContactHeaderItem header, SimpleDateFormat timeFormatter,\r\n                             SimpleDateFormat dateFormatter, GroupedRecentCall groupedRecentCall,\r\n                             HashMap<Integer, RecentContactsAdapter.LocalDataForRecentCall> localMap,\r\n                             HashMap<String, String> callLogToPhoneMap) {\r\n        this.context = context;\r\n        setHeader(header);\r\n    }\r\n\r\n    @Override\r\n    public boolean equals(Object o) {\r\n        if (o instanceof CallLogObject) {\r\n            GroupedRecentCall inItem = (GroupedRecentCall) o;\r\n            return this.groupedRecentCall.getCallLogObject().getCallDate().equals(inItem.getCallLogObject().getCallDate());\r\n        }\r\n        return false;\r\n    }\r\n\r\n    @Override\r\n    public int getLayoutRes() {\r\n        return R.layout.recent_contacts_item;\r\n    }\r\n\r\n    @Override\r\n    public ViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater inflater, ViewGroup parent) {\r\n        return new ViewHolder(inflater.inflate(getLayoutRes(), parent, false), adapter);\r\n    }\r\n\r\n    @Override\r\n    public void bindViewHolder(FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) {\r\n        // binding\r\n    }\r\n\r\npublic static final class ViewHolder extends FlexibleViewHolder {\r\n\r\n        public ImageView avatarView;\r\n        public OpenSansTextView moreCountView;\r\n        public OpenSansTextView text1View;\r\n        public OpenSansTextView text2View;\r\n        public ImageView moreView;\r\n\r\n        public ViewHolder(View view, FlexibleAdapter adapter) {\r\n            super(view, adapter);\r\n\r\n            avatarView = (ImageView) view.findViewById(R.id.avatar);\r\n            moreCountView = (OpenSansTextView) view.findViewById(R.id.moreCount);\r\n            text1View = (OpenSansTextView) view.findViewById(R.id.text1);\r\n            text2View = (OpenSansTextView) view.findViewById(R.id.text2);\r\n            moreView = (ImageView) view.findViewById(R.id.more);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nFragment (the rest of the view is instantiated in onCreateView\r\n```\r\n@Override\r\n    public void onActivityCreated(Bundle savedInstanceState) {\r\n        super.onActivityCreated(savedInstanceState);\r\n\r\n        FlexibleAdapter.enableLogs(true);\r\n\r\n        Context context = getContext();\r\n\r\n        if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CALL_LOG) == PackageManager.PERMISSION_GRANTED) {\r\n            CallLogUtils.getAllCallsFromLog(context, null);// use null so its not a recursive call to this function\r\n        }\r\n\r\n        SimpleDateFormat timeFormatter = new SimpleDateFormat(\"h:mm a\");\r\n        SimpleDateFormat dateFormatter = new SimpleDateFormat(\"MMM d\");\r\n\r\n        HashMap<Integer, RecentContactsAdapter.LocalDataForRecentCall> localMap = new HashMap<>();\r\n        HashMap<String, String> callLogToPhoneMap = new HashMap<>();\r\n\r\n        List<GroupedRecentCall> groupedRecentCallList = ModelManager.getCallsGrouped(context);\r\n        List<AbstractFlexibleItem> recentCallsWithHeaders = new ArrayList<>();\r\n\r\n        RecentContactHeaderItem communcationStates = new RecentContactHeaderItem(\"Communication Stats\");\r\n        RecentContactHeaderItem frequentCallers = new RecentContactHeaderItem(\"Frequent callers\");\r\n        RecentContactHeaderItem recentActivity = new RecentContactHeaderItem(\"Recent activity\");\r\n\r\n        for (int i = 0; i < groupedRecentCallList.size(); i++) {\r\n            GroupedRecentCall groupedRecentCall = groupedRecentCallList.get(i);\r\n            RecentContactItem item = new RecentContactItem(context, (i < groupedRecentCallList.size() / 2) ? frequentCallers : recentActivity, timeFormatter,\r\n                    dateFormatter, groupedRecentCall, localMap, callLogToPhoneMap);\r\n            item.setHeader((i < groupedRecentCallList.size() / 2) ? frequentCallers : recentActivity);\r\n            recentCallsWithHeaders.add(item);\r\n        }\r\n\r\n        adapter = new RecentContactsAdapter(context, recentCallsWithHeaders);\r\n\r\n        recyclerView = (RecyclerView) getView().findViewById(R.id.list);\r\n        recyclerView.setLayoutManager(new SmoothScrollLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));\r\n        // load adapter here for < 4.1\r\n        recyclerView.setAdapter(adapter);\r\n        recyclerView.setHasFixedSize(true);\r\n\r\n//        listView.setLayoutManager(new LinearLayoutManager(getContext()));\r\n        recyclerView.setItemAnimator(new DefaultItemAnimator() {\r\n            @Override\r\n            public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder, List<Object> payloads) {\r\n                return true;\r\n            }\r\n        });\r\n\r\n        adapter.setDisplayHeadersAtStartUp(true);\r\n        adapter.enableStickyHeaders();\r\n}\r\n```\r\n\r\nFragment layout\r\n```\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<!--- used by recent contacts and address book -->\r\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\">\r\n\r\n    <android.support.v4.widget.SwipeRefreshLayout\r\n        android:id=\"@+id/swipeContainer\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\">\r\n\r\n        <android.support.v7.widget.RecyclerView\r\n            android:id=\"@+id/list\"\r\n            android:background=\"@color/white\"\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\" />\r\n\r\n    </android.support.v4.widget.SwipeRefreshLayout>\r\n\r\n    <!-- needed for FlexibleAdapter sticky headers -->\r\n    <include layout=\"@layout/sticky_header_layout\"/>\r\n\r\n    <include\r\n        android:id=\"@android:id/empty\"\r\n        android:visibility=\"gone\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        layout=\"@layout/empty_layout\" />\r\n\r\n    <ProgressBar\r\n        android:id=\"@+id/progressBar\"\r\n        style=\"?android:attr/progressBarStyleSmall\"\r\n        android:layout_width=\"50dp\"\r\n        android:layout_height=\"50dp\"\r\n        android:layout_centerInParent=\"true\"\r\n        android:visibility=\"gone\"/>\r\n\r\n    <spokeo.com.spokeomobile.views.OpenSansTextView\r\n        android:id=\"@+id/progressText\"\r\n        android:layout_below=\"@id/progressBar\"\r\n        android:layout_marginTop=\"10dp\"\r\n        android:gravity=\"center\"\r\n        android:layout_centerHorizontal=\"true\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:textSize=\"14sp\"\r\n        android:text=\"Loading Connections\"\r\n        android:textColor=\"@color/dark_gray\"\r\n        android:visibility=\"gone\"/>\r\n\r\n</RelativeLayout>\r\n```"}}