Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
myinnos authored Jun 4, 2018
2 parents 71186cc + 3f3a180 commit 818eda3
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 128 deletions.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allprojects {
And then in the other gradle file(may be your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)
```java
dependencies {
compile 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.8'
compile 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.92'
}
```
How to use
Expand Down Expand Up @@ -79,10 +79,14 @@ Features
- Change IndexBarTextColor:
```java
mRecyclerView.setIndexBarTextColor("#FFFFFF");

mRecyclerView.setIndexBarTextColor(R.color.index_bar_text_color);
```
- Change IndexBarColor:
```java
mRecyclerView.setIndexBarColor("#33334c");

mRecyclerView.setIndexBarColor(R.color.index_bar_color);
```
- Change IndexBarCornerRadius:
```java
Expand Down Expand Up @@ -120,6 +124,8 @@ mRecyclerView.setIndexBarVisibility(true);
- Change IndexBarHighLateTextColor:
```java
mRecyclerView.setIndexbarHighLateTextColor("#33334c);
mRecyclerView.setIndexbarHighLateTextColor(R.color.index_bar_highlight_text_color);
```
- To hide/show IndexBarHighLateText:
```java
Expand Down
15 changes: 11 additions & 4 deletions alphabetsindexfastscrollrecycler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
final SDK_VERSION = '25.1.0'
final SDK_VERSION = '25.3.1'
apply plugin: 'com.github.dcendents.android-maven' // ADD THIS

group='com.github.jitpack'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 15
Expand All @@ -22,12 +22,19 @@ android {
}
}

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${SDK_VERSION}"
compile "com.android.support:design:${SDK_VERSION}"

androidTestCompile 'com.android.support.test:runner:1.0.0'
}

// build a jar with source files
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.myinnos.alphabetsindexfastscrollrecycler">

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">
<application >

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Created by MyInnos on 31-01-2017.
*/

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
Expand All @@ -13,6 +14,7 @@
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.support.annotation.ColorInt;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
Expand Down Expand Up @@ -45,10 +47,19 @@ public class IndexFastScrollRecyclerSection extends RecyclerView.AdapterDataObse
private Typeface setTypeface = null;
private Boolean setIndexBarVisibility = true;
private Boolean setSetIndexBarHighLateTextVisibility = false;
private String indexbarBackgroudColor;
private String indexbarTextColor;
private String indexbarHighLateTextColor;

private @ColorInt
int indexbarBackgroudColor;
private @ColorInt
int indexbarTextColor;
private @ColorInt
int indexbarHighLateTextColor;

private int setPreviewTextSize;
private @ColorInt
int previewBackgroundColor;
private @ColorInt
int previewTextColor;
private int previewBackgroudAlpha;
private int indexbarBackgroudAlpha;

