├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── photo0.jpg
│ │ │ │ ├── photo1.jpg
│ │ │ │ ├── photo2.jpg
│ │ │ │ ├── photo3.jpg
│ │ │ │ ├── photo4.jpg
│ │ │ │ ├── photo5.jpg
│ │ │ │ ├── photo6.jpg
│ │ │ │ └── photo7.jpg
│ │ │ ├── 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
│ │ │ │ ├── photo_layout.xml
│ │ │ │ ├── progress_bar_layout.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── info
│ │ │ │ └── nissiy
│ │ │ │ └── gridlayoutsample
│ │ │ │ ├── ProgressStub.java
│ │ │ │ ├── Photo.java
│ │ │ │ ├── Util.java
│ │ │ │ ├── ProgressBarLayoutHolder.java
│ │ │ │ ├── GridWithProgressLayoutManager.java
│ │ │ │ ├── GridSpacingItemDecoration.java
│ │ │ │ ├── RecyclerBaseAdapter.java
│ │ │ │ ├── EndlessScrollListener.java
│ │ │ │ ├── PhotoGridAdapter.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── info
│ │ │ └── nissiy
│ │ │ └── gridlayoutsample
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── info
│ │ └── nissiy
│ │ └── gridlayoutsample
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── images
└── screenshot.gif
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── gradle.properties
├── gradlew.bat
├── gradlew
└── LICENSE.txt
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/images/screenshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/images/screenshot.gif
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 8dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GridLayoutSample
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo0.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo5.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo6.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/photo7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/drawable-xxhdpi/photo7.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/ProgressStub.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | public class ProgressStub {
4 | }
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nissiy/GridLayoutSample/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | GridLayoutSample
2 | ========================================
3 | Implemented progressbar as footer in GridLayoutManager (RecyclerView)
4 |
5 | ## Screenshot
6 | 
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/Photo.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | public class Photo {
4 | public int drawableResId;
5 |
6 | public Photo(int drawableResId) {
7 | this.drawableResId = drawableResId;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 16 02:36:01 JST 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/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3f51b5
4 | #303f9f
5 | #536dfe
6 | #e8eaf6
7 |
8 |
--------------------------------------------------------------------------------
/app/src/test/java/info/nissiy/gridlayoutsample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/Util.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.content.Context;
4 | import android.content.res.Configuration;
5 |
6 | public class Util {
7 |
8 | private Util() {
9 | }
10 |
11 | public static boolean isLandscape(Context context) {
12 | return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/info/nissiy/gridlayoutsample/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/ProgressBarLayoutHolder.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.widget.FrameLayout;
5 |
6 | public class ProgressBarLayoutHolder extends RecyclerView.ViewHolder {
7 | public final FrameLayout progressBarLayout;
8 |
9 | public ProgressBarLayoutHolder(FrameLayout view) {
10 | super(view);
11 | progressBarLayout = view;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/photo_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/progress_bar_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/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 /Applications/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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'me.tatarka.retrolambda'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion '25.0.2'
7 |
8 | defaultConfig {
9 | applicationId "info.nissiy.gridlayoutsample"
10 | minSdkVersion 15
11 | targetSdkVersion 25
12 | versionCode 1
13 | versionName "0.0.1"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | compileOptions {
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | targetCompatibility JavaVersion.VERSION_1_8
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.android.support:appcompat-v7:25.3.0'
31 | compile 'com.android.support:recyclerview-v7:25.3.0'
32 | compile 'com.squareup.picasso:picasso:2.5.2'
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/GridWithProgressLayoutManager.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.GridLayoutManager;
5 |
6 | public class GridWithProgressLayoutManager extends GridLayoutManager {
7 |
8 | public GridWithProgressLayoutManager(Context context,
9 | final int spanCount,
10 | final RecyclerBaseAdapter adapter) {
11 | super(context, spanCount);
12 |
13 | SpanSizeLookup spanSizeLookup = new SpanSizeLookup() {
14 | @Override
15 | public int getSpanSize(int position) {
16 | if (adapter != null
17 | && adapter.getItemViewType(position) == RecyclerBaseAdapter.TYPE_PROG) {
18 | return spanCount;
19 | }
20 | return 1;
21 | }
22 | };
23 | spanSizeLookup.setSpanIndexCacheEnabled(true);
24 | setSpanSizeLookup(spanSizeLookup);
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/GridSpacingItemDecoration.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
8 | private int spanCount;
9 | private int spacing;
10 |
11 | public GridSpacingItemDecoration(int spanCount, int spacing) {
12 | this.spanCount = spanCount;
13 | this.spacing = spacing;
14 | }
15 |
16 | @Override
17 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
18 | // Skip in the case of ProgressBarLayoutHolder
19 | RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(view);
20 | if (viewHolder instanceof ProgressBarLayoutHolder) {
21 | return;
22 | }
23 |
24 | int position = parent.getChildAdapterPosition(view);
25 | int column = position % spanCount;
26 |
27 | outRect.left = column * spacing / spanCount;
28 | outRect.right = spacing - (column + 1) * spacing / spanCount;
29 | outRect.bottom = spacing;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/info/nissiy/gridlayoutsample/RecyclerBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package info.nissiy.gridlayoutsample;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import java.util.List;
7 |
8 | public abstract class RecyclerBaseAdapter extends RecyclerView.Adapter {
9 | public final static int TYPE_ITEM = 1;
10 | public final static int TYPE_PROG = 2;
11 |
12 | private final Object lock = new Object();
13 | protected final List