Aspsine / IRecyclerView

IRecyclerView is a custom RecyclerView that supports pull-to-refresh, pull-to-loadmore, customize refresh header and loadmore footer, add header views and footer views.
729 stars 146 forks source link

ClassCastException: Refresh header view must be an implement of RefreshTrigger #46

Closed Sumit-Chakole closed 6 years ago

Sumit-Chakole commented 6 years ago

If default Loadmorefooter and Refreshheader are available I am fine with it.

rv_posts.layoutManager = LinearLayoutManager(this)

// Pull to refresh
        rv_posts.setOnRefreshListener(OnRefreshListener() {
            fun onRefresh() {
                postLoadedIndex=0;
                fetchTrendingPosts(GetWallPostWSRequest( postLoadedIndex, POST_LOADING_STEP_SIZE));
            }
        });

        // Load more
        rv_posts.setOnLoadMoreListener(OnLoadMoreListener() {
            fun onLoadMore(loadMoreView: View) {
                fetchTrendingPosts(GetWallPostWSRequest( postLoadedIndex, POST_LOADING_STEP_SIZE));
                postLoadedIndex+= POST_LOADING_STEP_SIZE;
            }
        })
<com.aspsine.irecyclerview.IRecyclerView
        android:id="@+id/rv_posts"
        android:background="@android:color/transparent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:loadMoreEnabled="true"
        app:loadMoreFooterLayout="@layout/layout_irecyclerview_load_more_footer"
        app:refreshEnabled="true"
        app:refreshHeaderLayout="@layout/layout_irecyclerview_refresh_header"/>
Aspsine commented 6 years ago

app:refreshHeaderLayout="@layout/layout_irecyclerview_refresh_header"

layout_irecyclerview_refresh_header layout root view must implement com.aspsine.irecyclerview.RefreshTrigger interface. Or you will get ClassCastException: Refresh header view must be an implement of RefreshTrigger Exception.

Sumit-Chakole commented 6 years ago

May you please show demo layout_irecyclerview_refresh_header xml file please

Aspsine commented 6 years ago

https://github.com/Aspsine/IRecyclerView/blob/master/app/src/main/java/com/aspsine/irecyclerview/demo/ui/widget/header/ClassicRefreshHeaderView.java

<?xml version="1.0" encoding="utf-8"?>
<com.aspsine.irecyclerview.demo.ui.widget.header.ClassicRefreshHeaderView.java xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="120dp" />