├── sample
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── 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
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── values-v21
│ │ │ └── styles.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── menu
│ │ │ └── menu_activity.xml
│ │ └── layout
│ │ │ ├── item_image_layout.xml
│ │ │ ├── alter_empty.xml
│ │ │ ├── alter_loading.xml
│ │ │ ├── item_pictue_caption_layout.xml
│ │ │ ├── item_header_layout.xml
│ │ │ ├── recycler_view_layout.xml
│ │ │ └── activity_base_recycler_view.xml
│ │ ├── java
│ │ └── io
│ │ │ └── prashantslolanki3
│ │ │ └── snaprecyclerview
│ │ │ └── sample
│ │ │ ├── model
│ │ │ ├── HorizontalRecyclerModel.java
│ │ │ └── PictureCaption.java
│ │ │ ├── SampleData.java
│ │ │ ├── viewholders
│ │ │ ├── ImageViewHolder.java
│ │ │ ├── SinglePictureCaptionViewHolder.java
│ │ │ └── HorizontalRecyclerViewHolder.java
│ │ │ ├── BaseRecyclerViewActivity.java
│ │ │ └── MultiLayoutActivity.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── snaplibrary
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── prashantsolanki3
│ │ │ └── snaplibrary
│ │ │ └── snap
│ │ │ ├── recycler
│ │ │ ├── SnapOnItemClickListener.java
│ │ │ └── SnapOnItemTouchListener.java
│ │ │ ├── endless
│ │ │ ├── EndlessLoader.java
│ │ │ ├── EndlessRecyclerOnScrollListener.java
│ │ │ └── RecyclerViewPositionHelper.java
│ │ │ ├── SnapLayoutWrapper.java
│ │ │ ├── SnapMultiViewWrapper.java
│ │ │ ├── SnapViewHolder.java
│ │ │ ├── SnapMultiAdapter.java
│ │ │ ├── SnapAdapter.java
│ │ │ ├── AbstractSnapMultiAdapter.java
│ │ │ └── layoutmanagers
│ │ │ ├── SnapNestedLinearLayoutManger.java
│ │ │ └── SnapNestedGridLayoutManager.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── build.gradle
└── snaplibrary.iml
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── libraries
│ ├── support_annotations_23_1_1.xml
│ ├── appcompat_v7_23_1_1.xml
│ ├── recyclerview_v7_23_1_1.xml
│ └── support_v4_23_1_1.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .travis.yml
├── .gitattributes
├── gradle.properties
├── gradlew.bat
├── .gitignore
├── README.md
├── gradlew
└── Licence.md
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/snaplibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Snap-RecyclerView-Utils
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':snaplibrary'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/snaplibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Snap RecyclerView Utils Library
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prashantsolanki3/Snap-RecyclerView-Utils/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
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-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/recycler/SnapOnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap.recycler;
2 |
3 | import android.view.View;
4 |
5 | public interface SnapOnItemClickListener {
6 | void onItemClick(View view, int position);
7 |
8 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | android:
4 | components:
5 | - tools
6 | - build-tools-23.0.2
7 | - android-23
8 | - extra-google-m2repository
9 | - extra-android-support
10 | - extra-android-m2repository
11 |
12 | script: ./gradlew build
13 |
14 | before_install:
15 | - chmod +x gradlew
--------------------------------------------------------------------------------
/snaplibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Snap RecyclerView Utils
3 | SnapRecyclerViewUtils
4 |
5 | Hello world!
6 | Settings
7 | Multiple Layouts RecyclerView
8 |
9 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_activity.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_image_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_23_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/alter_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/alter_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/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 D:\Program Files (x86)\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 |
--------------------------------------------------------------------------------
/snaplibrary/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 D:\Program Files (x86)\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 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_pictue_caption_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/snaplibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | lintOptions {
8 | abortOnError false
9 | }
10 |
11 | defaultConfig {
12 | minSdkVersion 14
13 | targetSdkVersion 23
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | testCompile 'junit:junit:4.12'
28 | compile 'com.android.support:appcompat-v7:23.1.1'
29 | compile 'com.android.support:recyclerview-v7:23.1.1'
30 | }
31 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_header_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/endless/EndlessLoader.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap.endless;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 |
5 | import io.github.prashantsolanki3.snaplibrary.snap.AbstractSnapMultiAdapter;
6 |
7 | /**
8 | * Created by Prashant on 12/13/2015.
9 | *
10 | */
11 | public interface EndlessLoader {
12 |
13 | /**
14 | * Load more Items to your RecyclerView.
15 | * Do check for class type if you are using AbstractSnapMultiAdapter provided in params.
16 | * */
17 | void loadMore(final AbstractSnapMultiAdapter adapter,final int pageNo);
18 |
19 | /**
20 | * The stock onScrolled method provided by ReyclerView.onScrollListener.
21 | * */
22 | void onScrolled(RecyclerView recyclerView,int dx, int dy);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/libraries/appcompat_v7_23_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/recyclerview_v7_23_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/model/HorizontalRecyclerModel.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample.model;
2 |
3 | import java.util.ArrayList;
4 |
5 | /**
6 | * Created by Prashant on 12/12/2015.
7 | */
8 | public class HorizontalRecyclerModel {
9 |
10 | String title;
11 | ArrayList images;
12 |
13 | public HorizontalRecyclerModel(String title, ArrayList images) {
14 | this.title = title;
15 | this.images = images;
16 | }
17 |
18 | public HorizontalRecyclerModel() {
19 | }
20 |
21 | public String getTitle() {
22 | return title;
23 | }
24 |
25 | public void setTitle(String title) {
26 | this.title = title;
27 | }
28 |
29 | public ArrayList getImages() {
30 | return images;
31 | }
32 |
33 | public void setImages(ArrayList images) {
34 | this.images = images;
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/model/PictureCaption.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample.model;
2 |
3 | /**
4 | * Package io.prashantslolanki3.snaprecyclerview.sample.model
5 | *
6 | * Created by Prashant on 12/18/2015.
7 | *
8 | * Email: solankisrp2@gmail.com
9 | * Github: @prashantsolanki3
10 | */
11 | public class PictureCaption {
12 |
13 | String caption;
14 | String url;
15 |
16 | public PictureCaption(String caption, String url) {
17 | this.caption = caption;
18 | this.url = url;
19 | }
20 |
21 | public PictureCaption() {
22 | }
23 |
24 | public String getCaption() {
25 | return caption;
26 | }
27 |
28 | public void setCaption(String caption) {
29 | this.caption = caption;
30 | }
31 |
32 | public String getUrl() {
33 | return url;
34 | }
35 |
36 | public void setUrl(String url) {
37 | this.url = url;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_23_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/recycler_view_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | lintOptions {
8 | abortOnError false
9 | }
10 |
11 | defaultConfig {
12 | applicationId "io.github.prashantsolanki3.snaprecyclerviewutils"
13 | minSdkVersion 16
14 | targetSdkVersion 23
15 | versionCode 1
16 | versionName "1.0"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile project(":snaplibrary")
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.android.support:appcompat-v7:23.1.1'
31 | compile 'com.android.support:recyclerview-v7:23.1.1'
32 | compile 'com.github.bumptech.glide:glide:3.6.1'
33 | compile 'com.android.support:design:23.1.1'
34 | }
35 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/SnapLayoutWrapper.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap;
2 |
3 | import android.support.annotation.LayoutRes;
4 |
5 | /**
6 | * Created by Prashant on 12/12/2015.
7 | */
8 | public class SnapLayoutWrapper {
9 |
10 | Class model;
11 | Class extends SnapViewHolder> viewHolder;
12 | @LayoutRes
13 | Integer layoutId;
14 | Integer layoutType;
15 |
16 | public SnapLayoutWrapper(Class model,
17 | Class extends SnapViewHolder> viewHolder,
18 | @LayoutRes Integer layoutId,
19 | Integer layoutType) {
20 | this.model = model;
21 | this.viewHolder = viewHolder;
22 | this.layoutId = layoutId;
23 | this.layoutType = layoutType;
24 | }
25 |
26 | public Class getModel() {
27 | return model;
28 | }
29 |
30 | public Class extends SnapViewHolder> getViewHolder() {
31 | return viewHolder;
32 | }
33 |
34 | public Integer getLayoutId() {
35 | return layoutId;
36 | }
37 |
38 | public Integer getLayoutType() {
39 | return layoutType;
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/SnapMultiViewWrapper.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap;
2 |
3 | import android.support.annotation.LayoutRes;
4 |
5 | /**
6 | *
7 | * Created by Prashant on 12/12/2015.
8 | */
9 | public class SnapMultiViewWrapper {
10 |
11 | Class model;
12 | Class extends SnapViewHolder> viewHolder;
13 | @LayoutRes
14 | Integer layoutId;
15 | Integer layoutType;
16 |
17 | public SnapMultiViewWrapper(Class model,
18 | Class extends SnapViewHolder> viewHolder,
19 | @LayoutRes Integer layoutId,
20 | Integer layoutType) {
21 | this.model = model;
22 | this.viewHolder = viewHolder;
23 | this.layoutId = layoutId;
24 | this.layoutType = layoutType;
25 | }
26 |
27 | public Class getModel() {
28 | return model;
29 | }
30 |
31 | public Class extends SnapViewHolder> getViewHolder() {
32 | return viewHolder;
33 | }
34 |
35 | public Integer getLayoutId() {
36 | return layoutId;
37 | }
38 |
39 | public Integer getLayoutType() {
40 | return layoutType;
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/SnapViewHolder.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | /**
8 | * Created by Prashant on 12/5/2015.
9 | */
10 | public abstract class SnapViewHolder extends RecyclerView.ViewHolder {
11 |
12 |
13 |
14 | private Context context;
15 | private T itemData;
16 |
17 | public SnapViewHolder(View itemView, Context context) {
18 | super(itemView);
19 | this.context = context;
20 | }
21 |
22 | public T getItemData() {
23 | return itemData;
24 | }
25 |
26 | public void setItemData(T itemData) {
27 | this.itemData = itemData;
28 | }
29 |
30 | public void setContext(Context context) {
31 | this.context = context;
32 | }
33 |
34 | public Context getContext() {
35 | return context;
36 | }
37 |
38 | public abstract void populateViewHolder(T data, int pos);
39 |
40 | public abstract void animateViewHolder(SnapViewHolder viewHolder, int pos);
41 |
42 | public abstract void attachOnClickListeners(SnapViewHolder viewHolder, T item, int pos);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/SampleData.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Random;
5 |
6 | import io.prashantslolanki3.snaprecyclerview.sample.model.HorizontalRecyclerModel;
7 | import io.prashantslolanki3.snaprecyclerview.sample.model.PictureCaption;
8 |
9 | /**
10 | * Package io.prashantslolanki3.snaprecyclerview.sample
11 | *
12 | * Created by Prashant on 12/18/2015.
13 | *
14 | * Email: solankisrp2@gmail.com
15 | * Github: @prashantsolanki3
16 | */
17 | public class SampleData {
18 |
19 | public static ArrayList getHorizontalRecyclerModels(int noOfItems, int noOfImages) {
20 | ArrayList models = new ArrayList<>();
21 | Random random = new Random();
22 | for (int i = 0; i < noOfItems; i++) {
23 | models.add(new HorizontalRecyclerModel("Title: " + random.nextInt(),
24 | getImageUrls(noOfImages)));
25 | }
26 | return models;
27 | }
28 |
29 | public static ArrayList getImageUrls(int no) {
30 | ArrayList strings = new ArrayList<>();
31 | for (int i = 0; i < no; i++) {
32 | strings.add("http://lorempixel.com/300/300/abstract/These%20are%20Random%20Images/");
33 | }
34 | return strings;
35 | }
36 |
37 |
38 | public static PictureCaption getPictureCaption() {
39 | return new PictureCaption("Caption", getImageUrls(1).get(0));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_base_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/viewholders/ImageViewHolder.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample.viewholders;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 |
7 | import com.bumptech.glide.Glide;
8 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
9 |
10 | import io.github.prashantsolanki3.snaplibrary.snap.SnapViewHolder;
11 | import io.github.prashantsolanki3.snaprecyclerviewutils.R;
12 |
13 | /**
14 | * Package io.prashantslolanki3.snaprecyclerview.sample.viewholders
15 | *
16 | * Created by Prashant on 12/18/2015.
17 | *
18 | * Email: solankisrp2@gmail.com
19 | * Github: @prashantsolanki3
20 | */
21 | public class ImageViewHolder extends SnapViewHolder {
22 |
23 | final ImageView imageView;
24 |
25 | public ImageViewHolder(View itemView, Context context) {
26 | super(itemView, context);
27 | imageView = (ImageView) itemView.findViewById(R.id.item_iv);
28 | }
29 |
30 | @Override
31 | public void populateViewHolder(String data, int pos) {
32 | imageView.setImageDrawable(null);
33 | Glide.with(getContext())
34 | .load(data)
35 | .skipMemoryCache(true)
36 | .diskCacheStrategy(DiskCacheStrategy.NONE)
37 | .into(imageView);
38 | }
39 |
40 | @Override
41 | public void animateViewHolder(SnapViewHolder viewHolder, int pos) {
42 |
43 | }
44 |
45 | @Override
46 | public void attachOnClickListeners(SnapViewHolder viewHolder, String item, int pos) {
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/BaseRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 |
10 | import io.github.prashantsolanki3.snaprecyclerviewutils.R;
11 |
12 | public abstract class BaseRecyclerViewActivity extends AppCompatActivity {
13 |
14 | RecyclerView recyclerView;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_base_recycler_view);
20 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
21 | setSupportActionBar(toolbar);
22 | recyclerView = (RecyclerView) findViewById(R.id.recycler);
23 | recyclerView.setHasFixedSize(true);
24 | setLayoutManager(recyclerView);
25 | setAdapter(recyclerView);
26 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_add_items);
27 | fab.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View view) {
30 | setFabOnClickAction(view);
31 | }
32 | });
33 | }
34 |
35 | public abstract void setLayoutManager(RecyclerView recyclerView);
36 |
37 | public abstract void setAdapter(RecyclerView recyclerView);
38 |
39 | public abstract void setFabOnClickAction(View view);
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/recycler/SnapOnItemTouchListener.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap.recycler;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.GestureDetector;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 |
9 | public class SnapOnItemTouchListener implements RecyclerView.OnItemTouchListener {
10 |
11 | GestureDetector mGestureDetector;
12 |
13 | public SnapOnItemTouchListener(Context context, SnapOnItemClickListener listener) {
14 | mListener = listener;
15 | mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
16 | @Override
17 | public boolean onSingleTapUp(MotionEvent e) {
18 | return true;
19 | }
20 | });
21 | }
22 |
23 | @Override
24 | public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent e) {
25 | View childView = recyclerView.findChildViewUnder(e.getX(), e.getY());
26 |
27 | if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
28 | mListener.onItemClick(childView, recyclerView.getChildAdapterPosition(childView));
29 | return true;
30 | }
31 |
32 | return false;
33 | }
34 |
35 | @Override
36 | public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
37 | }
38 |
39 | @Override
40 | public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
41 |
42 | }
43 |
44 | private SnapOnItemClickListener mListener;
45 |
46 |
47 | }
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/viewholders/SinglePictureCaptionViewHolder.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample.viewholders;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 | import android.widget.TextView;
7 |
8 | import com.bumptech.glide.Glide;
9 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
10 |
11 | import io.github.prashantsolanki3.snaplibrary.snap.SnapViewHolder;
12 | import io.github.prashantsolanki3.snaprecyclerviewutils.R;
13 | import io.prashantslolanki3.snaprecyclerview.sample.model.PictureCaption;
14 |
15 | /**
16 | * Package io.prashantslolanki3.snaprecyclerview.sample.viewholders
17 | *
18 | * Created by Prashant on 12/18/2015.
19 | *
20 | * Email: solankisrp2@gmail.com
21 | * Github: @prashantsolanki3
22 | */
23 | public class SinglePictureCaptionViewHolder extends SnapViewHolder {
24 |
25 | final TextView title;
26 | final ImageView imageView;
27 |
28 | public SinglePictureCaptionViewHolder(View itemView, Context context) {
29 | super(itemView, context);
30 | title = (TextView) itemView.findViewById(R.id.item_title);
31 | imageView = (ImageView) itemView.findViewById(R.id.item_iv);
32 | }
33 |
34 | @Override
35 | public void populateViewHolder(PictureCaption data, int pos) {
36 | imageView.setImageDrawable(null);
37 | Glide.with(getContext())
38 | .load(data.getUrl())
39 | .asBitmap()
40 | .skipMemoryCache(true)
41 | .diskCacheStrategy(DiskCacheStrategy.NONE)
42 | .into(imageView);
43 |
44 | title.setText(data.getCaption());
45 | }
46 |
47 | @Override
48 | public void animateViewHolder(SnapViewHolder viewHolder, int pos) {
49 |
50 | }
51 |
52 | @Override
53 | public void attachOnClickListeners(SnapViewHolder viewHolder, PictureCaption item, int pos) {
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/prashantslolanki3/snaprecyclerview/sample/viewholders/HorizontalRecyclerViewHolder.java:
--------------------------------------------------------------------------------
1 | package io.prashantslolanki3.snaprecyclerview.sample.viewholders;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import io.github.prashantsolanki3.snaplibrary.snap.SnapAdapter;
10 | import io.github.prashantsolanki3.snaplibrary.snap.SnapViewHolder;
11 | import io.github.prashantsolanki3.snaprecyclerviewutils.R;
12 | import io.prashantslolanki3.snaprecyclerview.sample.model.HorizontalRecyclerModel;
13 |
14 | /**
15 | *
16 | * Created by Prashant on 12/12/2015.
17 | *
18 | */
19 | public class HorizontalRecyclerViewHolder extends SnapViewHolder {
20 |
21 | final TextView title;
22 | final RecyclerView recyclerView;
23 | SnapAdapter adapter;
24 |
25 | public HorizontalRecyclerViewHolder(View itemView, Context context) {
26 | super(itemView, context);
27 | recyclerView = (RecyclerView) itemView.findViewById(R.id.header_rv);
28 | title = (TextView) itemView.findViewById(R.id.item_title);
29 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext(),
30 | LinearLayoutManager.HORIZONTAL,
31 | false));
32 |
33 | adapter = new SnapAdapter<>(getContext(),
34 | String.class,
35 | R.layout.item_image_layout,
36 | ImageViewHolder.class);
37 |
38 | recyclerView.setAdapter(adapter);
39 |
40 | }
41 |
42 | @Override
43 | public void attachOnClickListeners(SnapViewHolder viewHolder, HorizontalRecyclerModel item, int pos) {
44 |
45 | }
46 |
47 | @Override
48 | public void animateViewHolder(SnapViewHolder viewHolder, int pos) {
49 |
50 | }
51 |
52 | @Override
53 | public void populateViewHolder(HorizontalRecyclerModel data, int pos) {
54 | title.setText(data.getTitle());
55 | adapter.set(data.getImages());
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/snaplibrary/src/main/java/io/github/prashantsolanki3/snaplibrary/snap/SnapMultiAdapter.java:
--------------------------------------------------------------------------------
1 | package io.github.prashantsolanki3.snaplibrary.snap;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.ViewGroup;
7 |
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Prashant Solanki.
12 | *
13 | * Github: prashantsolanki3
14 | * Email: prs.solanki@live.com
15 | */
16 | public class SnapMultiAdapter extends AbstractSnapMultiAdapter