private int indexPaintPaintColor = Color.WHITE;
Expand All @@ -60,6 +71,11 @@ public IndexFastScrollRecyclerSection(Context context, IndexFastScrollRecyclerVi
setIndexbarWidth = rv.mIndexbarWidth;
setIndexbarMargin = rv.mIndexbarMargin;
setPreviewPadding = rv.mPreviewPadding;
setPreviewTextSize = rv.mPreviewTextSize;
previewBackgroundColor = rv.mPreviewBackgroudColor;
previewTextColor = rv.mPreviewTextColor;
previewBackgroudAlpha = convertTransparentValueToBackgroundAlpha(rv.mPreviewTransparentValue);

setIndexBarCornerRadius = rv.mIndexBarCornerRadius;
indexbarBackgroudColor = rv.mIndexbarBackgroudColor;
indexbarTextColor = rv.mIndexbarTextColor;
Expand All @@ -82,7 +98,7 @@ public void draw(Canvas canvas) {
if (setIndexBarVisibility) {

Paint indexbarPaint = new Paint();
indexbarPaint.setColor(Color.parseColor(indexbarBackgroudColor));
indexbarPaint.setColor(indexbarBackgroudColor);
indexbarPaint.setAlpha(indexbarBackgroudAlpha);
indexbarPaint.setAntiAlias(true);
canvas.drawRoundRect(mIndexbarRect, setIndexBarCornerRadius * mDensity, setIndexBarCornerRadius * mDensity, indexbarPaint);
Expand All @@ -91,32 +107,33 @@ public void draw(Canvas canvas) {
// Preview is shown when mCurrentSection is set
if (previewVisibility && mCurrentSection >= 0 && mSections[mCurrentSection] != "") {
Paint previewPaint = new Paint();
previewPaint.setColor(Color.BLACK);
previewPaint.setAlpha(96);
previewPaint.setColor(previewBackgroundColor);
previewPaint.setAlpha(previewBackgroudAlpha);
previewPaint.setAntiAlias(true);
previewPaint.setShadowLayer(3, 0, 0, Color.argb(64, 0, 0, 0));

Paint previewTextPaint = new Paint();
previewTextPaint.setColor(Color.WHITE);
previewTextPaint.setColor(previewTextColor);
previewTextPaint.setAntiAlias(true);
previewTextPaint.setTextSize(50 * mScaledDensity);
previewTextPaint.setTextSize(setPreviewTextSize * mScaledDensity);
previewTextPaint.setTypeface(setTypeface);

float previewTextWidth = previewTextPaint.measureText(mSections[mCurrentSection]);
float previewSize = 2 * mPreviewPadding + previewTextPaint.descent() - previewTextPaint.ascent();
previewSize = Math.max(previewSize, previewTextWidth + 2 * mPreviewPadding);
RectF previewRect = new RectF((mListViewWidth - previewSize) / 2
, (mListViewHeight - previewSize) / 2
, (mListViewWidth - previewSize) / 2 + previewSize
, (mListViewHeight - previewSize) / 2 + previewSize);

canvas.drawRoundRect(previewRect, 5 * mDensity, 5 * mDensity, previewPaint);
canvas.drawText(mSections[mCurrentSection], previewRect.left + (previewSize - previewTextWidth) / 2 - 1
, previewRect.top + mPreviewPadding - previewTextPaint.ascent() + 1, previewTextPaint);
, previewRect.top + (previewSize - (previewTextPaint.descent() - previewTextPaint.ascent())) / 2 - previewTextPaint.ascent(), previewTextPaint);
fade(300);
}

Paint indexPaint = new Paint();
indexPaint.setColor(Color.parseColor(indexbarTextColor));
indexPaint.setColor(indexbarTextColor);
indexPaint.setAntiAlias(true);
indexPaint.setTextSize(setIndexTextSize * mScaledDensity);
indexPaint.setTypeface(setTypeface);
Expand All @@ -130,11 +147,11 @@ public void draw(Canvas canvas) {
if (mCurrentSection > -1 && i == mCurrentSection) {
indexPaint.setTypeface(Typeface.create(setTypeface, Typeface.BOLD));
indexPaint.setTextSize((setIndexTextSize + 3) * mScaledDensity);
indexPaint.setColor(Color.parseColor(indexbarHighLateTextColor));
indexPaint.setColor(indexbarHighLateTextColor);
} else {
indexPaint.setTypeface(setTypeface);
indexPaint.setTextSize(setIndexTextSize * mScaledDensity);
indexPaint.setColor(Color.parseColor(indexbarTextColor));
indexPaint.setColor(indexbarTextColor);
}
float paddingLeft = (mIndexbarWidth - indexPaint.measureText(mSections[i])) / 2;
canvas.drawText(mSections[i], mIndexbarRect.left + paddingLeft
Expand Down Expand Up @@ -247,6 +264,21 @@ private void fade(long delay) {
if (mLastFadeRunnable != null) {
mRecyclerView.removeCallbacks(mLastFadeRunnable);
}
}
mHandler.removeMessages(0);
mHandler.sendEmptyMessageAtTime(WHAT_FADE_PREVIEW, SystemClock.uptimeMillis() + delay);
}

@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {

@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);

if (msg.what == WHAT_FADE_PREVIEW) {
mRecyclerView.invalidate();
}
mLastFadeRunnable = new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -324,24 +356,52 @@ public void setPreviewVisibility(boolean shown) {
previewVisibility = shown;
}

/**
* @param value int to set the text size of the preview box
*/
public void setPreviewTextSize(int value) {
setPreviewTextSize = value;
}

/**
* @param color The color for the preview box
*/
public void setPreviewColor(@ColorInt int color) {
previewBackgroundColor = color;
}

/**
* @param color The text color for the preview box
*/
public void setPreviewTextColor(@ColorInt int color) {
previewTextColor = color;
}

/**
* @param value float to set the transparency value of the preview box
*/
public void setPreviewTransparentValue(float value) {
previewBackgroudAlpha = convertTransparentValueToBackgroundAlpha(value);
}

/**
* @param color The color for the scroll track
*/
public void setIndexBarColor(String color) {
public void setIndexBarColor(@ColorInt int color) {
indexbarBackgroudColor = color;
}

/**
* @param color The text color for the index bar
*/
public void setIndexBarTextColor(String color) {
public void setIndexBarTextColor(@ColorInt int color) {
indexbarTextColor = color;
}

/**
* @param color The text color for the index bar
*/
public void setIndexBarHighLateTextColor(String color) {
public void setIndexBarHighLateTextColor(@ColorInt int color) {
indexbarHighLateTextColor = color;
}

Expand Down
Loading

0 comments on commit 818eda3

Please sign in to comment.