├── .gitignore ├── LICENSE ├── README.md ├── android-colored-list.iml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── image_sample_1.png ├── image_sample_2.png ├── image_sample_3.png ├── image_sample_4.png ├── image_sample_5.png ├── image_sample_6.png ├── image_sample_7.png └── image_sample_8.png ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── smarttie │ │ └── coloredlist │ │ └── lib │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── smarttie │ │ │ └── coloredlist │ │ │ └── lib │ │ │ ├── manager │ │ │ ├── ColorTheme.java │ │ │ └── ColoredListManager.java │ │ │ ├── utils │ │ │ └── ColorUtils.java │ │ │ └── widget │ │ │ └── ColoredListAdapter.java │ └── res │ │ └── values │ │ ├── colors.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── smarttie │ └── coloredlist │ └── lib │ └── ExampleUnitTest.java ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sample.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── smarttie │ │ └── coloredlist │ │ └── sample │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── smarttie │ │ │ └── coloredlist │ │ │ └── sample │ │ │ ├── MainActivity.java │ │ │ └── SimpleAdapter.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── list_item.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-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── smarttie │ └── coloredlist │ └── sample │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Smarttie Software, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Android Colored List 2 | =============== 3 | 4 | This library provides support to generate Google Material Design colored lists. Works on API level 10 or later. 5 | 6 | --- 7 | 8 | Target platforms 9 | --- 10 | 11 | - API level 10 or later. 12 | 13 | 14 | Latest version 15 | --- 16 | 17 | - Version 1.0.0 (Apr. 23, 2016) 18 | 19 | 20 | Usage 21 | --- 22 | 23 | Please check the implementation of the simple examples. 24 | 25 | ### RecycleView related examples 26 | 27 | - [Basic](sample/src/main/java/com/smarttie/coloredlist/sample/) 28 | 29 | 30 | 31 | Primary classes/interfaces 32 | --- 33 | 34 | ### Color related classes/interfaces 35 | 36 | | Class/Interface name | Description | 37 | |---------------------------------------|----------------------------------------------------------| 38 | | [`ColoredListManager`](library/src/main/java/com/smarttie/coloredlist/lib/manager/ColoredListManager.java) | Provides Color operations | 39 | | [`ColoredListAdapter`](library/src/main/java/com/smarttie/coloredlist/lib/widget/ColoredListAdapter.java) | Implement this interface on your RecyclerView.Adapter | 40 | | [`ColorTheme`](library/src/main/java/com/smarttie/coloredlist/lib/manager/ColorTheme.java) | Defines a set of predefined colors to tint the lists | 41 | 42 | 43 | Visual Examples 44 | --- 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | License 57 | --- 58 | 59 | This library is licensed under the MIT License. 60 | 61 | See [`LICENSE`](LICENSE) for full of the license text. 62 | 63 | The MIT License (MIT) 64 | 65 | Copyright (c) 2016 Smarttie Software, Inc. 66 | 67 | Permission is hereby granted, free of charge, to any person obtaining a copy 68 | of this software and associated documentation files (the "Software"), to deal 69 | in the Software without restriction, including without limitation the rights 70 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 71 | copies of the Software, and to permit persons to whom the Software is 72 | furnished to do so, subject to the following conditions: 73 | 74 | The above copyright notice and this permission notice shall be included in all 75 | copies or substantial portions of the Software. 76 | 77 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 78 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 79 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 80 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 81 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 82 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 83 | SOFTWARE. 84 | -------------------------------------------------------------------------------- /android-colored-list.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.0.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 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.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /images/image_sample_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_1.png -------------------------------------------------------------------------------- /images/image_sample_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_2.png -------------------------------------------------------------------------------- /images/image_sample_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_3.png -------------------------------------------------------------------------------- /images/image_sample_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_4.png -------------------------------------------------------------------------------- /images/image_sample_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_5.png -------------------------------------------------------------------------------- /images/image_sample_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_6.png -------------------------------------------------------------------------------- /images/image_sample_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_7.png -------------------------------------------------------------------------------- /images/image_sample_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/images/image_sample_8.png -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 10 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.3.0' 25 | compile 'com.android.support:recyclerview-v7:23.3.0' 26 | } 27 | -------------------------------------------------------------------------------- /library/library.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /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 /Users/angellopez/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 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/smarttie/coloredlist/lib/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.lib; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase 10 | { 11 | public ApplicationTest() 12 | { 13 | super(Application.class); 14 | } 15 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/smarttie/coloredlist/lib/manager/ColorTheme.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | *

4 | * Copyright (c) 2016 Smarttie Software, Inc. 5 | *

6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | *

13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | *

