Pagination view for Android to show large amount of data just like Database paginator view.
Pagination view for Android to show large amount of data just like PHP paginator.
dependencies {
compile 'com.pkj.wow.paginationview:PaginationView:1.0.2-7'
}
<com.pkj.wow.paginationview.PaginationView
android:id="@+id/pagination_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
/>
mPaginationView.setPager(list.size());
mPaginationView.setOnPagerUpdate(new PaginationView.OnPagerUpdate() {
@Override
public void onUpdate(int pageNumber, int pageSize) {
// query your data from page number to page size according to your requirement
...
// notify your adapter
}
});
Activity layout file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clipChildren="false"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.pkj.wow.paginationview.PaginationView
android:id="@+id/pagination_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
/>
</LinearLayout>
Activity code
mAdapter = new MyAdapter(getDataset(0, pageSize));
mRecyclerView.setAdapter(mAdapter);
mPaginationView.setPager(size);
mPaginationView.setOnPagerUpdate(new PaginationView.OnPagerUpdate() {
@Override
public void onUpdate(int pageNumber, int pageSize) {
mAdapter.setDataset(getDataset(pageNumber, pageSize));
mAdapter.notifyDataSetChanged();
}
});
Copyright 2018 Pankaj Jangid
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.