diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9c4de58
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..8d31931
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+MaterialScrollBar
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..6fdf987
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..897879b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c0370da
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MaterialScrollBar.iml b/MaterialScrollBar.iml
new file mode 100644
index 0000000..98d4177
--- /dev/null
+++ b/MaterialScrollBar.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/app.iml b/app/app.iml
new file mode 100644
index 0000000..ab9ffeb
--- /dev/null
+++ b/app/app.iml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..7aad36f
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,29 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "23.0.0"
+
+ defaultConfig {
+ applicationId "com.turingtechnologies.materialscrollbardemo"
+ minSdkVersion 9
+ targetSdkVersion 23
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ compile 'com.android.support:recyclerview-v7:23.0.0'
+ compile 'org.apache.commons:commons-lang3:3.4'
+ compile project(':lib')
+ compile 'com.pnikosis:materialish-progress:1.5'
+ compile 'com.android.support:appcompat-v7:23.0.0'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..a1a81d3
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Program Files (x86)\Android\SDK/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/app/src/androidTest/java/com/turingtechnologies/materialscrollbardemo/ApplicationTest.java b/app/src/androidTest/java/com/turingtechnologies/materialscrollbardemo/ApplicationTest.java
new file mode 100644
index 0000000..cb5d649
--- /dev/null
+++ b/app/src/androidTest/java/com/turingtechnologies/materialscrollbardemo/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.turingtechnologies.materialscrollbardemo;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..b112ef9
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/turingtechnologies/materialscrollbardemo/DemoAdapter.java b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/DemoAdapter.java
new file mode 100644
index 0000000..eaa8e1f
--- /dev/null
+++ b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/DemoAdapter.java
@@ -0,0 +1,113 @@
+package com.turingtechnologies.materialscrollbardemo;
+
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.turingtechnologies.materialscrollbar.INameableAdapter;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+
+public class DemoAdapter extends RecyclerView.Adapter implements INameableAdapter{
+
+ public ArrayList filterLabel = new ArrayList<>();
+ public ArrayList filterIcon = new ArrayList<>();
+ public ArrayList filterPackage = new ArrayList<>();
+ public boolean fil = false;
+ private Activity act;
+
+ DemoAdapter(PackageManager pman, Activity a){
+ act = a;
+ }
+
+ public void setFilter(final String f) {
+ filterLabel.clear();
+ filterIcon.clear();
+ filterPackage.clear();
+ if (!f.equals("")) {
+ fil = true;
+ for (int i = 0; i < SplashActivity.pkgLabelList.size(); i++) {
+ if (StringUtils.containsIgnoreCase(SplashActivity.pkgLabelList.get(i), f)) {
+ filterLabel.add(SplashActivity.pkgLabelList.get(i));
+ filterIcon.add(SplashActivity.pkgIconList.get(i));
+ filterPackage.add(SplashActivity.pkgPackageList.get(i));
+ }
+ }
+ } else {
+ fil = false;
+ }
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public Character getCharacterForElement(int element) {
+ if(fil){
+ Character c = filterLabel.get(element).charAt(0);
+ if(Character.isDigit(c)){
+ c = '#';
+ }
+ return c;
+ } else {
+ Character c = SplashActivity.pkgLabelList.get(element).charAt(0);
+ if(Character.isDigit(c)){
+ c = '#';
+ }
+ return c;
+ }
+ }
+
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ // each data item is just a string in this case
+ public TextView label;
+ public ImageView icon;
+ public ViewHolder(View v) {
+ super(v);
+ label = (TextView) v.findViewById(R.id.textView);
+ icon = (ImageView) v.findViewById(R.id.imageView);
+ }
+ }
+
+ @Override
+ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout, parent, false);
+ return new ViewHolder(v);
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolder holder, int position) {
+ if(fil){
+ holder.label.setText(filterLabel.get(position));
+ holder.icon.setImageDrawable(filterIcon.get(position));
+ } else {
+ holder.label.setText(SplashActivity.pkgLabelList.get(position));
+ holder.icon.setImageDrawable(SplashActivity.pkgIconList.get(position));
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ if(fil){
+ return filterLabel.size();
+ } else {
+ try{
+ return SplashActivity.pkgLabelList.size();
+ } catch (NullPointerException e){
+ Intent i = new Intent(act, SplashActivity.class);
+ i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ act.startActivity(i);
+ }
+ return 0;
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/turingtechnologies/materialscrollbardemo/MainActivity.java b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/MainActivity.java
new file mode 100644
index 0000000..380ef0c
--- /dev/null
+++ b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/MainActivity.java
@@ -0,0 +1,27 @@
+package com.turingtechnologies.materialscrollbardemo;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+
+import com.turingtechnologies.materialscrollbar.MaterialScrollBar;
+import com.turingtechnologies.materialscrollbar.SectionIndicator;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ RecyclerView recyclerView = ((RecyclerView)findViewById(R.id.recyclerView));
+ MaterialScrollBar materialScrollBar = ((MaterialScrollBar) findViewById(R.id.materialScrollBar));
+ recyclerView.setAdapter(new DemoAdapter(getPackageManager(), this));
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ materialScrollBar.setRecyclerView(recyclerView);
+ materialScrollBar.setSectionIndicator((SectionIndicator) findViewById(R.id.sectionIndicator));
+
+ }
+
+}
diff --git a/app/src/main/java/com/turingtechnologies/materialscrollbardemo/SplashActivity.java b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/SplashActivity.java
new file mode 100644
index 0000000..ddb4686
--- /dev/null
+++ b/app/src/main/java/com/turingtechnologies/materialscrollbardemo/SplashActivity.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2015, Turing Technologies, an unincorporated organisation of Wynne Plaga
+ */
+
+package com.turingtechnologies.materialscrollbardemo;
+
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class SplashActivity extends AppCompatActivity {
+
+ private List pkgAppsList;
+ public static ArrayList pkgLabelList = new ArrayList<>();
+ public static ArrayList pkgIconList = new ArrayList<>();
+ public static ArrayList pkgPackageList = new ArrayList<>();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_splash);
+
+ getSupportActionBar().hide();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+
+ getWindow().setStatusBarColor(Color.TRANSPARENT);
+ }
+
+ pkgAppsList = getPackageManager().getInstalledApplications(PackageManager.GET_ACTIVITIES);
+ for(int i = 0; i < pkgAppsList.size(); i++){
+ if(getPackageManager().getLaunchIntentForPackage(pkgAppsList.get(i).packageName) == null || (!BuildConfig.DEBUG && pkgAppsList.get(i).packageName.contains("com.turingtechnologies.youNote"))){
+ pkgAppsList.remove(i);
+ i--;
+ }
+ }
+
+ class Alpha extends Thread{
+
+ @Override
+ public void run() {
+ Collections.sort(pkgAppsList, new Comparator() {
+ @Override
+ public int compare(ApplicationInfo o1, ApplicationInfo o2) {
+ return o1.loadLabel(getPackageManager()).toString().compareTo(o2.loadLabel(getPackageManager()).toString());
+ }
+ });
+ for(int i = 0; i < pkgAppsList.size(); i++){
+ pkgLabelList.add(pkgAppsList.get(i).loadLabel(getPackageManager()).toString());
+ }
+ for(int i = 0; i < pkgAppsList.size(); i++){
+ pkgPackageList.add(pkgAppsList.get(i).packageName);
+ }
+ for(int i = 0; i < pkgAppsList.size(); i++){
+ pkgIconList.add(pkgAppsList.get(i).loadIcon(getPackageManager()));
+ }
+ pkgAppsList = null;
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Intent main = new Intent(getApplicationContext(), MainActivity.class);
+ startActivity(main);
+ }
+ });
+ }
+ }
+
+ Alpha alpha = new Alpha();
+ alpha.setName("App Sorter");
+ alpha.setPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
+ alpha.start();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..5317084
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml
new file mode 100644
index 0000000..ce76004
--- /dev/null
+++ b/app/src/main/res/layout/activity_splash.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/app/src/main/res/layout/item_layout.xml b/app/src/main/res/layout/item_layout.xml
new file mode 100644
index 0000000..57546a4
--- /dev/null
+++ b/app/src/main/res/layout/item_layout.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..d781ec5
--- /dev/null
+++ b/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 64dp
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..db5dc0d
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,6 @@
+
+ Material ScrollBar demo
+
+ Hello world!
+ Settings
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..f0b1b63
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..1b7886d
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,19 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.3.0'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..88d406e
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Aug 21 23:28:38 EDT 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 0000000..4992a32
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1,7 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+.DS_Store
+.idea
+*.iml
+/build
\ No newline at end of file
diff --git a/lib/build.gradle b/lib/build.gradle
new file mode 100644
index 0000000..b5a14dc
--- /dev/null
+++ b/lib/build.gradle
@@ -0,0 +1,19 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "23.0.0"
+
+ defaultConfig {
+ minSdkVersion 7
+ targetSdkVersion 23
+ versionCode 3
+ versionName "2.0"
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ compile 'com.nineoldandroids:library:2.4.0'
+ compile 'com.android.support:recyclerview-v7:23.0.0'
+}
\ No newline at end of file
diff --git a/lib/gradle.properties b/lib/gradle.properties
new file mode 100644
index 0000000..c7001c1
--- /dev/null
+++ b/lib/gradle.properties
@@ -0,0 +1,3 @@
+POM_NAME=Material Scroll Bar
+POM_ARTIFACT_ID=materialScrollBar
+POM_PACKAGING=aar
\ No newline at end of file
diff --git a/lib/gradle/wrapper/gradle-wrapper.jar b/lib/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/lib/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/lib/gradle/wrapper/gradle-wrapper.properties b/lib/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..4b5d586
--- /dev/null
+++ b/lib/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Aug 19 23:30:01 EDT 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/lib/gradlew b/lib/gradlew
new file mode 100644
index 0000000..91a7e26
--- /dev/null
+++ b/lib/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/lib/gradlew.bat b/lib/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/lib/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/proguard-rules.pro b/lib/proguard-rules.pro
new file mode 100644
index 0000000..a1a81d3
--- /dev/null
+++ b/lib/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Program Files (x86)\Android\SDK/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/lib/src/androidTest/java/com/turingtechnologies/materialscrollbar/ApplicationTest.java b/lib/src/androidTest/java/com/turingtechnologies/materialscrollbar/ApplicationTest.java
new file mode 100644
index 0000000..87f3749
--- /dev/null
+++ b/lib/src/androidTest/java/com/turingtechnologies/materialscrollbar/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.turingtechnologies.materialscrollbar;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2aa7b96
--- /dev/null
+++ b/lib/src/main/AndroidManifest.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbar/INameableAdapter.java b/lib/src/main/java/com/turingtechnologies/materialscrollbar/INameableAdapter.java
new file mode 100644
index 0000000..b4d65db
--- /dev/null
+++ b/lib/src/main/java/com/turingtechnologies/materialscrollbar/INameableAdapter.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2015, Turing Technologies, an unincorporated organisation of Wynne Plaga
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.turingtechnologies.materialscrollbar;
+
+public interface INameableAdapter {
+
+ /**
+ * This should return the character that the SectionIndicator should display for the corresponding element.
+ * @param element of the adapter that should be titled.
+ */
+ Character getCharacterForElement(int element);
+
+}
diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java b/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java
new file mode 100644
index 0000000..1ccc38a
--- /dev/null
+++ b/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java
@@ -0,0 +1,340 @@
+/*
+ * Copyright © 2015, Turing Technologies, an unincorporated organisation of Wynne Plaga
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.turingtechnologies.materialscrollbar;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.os.Build;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
+import android.widget.RelativeLayout;
+
+import com.nineoldandroids.view.ViewHelper;
+
+public class MaterialScrollBar extends RelativeLayout {
+
+ private View background;
+ private View handle;
+ protected int handleColour;
+ protected Activity a;
+ private ScrollListener scrollListener = new ScrollListener(this);
+ private boolean hidden = true;
+ private int hideDuration = 2500;
+ private boolean hide = true;
+ protected RecyclerView recyclerView;
+ private SectionIndicator sectionIndicator;
+
+ class BarFade extends Thread {
+
+ MaterialScrollBar materialScrollBar;
+
+ BarFade(MaterialScrollBar msb){
+ materialScrollBar = msb;
+ }
+
+ long time = 0;
+ boolean run = false;
+
+ @Override
+ public void run() {
+ try{
+ while(true){
+ if(time <= System.currentTimeMillis() && run){
+ run = false;
+ materialScrollBar.a.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
+ anim.setDuration(500);
+ anim.setFillAfter(true);
+ hidden = true;
+ materialScrollBar.startAnimation(anim);
+ }
+ });
+ }
+ Thread.sleep(100);
+ }
+ } catch (InterruptedException e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+ BarFade fade;
+
+ public MaterialScrollBar(Context context, AttributeSet attributeSet){
+ super(context, attributeSet);
+
+ if(!isInEditMode()){
+ a = (Activity) context;
+ }
+ background = new View(context);
+ LayoutParams lp = new RelativeLayout.LayoutParams((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()), LayoutParams.MATCH_PARENT);
+ lp.addRule(ALIGN_PARENT_RIGHT);
+ background.setLayoutParams(lp);
+ TypedArray attributes = getContext().getTheme().obtainStyledAttributes(attributeSet, R.styleable.MaterialScrollBar, 0, 0);
+ background.setBackgroundColor(attributes.getColor(R.styleable.MaterialScrollBar_barColour, getResources().getColor(android.R.color.darker_gray)));
+ com.nineoldandroids.view.ViewHelper.setAlpha(background, 0.4F);
+
+ handle = new View(context);
+ lp = new RelativeLayout.LayoutParams((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()),
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, getResources().getDisplayMetrics()));
+ lp.addRule(ALIGN_PARENT_RIGHT);
+ handle.setLayoutParams(lp);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ handleColour = attributes.getColor(R.styleable.MaterialScrollBar_handleColour, fetchAccentColor(context));
+ handle.setBackgroundColor(handleColour);
+ } else {
+ handleColour = attributes.getColor(R.styleable.MaterialScrollBar_handleColour, Color.parseColor("#9c9c9c"));
+ handle.setBackgroundColor(handleColour);
+ }
+
+ addView(background);
+ addView(handle);
+
+ setTouchIntercept();
+
+ fade = new BarFade(this);
+ fade.start();
+
+ TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
+ anim.setFillAfter(true);
+ startAnimation(anim);
+ }
+
+ /**
+ * @param rv to assign as the ScrollBar's recycler view.
+ */
+ public MaterialScrollBar setRecyclerView(RecyclerView rv){
+ recyclerView = rv;
+ rv.addOnScrollListener(this.scrollListener);
+ return this;
+ }
+
+ class recyclerViewNotSetException extends RuntimeException{
+ public recyclerViewNotSetException(String message) { super(message); }
+ }
+
+ private void setTouchIntercept(){
+ setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() != MotionEvent.ACTION_UP) {
+ try {
+ recyclerView.scrollToPosition((int) (recyclerView.getAdapter().getItemCount() * (event.getY() / (getHeight() - handle.getHeight()))));
+ if(sectionIndicator != null && sectionIndicator.getVisibility() == INVISIBLE){
+ sectionIndicator.setVisibility(VISIBLE);
+ }
+ } catch (NullPointerException e) {
+ throw new recyclerViewNotSetException("You failed to run setRecyclerView()! You must do this.");
+ }
+
+ if (hide) {
+ if (hidden) {
+ hidden = false;
+ TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
+ anim.setDuration(500);
+ anim.setFillAfter(true);
+ startAnimation(anim);
+ }
+ }
+ } else {
+ if(sectionIndicator != null && sectionIndicator.getVisibility() == VISIBLE){
+ sectionIndicator.setVisibility(INVISIBLE);
+ }
+
+ if (hide) {
+ fade.run = true;
+ fade.time = System.currentTimeMillis() + hideDuration;
+ }
+ }
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * Provides the ability to programmatically set the hide duration of the scrollbar.
+ * @param duration for the bar to remain visible after inactivity before hiding.
+ */
+ public MaterialScrollBar setHideDuration(int duration){
+ this.hideDuration = duration;
+ return this;
+ }
+
+ /**
+ * Provides the ability to programmatically set the colour of the scrollbar handle.
+ * @param colour to set the handle.
+ */
+ public MaterialScrollBar setHandleColour(String colour){
+ handle.setBackgroundColor(Color.parseColor(colour));
+ return this;
+ }
+
+ /**
+ * Provides the ability to programmatically set the colour of the scrollbar handle.
+ * @param colour to set the handle.
+ */
+ public MaterialScrollBar setHandleColour(int colour){
+ handle.setBackgroundColor(colour);
+ return this;
+ }
+
+ /**
+ * Provides the ability to programmatically set the colour of the scrollbar.
+ * @param colour to set the bar.
+ */
+ public MaterialScrollBar setBarColour(String colour){
+ background.setBackgroundColor(Color.parseColor(colour));
+ return this;
+ }
+
+ /**
+ * Provides the ability to programmatically set the colour of the scrollbar.
+ * @param colour to set the bar.
+ */
+ public MaterialScrollBar setBarColour(int colour){
+ background.setBackgroundColor(colour);
+ return this;
+ }
+
+ /**
+ * Provides the ability to programmatically alter whether the scrollbar
+ * should hide after a period of inactivity or not.
+ * @param hide sets whether the bar should hide or not.
+ */
+ public MaterialScrollBar setAutoHide(Boolean hide){
+ if(!hide){
+ fade.interrupt();
+ TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
+ anim.setFillAfter(true);
+ startAnimation(anim);
+ } else if (!this.hide){
+ fade.start();
+ }
+ this.hide = hide;
+ return this;
+ }
+
+ class adapterNotNameableException extends RuntimeException{
+ public adapterNotNameableException(String message) { super(message); }
+ }
+
+ /**
+ * Sets the section indicator which accompanies this scroll bar.
+ * @param sectionIndicator which should be paired to this scroll bar.
+ */
+ public MaterialScrollBar setSectionIndicator(SectionIndicator sectionIndicator) {
+ if(!(recyclerView.getAdapter() instanceof INameableAdapter)){
+ throw new adapterNotNameableException("In order to add a sectionIndicator, the adapter for your recyclerView MUST implement INameableAdapter.");
+ }
+ this.sectionIndicator = sectionIndicator;
+ sectionIndicator.pairScrollBar(this);
+ return this;
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ protected int fetchAccentColor(Context context) {
+ TypedValue typedValue = new TypedValue();
+
+ TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.colorAccent });
+ int color = a.getColor(0, 0);
+
+ a.recycle();
+
+ return color;
+ }
+
+ private class ScrollListener extends RecyclerView.OnScrollListener {
+
+ MaterialScrollBar materialScrollBar;
+
+ protected ScrollListener(MaterialScrollBar msb){
+ materialScrollBar = msb;
+ }
+
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ super.onScrolled(recyclerView, dx, dy);
+
+ ViewHelper.setY(handle, calculateScrollProgress(recyclerView) * (materialScrollBar.getHeight() - handle.getHeight()));
+ if(sectionIndicator != null && sectionIndicator.getVisibility() == VISIBLE){
+ sectionIndicator.setScroll(calculateScrollProgress(recyclerView) * (materialScrollBar.getHeight() - handle.getHeight()));
+ }
+ }
+
+ public float calculateScrollProgress(RecyclerView recyclerView) {
+ LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
+ int lastFullyVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
+
+ View visibleChild = recyclerView.getChildAt(0);
+ if (visibleChild == null) {
+ return 0;
+ }
+ RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(visibleChild);
+ int itemHeight = holder.itemView.getHeight();
+ int recyclerHeight = recyclerView.getHeight();
+ int itemsInWindow = recyclerHeight / itemHeight;
+
+ int numItemsInList = recyclerView.getAdapter().getItemCount();
+ int numScrollableSectionsInList = numItemsInList - itemsInWindow;
+ int indexOfLastFullyVisibleItemInFirstSection = numItemsInList - numScrollableSectionsInList - 1;
+
+ int currentSection = lastFullyVisiblePosition - indexOfLastFullyVisibleItemInFirstSection;
+ if(sectionIndicator.getVisibility() == VISIBLE){
+ if(currentSection == 0){
+ sectionIndicator.setCharacter(((INameableAdapter)recyclerView.getAdapter()).getCharacterForElement(currentSection));
+ } else {
+ sectionIndicator.setCharacter(((INameableAdapter)recyclerView.getAdapter()).getCharacterForElement(currentSection - 1));
+ }
+ }
+
+ return (float) currentSection / numScrollableSectionsInList;
+ }
+
+ @Override
+ public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+
+ if(hide){
+ if(newState == RecyclerView.SCROLL_STATE_IDLE){
+ fade.time = System.currentTimeMillis() + hideDuration;
+ fade.run = true;
+ } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
+ fade.run = false;
+ if(hidden){
+ hidden = false;
+ TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
+ anim.setDuration(500);
+ anim.setFillAfter(true);
+ materialScrollBar.startAnimation(anim);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbar/SectionIndicator.java b/lib/src/main/java/com/turingtechnologies/materialscrollbar/SectionIndicator.java
new file mode 100644
index 0000000..f315953
--- /dev/null
+++ b/lib/src/main/java/com/turingtechnologies/materialscrollbar/SectionIndicator.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2015, Turing Technologies, an unincorporated organisation of Wynne Plaga
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.turingtechnologies.materialscrollbar;
+
+
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Build;
+import android.support.v4.content.ContextCompat;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.ViewGroup;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.nineoldandroids.view.ViewHelper;
+
+public class SectionIndicator extends RelativeLayout{
+
+ MaterialScrollBar materialScrollBar;
+ RelativeLayout indicator;
+ TextView textView;
+
+ public SectionIndicator(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ indicator = new RelativeLayout(context);
+ if(Build.VERSION.SDK_INT >= 16){
+ indicator.setBackground(ContextCompat.getDrawable(context, R.drawable.indicator));
+ } else {
+ indicator.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.indicator));
+ }
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(getDP(100), getDP(100));
+ lp.setMargins(0, 0, getDP(8), 0);
+ setVisibility(INVISIBLE);
+
+ textView = new TextView(context);
+ textView.setText("#");
+ textView.setTextColor(getResources().getColor(android.R.color.white));
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50);
+ LayoutParams tvlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ tvlp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+
+ addView(indicator, lp);
+ indicator.addView(textView, tvlp);
+ }
+
+ protected void setScroll(float y){
+ y -= getDP(74);
+ if(y < 0){
+ y += getDP(98);
+ indicator.setScaleY(-1F);
+ textView.setScaleY(-1F);
+ ViewHelper.setY(indicator, y);
+ } else {
+ indicator.setScaleY(1F);
+ textView.setScaleY(1F);
+ ViewHelper.setY(indicator, y);
+ }
+ }
+
+ protected void setCharacter(Character c){
+ textView.setText(c.toString());
+ }
+
+ private int getDP(int dp){
+ return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
+ }
+
+ protected void pairScrollBar(MaterialScrollBar msb){
+ materialScrollBar = msb;
+ ((GradientDrawable)indicator.getBackground()).setColor(materialScrollBar.handleColour);
+ }
+
+}
\ No newline at end of file
diff --git a/lib/src/main/res/drawable/indicator.xml b/lib/src/main/res/drawable/indicator.xml
new file mode 100644
index 0000000..09c7229
--- /dev/null
+++ b/lib/src/main/res/drawable/indicator.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/values/attrs.xml b/lib/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..896f0f2
--- /dev/null
+++ b/lib/src/main/res/values/attrs.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/values/strings.xml b/lib/src/main/res/values/strings.xml
new file mode 100644
index 0000000..d852f1f
--- /dev/null
+++ b/lib/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ MaterialScrollBar
+
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..3a5a919
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':lib', ':app'