16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.smarttie.coloredlist.lib.manager; 26 | 27 | import android.content.Context; 28 | 29 | import com.smarttie.coloredlist.lib.R; 30 | import com.smarttie.coloredlist.lib.utils.ColorUtils; 31 | 32 | /** 33 | * ColorTheme defines a set of predefined colors based on Google Material Design colors. 34 | * 35 | * @see 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | *

16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.smarttie.coloredlist.lib.manager; 26 | 27 | import android.content.Context; 28 | import android.graphics.Color; 29 | import android.graphics.drawable.ColorDrawable; 30 | import android.graphics.drawable.StateListDrawable; 31 | 32 | import com.smarttie.coloredlist.lib.utils.ColorUtils; 33 | 34 | import java.util.ArrayList; 35 | 36 | 37 | /** 38 | * ColoredListManager is a manager used to calculate a list of colors departing of 39 | * the same base color. Each color in the list has a small degradation that differentiates 40 | * it from the previous and next color. When used to color a list of views, it generates 41 | * a nice looking effect on the list. 42 | *

43 | * This manager is a good choice to be used along with {@code RecycleView}, {@code ListView} 44 | * or any similar visual component. 45 | */ 46 | public class ColoredListManager 47 | { 48 | /** 49 | * if the list count is less or equals to this number, the colors will be 50 | * generated based on a pre-populated color list. If the length grows, the 51 | * colors will start to be generated dynamically 52 | */ 53 | private static final int MAX_STATIC_LENGTH = 15; 54 | 55 | private static final float DEFAULT_MIN_HSV_VALUE = 0.2f; 56 | private static final float DEFAULT_MAX_HSV_VALUE = 0f; 57 | 58 | private Context mContext; 59 | private ColorTheme mTheme; 60 | 61 | private float mMinHSVValue = DEFAULT_MIN_HSV_VALUE; 62 | private float mMaxHSVValue = DEFAULT_MAX_HSV_VALUE; 63 | private float mTotalHsvValue; 64 | private float mIncrementsHSVValue; 65 | 66 | private int mListLength = 0; 67 | private final ArrayList mStaticColorList = new ArrayList<>(MAX_STATIC_LENGTH); 68 | 69 | 70 | /** 71 | * Returns the minimum HSV value to be used to calculate the bottom limit color 72 | * 73 | * @return the minimum HSV value 74 | */ 75 | public float getMinHSVValue() 76 | { 77 | return mMinHSVValue; 78 | } 79 | 80 | /** 81 | * Specifies the minimum HSV value to be used to calculate the bottom limit color 82 | * 83 | * @param mMinHSVValue the minimum HSV value 84 | */ 85 | public void setMinHSVValue(float mMinHSVValue) 86 | { 87 | this.mMinHSVValue = mMinHSVValue; 88 | updateManagerValues(); 89 | } 90 | 91 | /** 92 | * Returns the maximum HSV value to be used to calculate the top limit color 93 | * 94 | * @return the maximum HSV value 95 | */ 96 | public float getMaxHSVValue() 97 | { 98 | return mMaxHSVValue; 99 | } 100 | 101 | /** 102 | * Specifies the maximum HSV value to be used to calculate the top limit color 103 | * 104 | * @param mMaxHSVValue the maximum HSV value 105 | */ 106 | public void setMaxHSVValue(float mMaxHSVValue) 107 | { 108 | this.mMaxHSVValue = mMaxHSVValue; 109 | updateManagerValues(); 110 | } 111 | 112 | /** 113 | * Specifies the base color theme used to color a list 114 | * 115 | * @param theme the base color theme 116 | */ 117 | public void setColorTheme(ColorTheme theme) 118 | { 119 | mTheme = theme; 120 | updateManagerValues(); 121 | } 122 | 123 | 124 | /** 125 | * Constructs a new instance of {@code ColoredListManager} with the specified 126 | * color theme. 127 | * 128 | * @param context the context the list is running in, through which it can access 129 | * resources, etc. 130 | * @param theme the color theme used to color the list 131 | */ 132 | public ColoredListManager(Context context, ColorTheme theme) 133 | { 134 | mContext = context; 135 | mTheme = theme; 136 | 137 | updateBaseValues(); 138 | } 139 | 140 | /** 141 | * Constructs a new instance of {@code ColoredListManager} with the specified 142 | * color theme. 143 | * 144 | * @param context the context the list is running in, through which it can access 145 | * resources, etc. 146 | * @param theme the color theme used to color the list 147 | * @param listLength the length of the list to be colored 148 | */ 149 | public ColoredListManager(Context context, ColorTheme theme, int listLength) 150 | { 151 | this(context, theme); 152 | updateListLength(listLength); 153 | } 154 | 155 | private void updateBaseValues() 156 | { 157 | float[] hsv = ColorUtils.colorToHSV(mTheme.getColor(mContext)); 158 | mMaxHSVValue = hsv[2]; 159 | mTotalHsvValue = mMaxHSVValue - mMinHSVValue; 160 | } 161 | 162 | /** 163 | * Updates the length of the list that is being colored with this manager. 164 | * This is needed to enable the manager to calculate the different degradation levels 165 | * to be used on the colored list. 166 | *

167 | * Ensure to call this method every time the colored list changes of size. 168 | * 169 | * @param listLength the length of the list to be colored 170 | */ 171 | public void updateListLength(int listLength) 172 | { 173 | mListLength = listLength; 174 | 175 | //updating hsv increments 176 | if (mListLength == 0) 177 | { 178 | mIncrementsHSVValue = 0; 179 | } 180 | else 181 | { 182 | mIncrementsHSVValue = mTotalHsvValue / mListLength; 183 | } 184 | generateStaticColorList(); 185 | } 186 | 187 | private void updateManagerValues() 188 | { 189 | updateBaseValues(); 190 | updateListLength(mListLength); 191 | } 192 | 193 | private void generateStaticColorList() 194 | { 195 | float staticIncrementsHSVValue = mTotalHsvValue / MAX_STATIC_LENGTH; 196 | 197 | mStaticColorList.clear(); 198 | for (int a = 0; a < MAX_STATIC_LENGTH; a++) 199 | { 200 | mStaticColorList.add(getColor(staticIncrementsHSVValue, a)); 201 | } 202 | } 203 | 204 | /** 205 | * Returns the base theme color used to color the list 206 | * 207 | * @return the base theme color 208 | */ 209 | public int getBaseColor() 210 | { 211 | return mTheme.getColor(mContext); 212 | } 213 | 214 | /** 215 | * Returns a selector with the color for the specified position based on the color 216 | * degradation 217 | * 218 | * @param position the position of the view in the list to be colored 219 | * @return a selector with the color for the specified row 220 | */ 221 | public StateListDrawable getColorSelector(int position) 222 | { 223 | int rowColor = getColor(position); 224 | int baseColor = mTheme.getColor(mContext); 225 | 226 | StateListDrawable stateListDrawable = new StateListDrawable(); 227 | stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, 228 | new ColorDrawable(baseColor)); 229 | stateListDrawable.addState(new int[]{android.R.attr.state_focused}, 230 | new ColorDrawable(baseColor)); 231 | stateListDrawable.addState(new int[0], 232 | new ColorDrawable(rowColor)); 233 | 234 | return stateListDrawable; 235 | } 236 | 237 | /** 238 | * Returns the color for the specified position based on the color degradation 239 | * 240 | * @param position the position of the view in the list to be colored 241 | * @return the color for the specified position 242 | */ 243 | public int getColor(int position) 244 | { 245 | if (mListLength <= MAX_STATIC_LENGTH) 246 | { 247 | return mStaticColorList.get(position); 248 | } 249 | 250 | return getColor(mIncrementsHSVValue, position); 251 | } 252 | 253 | private int getColor(float incrementsHSVValue, int rowPosition) 254 | { 255 | float[] hsv = ColorUtils.colorToHSV(mTheme.getColor(mContext)); 256 | hsv[2] = mMaxHSVValue - (incrementsHSVValue * rowPosition); 257 | return Color.HSVToColor(hsv); 258 | } 259 | } -------------------------------------------------------------------------------- /library/src/main/java/com/smarttie/coloredlist/lib/utils/ColorUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | *

4 | * Copyright (c) 2016 Smarttie Software, Inc. 5 | *

6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | *

13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | *

16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.smarttie.coloredlist.lib.utils; 26 | 27 | 28 | import android.graphics.Color; 29 | 30 | /** 31 | * Utility class that holds methods related to color processing 32 | */ 33 | public class ColorUtils 34 | { 35 | /** 36 | * Convert an ARGB color to its hexadecimal representation 37 | * 38 | * @param color an ARGB color 39 | * @return the resulting hexadecimal representation for the received color 40 | */ 41 | public static String colorToHex(int color) 42 | { 43 | return String.format("#%06X", (0xFFFFFF & color)); 44 | } 45 | 46 | /** 47 | * Convert an ARGB color to HSV components 48 | * 49 | * @param color an ARGB color 50 | * @return the HSV components for the specified color 51 | */ 52 | public static float[] colorToHSV(int color) 53 | { 54 | int r = Color.red(color); 55 | int g = Color.green(color); 56 | int b = Color.blue(color); 57 | 58 | float[] hsv = new float[3]; 59 | Color.RGBToHSV(r, g, b, hsv); 60 | return hsv; 61 | } 62 | } -------------------------------------------------------------------------------- /library/src/main/java/com/smarttie/coloredlist/lib/widget/ColoredListAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | *

4 | * Copyright (c) 2016 Smarttie Software, Inc. 5 | *

6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | *

13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | *

16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.smarttie.coloredlist.lib.widget; 26 | 27 | import android.content.Context; 28 | import android.support.v7.widget.RecyclerView; 29 | 30 | import com.smarttie.coloredlist.lib.manager.ColorTheme; 31 | import com.smarttie.coloredlist.lib.manager.ColoredListManager; 32 | 33 | /** 34 | * Base Adapter used along with a RecycleView to generate a colored list of elements. 35 | * This adapter provides specific methods to use when binding a view for a specific 36 | * position, to tint the view with the proper color corresponding for that position. 37 | */ 38 | public abstract class ColoredListAdapter extends 39 | RecyclerView.Adapter 40 | { 41 | private static final String TAG = "ColoredListAdapter"; 42 | private ColoredListManager mColoredListManager; 43 | 44 | 45 | /** 46 | * Returns the {@code ColoredListManager} used to tint the list generated by this 47 | * adapter. 48 | * 49 | * @return the {@code ColoredListManager} used to tint the list 50 | */ 51 | public ColoredListManager getColoredListManager() 52 | { 53 | return mColoredListManager; 54 | } 55 | 56 | /** 57 | * Constructs a new instance of {@code ColoredListAdapter} with the specified 58 | * color theme. 59 | * 60 | * @param contexts the context to access resources 61 | * @param colorTheme the color theme so use to tint the views for specific positions 62 | */ 63 | public ColoredListAdapter(Context contexts, ColorTheme colorTheme) 64 | { 65 | mColoredListManager = new ColoredListManager(contexts, colorTheme); 66 | registerAdapterDataObserver(mDataObserver); 67 | } 68 | 69 | /** 70 | * Returns the color for the specified position based on the color degradation 71 | * 72 | * @param position the position of the view in the list to be colored 73 | * @return the proper color to use to tint the view in the specified position 74 | */ 75 | public int getColor(int position) 76 | { 77 | return mColoredListManager.getColor(position); 78 | } 79 | 80 | /** 81 | * Specifies the base color theme used to color the list filled by this adapter 82 | * 83 | * @param theme the base color theme 84 | */ 85 | public void setColorTheme(ColorTheme theme) 86 | { 87 | mColoredListManager.setColorTheme(theme); 88 | notifyDataSetChanged(); 89 | } 90 | 91 | private RecyclerView.AdapterDataObserver mDataObserver 92 | = new RecyclerView.AdapterDataObserver() 93 | { 94 | @Override 95 | public void onChanged() 96 | { 97 | super.onChanged(); 98 | mColoredListManager.updateListLength(getItemCount()); 99 | } 100 | }; 101 | } -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #F44336 6 | #E91E63 7 | #FA029E 8 | #9C27B0 9 | #673AB7 10 | #3F51B5 11 | #2196F3 12 | #03A9F4 13 | #00BCD4 14 | #009688 15 | #4CAF50 16 | #8BC34A 17 | #CDDC39 18 | #FFEB3B 19 | #FFC107 20 | #FF9800 21 | #FF5722 22 | #795548 23 | #9E9E9E 24 | #607D8B 25 | #000000 26 | #FFFFFF 27 | 28 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ColoredList 3 | 4 | -------------------------------------------------------------------------------- /library/src/test/java/com/smarttie/coloredlist/lib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.lib; 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 | { 12 | @Test 13 | public void addition_isCorrect() throws Exception 14 | { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.smarttie.coloredlist.sample" 9 | minSdkVersion 10 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | compile 'com.android.support:recyclerview-v7:23.3.0' 27 | compile project(':library') 28 | } 29 | -------------------------------------------------------------------------------- /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 /Users/angellopez/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 | -------------------------------------------------------------------------------- /sample/sample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/smarttie/coloredlist/sample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.sample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase 10 | { 11 | public ApplicationTest() 12 | { 13 | super(Application.class); 14 | } 15 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/java/com/smarttie/coloredlist/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.sample; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | 9 | import com.smarttie.coloredlist.lib.manager.ColorTheme; 10 | 11 | public class MainActivity extends AppCompatActivity 12 | { 13 | 14 | private RecyclerView mRecyclerView; 15 | private SimpleAdapter mAdapter; 16 | private RecyclerView.LayoutManager mLayoutManager; 17 | private String[] mItems; 18 | private int mCurrentThemePosition = 0; 19 | 20 | private Handler mHandler = new Handler(); 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) 24 | { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_main); 27 | 28 | mLayoutManager = new LinearLayoutManager(this); 29 | mAdapter = new SimpleAdapter(this, ColorTheme.RED); 30 | 31 | mRecyclerView = (RecyclerView) findViewById(R.id.list_recycle_view); 32 | mRecyclerView.setLayoutManager(mLayoutManager); 33 | mRecyclerView.setAdapter(mAdapter); 34 | 35 | mItems = getResources().getStringArray(R.array.item_list); 36 | mHandler.post(mUpdateListRunnable); 37 | } 38 | 39 | private final Runnable mUpdateListRunnable = new Runnable() 40 | { 41 | @Override 42 | public void run() 43 | { 44 | int position = mAdapter.getItemCount(); 45 | if (position < mItems.length) 46 | { 47 | mAdapter.add(mItems[position]); 48 | mHandler.postDelayed(mUpdateListRunnable, 600); 49 | } 50 | else if ((mCurrentThemePosition + 1) < ColorTheme.values().length) 51 | { 52 | mCurrentThemePosition++; 53 | mAdapter.setColorTheme(ColorTheme.values()[mCurrentThemePosition]); 54 | mHandler.postDelayed(mUpdateListRunnable, 3000); 55 | } 56 | } 57 | }; 58 | } -------------------------------------------------------------------------------- /sample/src/main/java/com/smarttie/coloredlist/sample/SimpleAdapter.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.sample; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.smarttie.coloredlist.lib.manager.ColorTheme; 12 | import com.smarttie.coloredlist.lib.widget.ColoredListAdapter; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Arrays; 16 | 17 | public class SimpleAdapter extends ColoredListAdapter 18 | { 19 | private static final String TAG = "SimpleAdapter"; 20 | 21 | private ArrayList mDataSet; 22 | 23 | public static class ViewHolder extends RecyclerView.ViewHolder 24 | { 25 | public TextView mTitleTextView; 26 | 27 | public ViewHolder(View v) 28 | { 29 | super(v); 30 | mTitleTextView = (TextView) v.findViewById(R.id.title_text_view); 31 | } 32 | } 33 | 34 | public SimpleAdapter(Context contexts, ColorTheme colorTheme) 35 | { 36 | super(contexts, colorTheme); 37 | mDataSet = new ArrayList<>(); 38 | } 39 | 40 | @Override 41 | public int getItemCount() 42 | { 43 | return mDataSet.size(); 44 | } 45 | 46 | public void add(String item) 47 | { 48 | mDataSet.add(item); 49 | notifyDataSetChanged(); 50 | } 51 | 52 | public void addAll(String[] items) 53 | { 54 | mDataSet.addAll(Arrays.asList(items)); 55 | notifyDataSetChanged(); 56 | } 57 | 58 | @Override 59 | public SimpleAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, 60 | int viewType) 61 | { 62 | View v = LayoutInflater.from(parent.getContext()) 63 | .inflate(R.layout.list_item, parent, false); 64 | 65 | return new ViewHolder(v); 66 | } 67 | 68 | @Override 69 | public void onBindViewHolder(SimpleAdapter.ViewHolder holder, int position) 70 | { 71 | Log.i(TAG, "onBindViewHolder: " + position); 72 | holder.mTitleTextView.setText(mDataSet.get(position)); 73 | holder.itemView.setBackgroundColor(getColor(position)); 74 | } 75 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Smarttie/android-colored-list/dc83aa0ab5aac59f3a3883291a49ba4398e76894/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ColoredList 3 | 4 | 5 | Sara Robinson 6 | Norma Barnes 7 | Janice Walker 8 | Annie Martin 9 | Victor Thompson 10 | Alan Rodriguez 11 | Brenda Ward 12 | Douglas Carter 13 | Joyce Gray 14 | Steve Bryant 15 | Christina Henderson 16 | Helen Johnson 17 | Paul Garcia 18 | Doris Young 19 | Stephen Brown 20 | Richard Collins 21 | Joe Flores 22 | Jose James 23 | Sarah Campbell 24 | Maria Foster 25 | Lori Wilson 26 | Steven Simmons 27 | Craig Parker 28 | Heather Washington 29 | Anthony Howard 30 | 31 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/smarttie/coloredlist/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.smarttie.coloredlist.sample; 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 | { 12 | @Test 13 | public void addition_isCorrect() throws Exception 14 | { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | --------------------------------------------------------------------------------