├── sample ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── layout │ │ │ │ ├── error.xml │ │ │ │ ├── item_layout.xml │ │ │ │ └── activity_main.xml │ │ │ └── values-w820dp │ │ │ │ └── dimens.xml │ │ ├── java │ │ │ └── ru │ │ │ │ └── alexbykov │ │ │ │ └── pagination │ │ │ │ ├── views │ │ │ │ └── IMainActivityView.java │ │ │ │ ├── adapters │ │ │ │ ├── PaginateDelegate.java │ │ │ │ └── TestAdapter.java │ │ │ │ ├── utils │ │ │ │ ├── RandomUtils.java │ │ │ │ └── MockUtils.java │ │ │ │ ├── presenters │ │ │ │ └── MainActivityPresenter.java │ │ │ │ └── activities │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── ru │ │ │ └── alexbykov │ │ │ └── pagination │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── ru │ │ └── alexbykov │ │ └── pagination │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── no_pagination_button_ripple.xml │ │ │ │ └── no_pagination_button_selector.xml │ │ │ ├── layout │ │ │ │ ├── item_loading.xml │ │ │ │ └── item_error.xml │ │ │ └── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── colors.xml │ │ └── java │ │ │ └── ru │ │ │ └── alexbykov │ │ │ └── nopaginate │ │ │ ├── item │ │ │ ├── BaseGridLayoutManagerItem.java │ │ │ ├── BaseLinearLayoutManagerItem.java │ │ │ ├── DefaultGridLayoutItem.java │ │ │ ├── LoadingItem.java │ │ │ └── ErrorItem.java │ │ │ ├── callback │ │ │ ├── OnLoadMoreListener.java │ │ │ ├── OnRepeatListener.java │ │ │ ├── OnAdapterChangeListener.java │ │ │ ├── OnLoadMore.java │ │ │ └── PaginateView.java │ │ │ └── paginate │ │ │ ├── PaginateStatus.java │ │ │ ├── grid │ │ │ └── WrapperSpanSizeLookup.java │ │ │ ├── WrapperAdapterObserver.java │ │ │ ├── ScrollUtils.java │ │ │ ├── NoPaginateBuilder.java │ │ │ ├── WrapperAdapter.java │ │ │ ├── PaginateBuilder.java │ │ │ ├── NoPaginate.java │ │ │ └── Paginate.java │ ├── test │ │ └── java │ │ │ └── ru │ │ │ └── alexbykov │ │ │ └── nopaginate │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── ru │ │ └── alexbykov │ │ └── nopaginate │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── art ├── error.jpg └── loading.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── CONTRIBUTING.md ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | -------------------------------------------------------------------------------- /art/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/art/error.jpg -------------------------------------------------------------------------------- /art/loading.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/art/loading.jpg -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Pagination 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NoNews/NoPaginate/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/no_pagination_button_ripple.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/layout/item_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Dec 15 10:40:41 MSK 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/item/BaseGridLayoutManagerItem.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.item; 2 | 3 | 4 | /** 5 | * @author @Marko Milos, original repository: https://github.com/MarkoMilos/Paginate 6 | */ 7 | 8 | public interface BaseGridLayoutManagerItem { 9 | int getSpanSize(); 10 | } 11 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | NoPagination 3 | Network Error. Please check your connection and try 4 | later 5 | 6 | repeat 7 | 8 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/error.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/callback/OnLoadMoreListener.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.callback; 2 | 3 | /** 4 | * @author Alex Bykov 5 | * Date: 15.12.2017. 6 | *

7 | * You can contact me at me@alexbykov.ru 8 | */ 9 | 10 | public interface OnLoadMoreListener { 11 | void onLoadMore(); 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/callback/OnRepeatListener.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.callback; 2 | 3 | /** 4 | * Date: 13.08.2017 5 | * Time: 11:08 6 | * Project: NoPagination 7 | * 8 | * @author Alex Bykov 9 | * You can contact me at me@alexbykov.ru 10 | */ 11 | public interface OnRepeatListener { 12 | 13 | void onClickRepeat(); 14 | } 15 | -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #2196F3 4 | #90CAF9 5 | #fff 6 | #E0E0E0 7 | 8 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/callback/OnAdapterChangeListener.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.callback; 2 | 3 | /** 4 | * Date: 12.08.2017 5 | * Time: 11:02 6 | * Project: NoPagination 7 | * 8 | * @author Alex Bykov 9 | * You can contact me at me@alexbykov.ru 10 | */ 11 | 12 | public interface OnAdapterChangeListener { 13 | 14 | void onAdapterChange(); 15 | } 16 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_layout.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/callback/OnLoadMore.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.callback; 2 | 3 | /** 4 | * Created by Alex Bykov on 11.08.2017. 5 | * You can contact me at: me@alexbykov.ru. 6 | */ 7 | 8 | 9 | /** 10 | * Use OnLoadMoreListener instead this callback. 11 | * It will be remove in future 12 | */ 13 | 14 | @Deprecated 15 | public interface OnLoadMore { 16 | 17 | void onLoadMore(); 18 | } 19 | -------------------------------------------------------------------------------- /sample/src/main/java/ru/alexbykov/pagination/views/IMainActivityView.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination.views; 2 | 3 | import java.util.List; 4 | 5 | import ru.alexbykov.nopaginate.callback.PaginateView; 6 | 7 | /** 8 | * Created by Alex Bykov on 11.08.2017. 9 | * You can contact me at: me@alexbykov.ru. 10 | */ 11 | 12 | public interface IMainActivityView extends PaginateView { 13 | 14 | void addItems(List items); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/java/ru/alexbykov/pagination/adapters/PaginateDelegate.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination.adapters; 2 | 3 | /** 4 | * Created by Alex Bykov on 11.08.2017. 5 | * You can contact me at: me@alexbykov.ru. 6 | */ 7 | 8 | public class PaginateDelegate { 9 | 10 | private int limit; 11 | private int offset; 12 | private boolean isLoading; 13 | private boolean hasLoadedAllItems; 14 | private boolean isNetwokrError; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sample/src/main/java/ru/alexbykov/pagination/utils/RandomUtils.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination.utils; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * Created by Alex Bykov on 14.08.2017. 7 | * You can contact me at: me@alexbykov.ru. 8 | */ 9 | 10 | public class RandomUtils { 11 | private RandomUtils() { 12 | } 13 | public static boolean getRandomBoolean() { 14 | Random random = new Random(); 15 | return random.nextBoolean(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/callback/PaginateView.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.callback; 2 | 3 | /** 4 | * Date: 12.08.2017 5 | * Time: 18:48 6 | * Project: NoPagination 7 | * 8 | * @author Alex Bykov 9 | * You can contact me at me@alexbykov.ru 10 | */ 11 | public interface PaginateView { 12 | 13 | void showPaginateLoading(boolean show); 14 | 15 | void showPaginateError(boolean show); 16 | 17 | void setPaginateNoMoreData(boolean show); 18 | } 19 | -------------------------------------------------------------------------------- /library/src/test/java/ru/alexbykov/nopaginate/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/src/test/java/ru/alexbykov/pagination/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/item/BaseLinearLayoutManagerItem.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.item; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.ViewGroup; 5 | 6 | 7 | /** 8 | * @author @Marko Milos, original repository: https://github.com/MarkoMilos/Paginate 9 | */ 10 | 11 | 12 | public interface BaseLinearLayoutManagerItem { 13 | 14 | RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType); 15 | void onBindViewHolder(RecyclerView.ViewHolder holder, int position); 16 | } 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please ensure your pull request adheres to the following guidelines: 4 | 5 | - Before implementing a new feature, first make issue with a detailed description of what you want to do (it's can save your time) 6 | - Search previous pull request before making a new one, as yours may be a duplicate. 7 | - Don't forget to do format code (`WIN+L` on Windows, `CMD+Shit+L` on Mac OS) 8 | - Make an individual pull request for each suggestion. 9 | - Base branch for pull request — `develop` 10 | 11 | 12 | ### If possible, write a unit test to your change 13 | 14 | Thank you for your suggestions! 15 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/no_pagination_button_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/paginate/PaginateStatus.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.paginate; 2 | 3 | /** 4 | * Date: 12.08.2017 5 | * Time: 17:44 6 | * Project: NoPagination 7 | * 8 | * @author Alex Bykov 9 | * You can contact me at me@alexbykov.ru 10 | */ 11 | enum PaginateStatus { 12 | 13 | NO_MORE_ITEMS, LOADING, ERROR; 14 | 15 | public static PaginateStatus getStatus(boolean loadedAllItems, boolean adapterError) { 16 | if (loadedAllItems) return NO_MORE_ITEMS; 17 | else if (adapterError) { 18 | return ERROR; 19 | } else { 20 | return LOADING; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\bikal\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\bikal\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/ru/alexbykov/pagination/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("alexbykov.ru.pagination", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/androidTest/java/ru/alexbykov/nopaginate/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("alexbykov.ru.nopagination.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/android 2 | 3 | ### Android ### 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the ART/Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # Intellij 39 | *.iml 40 | .idea/workspace.xml 41 | .idea/tasks.xml 42 | .idea/libraries 43 | 44 | # Keystore files 45 | *.jks 46 | 47 | # External native build folder generated in Android Studio 2.2 and later 48 | .externalNativeBuild 49 | 50 | ### Android Patch ### 51 | gen-external-apklibs 52 | .idea/ 53 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/item/DefaultGridLayoutItem.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.item; 2 | 3 | import android.support.v7.widget.GridLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | 6 | 7 | /** 8 | * @author @Marko Milos, original repository: https://github.com/MarkoMilos/Paginate 9 | */ 10 | 11 | 12 | public final class DefaultGridLayoutItem implements BaseGridLayoutManagerItem { 13 | private final int loadingListItemSpan; 14 | 15 | public DefaultGridLayoutItem(RecyclerView.LayoutManager layoutManager) { 16 | if (layoutManager instanceof GridLayoutManager) { 17 | // By default full span will be used for loading list item 18 | loadingListItemSpan = ((GridLayoutManager) layoutManager).getSpanCount(); 19 | } else { 20 | loadingListItemSpan = 1; 21 | } 22 | } 23 | 24 | @Override 25 | public int getSpanSize() { 26 | return loadingListItemSpan; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/ru/alexbykov/nopaginate/item/LoadingItem.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.nopaginate.item; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import ru.alexbykov.nopaginate.R; 9 | 10 | /** 11 | * Created by Alex Bykov on 11.08.2017. 12 | * You can contact me at: me@alexbykov.ru. 13 | */ 14 | 15 | public interface LoadingItem extends BaseLinearLayoutManagerItem { 16 | 17 | 18 | LoadingItem DEFAULT = new LoadingItem() { 19 | @Override 20 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 21 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_loading, parent, false); 22 | return new RecyclerView.ViewHolder(view) { 23 | }; 24 | } 25 | 26 | @Override 27 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 28 | 29 | } 30 | }; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sample/src/main/java/ru/alexbykov/pagination/utils/MockUtils.java: -------------------------------------------------------------------------------- 1 | package ru.alexbykov.pagination.utils; 2 | 3 | import android.os.Handler; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Alex Bykov on 14.08.2017. 10 | * You can contact me at: me@alexbykov.ru. 11 | */ 12 | 13 | public class MockUtils { 14 | 15 | private MockUtils() { 16 | } 17 | 18 | public static List getMockItems() { 19 | final List list = new ArrayList<>(); 20 | for (int i = 0; i < 20; i++) { 21 | list.add(i); 22 | } 23 | return list; 24 | } 25 | 26 | 27 | public static void mockHttpRequest(final NetworkCallback networkCallback) { 28 | new Handler().postDelayed(() -> { 29 | if (RandomUtils.getRandomBoolean()) { 30 | networkCallback.onSuccess(); 31 | } 32 | else networkCallback.onError(); 33 | }, 2000); 34 | } 35 | 36 | 37 | public interface NetworkCallback { 38 | void onSuccess(); 39 | 40 | void onError(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /library/src/main/res/layout/item_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 16 | 17 | 24 | 25 |