├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tdscientist │ │ └── shelfview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── cover.jpg │ ├── java │ │ └── com │ │ │ └── tdscientist │ │ │ └── shelfviewSample │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable │ │ └── cover.png │ │ ├── layout │ │ └── activity_main.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 │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tdscientist │ └── shelfview │ └── ExampleUnitTest.java ├── build.gradle ├── desc.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── landscape.png ├── portrait.png ├── settings.gradle └── shelfview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── tdscientist │ └── shelfview │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── tdscientist │ │ └── shelfview │ │ ├── BookModel.java │ │ ├── ShelfAdapter.java │ │ ├── ShelfModel.java │ │ ├── ShelfView.java │ │ └── Utils.java └── res │ ├── drawable-hdpi │ ├── grid_item_background_center.9.png │ ├── grid_item_background_left.9.png │ └── grid_item_background_right.9.png │ ├── drawable-mdpi │ ├── grid_item_background_center.9.png │ ├── grid_item_background_left.9.png │ └── grid_item_background_right.9.png │ ├── drawable-xhdpi │ ├── grid_item_background_center.9.png │ ├── grid_item_background_left.9.png │ └── grid_item_background_right.9.png │ ├── drawable-xxhdpi │ ├── grid_item_background_center.9.png │ ├── grid_item_background_left.9.png │ └── grid_item_background_right.9.png │ ├── drawable │ ├── book_spine_grey_blend.xml │ └── book_spine_white_blend.xml │ ├── layout │ ├── book_cover.xml │ └── book_shelf_grid_item.xml │ └── values │ ├── dimens.xml │ └── strings.xml └── test └── java └── com └── tdscientist └── shelfview └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Shelf View -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ShelfView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5299) [![MaterialUp](https://img.shields.io/badge/MaterialUp-ShelfView-deepblue.svg?style=flat)](https://material.uplabs.com/posts/shelfview) 2 | 3 | 4 | ## ShelfView ## 5 | 6 | *Android custom view to display books on shelf* ` ` **([iOS version is available here](https://github.com/tdscientist/ShelfView-iOS))** 7 | 8 | 9 | 10 | 11 | 12 | 13 | #### How to use #### 14 | ---- 15 | 16 | **build.gradle** 17 | ``` 18 | allprojects { 19 | repositories { 20 | maven { 21 | url 'https://jitpack.io' 22 | } 23 | } 24 | } 25 | ``` 26 | 27 | 28 | ``` 29 | dependencies { 30 | compile 'com.github.tdscientist:ShelfView:v1.0' 31 | } 32 | ``` 33 | 34 | **Layout** 35 | ``` 36 | 40 | 41 | ``` 42 | 43 | 44 | **Activity** 45 | ``` 46 | import com.tdscientist.shelfview.BookModel; 47 | import com.tdscientist.shelfview.ShelfView; 48 | import java.util.ArrayList; 49 | 50 | public class MainActivity extends AppCompatActivity implements ShelfView.BookClickListener { 51 | 52 | @Override 53 | protected void onCreate(Bundle savedInstanceState) { 54 | super.onCreate(savedInstanceState); 55 | setContentView(R.layout.activity_main); 56 | 57 | ShelfView shelfView = (ShelfView) findViewById(R.id.shelfView); 58 | shelfView.setOnBookClicked(this); 59 | ArrayList models = new ArrayList<>(); 60 | 61 | models.add(new BookModel("http://eurodroid.com/pics/beginning_android_book.jpg", "1", "Beginning Android")); 62 | 63 | shelfView.loadData(models, ShelfView.BOOK_SOURCE_URL); 64 | 65 | 66 | } 67 | 68 | @Override 69 | public void onBookClicked(int position, String bookId, String bookTitle) { 70 | // handle click events here 71 | //Toast.makeText(this, bookTitle, Toast.LENGTH_SHORT).show(); 72 | } 73 | } 74 | 75 | ``` 76 | 77 | 78 | 79 | #### Loading book covers from other sources #### 80 | ---- 81 | 82 | * Internal/External directory in the device 83 | ``` 84 | model.add(new BookModel("/path/to/android_book_cover.jpg", "1", "Let's Talk About Android")); 85 | shelfView.loadData(model, ShelfView.BOOK_SOURCE_FILE); 86 | ``` 87 | 88 | 89 | 90 | * Assets folder 91 | ``` 92 | model.add(new BookModel("android.jpg", "1", "Android for Experts")); 93 | shelfView.loadData(model, ShelfView.BOOK_SOURCE_ASSETS_FOLDER); 94 | ``` 95 | 96 | 97 | 98 | * Drawable folder 99 | ``` 100 | model.add(new BookModel("alice", "1", "Alice in Wonderland")); 101 | shelfView.loadData(model, ShelfView.BOOK_SOURCE_DRAWABLE_FOLDER); 102 | ``` 103 | 104 | 105 | #### Permissions #### 106 | ---- 107 | ``` 108 | 109 | 110 | ``` 111 | 112 | 113 | 114 | #### License #### 115 | ---- 116 | ``` 117 | Copyright 2017 Adeyinka Adediji 118 | 119 | Licensed under the Apache License, Version 2.0 (the "License"); 120 | you may not use this file except in compliance with the License. 121 | You may obtain a copy of the License at 122 | 123 | http://www.apache.org/licenses/LICENSE-2.0 124 | 125 | Unless required by applicable law or agreed to in writing, software 126 | distributed under the License is distributed on an "AS IS" BASIS, 127 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128 | See the License for the specific language governing permissions and 129 | limitations under the License. 130 | ``` 131 | 132 | 133 | #### Contributions & Bug Reporting #### 134 | --- 135 | tdscientist@gmail.com 136 | 137 | 138 | 139 | #### Credits #### 140 | --- 141 | * [Picasso](https://github.com/square/picasso) 142 | 143 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.tdscientist.shelfviewTest" 9 | minSdkVersion 17 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | generatedDensities = [] 14 | } 15 | aaptOptions { 16 | additionalParameters "--no-version-vectors" 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(include: ['*.jar'], dir: 'libs') 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:25.1.0' 30 | compile project(':shelfview') 31 | } 32 | -------------------------------------------------------------------------------- /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 /Users/Scientist/Library/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/androidTest/java/com/tdscientist/shelfview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.tdscientist.shelfview; 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/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/assets/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/assets/cover.jpg -------------------------------------------------------------------------------- /app/src/main/java/com/tdscientist/shelfviewSample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tdscientist.shelfviewSample; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.Toast; 6 | 7 | import com.tdscientist.shelfview.BookModel; 8 | import com.tdscientist.shelfview.ShelfView; 9 | 10 | import java.util.ArrayList; 11 | 12 | /** 13 | * Copyright (c) 2017 Adediji Adeyinka(tdscientist) 14 | * All rights reserved 15 | * Created on 16-Feb-2017 16 | */ 17 | 18 | public class MainActivity extends AppCompatActivity implements ShelfView.BookClickListener { 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | ShelfView shelfView = (ShelfView) findViewById(R.id.shelfView); 26 | shelfView.setOnBookClicked(this); 27 | ArrayList model = new ArrayList<>(); 28 | 29 | model.add(new BookModel(getString(R.string.url_smashing_android_ui), "1", getString(R.string.title_smashing_android_ui))); 30 | model.add(new BookModel(getString(R.string.url_android_app_dev_for_dummies), "2", getString(R.string.title_android_app_dev_for_dummies))); 31 | model.add(new BookModel(getString(R.string.url_beginning_android), "3", getString(R.string.title_beginning_android))); 32 | model.add(new BookModel(getString(R.string.url_professional_android_programming), "4", getString(R.string.title_professional_android_programming))); 33 | model.add(new BookModel(getString(R.string.url_android_programming_pshing_the_limits), "5", getString(R.string.title_android_programming_pshing_the_limits))); 34 | model.add(new BookModel(getString(R.string.url_100_q_and_a), "6", getString(R.string.title_100_q_and_a))); 35 | model.add(new BookModel(getString(R.string.url_android_programming_for_beginners), "7", getString(R.string.title_android_programming_for_beginners))); 36 | model.add(new BookModel(getString(R.string.url_android_programming), "8", getString(R.string.title_android_programming))); 37 | 38 | shelfView.loadData(model, ShelfView.BOOK_SOURCE_URL); 39 | 40 | 41 | } 42 | 43 | 44 | @Override 45 | public void onBookClicked(int position, String bookId, String bookTitle) { 46 | Toast.makeText(this, bookTitle, Toast.LENGTH_SHORT).show(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/drawable/cover.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdscientist/ShelfView/59314a024fae5b12192c9282289db53aee21d9ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Shelf View 3 | http://3.bp.blogspot.com/-aDUhP55KerE/UGbxmCkyKOI/AAAAAAAAKM8/Ms7Hs6Ln524/s1600/cover.png 4 | https://raw.githubusercontent.com/emmby/android-for-dummies-v3/master/assets/book-cover.png 5 | http://eurodroid.com/pics/beginning_android_book.jpg 6 | http://devproconnections.com/site-files/devproconnections.com/files/uploads/2014/06/Riley%20DCM1061%20Pro_Android_book_cover.jpg 7 | http://whatpixel.com/images/2016/08/android-programming-pushing-the-limits.jpg 8 | http://www.lopez-manas.com/wp-content/uploads/2015/07/cover-Kopie-212x300.png 9 | https://www.packtpub.com/sites/default/files/9781785883262.png 10 | http://www.informit.com/ShowCover.aspx?isbn=0672336286 11 | SMASHING Android UI 12 | Android App Development for DUMMIES 13 | Beginning Android 14 | Professional Android Programming 15 | ANDROID PROGRAMMING PUSHING THE LIMITS 16 | 17 | Android Programming for Beginners 18 | Android Programming 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |