From 2cad8477b6c66f312d466d8c8ea6d3c550c0dede Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Thu, 7 Apr 2016 18:14:40 +0300
Subject: [PATCH 01/64] Fixes Release 1.1.2
---
library/build.gradle | 4 ++--
.../src/main/java/com/gigamole/library/NavigationTabBar.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/library/build.gradle b/library/build.gradle
index 7ad9b86..0d73c12 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.1"
+version = "1.1.2"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.1"
+ versionName "1.1.2"
}
buildTypes {
release {
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 8711fb8..a08e281 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -548,13 +548,13 @@ public void setOnTabBarSelectedIndexListener(final OnTabBarSelectedIndexListener
mAnimatorListener = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(final Animator animation) {
- if (mOnTabBarSelectedIndexListener != null && !mIsViewPagerMode)
+ if (mOnTabBarSelectedIndexListener != null)
mOnTabBarSelectedIndexListener.onStartTabSelected(mModels.get(mIndex), mIndex);
}
@Override
public void onAnimationEnd(final Animator animation) {
- if (mOnTabBarSelectedIndexListener != null && !mIsViewPagerMode)
+ if (mOnTabBarSelectedIndexListener != null)
mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
}
From 186517a46acdf52d2182ac040a56f237fef7913b Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Thu, 7 Apr 2016 18:15:35 +0300
Subject: [PATCH 02/64] Fixes Release 1.1.2
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index b6a35f6..c8e4299 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.1'
+compile 'com.github.devlight.navigationtabbar:library:1.1.2'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.1
+ 1.1.2
aar
```
From bc6101d49ed305cfb290910d0038446ad84f72b3 Mon Sep 17 00:00:00 2001
From: A-Ar Concepcion
Date: Fri, 8 Apr 2016 17:40:33 +0800
Subject: [PATCH 03/64] Add support for Vector Drawables
---
.../com/gigamole/library/NavigationTabBar.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index a08e281..3e5d508 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -1240,9 +1240,18 @@ public static class Model {
public Model(final Drawable icon, final int color) {
mColor = color;
- mIcon = icon != null ? ((BitmapDrawable) icon).getBitmap() :
- Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
-
+ if (icon != null) {
+ if(icon instanceof BitmapDrawable) {
+ mIcon = ((BitmapDrawable) icon).getBitmap();
+ } else {
+ mIcon = Bitmap.createBitmap(icon.getIntrinsicWidth(),icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(mIcon);
+ icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ icon.draw(canvas);
+ }
+ } else {
+ mIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
+ }
mBadgeAnimator.addListener(new Animator.AnimatorListener() {
@Override
From ab389091ee7ba352f7e4a95f5b4fdf0a5e06accb Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Mon, 11 Apr 2016 10:06:20 +0300
Subject: [PATCH 04/64] Update 1.1.3
---
README.md | 4 ++--
library/build.gradle | 4 ++--
.../gigamole/library/NavigationTabBar.java | 23 +++++++++++--------
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index c8e4299..9922b0a 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.2'
+compile 'com.github.devlight.navigationtabbar:library:1.1.3'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.2
+ 1.1.3
aar
```
diff --git a/library/build.gradle b/library/build.gradle
index 0d73c12..e77a152 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.2"
+version = "1.1.3"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.2"
+ versionName "1.1.3"
}
buildTypes {
release {
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 3e5d508..0bd73b7 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -969,12 +969,13 @@ else if (i == mIndex)
// Draw pointer with active color to wrap out active icon
if (mCornersRadius == 0) mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
- else mIconsCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
+ else
+ mIconsCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
// Draw general bitmap
canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
// Draw icons bitmap on top
- canvas.drawBitmap( mIconsBitmap, 0.0f, pointerBadgeMargin, null);
+ canvas.drawBitmap(mIconsBitmap, 0.0f, pointerBadgeMargin, null);
// If is not badged, exit
if (!mIsBadged) return;
@@ -1068,7 +1069,7 @@ private void updateCurrentModel(
model.mIconMatrix.postScale(
model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
matrixCenterX, matrixCenterY + (mIsTitled && mTitleMode == TitleMode.ACTIVE ?
- mTitleMargin * 0.5f * interpolation : 0.0f)
+ mTitleMargin * 0.5f * interpolation : 0.0f)
);
mModelTitlePaint.setTextSize(mModelTitleSize * textScale);
@@ -1097,7 +1098,7 @@ private void updateLastModel(
model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
matrixCenterX, matrixCenterY + (mIsTitled && mTitleMode == TitleMode.ACTIVE ?
- mTitleMargin * 0.5f - (mTitleMargin * 0.5f * lastInterpolation) : 0.0f)
+ mTitleMargin * 0.5f - (mTitleMargin * 0.5f * lastInterpolation) : 0.0f)
);
mModelTitlePaint.setTextSize(mModelTitleSize * textLastScale);
@@ -1241,17 +1242,21 @@ public static class Model {
public Model(final Drawable icon, final int color) {
mColor = color;
if (icon != null) {
- if(icon instanceof BitmapDrawable) {
- mIcon = ((BitmapDrawable) icon).getBitmap();
- } else {
- mIcon = Bitmap.createBitmap(icon.getIntrinsicWidth(),icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(mIcon);
+ if (icon instanceof BitmapDrawable) mIcon = ((BitmapDrawable) icon).getBitmap();
+ else {
+ mIcon = Bitmap.createBitmap(
+ icon.getIntrinsicWidth(),
+ icon.getIntrinsicHeight(),
+ Bitmap.Config.ARGB_8888
+ );
+ final Canvas canvas = new Canvas(mIcon);
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
icon.draw(canvas);
}
} else {
mIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
}
+
mBadgeAnimator.addListener(new Animator.AnimatorListener() {
@Override
From b331fe45b9de08571ed53aaf0c23783bd48c0422 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Mon, 18 Apr 2016 11:14:17 +0300
Subject: [PATCH 05/64] Update 1.1.4
---
README.md | 4 ++--
app/src/main/AndroidManifest.xml | 3 ++-
.../HorizontalNtbActivity.java | 14 ++++++++-----
library/build.gradle | 4 ++--
.../gigamole/library/NavigationTabBar.java | 20 ++++++++++++++++++-
5 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 9922b0a..8c79917 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.3'
+compile 'com.github.devlight.navigationtabbar:library:1.1.4'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.3
+ 1.1.4
aar
```
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f18db43..8bfe1ea 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,7 +17,8 @@
-
+
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
index 5bdc2ea..d01bf39 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
@@ -81,16 +81,20 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4]), "Medal"));
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
-
- navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
+ navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
- public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
+ public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
}
@Override
- public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
- model.hideBadge();
+ public void onPageSelected(final int position) {
+ navigationTabBar.getModels().get(position).hideBadge();
+ }
+
+ @Override
+ public void onPageScrollStateChanged(final int state) {
+
}
});
diff --git a/library/build.gradle b/library/build.gradle
index e77a152..224e105 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.3"
+version = "1.1.4"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.3"
+ versionName "1.1.4"
}
buildTypes {
release {
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 0bd73b7..df75632 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -19,6 +19,7 @@
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -1186,7 +1187,7 @@ public Parcelable onSaveInstanceState() {
return savedState;
}
- static class SavedState extends BaseSavedState {
+ private static class SavedState extends BaseSavedState {
int index;
public SavedState(Parcelable superState) {
@@ -1218,6 +1219,23 @@ public SavedState[] newArray(int size) {
};
}
+ @Override
+ protected void onConfigurationChanged(final Configuration newConfig) {
+ // Config view on rotate etc.
+ super.onConfigurationChanged(newConfig);
+ requestLayout();
+
+ // Refresh pointer and state after config changed to current
+ final int tempIndex = mIndex;
+ setModelIndex(INVALID_INDEX, true);
+ post(new Runnable() {
+ @Override
+ public void run() {
+ setModelIndex(tempIndex, true);
+ }
+ });
+ }
+
// Model class
public static class Model {
From 070796707768e1291b79f7e2ba2b7670a4c80b59 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 19 Apr 2016 23:24:26 +0300
Subject: [PATCH 06/64] Update 1.1.5
---
README.md | 9 ++-
.../res/layout/activity_horizontal_ntb.xml | 1 +
.../main/res/layout/activity_samples_ntb.xml | 2 +
library/build.gradle | 4 +-
.../gigamole/library/NavigationTabBar.java | 63 ++++++++++++++-----
library/src/main/res/values/attrs.xml | 1 +
6 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index 8c79917..92e7700 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.4'
+compile 'com.github.devlight.navigationtabbar:library:1.1.5'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.4
+ 1.1.5
aar
```
@@ -81,6 +81,10 @@ For NTB you can set such parameters as:
allows you to handle mode of the model title show. Can show all or only active.
+ - scale mode:
+
+ allows you to handle mode of the model icon and title scale.
+
- badge position:
allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).
@@ -187,6 +191,7 @@ And XML init:
app:ntb_inactive_color="#000"
app:ntb_badged="true"
app:ntb_titled="true"
+ app:ntb_scaled="true"
app:ntb_title_mode="all"
app:ntb_badge_position="right"
app:ntb_badge_gravity="top"
diff --git a/app/src/main/res/layout/activity_horizontal_ntb.xml b/app/src/main/res/layout/activity_horizontal_ntb.xml
index 5832815..701b0f8 100644
--- a/app/src/main/res/layout/activity_horizontal_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_ntb.xml
@@ -33,6 +33,7 @@
app:ntb_badge_gravity="top"
app:ntb_badge_position="right"
app:ntb_badged="true"
+ app:ntb_scaled="true"
app:ntb_title_mode="all"
app:ntb_titled="true"/>
diff --git a/app/src/main/res/layout/activity_samples_ntb.xml b/app/src/main/res/layout/activity_samples_ntb.xml
index 2e3f036..fc654e4 100644
--- a/app/src/main/res/layout/activity_samples_ntb.xml
+++ b/app/src/main/res/layout/activity_samples_ntb.xml
@@ -28,6 +28,7 @@
android:layout_gravity="center"
android:background="#605271"
app:ntb_active_color="#000"
+ app:ntb_scaled="false"
app:ntb_inactive_color="#fff"
app:ntb_animation_duration="1000"/>
@@ -108,6 +109,7 @@
app:ntb_animation_duration="400"
app:ntb_preview_colors="@array/red_wine"
app:ntb_corners_radius="50dp"
+ app:ntb_scaled="false"
app:ntb_active_color="#8d88e4"
app:ntb_inactive_color="#dddfec"/>
diff --git a/library/build.gradle b/library/build.gradle
index 224e105..9e9c365 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.4"
+version = "1.1.5"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.4"
+ versionName "1.1.5"
}
buildTypes {
release {
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index df75632..90a71ea 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -70,16 +70,17 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
private final static float MIN_FRACTION = 0.0f;
+ private final static float NON_SCALED_FRACTION = 0.35f;
private final static float MAX_FRACTION = 1.0f;
private final static int MIN_ALPHA = 0;
private final static int MAX_ALPHA = 255;
- private final static float ACTIVE_ICON_SCALE_BY = 0.35f;
- private final static float ICON_SIZE_FRACTION = 0.4f;
+ private final static float ACTIVE_ICON_SCALE_BY = 0.3f;
+ private final static float ICON_SIZE_FRACTION = 0.45f;
- private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.25f;
- private final static float TITLE_ICON_SIZE_FRACTION = 0.4f;
+ private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2f;
+ private final static float TITLE_ICON_SIZE_FRACTION = 0.45f;
private final static float TITLE_ACTIVE_SCALE_BY = 0.2f;
private final static float TITLE_SIZE_FRACTION = 0.2f;
private final static float TITLE_MARGIN_FRACTION = 0.15f;
@@ -227,6 +228,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private boolean mIsTitled;
// Detect if model has badge
private boolean mIsBadged;
+ // Detect if model icon scaled
+ private boolean mIsScaled;
// Detect if model badge have custom typeface
private boolean mIsBadgeUseTypeface;
// Detect if is bar mode or indicator pager mode
@@ -274,6 +277,9 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
setIsBadged(
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false)
);
+ setIsScaled(
+ typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true)
+ );
setIsBadgeUseTypeface(
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
);
@@ -395,6 +401,15 @@ public void setIsBadged(final boolean isBadged) {
requestLayout();
}
+ public boolean isScaled() {
+ return mIsScaled;
+ }
+
+ public void setIsScaled(final boolean isScaled) {
+ mIsScaled = isScaled;
+ requestLayout();
+ }
+
public boolean isBadgeUseTypeface() {
return mIsBadgeUseTypeface;
}
@@ -912,18 +927,26 @@ protected void onDraw(final Canvas canvas) {
// Get interpolated fraction for left last and current models
final float interpolation = mResizeInterpolator.getResizeInterpolation(mFraction, true);
final float lastInterpolation = mResizeInterpolator.getResizeInterpolation(mFraction, false);
+// final float interpolation =
+// mIsScaled ? mResizeInterpolator.getResizeInterpolation(mFraction, true);
+// final float lastInterpolation =
+// mIsScaled ? mResizeInterpolator.getResizeInterpolation(mFraction, false) :
+// (MAX_FRACTION - NON_SCALED_FRACTION);
// Scale value relative to interpolation
- final float matrixScale = model.mActiveIconScaleBy * interpolation;
- final float matrixLastScale = model.mActiveIconScaleBy * lastInterpolation;
+ final float matrixScale = model.mActiveIconScaleBy *
+ (mIsScaled ? interpolation : NON_SCALED_FRACTION);
+ final float matrixLastScale = model.mActiveIconScaleBy *
+ (mIsScaled ? lastInterpolation : (MAX_FRACTION - NON_SCALED_FRACTION));
// Get title alpha relative to interpolation
final int titleAlpha = (int) (MAX_ALPHA * interpolation);
final int titleLastAlpha = MAX_ALPHA - (int) (MAX_ALPHA * lastInterpolation);
// Get title scale relative to interpolation
- final float titleScale = MAX_FRACTION + (interpolation * TITLE_ACTIVE_SCALE_BY);
- final float titleLastScale = (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY) -
- (lastInterpolation * TITLE_ACTIVE_SCALE_BY);
+ final float titleScale = MAX_FRACTION +
+ ((mIsScaled ? interpolation : NON_SCALED_FRACTION) * TITLE_ACTIVE_SCALE_BY);
+ final float titleLastScale = mIsScaled ? (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY) -
+ (lastInterpolation * TITLE_ACTIVE_SCALE_BY) : titleScale;
// Check if we handle models from touch on NTP or from ViewPager
// There is a strange logic of ViewPager onPageScrolled method, so it is
@@ -940,12 +963,14 @@ else if (mLastIndex == i)
);
else
updateInactiveModel(
- model, leftOffset, topOffset, matrixCenterX, matrixCenterY
+ model, leftOffset, topOffset, titleScale,
+ matrixScale, matrixCenterX, matrixCenterY
);
} else {
if (i != mIndex && i != mIndex + 1)
updateInactiveModel(
- model, leftOffset, topOffset, matrixCenterX, matrixCenterY
+ model, leftOffset, topOffset, titleScale,
+ matrixScale, matrixCenterX, matrixCenterY
);
else if (i == mIndex + 1)
updateCurrentModel(
@@ -1111,17 +1136,25 @@ private void updateInactiveModel(
final Model model,
final float leftOffset,
final float topOffset,
+ final float textScale,
+ final float matrixScale,
final float matrixCenterX,
final float matrixCenterY
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(leftOffset, topOffset);
- model.mIconMatrix.postScale(
- model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
- );
+ if (mIsScaled)
+ model.mIconMatrix.postScale(
+ model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
+ );
+ else
+ model.mIconMatrix.postScale(
+ model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
+ matrixCenterX, matrixCenterY
+ );
- mModelTitlePaint.setTextSize(mModelTitleSize);
+ mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? 1.0f : textScale));
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(MIN_ALPHA);
}
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index 47ec2da..c3dc53d 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -4,6 +4,7 @@
+
From 84ad75fed989f4281b6e81ee23cf28f67d99c0af Mon Sep 17 00:00:00 2001
From: Mohamed Ezzat
Date: Fri, 29 Apr 2016 00:45:06 +0200
Subject: [PATCH 07/64] Multiple quality improvements
---
.../navigationtabbar/HorizontalNtbActivity.java | 2 ++
.../gigamole/navigationtabbar/MainActivity.java | 2 ++
.../com/gigamole/library/NavigationTabBar.java | 17 +++++++++--------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
index d01bf39..5acc3d3 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
@@ -128,6 +128,8 @@ public void run() {
case 4:
model.setBadgeTitle("777");
break;
+ default:
+ break;
}
navigationTabBar.postDelayed(new Runnable() {
@Override
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
index d549f35..21e46e3 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
@@ -63,6 +63,8 @@ public void onAnimationEnd(final View view) {
new Intent(MainActivity.this, SamplesNtbActivity.class)
);
break;
+ default:
+ break;
}
}
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 90a71ea..718adba 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -51,6 +51,7 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
/**
@@ -110,8 +111,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private RectF mBounds = new RectF();
private RectF mPointerBounds = new RectF();
// Badge bounds and bg badge bounds
- final Rect mBadgeBounds = new Rect();
- final RectF mBgBadgeBounds = new RectF();
+ private final Rect mBadgeBounds = new Rect();
+ private final RectF mBgBadgeBounds = new RectF();
// Canvas, where all of other canvas will be merged
private Bitmap mBitmap;
@@ -149,7 +150,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for icon mask pointer
- final Paint mIconPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mIconPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
{
setStyle(Style.FILL);
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
@@ -157,7 +158,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for model title
- final Paint mModelTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mModelTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
{
setDither(true);
setColor(Color.WHITE);
@@ -166,7 +167,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for badge
- final Paint mBadgePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mBadgePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
{
setDither(true);
setTextAlign(Align.CENTER);
@@ -180,7 +181,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private int mAnimationDuration;
// NTP models
- private ArrayList mModels = new ArrayList<>();
+ private List mModels = new ArrayList<>();
// Variables for ViewPager
private ViewPager mViewPager;
@@ -361,11 +362,11 @@ public void setAnimationDuration(final int animationDuration) {
resetScroller();
}
- public ArrayList getModels() {
+ public List getModels() {
return mModels;
}
- public void setModels(final ArrayList models) {
+ public void setModels(final List models) {
//Set update listeners to badge model animation
for (final Model model : models) {
model.mBadgeAnimator.removeAllUpdateListeners();
From baed5beb92b178d026f935e266f4046f202fd56b Mon Sep 17 00:00:00 2001
From: Mohamed Ezzat
Date: Thu, 5 May 2016 04:49:55 +0200
Subject: [PATCH 08/64] pmd:ImmutableField - Immutable Field
---
.../com/gigamole/library/NavigationTabBar.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 718adba..3e9d01d 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -108,8 +108,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static Interpolator ACCELERATE_INTERPOLATOR = new AccelerateInterpolator();
// NTP and pointer bounds
- private RectF mBounds = new RectF();
- private RectF mPointerBounds = new RectF();
+ private final RectF mBounds = new RectF();
+ private final RectF mPointerBounds = new RectF();
// Badge bounds and bg badge bounds
private final Rect mBadgeBounds = new Rect();
private final RectF mBgBadgeBounds = new RectF();
@@ -127,7 +127,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private Canvas mPointerCanvas;
// Main paint
- private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
{
setDither(true);
setStyle(Style.FILL);
@@ -135,7 +135,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Pointer paint
- private Paint mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
{
setDither(true);
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
@@ -143,7 +143,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Icons paint
- private Paint mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
{
setDither(true);
}
@@ -176,8 +176,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Variables for animator
- private ValueAnimator mAnimator = new ValueAnimator();
- private ResizeInterpolator mResizeInterpolator = new ResizeInterpolator();
+ private final ValueAnimator mAnimator = new ValueAnimator();
+ private final ResizeInterpolator mResizeInterpolator = new ResizeInterpolator();
private int mAnimationDuration;
// NTP models
@@ -1277,7 +1277,7 @@ public static class Model {
private int mColor;
private Bitmap mIcon;
- private Matrix mIconMatrix = new Matrix();
+ private final Matrix mIconMatrix = new Matrix();
private String mBadgeTitle = "";
private String mTempBadgeTitle = "";
@@ -1286,7 +1286,7 @@ public static class Model {
private boolean mIsBadgeShowed;
private boolean mIsBadgeUpdated;
- private ValueAnimator mBadgeAnimator = new ValueAnimator();
+ private final ValueAnimator mBadgeAnimator = new ValueAnimator();
private float mInactiveIconScale;
private float mActiveIconScaleBy;
From 8667f004aadf22a93f82560b69cc6d39dac86d0a Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 7 May 2016 14:35:02 +0300
Subject: [PATCH 09/64] Update 1.1.6
---
README.md | 48 +++++++-----
.../HorizontalNtbActivity.java | 2 +-
.../TopHorizontalNtbActivity.java | 2 +-
.../navigationtabbar/VerticalNtbActivity.java | 2 +-
.../layout/activity_horizontal_top_ntb.xml | 2 +
.../res/layout/{vp_item.xml => item_vp.xml} | 0
build.gradle | 2 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
library/build.gradle | 4 +-
.../gigamole/library/NavigationTabBar.java | 75 +++++++++++++------
library/src/main/res/values/attrs.xml | 2 +
11 files changed, 93 insertions(+), 50 deletions(-)
rename app/src/main/res/layout/{vp_item.xml => item_vp.xml} (100%)
diff --git a/README.md b/README.md
index 92e7700..628a6fa 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ NavigationTabBar
Navigation tab bar with colorful interactions.
-Horizontal NTB|NTB bottom, badge, all title |NTB top, badge, typeface, active title|Vertical NTB|NTB Samples|
+Horizontal NTB|NTB bottom, badge, all title |NTB top, colored badge, typeface, active title|Vertical NTB|NTB Samples|
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
||||
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.5'
+compile 'com.github.devlight.navigationtabbar:library:1.1.6'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.5
+ 1.1.6
aar
```
@@ -59,23 +59,23 @@ For NTB you can set such parameters as:
- models:
- allows you to set NTB models, where you set icon color. Can be set up only via code.
+ allows you to set NTB models, where you set icon color. Can be set up only via code.
- view pager:
- allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
+ allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
- model title:
- allows you to enable title in you model.
+ allows you to enable title in you model.
- model badge:
- allows you to enable badge in you model.
+ allows you to enable badge in you model.
- use custom typeface on badge:
- allows you to handle set of custom typeface in your badge.
+ allows you to handle set of custom typeface in your badge.
- title mode:
@@ -87,42 +87,48 @@ For NTB you can set such parameters as:
- badge position:
- allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).
+ allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).
- badge gravity:
- allows you to set the badge gravity in NTB. Can be top or bottom.
+ allows you to set the badge gravity in NTB. Can be top or bottom.
+
+ - badge colors:
+
+ allows you to set the badge bg and title colors.
- typeface:
- allows you to set custom typeface to your title.
+ allows you to set custom typeface to your title.
- corners radius:
- allows you to set corners radius of pointer.
+ allows you to set corners radius of pointer.
- animation duration:
- allows you to set animation duration.
+ allows you to set animation duration.
- inactive color:
- allows you to set inactive icon color.
+ allows you to set inactive icon color.
- active color:
- allows you to set active icon color.
+ allows you to set active icon color.
- tab bar listener:
- allows you to set listener which triggering on start or on end when you set model index.
+ allows you to set listener which triggering on start or on end when you set model index.
- preview colors:
- allows you to set preview colors, which generate count of models equals to count of colors.
+ allows you to set preview colors, which generate count of models equals to count of colors.
Orientation automatically detected according to view size.
+By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set badge bg and title color to 0.
+
If your set ViewPager you can action down on active pointer and do like drag.
Check out in code init:
@@ -150,6 +156,8 @@ navigationTabBar.setTypeface("fonts/custom_font.ttf");
navigationTabBar.setIsBadged(true);
navigationTabBar.setIsTitled(true);
navigationTabBar.setIsBadgeUseTypeface(true);
+navigationTabBar.setBadgeBgColor(Color.RED);
+navigationTabBar.setBadgeTitleColor(Color.WHITE);
```
If you want to set the background to NTB, you need to create some view at he bottom of NTB in layout and then set height of your background view like this:
@@ -195,6 +203,8 @@ And XML init:
app:ntb_title_mode="all"
app:ntb_badge_position="right"
app:ntb_badge_gravity="top"
+ app:ntb_badge_bg_color="#ffff0000"
+ app:ntb_badge_title_color="#ffffffff"
app:ntb_typeface="fonts/custom_typeface.ttf"
app:ntb_badge_use_typeface="true"/>
```
@@ -214,7 +224,7 @@ Inspiration
Tapbar interactions| Circle interactions | Title interactions
:-------------------------:|:-------------------------:|:-------------------------:
-||
+||
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
@@ -223,4 +233,4 @@ Author
Made in [DevLight Mobile Agency](https://github.com/DevLight-Mobile-Agency)
-Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:http://gigamole53@gmail.com)
\ No newline at end of file
+Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
\ No newline at end of file
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
index d01bf39..d3b1c32 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
@@ -55,7 +55,7 @@ public void destroyItem(final View container, final int position, final Object o
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(
- getBaseContext()).inflate(R.layout.vp_item, null, false);
+ getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
index 1834bc2..5ace335 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
@@ -56,7 +56,7 @@ public void destroyItem(final View container, final int position, final Object o
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(
- getBaseContext()).inflate(R.layout.vp_item, null, false);
+ getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
index 6e3b7c3..9654297 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
@@ -55,7 +55,7 @@ public void destroyItem(final View container, final int position, final Object o
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(
- getBaseContext()).inflate(R.layout.vp_item, null, false);
+ getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
diff --git a/app/src/main/res/layout/activity_horizontal_top_ntb.xml b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
index 520622c..7c5077d 100644
--- a/app/src/main/res/layout/activity_horizontal_top_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
@@ -38,6 +38,8 @@
app:ntb_badge_gravity="bottom"
app:ntb_badge_position="left"
app:ntb_badge_use_typeface="true"
+ app:ntb_badge_bg_color="#ffff0000"
+ app:ntb_badge_title_color="#ffffffff"
app:ntb_badged="true"
app:ntb_title_mode="active"
app:ntb_titled="true"
diff --git a/app/src/main/res/layout/vp_item.xml b/app/src/main/res/layout/item_vp.xml
similarity index 100%
rename from app/src/main/res/layout/vp_item.xml
rename to app/src/main/res/layout/item_vp.xml
diff --git a/build.gradle b/build.gradle
index ba818b7..cd70ee5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:2.1.0'
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ec41c8e..05ac656 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Mar 28 17:22:59 EEST 2016
+#Sat May 07 12:59:05 EEST 2016
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
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 9e9c365..bdd95ee 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.5"
+version = "1.1.6"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.5"
+ versionName "1.1.6"
}
buildTypes {
release {
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 90a71ea..195dee7 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -19,6 +19,7 @@
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -49,8 +50,10 @@
import android.view.animation.LinearInterpolator;
import android.widget.Scroller;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Random;
/**
@@ -87,7 +90,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static float BADGE_HORIZONTAL_FRACTION = 0.5f;
private final static float BADGE_VERTICAL_FRACTION = 0.75f;
- private final static float BADGE_TITLE_SIZE_FRACTION = 0.85f;
+ private final static float BADGE_TITLE_SIZE_FRACTION = 0.9f;
private final static int ALL_INDEX = 0;
private final static int ACTIVE_INDEX = 1;
@@ -212,6 +215,12 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Model badge gravity: top or bottom
private BadgeGravity mBadgeGravity;
+ // Model badge bg and title color.
+ // By default badge bg color is the active model color and badge title color is the model bg color
+ // To reset colors just set bg and title color to 0
+ private int mBadgeTitleColor;
+ private int mBadgeBgColor;
+
// Indexes
private int mLastIndex = INVALID_INDEX;
private int mIndex = INVALID_INDEX;
@@ -271,30 +280,24 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
try {
- setIsTitled(
- typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false)
- );
- setIsBadged(
- typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false)
- );
- setIsScaled(
- typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true)
- );
+ setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
+ setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
+ setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
setIsBadgeUseTypeface(
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
);
- setTitleMode(
- typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX)
- );
+
+ setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
setBadgePosition(
typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX)
);
setBadgeGravity(
typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX)
);
- setTypeface(
- typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface)
- );
+ setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, 0));
+ setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, 0));
+
+ setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
setInactiveColor(
typedArray.getColor(
R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR
@@ -483,11 +486,29 @@ public void setBadgeGravity(final BadgeGravity badgeGravity) {
requestLayout();
}
+ public int getBadgeBgColor() {
+ return mBadgeBgColor;
+ }
+
+ public void setBadgeBgColor(final int badgeBgColor) {
+ mBadgeBgColor = badgeBgColor;
+ }
+
+ public int getBadgeTitleColor() {
+ return mBadgeTitleColor;
+ }
+
+ public void setBadgeTitleColor(final int badgeTitleColor) {
+ mBadgeTitleColor = badgeTitleColor;
+ }
+
public Typeface getTypeface() {
return mTypeface;
}
public void setTypeface(final String typeface) {
+ if (TextUtils.isEmpty(typeface)) return;
+
Typeface tempTypeface;
try {
tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface);
@@ -566,10 +587,18 @@ public void setOnTabBarSelectedIndexListener(final OnTabBarSelectedIndexListener
public void onAnimationStart(final Animator animation) {
if (mOnTabBarSelectedIndexListener != null)
mOnTabBarSelectedIndexListener.onStartTabSelected(mModels.get(mIndex), mIndex);
+
+ animation.removeListener(this);
+ animation.addListener(this);
}
@Override
public void onAnimationEnd(final Animator animation) {
+ if (mIsViewPagerMode) return;
+
+ animation.removeListener(this);
+ animation.addListener(this);
+
if (mOnTabBarSelectedIndexListener != null)
mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
}
@@ -927,11 +956,6 @@ protected void onDraw(final Canvas canvas) {
// Get interpolated fraction for left last and current models
final float interpolation = mResizeInterpolator.getResizeInterpolation(mFraction, true);
final float lastInterpolation = mResizeInterpolator.getResizeInterpolation(mFraction, false);
-// final float interpolation =
-// mIsScaled ? mResizeInterpolator.getResizeInterpolation(mFraction, true);
-// final float lastInterpolation =
-// mIsScaled ? mResizeInterpolator.getResizeInterpolation(mFraction, false) :
-// (MAX_FRACTION - NON_SCALED_FRACTION);
// Scale value relative to interpolation
final float matrixScale = model.mActiveIconScaleBy *
@@ -1050,7 +1074,7 @@ else if (i == mIndex)
// Set color and alpha for badge bg
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
- else mBadgePaint.setColor(mActiveColor);
+ else mBadgePaint.setColor(mBadgeBgColor == 0 ? mActiveColor : mBadgeBgColor);
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set corners to round rect for badge bg and draw
@@ -1059,7 +1083,7 @@ else if (i == mIndex)
// Set color and alpha for badge title
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
- else mBadgePaint.setColor(model.getColor());
+ else mBadgePaint.setColor(mBadgeTitleColor == 0 ? model.getColor() : mBadgeTitleColor);
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set badge title center position and draw title
@@ -1312,10 +1336,15 @@ public Model(final Drawable icon, final int color) {
@Override
public void onAnimationStart(final Animator animation) {
+ animation.removeListener(this);
+ animation.addListener(this);
}
@Override
public void onAnimationEnd(final Animator animation) {
+ animation.removeListener(this);
+ animation.addListener(this);
+
// Detect whether we just update text and don`t reset show state
if (!mIsBadgeUpdated) mIsBadgeShowed = !mIsBadgeShowed;
else mIsBadgeUpdated = false;
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index c3dc53d..f12c014 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -20,6 +20,8 @@
+
+
From 5121a33e8298be2dedd030ec878dc091e25fc25e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 7 May 2016 14:39:29 +0300
Subject: [PATCH 10/64] Update README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 628a6fa..bc558cc 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Navigation tab bar with colorful interactions.
Horizontal NTB|NTB bottom, badge, all title |NTB top, colored badge, typeface, active title|Vertical NTB|NTB Samples|
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
-||||
+||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
From b18338419a36af5207a57d3f915e007031af7202 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 14 May 2016 14:37:38 +0300
Subject: [PATCH 11/64] CoordinatorLayout usage update
---
app/build.gradle | 4 +-
.../TopHorizontalNtbActivity.java | 47 +++++++++++-
.../layout/activity_horizontal_top_ntb.xml | 72 ++++++++++---------
app/src/main/res/layout/item_list.xml | 23 ++++++
app/src/main/res/layout/item_vp_list.xml | 19 +++++
5 files changed, 129 insertions(+), 36 deletions(-)
create mode 100644 app/src/main/res/layout/item_list.xml
create mode 100644 app/src/main/res/layout/item_vp_list.xml
diff --git a/app/build.gradle b/app/build.gradle
index a3466fc..8a8c4af 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,5 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
- compile 'com.android.support:appcompat-v7:23.2.1'
+ compile 'com.android.support:appcompat-v7:23.3.0'
+ compile 'com.android.support:design:23.3.0'
+ compile 'com.android.support:support-v4:24.0.0-alpha2'
}
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
index 5ace335..da5ce89 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
@@ -5,6 +5,8 @@
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -56,10 +58,15 @@ public void destroyItem(final View container, final int position, final Object o
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(
- getBaseContext()).inflate(R.layout.item_vp, null, false);
+ getBaseContext()).inflate(R.layout.item_vp_list, null, false);
- final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
- txtPage.setText(String.format("Page #%d", position));
+ final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv);
+ recyclerView.setHasFixedSize(true);
+ recyclerView.setLayoutManager(new LinearLayoutManager(
+ getBaseContext(), LinearLayoutManager.VERTICAL, false
+ )
+ );
+ recyclerView.setAdapter(new RecycleAdapter());
container.addView(view);
return view;
@@ -89,6 +96,11 @@ public void run() {
final View bgNavigationTabBar = findViewById(R.id.bg_ntb_horizontal);
bgNavigationTabBar.getLayoutParams().height = (int) navigationTabBar.getBarHeight();
bgNavigationTabBar.requestLayout();
+
+ final View viewPager = findViewById(R.id.vp_horizontal_ntb);
+ ((ViewGroup.MarginLayoutParams) viewPager.getLayoutParams()).topMargin =
+ (int) -navigationTabBar.getBadgeMargin();
+ viewPager.requestLayout();
}
});
@@ -123,4 +135,33 @@ public void run() {
}
});
}
+
+ public class RecycleAdapter extends RecyclerView.Adapter {
+
+ @Override
+ public ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
+ final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_list, parent, false);
+ return new ViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(final ViewHolder holder, final int position) {
+ holder.txt.setText(String.format("Navigation Item #%d", position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return 20;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+
+ public TextView txt;
+
+ public ViewHolder(final View itemView) {
+ super(itemView);
+ txt = (TextView) itemView.findViewById(R.id.txt_vp_item_list);
+ }
+ }
+ }
}
diff --git a/app/src/main/res/layout/activity_horizontal_top_ntb.xml b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
index 7c5077d..e8861f1 100644
--- a/app/src/main/res/layout/activity_horizontal_top_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
@@ -1,5 +1,5 @@
-
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ android:layout_gravity="bottom"/>
-
-
-
-
-
-
-
+
diff --git a/app/src/main/res/layout/item_list.xml b/app/src/main/res/layout/item_list.xml
new file mode 100644
index 0000000..95fd221
--- /dev/null
+++ b/app/src/main/res/layout/item_list.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_vp_list.xml b/app/src/main/res/layout/item_vp_list.xml
new file mode 100644
index 0000000..9474696
--- /dev/null
+++ b/app/src/main/res/layout/item_vp_list.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
From bab43dd5fafae5acffa68f6ace7fe7a4fd4c34a1 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 14 May 2016 14:46:37 +0300
Subject: [PATCH 12/64] CoordinatorLayout usage update
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index bc558cc..06a1e8e 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,9 @@ NavigationTabBar
Navigation tab bar with colorful interactions.
-Horizontal NTB|NTB bottom, badge, all title |NTB top, colored badge, typeface, active title|Vertical NTB|NTB Samples|
+Horizontal NTB|NTB bottom, badge, all title |NTB with CoordinatorLayout|Vertical NTB|NTB Samples|
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
-||||
+||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
From ea05fd6aa086c161846ee5e23b86e4823cea9c7e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 20 May 2016 15:34:20 +0300
Subject: [PATCH 13/64] Update 1.1.8
---
README.md | 74 +++++--
.../HorizontalNtbActivity.java | 75 ++++---
.../navigationtabbar/SamplesNtbActivity.java | 185 +++++++++++------
.../TopHorizontalNtbActivity.java | 53 +++--
.../navigationtabbar/VerticalNtbActivity.java | 80 +++++---
.../layout/activity_horizontal_top_ntb.xml | 1 +
.../gigamole/library/NavigationTabBar.java | 194 +++++++++++++++---
7 files changed, 481 insertions(+), 181 deletions(-)
diff --git a/README.md b/README.md
index 06a1e8e..6307917 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,9 @@ NavigationTabBar
Navigation tab bar with colorful interactions.
-Horizontal NTB|NTB bottom, badge, all title |NTB with CoordinatorLayout|Vertical NTB|NTB Samples|
+Horizontal NTB|NTB with selected icons |NTB with CoordinatorLayout|Vertical NTB|NTB Samples|
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
-||||
+||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.6'
+compile 'com.github.devlight.navigationtabbar:library:1.1.8'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.6
+ 1.1.8
aar
```
@@ -50,7 +50,7 @@ Or Maven:
Android SDK Version
=========
-NavigationTabBar requires a minimum sdk version of 11.
+NavigationTabBar requires a minimum SDK version of 11.
Sample
========
@@ -59,12 +59,16 @@ For NTB you can set such parameters as:
- models:
- allows you to set NTB models, where you set icon color. Can be set up only via code.
+ allows you to set NTB models, where you set icon and color. Can be set up only via code.
- view pager:
allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
+ - model selected icon:
+
+ allows you to set selected icon when current model is active.
+
- model title:
allows you to enable title in you model.
@@ -125,6 +129,12 @@ For NTB you can set such parameters as:
allows you to set preview colors, which generate count of models equals to count of colors.
+Creation of models occurs through Builder pattern.
+
+ModelBuilder requires two fields: icon and color. Title, badge title and selected icon is optional.
+
+You can set selected icon. Resize and scale of selected icon equals to original icon.
+
Orientation automatically detected according to view size.
By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set badge bg and title color to 0.
@@ -136,16 +146,46 @@ Check out in code init:
```java
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb);
final ArrayList models = new ArrayList<>();
-models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), colors[0]));
-models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), colors[1]));
-models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), colors[2]));
-models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), colors[3]));
-models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), colors[4]));
+models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first),
+ Color.parseColor(colors[0])
+ ).title("Heart")
+ .badgeTitle("NTB")
+ .build()
+);
+models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second),
+ Color.parseColor(colors[1])
+ ).title("Cup")
+ .badgeTitle("with")
+ .build()
+);
+models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third),
+ Color.parseColor(colors[2])
+ ).title("Diploma")
+ .badgeTitle("state")
+ .build()
+);
+models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth),
+ Color.parseColor(colors[3])
+ ).title("Flag")
+ .badgeTitle("icon")
+ .build()
+);
+models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth),
+ Color.parseColor(colors[4])
+ ).title("Medal")
+ .badgeTitle("777")
+ .build()
+);
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
@@ -222,7 +262,7 @@ Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/Navi
Inspiration
======
-Tapbar interactions| Circle interactions | Title interactions
+TapBar interactions| Circle interactions | Title interactions
:-------------------------:|:-------------------------:|:-------------------------:
||
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
index a0aa96f..bd91aa0 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
@@ -69,16 +69,52 @@ public Object instantiateItem(final ViewGroup container, final int position) {
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList models = new ArrayList<>();
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0]), "Heart"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1]), "Cup"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2]), "Diploma"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3]), "Flag"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4]), "Medal"));
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first),
+ Color.parseColor(colors[0]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_sixth))
+ .title("Heart")
+ .badgeTitle("NTB")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second),
+ Color.parseColor(colors[1]))
+// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("Cup")
+ .badgeTitle("with")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third),
+ Color.parseColor(colors[2]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_seventh))
+ .title("Diploma")
+ .badgeTitle("state")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth),
+ Color.parseColor(colors[3]))
+// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("Flag")
+ .badgeTitle("icon")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth),
+ Color.parseColor(colors[4]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("Medal")
+ .badgeTitle("777")
+ .build()
+ );
+
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@@ -112,25 +148,6 @@ public void run() {
public void run() {
for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
- switch (i) {
- case 0:
- model.setBadgeTitle("NTB");
- break;
- case 1:
- model.setBadgeTitle("with");
- break;
- case 2:
- model.setBadgeTitle("title");
- break;
- case 3:
- model.setBadgeTitle("badge");
- break;
- case 4:
- model.setBadgeTitle("777");
- break;
- default:
- break;
- }
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
index ac9a6c0..097263f 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
@@ -22,79 +22,134 @@ protected void onCreate(final Bundle savedInstanceState) {
initUI();
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- System.runFinalization();
- Runtime.getRuntime().gc();
- System.gc();
- }
-
private void initUI() {
final NavigationTabBar ntbSample1 = (NavigationTabBar) findViewById(R.id.ntb_sample_1);
final ArrayList models1 = new ArrayList<>();
- models1.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), Color.WHITE));
- models1.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), Color.LTGRAY));
- models1.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), Color.GRAY));
- models1.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), Color.DKGRAY));
+ models1.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first), Color.WHITE
+ ).build()
+ );
+ models1.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second), Color.LTGRAY
+ ).build()
+ );
+ models1.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third), Color.GRAY
+ ).build()
+ );
+ models1.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth), Color.DKGRAY
+ ).build()
+ );
ntbSample1.setModels(models1);
final NavigationTabBar ntbSample2 = (NavigationTabBar) findViewById(R.id.ntb_sample_2);
final ArrayList models2 = new ArrayList<>();
- models2.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_seventh), Color.YELLOW));
- models2.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_sixth), Color.YELLOW));
- models2.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), Color.YELLOW));
- models2.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_eighth), Color.YELLOW));
- models2.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), Color.YELLOW));
+ models2.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_seventh), Color.YELLOW
+ ).build()
+ );
+ models2.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_sixth), Color.YELLOW
+ ).build()
+ );
+ models2.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth), Color.YELLOW
+ ).build()
+ );
+ models2.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_eighth), Color.YELLOW
+ ).build()
+ );
+ models2.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second), Color.YELLOW
+ ).build()
+ );
ntbSample2.setModels(models2);
ntbSample2.setModelIndex(3, true);
final NavigationTabBar ntbSample3 = (NavigationTabBar) findViewById(R.id.ntb_sample_3);
final ArrayList models3 = new ArrayList<>();
- models3.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_seventh), Color.RED));
- models3.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_seventh), Color.RED));
- models3.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_seventh), Color.RED));
+ models3.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_seventh), Color.RED
+ ).build()
+ );
+ models3.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_seventh), Color.RED
+ ).build()
+ );
+ models3.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_seventh), Color.RED
+ ).build()
+ );
ntbSample3.setModels(models3);
ntbSample3.setModelIndex(1, true);
final NavigationTabBar ntbSample4 = (NavigationTabBar) findViewById(R.id.ntb_sample_4);
final int bgColor = Color.parseColor("#423752");
final ArrayList models4 = new ArrayList<>();
- models4.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), bgColor));
- models4.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), bgColor));
- models4.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), bgColor));
- models4.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_sixth), bgColor));
- models4.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), bgColor));
+ models4.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth), bgColor
+ ).build()
+ );
+ models4.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first), bgColor
+ ).build()
+ );
+ models4.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth), bgColor
+ ).build()
+ );
+ models4.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_sixth), bgColor
+ ).build()
+ );
+ models4.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third), bgColor
+ ).build()
+ );
ntbSample4.setModels(models4);
ntbSample4.setModelIndex(2, true);
final NavigationTabBar ntbSample5 = (NavigationTabBar) findViewById(R.id.ntb_sample_5);
final ArrayList models5 = new ArrayList<>();
- models5.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), Color.WHITE));
- models5.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), Color.WHITE));
- models5.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), Color.WHITE));
- models5.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_sixth), Color.WHITE));
+ models5.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth), Color.WHITE
+ ).build()
+ );
+ models5.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first), Color.WHITE
+ ).build()
+ );
+ models5.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth), Color.WHITE
+ ).build()
+ );
+ models5.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_sixth), Color.WHITE
+ ).build()
+ );
ntbSample5.setModels(models5);
ntbSample5.setModelIndex(2, true);
ntbSample5.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@@ -111,18 +166,30 @@ public void onEndTabSelected(final NavigationTabBar.Model model, final int index
final NavigationTabBar ntbSample6 = (NavigationTabBar) findViewById(R.id.ntb_sample_6);
final ArrayList models6 = new ArrayList<>();
- models6.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), randomColor()));
- models6.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), randomColor()));
- models6.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), randomColor()));
- models6.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_sixth), randomColor()));
+ models6.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth), randomColor()
+ ).build()
+ );
+ models6.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first), randomColor()
+ ).build()
+ );
+ models6.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth), randomColor()
+ ).build()
+ );
+ models6.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_sixth), randomColor()
+ ).build()
+ );
ntbSample6.setModels(models6);
}
- private int randomColor(){
+ private int randomColor() {
float[] TEMP_HSL = new float[]{0, 0, 0};
float[] hsl = TEMP_HSL;
hsl[0] = (float) (Math.random() * 360);
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
index da5ce89..6f32fc8 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
@@ -29,14 +29,6 @@ protected void onCreate(final Bundle savedInstanceState) {
initUI();
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- System.runFinalization();
- Runtime.getRuntime().gc();
- System.gc();
- }
-
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(new PagerAdapter() {
@@ -77,16 +69,41 @@ public Object instantiateItem(final ViewGroup container, final int position) {
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList models = new ArrayList<>();
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0]), "Heart"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1]), "Cup"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2]), "Diploma"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3]), "Flag"));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4]), "Medal"));
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first),
+ Color.parseColor(colors[0]))
+ .title("Heart")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second),
+ Color.parseColor(colors[1]))
+ .title("Cup")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third),
+ Color.parseColor(colors[2]))
+ .title("Diploma")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth),
+ Color.parseColor(colors[3]))
+ .title("Flag")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth),
+ Color.parseColor(colors[4]))
+ .title("Medal")
+ .build()
+ );
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
index 9654297..53275a7 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
@@ -26,14 +26,6 @@ protected void onCreate(final Bundle savedInstanceState) {
initUI();
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- System.runFinalization();
- Runtime.getRuntime().gc();
- System.gc();
- }
-
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_vertical_ntb);
viewPager.setAdapter(new PagerAdapter() {
@@ -69,22 +61,62 @@ public Object instantiateItem(final ViewGroup container, final int position) {
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_vertical);
final ArrayList models = new ArrayList<>();
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_sixth), Color.parseColor(colors[5])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_seventh), Color.parseColor(colors[6])));
- models.add(new NavigationTabBar.Model(
- getResources().getDrawable(R.drawable.ic_eighth), Color.parseColor(colors[7])));
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first),
+ Color.parseColor(colors[0]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second),
+ Color.parseColor(colors[1]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third),
+ Color.parseColor(colors[2]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth),
+ Color.parseColor(colors[3]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth),
+ Color.parseColor(colors[4]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_sixth),
+ Color.parseColor(colors[5]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_seventh),
+ Color.parseColor(colors[6]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_eighth),
+ Color.parseColor(colors[7]))
+ .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .build()
+ );
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 4);
diff --git a/app/src/main/res/layout/activity_horizontal_top_ntb.xml b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
index e8861f1..ef221b7 100644
--- a/app/src/main/res/layout/activity_horizontal_top_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
@@ -43,6 +43,7 @@
app:ntb_badged="true"
app:ntb_title_mode="active"
app:ntb_titled="true"
+ app:ntb_scaled="false"
app:ntb_typeface="fonts/agency.ttf"/>
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 5c1af67..3da5054 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -19,7 +19,6 @@
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
-import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -50,10 +49,8 @@
import android.view.animation.LinearInterpolator;
import android.widget.Scroller;
-import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Random;
@@ -151,6 +148,11 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
setDither(true);
}
};
+ private final Paint mSelectedIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ {
+ setDither(true);
+ }
+ };
// Paint for icon mask pointer
private final Paint mIconPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
@@ -346,7 +348,7 @@ public void onAnimationUpdate(final ValueAnimator animation) {
previewColors = typedArray.getResources().getStringArray(R.array.default_preview);
for (String previewColor : previewColors)
- mModels.add(new Model(null, Color.parseColor(previewColor)));
+ mModels.add(new Model.Builder(null, Color.parseColor(previewColor)).build());
requestLayout();
}
}
@@ -553,6 +555,7 @@ public void setInactiveColor(final int inactiveColor) {
// Set color filter to wrap icons with inactive color
mIconPaint.setColorFilter(new PorterDuffColorFilter(inactiveColor, PorterDuff.Mode.SRC_IN));
+ mSelectedIconPaint.setColorFilter(new PorterDuffColorFilter(inactiveColor, PorterDuff.Mode.SRC_IN));
mModelTitlePaint.setColor(mInactiveColor);
postInvalidate();
}
@@ -973,6 +976,9 @@ protected void onDraw(final Canvas canvas) {
final float titleLastScale = mIsScaled ? (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY) -
(lastInterpolation * TITLE_ACTIVE_SCALE_BY) : titleScale;
+ mIconPaint.setAlpha(MAX_ALPHA);
+ if (model.mSelectedIcon != null) mSelectedIconPaint.setAlpha(MAX_ALPHA);
+
// Check if we handle models from touch on NTP or from ViewPager
// There is a strange logic of ViewPager onPageScrolled method, so it is
if (mIsSetIndexFromTabBar) {
@@ -1009,8 +1015,18 @@ else if (i == mIndex)
);
}
- // Draw model icon
- mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
+ // Draw original model icon
+ if (model.mSelectedIcon == null) {
+ mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
+ } else {
+ if (mIconPaint.getAlpha() != MIN_ALPHA)
+ // Draw original icon when is visible
+ mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
+ }
+ // Draw selected icon when exist and visible
+ if (model.mSelectedIcon != null && mSelectedIconPaint.getAlpha() != MIN_ALPHA)
+ mIconsCanvas.drawBitmap(model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint);
+
if (mIsTitled)
mIconsCanvas.drawText(
isInEditMode() ? PREVIEW_TITLE : model.getTitle(),
@@ -1125,6 +1141,33 @@ private void updateCurrentModel(
mModelTitlePaint.setTextSize(mModelTitleSize * textScale);
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(textAlpha);
+
+ if (model.mSelectedIcon == null) {
+ mIconPaint.setAlpha(MAX_ALPHA);
+ return;
+ }
+
+ // Calculate cross fade alpha between icon and selected icon
+ final float iconAlpha;
+ final float selectedIconAlpha;
+ if (interpolation <= 0.475F) {
+ iconAlpha = MAX_FRACTION - interpolation * 2.1F;
+ selectedIconAlpha = MIN_FRACTION;
+ } else if (interpolation >= 0.525F) {
+ iconAlpha = MIN_FRACTION;
+ selectedIconAlpha = (interpolation - 0.55F) * 1.9F;
+ } else {
+ iconAlpha = MIN_FRACTION;
+ selectedIconAlpha = MIN_FRACTION;
+ }
+
+ mIconPaint.setAlpha(
+ (int) (MAX_ALPHA * clampValue(iconAlpha, MIN_FRACTION, MAX_FRACTION))
+ );
+ mSelectedIconPaint.setAlpha(
+ (int) (MAX_ALPHA * clampValue(selectedIconAlpha, MIN_FRACTION, MAX_FRACTION))
+ );
+
}
// Method to transform last fraction of NTB and position
@@ -1154,6 +1197,32 @@ private void updateLastModel(
mModelTitlePaint.setTextSize(mModelTitleSize * textLastScale);
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(textLastAlpha);
+
+ if (model.mSelectedIcon == null) {
+ mIconPaint.setAlpha(MAX_ALPHA);
+ return;
+ }
+
+ // Calculate cross fade alpha between icon and selected icon
+ final float iconAlpha;
+ final float selectedIconAlpha;
+ if (lastInterpolation <= 0.475F) {
+ iconAlpha = MIN_FRACTION;
+ selectedIconAlpha = MAX_FRACTION - lastInterpolation * 2.1F;
+ } else if (lastInterpolation >= 0.525F) {
+ iconAlpha = (lastInterpolation - 0.55F) * 1.9F;
+ selectedIconAlpha = MIN_FRACTION;
+ } else {
+ iconAlpha = MIN_FRACTION;
+ selectedIconAlpha = MIN_FRACTION;
+ }
+
+ mIconPaint.setAlpha(
+ (int) (MAX_ALPHA * clampValue(iconAlpha, MIN_FRACTION, MAX_FRACTION))
+ );
+ mSelectedIconPaint.setAlpha(
+ (int) (MAX_ALPHA * clampValue(selectedIconAlpha, MIN_FRACTION, MAX_FRACTION))
+ );
}
// Method to transform others fraction of NTB and position
@@ -1181,6 +1250,14 @@ private void updateInactiveModel(
mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? 1.0f : textScale));
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(MIN_ALPHA);
+
+ // Reset icons alpha
+ if (model.mSelectedIcon == null) {
+ mIconPaint.setAlpha(MAX_ALPHA);
+ return;
+ }
+
+ mSelectedIconPaint.setAlpha(MIN_ALPHA);
}
@Override
@@ -1294,15 +1371,21 @@ public void run() {
});
}
+ // Clamp value to max and min bounds
+ private float clampValue(final float value, final float max, final float min) {
+ return Math.max(Math.min(value, min), max);
+ }
+
// Model class
public static class Model {
- private String mTitle = "";
private int mColor;
private Bitmap mIcon;
+ private Bitmap mSelectedIcon;
private final Matrix mIconMatrix = new Matrix();
+ private String mTitle = "";
private String mBadgeTitle = "";
private String mTempBadgeTitle = "";
private float mBadgeFraction;
@@ -1315,23 +1398,12 @@ public static class Model {
private float mInactiveIconScale;
private float mActiveIconScaleBy;
- public Model(final Drawable icon, final int color) {
- mColor = color;
- if (icon != null) {
- if (icon instanceof BitmapDrawable) mIcon = ((BitmapDrawable) icon).getBitmap();
- else {
- mIcon = Bitmap.createBitmap(
- icon.getIntrinsicWidth(),
- icon.getIntrinsicHeight(),
- Bitmap.Config.ARGB_8888
- );
- final Canvas canvas = new Canvas(mIcon);
- icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- icon.draw(canvas);
- }
- } else {
- mIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
- }
+ public Model(final Builder builder) {
+ mColor = builder.mColor;
+ mIcon = builder.mIcon;
+ mSelectedIcon = builder.mSelectedIcon;
+ mTitle = builder.mTitle;
+ mBadgeTitle = builder.mBadgeTitle;
mBadgeAnimator.addListener(new Animator.AnimatorListener() {
@@ -1364,16 +1436,6 @@ public void onAnimationRepeat(final Animator animation) {
});
}
- public Model(final Drawable icon, final int color, final String title) {
- this(icon, color);
- mTitle = title;
- }
-
- public Model(final Drawable icon, final int color, final String title, final String badgeTitle) {
- this(icon, color, title);
- mBadgeTitle = badgeTitle;
- }
-
public String getTitle() {
return mTitle;
}
@@ -1450,6 +1512,70 @@ public void hideBadge() {
mBadgeAnimator.setRepeatCount(0);
mBadgeAnimator.start();
}
+
+ public static class Builder {
+
+ private int mColor;
+
+ private Bitmap mIcon;
+ private Bitmap mSelectedIcon;
+
+ private String mTitle;
+ private String mBadgeTitle;
+
+ public Builder(final Drawable icon, final int color) {
+ mColor = color;
+
+ if (icon != null) {
+ if (icon instanceof BitmapDrawable) mIcon = ((BitmapDrawable) icon).getBitmap();
+ else {
+ mIcon = Bitmap.createBitmap(
+ icon.getIntrinsicWidth(),
+ icon.getIntrinsicHeight(),
+ Bitmap.Config.ARGB_8888
+ );
+ final Canvas canvas = new Canvas(mIcon);
+ icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ icon.draw(canvas);
+ }
+ } else {
+ mIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
+ }
+ }
+
+ public Builder selectedIcon(final Drawable selectedIcon) {
+ if (selectedIcon != null) {
+ if (selectedIcon instanceof BitmapDrawable)
+ mSelectedIcon = ((BitmapDrawable) selectedIcon).getBitmap();
+ else {
+ mSelectedIcon = Bitmap.createBitmap(
+ selectedIcon.getIntrinsicWidth(),
+ selectedIcon.getIntrinsicHeight(),
+ Bitmap.Config.ARGB_8888
+ );
+ final Canvas canvas = new Canvas(mSelectedIcon);
+ selectedIcon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ selectedIcon.draw(canvas);
+ }
+ } else mSelectedIcon = null;
+
+ return this;
+ }
+
+ public Builder title(final String title) {
+ mTitle = title;
+ return this;
+ }
+
+ public Builder badgeTitle(final String title) {
+ mBadgeTitle = title;
+ return this;
+ }
+
+ public Model build() {
+ return new Model(this);
+ }
+ }
}
// Custom scroller with custom scroll duration
From d98332af7bfc83d3a65ae4de86b27dd370964adf Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 20 May 2016 15:36:40 +0300
Subject: [PATCH 14/64] Update 1.1.8
---
README.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/README.md b/README.md
index 6307917..ab94d99 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,8 @@ NavigationTabBar requires a minimum SDK version of 11.
Sample
========
+Parameters
+
For NTB you can set such parameters as:
- models:
@@ -129,6 +131,8 @@ For NTB you can set such parameters as:
allows you to set preview colors, which generate count of models equals to count of colors.
+Tips
+
Creation of models occurs through Builder pattern.
ModelBuilder requires two fields: icon and color. Title, badge title and selected icon is optional.
@@ -141,6 +145,8 @@ By default badge bg color is the active model color and badge title color is the
If your set ViewPager you can action down on active pointer and do like drag.
+Init
+
Check out in code init:
```java
From 98ec195cd02aa90e85d6be245d6e73b7bae17cd7 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 20 May 2016 15:39:17 +0300
Subject: [PATCH 15/64] Update 1.1.8
---
library/build.gradle | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/library/build.gradle b/library/build.gradle
index bdd95ee..1a2fc21 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.6"
+version = "1.1.8"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.6"
+ versionName "1.1.8"
}
buildTypes {
release {
From 1775a0a8a5f71bf0f622949783a6cfe5f4da384b Mon Sep 17 00:00:00 2001
From: daely
Date: Thu, 2 Jun 2016 12:59:27 +0300
Subject: [PATCH 16/64] added support for autoscroll of NavigationTabBar at
bottom of coordinator layout. See new demo: Horizontal(Coordinator Layout)
NavigationTabBar. The code was adapted from
---
README.md | 7 +-
app/build.gradle | 2 +-
app/src/main/AndroidManifest.xml | 1 +
.../HorizontalCoordinatorNtbActivity.java | 188 ++++++++
.../navigationtabbar/MainActivity.java | 7 +
.../activity_horizontal_coordinator_ntb.xml | 90 ++++
app/src/main/res/layout/activity_main.xml | 18 +-
app/src/main/res/values/dimens.xml | 4 +
app/src/main/res/values/styles.xml | 2 +-
library/build.gradle | 4 +-
.../BottomNavigationTabBarBehavior.java | 406 ++++++++++++++++++
.../gigamole/library/NavigationTabBar.java | 146 +++++++
.../library/VerticalScrollingBehavior.java | 146 +++++++
13 files changed, 1014 insertions(+), 7 deletions(-)
create mode 100644 app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
create mode 100644 app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
create mode 100644 app/src/main/res/values/dimens.xml
create mode 100644 library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
create mode 100644 library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
diff --git a/README.md b/README.md
index ab94d99..9164a48 100644
--- a/README.md
+++ b/README.md
@@ -228,7 +228,12 @@ model.showBadge();
model.toggleBadge();
model.updateBadgeTitle("Here some title like NEW or some integer value");
```
-
+
+To enable translation inside CoordinatorLayout when at bottom of screen:
+```java
+bottomNavigation.setBehaviorTranslationEnabled(true);
+```
+
Other methods check out in sample.
And XML init:
diff --git a/app/build.gradle b/app/build.gradle
index 8a8c4af..7a55400 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -24,5 +24,5 @@ dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
- compile 'com.android.support:support-v4:24.0.0-alpha2'
+ compile 'com.android.support:support-v4:23.3.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8bfe1ea..36bb73b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -20,6 +20,7 @@
+
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
new file mode 100644
index 0000000..ecbc49b
--- /dev/null
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
@@ -0,0 +1,188 @@
+package com.gigamole.navigationtabbar;
+
+import android.app.Activity;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.gigamole.library.NavigationTabBar;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+/**
+ * Created by GIGAMOLE on 28.03.2016.
+ */
+public class HorizontalCoordinatorNtbActivity extends Activity {
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_horizontal_coordinator_ntb);
+ initUI();
+ }
+
+ private void initUI() {
+ final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
+ viewPager.setAdapter(new PagerAdapter() {
+ @Override
+ public int getCount() {
+ return 5;
+ }
+
+ @Override
+ public boolean isViewFromObject(final View view, final Object object) {
+ return view.equals(object);
+ }
+
+ @Override
+ public void destroyItem(final View container, final int position, final Object object) {
+ ((ViewPager) container).removeView((View) object);
+ }
+
+ @Override
+ public Object instantiateItem(final ViewGroup container, final int position) {
+ final View view = LayoutInflater.from(
+ getBaseContext()).inflate(R.layout.item_vp_list, null, false);
+
+ final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv);
+ recyclerView.setHasFixedSize(true);
+ recyclerView.setLayoutManager(new LinearLayoutManager(
+ getBaseContext(), LinearLayoutManager.VERTICAL, false
+ )
+ );
+ recyclerView.setAdapter(new RecycleAdapter());
+
+ container.addView(view);
+ return view;
+ }
+ });
+
+ final String[] colors = getResources().getStringArray(R.array.default_preview);
+
+ final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
+ final ArrayList models = new ArrayList<>();
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_first),
+ Color.parseColor(colors[0]))
+ .title("Heart")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_second),
+ Color.parseColor(colors[1]))
+ .title("Cup")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_third),
+ Color.parseColor(colors[2]))
+ .title("Diploma")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fourth),
+ Color.parseColor(colors[3]))
+ .title("Flag")
+ .build()
+ );
+ models.add(
+ new NavigationTabBar.Model.Builder(
+ getResources().getDrawable(R.drawable.ic_fifth),
+ Color.parseColor(colors[4]))
+ .title("Medal")
+ .build()
+ );
+ //IMPORTANT: ENABLE SCROLL BEHAVIOUR IN COORDINATOR LAYOUT
+ navigationTabBar.setBehaviorTranslationEnabled(true);
+
+ navigationTabBar.setModels(models);
+ navigationTabBar.setViewPager(viewPager, 2);
+
+ final View bgNavigationTabBar = findViewById(R.id.bg_ntb_horizontal);
+ //THE FOLLOWING LINE IS IMPORTANT IF YOU WANT THE BACKGROUND VIEW SCROLL BEHAVIOUR TO MATCH
+ //THE TABBAR SCROLL BEHAVIOR IN THE COORDINATOR LAYOUT
+ navigationTabBar.setBackgroundView(bgNavigationTabBar);
+
+ navigationTabBar.post(new Runnable() {
+ @Override
+ public void run() {
+ final View viewPager = findViewById(R.id.vp_horizontal_ntb);
+ ((ViewGroup.MarginLayoutParams) viewPager.getLayoutParams()).topMargin =
+ (int) -navigationTabBar.getBadgeMargin();
+ viewPager.requestLayout();
+ }
+ });
+
+ navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
+ @Override
+ public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
+
+ }
+
+ @Override
+ public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
+ model.hideBadge();
+ }
+ });
+
+ findViewById(R.id.mask).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
+ final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
+ navigationTabBar.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ final String title = String.valueOf(new Random().nextInt(15));
+ if (!model.isBadgeShowed()) {
+ model.setBadgeTitle(title);
+ model.showBadge();
+ } else model.updateBadgeTitle(title);
+ }
+ }, i * 100);
+ }
+ }
+ });
+ }
+
+ public class RecycleAdapter extends RecyclerView.Adapter {
+
+ @Override
+ public ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
+ final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_list, parent, false);
+ return new ViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(final ViewHolder holder, final int position) {
+ holder.txt.setText(String.format("Navigation Item #%d", position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return 20;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+
+ public TextView txt;
+
+ public ViewHolder(final View itemView) {
+ super(itemView);
+ txt = (TextView) itemView.findViewById(R.id.txt_vp_item_list);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
index 21e46e3..d0fc224 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
@@ -19,6 +19,8 @@ protected void onCreate(Bundle savedInstanceState) {
private void initUI() {
final View btnHorizontalNtb = findViewById(R.id.btn_horizontal_ntb);
btnHorizontalNtb.setOnClickListener(this);
+ final View btnHorizontalCoordinatorNtb = findViewById(R.id.btn_horizontal_coordinator_ntb);
+ btnHorizontalCoordinatorNtb.setOnClickListener(this);
final View btnTopHorizontalNtb = findViewById(R.id.btn_horizontal_top_ntb);
btnTopHorizontalNtb.setOnClickListener(this);
final View btnVerticalNtb = findViewById(R.id.btn_vertical_ntb);
@@ -53,6 +55,11 @@ public void onAnimationEnd(final View view) {
new Intent(MainActivity.this, TopHorizontalNtbActivity.class)
);
break;
+ case R.id.btn_horizontal_coordinator_ntb:
+ startActivity(
+ new Intent(MainActivity.this, HorizontalCoordinatorNtbActivity.class)
+ );
+ break;
case R.id.btn_vertical_ntb:
startActivity(
new Intent(MainActivity.this, VerticalNtbActivity.class)
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
new file mode 100644
index 0000000..4894b16
--- /dev/null
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 7b92cf2..42818b7 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:weightSum="4"
+ android:weightSum="5"
android:background="#423752">
-
+
+
+ 180dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 52071e1..6c5d7ef 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -2,5 +2,5 @@
-
+
diff --git a/library/build.gradle b/library/build.gradle
index 1a2fc21..4d16b87 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -41,8 +41,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:23.1.0'
- compile 'org.jsoup:jsoup:+'
+ compile 'com.android.support:design:23.4.0'
+// compile 'org.jsoup:jsoup:+'
}
def siteUrl = 'https://github.com/DevLight-Mobile-Agency/NavigationTabBar'
diff --git a/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java b/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
new file mode 100644
index 0000000..81bc4cb
--- /dev/null
+++ b/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
@@ -0,0 +1,406 @@
+package com.gigamole.library;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v4.view.ViewCompat;
+import android.support.v4.view.ViewPropertyAnimatorCompat;
+import android.support.v4.view.ViewPropertyAnimatorUpdateListener;
+import android.support.v4.view.animation.LinearOutSlowInInterpolator;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Interpolator;
+
+/**
+ *
+ */
+public class BottomNavigationTabBarBehavior extends VerticalScrollingBehavior {
+ private static final class ViewPropertyAnimatorCompat2 {
+ private ViewPropertyAnimatorCompat va1;
+ private ViewPropertyAnimatorCompat va2;
+
+ public ViewPropertyAnimatorCompat2(NavigationTabBar ntb) {
+ va1 = ViewCompat.animate(ntb);
+ va2 = null;
+ View bg = ntb.getBackgroundView();
+ if (bg != null) {
+ va2 = ViewCompat.animate(bg);
+ }
+ }
+
+ public void setDuration(long d) {
+ va1.setDuration(d);
+ if(va2!=null) va2.setDuration(d);
+ }
+
+ public void setUpdateListener(ViewPropertyAnimatorUpdateListener viewPropertyAnimatorUpdateListener) {
+ va1.setUpdateListener(viewPropertyAnimatorUpdateListener);
+ //DON'T SET listener for va2!! we just need one updatelistener!
+ }
+
+ public void setInterpolator(Interpolator interpolator) {
+ va1.setInterpolator(interpolator);
+ if(va2!=null) va2.setInterpolator(interpolator);
+ }
+
+ public void cancel() {
+ va1.cancel();
+ if(va2!=null) va2.cancel();
+ }
+
+
+ public void translationY_start(int offset) {
+ va1.translationY(offset).start();
+ if(va2!=null) va2.translationY(offset).start();
+ }
+ }
+ private static final class ObjectAnimator2 {
+ private ObjectAnimator va1;
+ private ObjectAnimator va2;
+ public ObjectAnimator2(ObjectAnimator va1,ObjectAnimator va2) {
+ this.va1=va1;
+ this.va2=va2;
+ }
+
+ public void cancel() {
+ va1.cancel();
+ if(va2!=null) va2.cancel();
+ }
+
+ public void start() {
+ va1.start();
+ if(va2!=null) va2.start();
+ }
+
+ public void setDuration(int d) {
+ va1.setDuration(d);
+ if(va2!=null) va2.setDuration(d);
+ }
+
+ public void setInterpolator(Interpolator interpolator) {
+ va1.setInterpolator(interpolator);
+ if(va2!=null) va2.setInterpolator(interpolator);
+ }
+
+ public void addUpdateListener(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
+ va1.addUpdateListener(animatorUpdateListener);
+ }
+ }
+
+ private static final Interpolator INTERPOLATOR = new LinearOutSlowInInterpolator();
+ private static final int ANIM_DURATION = 300;
+
+ private boolean hidden = false;
+ private ViewPropertyAnimatorCompat2 translationAnimator;
+ private ObjectAnimator2 translationObjectAnimator;
+ private Snackbar.SnackbarLayout snackbarLayout;
+ private FloatingActionButton floatingActionButton;
+ private int mSnackbarHeight = -1;
+ private boolean fabBottomMarginInitialized = false;
+ private float targetOffset = 0, fabTargetOffset = 0, fabDefaultBottomMargin = 0, snackBarY = 0;
+ private boolean behaviorTranslationEnabled = true;
+
+ /**
+ * Constructor
+ */
+ public BottomNavigationTabBarBehavior() {
+ super();
+ }
+
+ public BottomNavigationTabBarBehavior(boolean behaviorTranslationEnabled) {
+ super();
+ this.behaviorTranslationEnabled = behaviorTranslationEnabled;
+ }
+
+ public BottomNavigationTabBarBehavior(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
+ a.recycle();
+ }
+
+ @Override
+ public boolean onLayoutChild(CoordinatorLayout parent, NavigationTabBar child, int layoutDirection) {
+ boolean layoutChild = super.onLayoutChild(parent, child, layoutDirection);
+ return layoutChild;
+ }
+
+
+ @Override
+ public boolean onDependentViewChanged(CoordinatorLayout parent,NavigationTabBar child, View dependency) {
+ return super.onDependentViewChanged(parent, child, dependency);
+ }
+
+ @Override
+ public void onDependentViewRemoved(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
+ super.onDependentViewRemoved(parent, child, dependency);
+ }
+
+ @Override
+ public boolean layoutDependsOn(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
+ updateSnackbar(child, dependency);
+ updateFloatingActionButton(dependency);
+ return super.layoutDependsOn(parent, child, dependency);
+ }
+
+ @Override
+ public void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll) {
+ }
+
+ @Override
+ public void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection) {
+ }
+
+ @Override
+ protected boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection) {
+ return false;
+ }
+
+ @Override
+ public void onNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
+ super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
+ if (dyConsumed < 0) {
+ handleDirection(child, ScrollDirection.SCROLL_DIRECTION_DOWN);
+ } else if (dyConsumed > 0) {
+ handleDirection(child, ScrollDirection.SCROLL_DIRECTION_UP);
+ }
+ }
+
+ @Override
+ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View directTargetChild, View target, int nestedScrollAxes) {
+ return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
+ }
+
+ /**
+ * Handle scroll direction
+ * @param child
+ * @param scrollDirection
+ */
+ private void handleDirection(NavigationTabBar child, int scrollDirection) {
+ if (!behaviorTranslationEnabled) {
+ return;
+ }
+ if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && hidden) {
+ hidden = false;
+ animateOffset(child, 0, false, true);
+ } else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !hidden) {
+ hidden = true;
+ animateOffset(child, child.getHeight(), false, true);
+ }
+ }
+
+ /**
+ * Animate offset
+ *
+ * @param child
+ * @param offset
+ */
+ private void animateOffset(final NavigationTabBar child, final int offset, boolean forceAnimation, boolean withAnimation) {
+ if (!behaviorTranslationEnabled && !forceAnimation) {
+ return;
+ }
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+ ensureOrCancelObjectAnimation(child, offset, withAnimation);
+ translationObjectAnimator.start();
+ } else {
+ ensureOrCancelAnimator(child, withAnimation);
+ translationAnimator.translationY_start(offset);
+ }
+ }
+
+ /**
+ * Manage animation for Android >= KITKAT
+ *
+ * @param child
+ */
+ private void ensureOrCancelAnimator(NavigationTabBar child, boolean withAnimation) {
+ if (translationAnimator == null) {
+ translationAnimator = new ViewPropertyAnimatorCompat2(child);
+ translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
+ translationAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(View view) {
+ // Animate snackbar
+ if (snackbarLayout != null && snackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ targetOffset = view.getMeasuredHeight() - view.getTranslationY();
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) snackbarLayout.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) targetOffset);
+ snackbarLayout.requestLayout();
+ }
+ // Animate Floating Action Button
+ if (floatingActionButton != null && floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
+ fabTargetOffset = fabDefaultBottomMargin - view.getTranslationY() + snackBarY;
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
+ floatingActionButton.requestLayout();
+ }
+ }
+ });
+ translationAnimator.setInterpolator(INTERPOLATOR);
+ } else {
+ translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
+ translationAnimator.cancel();
+ }
+ }
+
+ private static ObjectAnimator objectAnimatorOfTranslationY(View target, int offset) {
+ ObjectAnimator res;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ res = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, offset);
+ } else {
+ res = new ObjectAnimator();
+ res.setTarget(target);
+ res.setPropertyName("translationY");
+ res.setFloatValues(offset);
+ }
+ return res;
+ }
+
+
+ /**
+ * Manage animation for Android < KITKAT
+ *
+ * @param child
+ */
+ private void ensureOrCancelObjectAnimation(final NavigationTabBar child, final int offset, boolean withAnimation) {
+
+ if (translationObjectAnimator != null) {
+ translationObjectAnimator.cancel();
+ }
+
+ ObjectAnimator ta1= objectAnimatorOfTranslationY(child,offset);
+ ObjectAnimator ta2=null;
+ View bg= child.getBackgroundView();
+ if(bg!=null) {
+ ta2= objectAnimatorOfTranslationY(bg,offset);
+ }
+ translationObjectAnimator=new ObjectAnimator2(ta1,ta2);
+ translationObjectAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
+ translationObjectAnimator.setInterpolator(INTERPOLATOR);
+ translationObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ if (snackbarLayout != null && snackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ targetOffset = child.getMeasuredHeight() - child.getTranslationY();
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) snackbarLayout.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) targetOffset);
+ snackbarLayout.requestLayout();
+ }
+ // Animate Floating Action Button
+ if (floatingActionButton != null && floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
+ fabTargetOffset = fabDefaultBottomMargin - child.getTranslationY() + snackBarY;
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
+ floatingActionButton.requestLayout();
+ }
+ }
+ });
+ }
+
+
+ public static BottomNavigationTabBarBehavior from(NavigationTabBar view) {
+ ViewGroup.LayoutParams params = view.getLayoutParams();
+ if (!(params instanceof CoordinatorLayout.LayoutParams)) {
+ throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
+ }
+ CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params)
+ .getBehavior();
+ if (!(behavior instanceof BottomNavigationTabBarBehavior)) {
+ throw new IllegalArgumentException(
+ "The view is not associated with BottomNavigationTabBarBehavior");
+ }
+ return (BottomNavigationTabBarBehavior) behavior;
+ }
+
+ /**
+ * Enable or not the behavior translation
+ * @param behaviorTranslationEnabled
+ */
+ public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
+ this.behaviorTranslationEnabled = behaviorTranslationEnabled;
+ }
+
+ /**
+ * Hide AHBottomNavigation with animation
+ * @param view
+ * @param offset
+ */
+ public void hideView(NavigationTabBar view, int offset, boolean withAnimation) {
+ if (!hidden) {
+ hidden = true;
+ animateOffset(view, offset, true, withAnimation);
+ }
+ }
+
+ /**
+ * Reset AHBottomNavigation position with animation
+ * @param view
+ */
+ public void resetOffset(NavigationTabBar view, boolean withAnimation) {
+ if (hidden) {
+ hidden = false;
+ animateOffset(view, 0, true, withAnimation);
+ }
+ }
+
+ /**
+ * Update Snackbar bottom margin
+ */
+ public void updateSnackbar(final View child, View dependency) {
+
+ if (dependency != null && dependency instanceof Snackbar.SnackbarLayout) {
+
+ snackbarLayout = (Snackbar.SnackbarLayout) dependency;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ snackbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ if (floatingActionButton != null &&
+ floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
+ snackBarY = bottom - v.getY();
+ fabTargetOffset = fabDefaultBottomMargin - child.getTranslationY() + snackBarY;
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
+ floatingActionButton.requestLayout();
+ }
+ }
+ });
+ }
+
+ if (mSnackbarHeight == -1) {
+ mSnackbarHeight = dependency.getHeight();
+ }
+
+ int targetMargin = (int) (child.getMeasuredHeight() - child.getTranslationY());
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ child.bringToFront();
+ }
+
+ if (dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, targetMargin);
+ dependency.requestLayout();
+ }
+ }
+ }
+
+ /**
+ * Update floating action button bottom margin
+ */
+ public void updateFloatingActionButton(View dependency) {
+ if (dependency != null && dependency instanceof FloatingActionButton) {
+ floatingActionButton = (FloatingActionButton) dependency;
+ if (!fabBottomMarginInitialized && dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ fabBottomMarginInitialized = true;
+ ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
+ fabDefaultBottomMargin = p.bottomMargin;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 3da5054..6b22aa3 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -36,12 +36,16 @@
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
+import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
@@ -114,6 +118,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final Rect mBadgeBounds = new Rect();
private final RectF mBgBadgeBounds = new RectF();
+ //external backgroundView for the tab layout
+ private View backgroundView=null;
// Canvas, where all of other canvas will be merged
private Bitmap mBitmap;
private Canvas mCanvas;
@@ -126,6 +132,14 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private Bitmap mPointerBitmap;
private Canvas mPointerCanvas;
+ private int navBarHeight; //updated in OnMeasure()
+ private boolean isBehaviorTranslationSet = false;
+ private boolean behaviorTranslationEnabled = false;
+ private boolean needHideBottomNavigation = false;
+ private boolean hideBottomNavigationWithAnimation = false;
+ private BottomNavigationTabBarBehavior bottomNavigationBehavior;
+
+
// Main paint
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
{
@@ -782,9 +796,11 @@ public boolean onTouchEvent(final MotionEvent event) {
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
// Get measure size
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int height = MeasureSpec.getSize(heightMeasureSpec);
+ navBarHeight=height;
if (mModels.isEmpty() || width == 0 || height == 0) return;
@@ -814,6 +830,7 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
}
} else {
mIsHorizontalOrientation = false;
+ behaviorTranslationEnabled=false; //disable vertical translation in coordinator layout
mIsTitled = false;
mIsBadged = false;
@@ -871,6 +888,13 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
mEndPointerX = mStartPointerX;
updateIndicatorPosition(MAX_FRACTION);
}
+
+ if (!isBehaviorTranslationSet) {
+ //The translation behavior has to be set up after the super.onMeasure has been called.
+ setBehaviorTranslationEnabled(behaviorTranslationEnabled);
+ isBehaviorTranslationSet = true;
+ }
+
}
@Override
@@ -1322,6 +1346,27 @@ public Parcelable onSaveInstanceState() {
return savedState;
}
+ /**
+ * set the background view for the tab bar
+ * Also make sure that the background view height match the tab bar height
+ * you should call this like this:
+ *
+ * @param bg
+ */
+ public void setBackgroundView(final View bg) {
+ post(new Runnable() {
+ @Override
+ public void run() {
+ bg.getLayoutParams().height = (int) getBarHeight();
+ bg.requestLayout();
+ backgroundView=bg;
+ }
+ });
+ }
+ public View getBackgroundView() {
+ return backgroundView;
+ }
+
private static class SavedState extends BaseSavedState {
int index;
@@ -1649,4 +1694,105 @@ public interface OnTabBarSelectedIndexListener {
void onEndTabSelected(final Model model, final int index);
}
+
+
+ /**
+ * Return if the behavior translation is enabled
+ *
+ * @return a boolean value
+ */
+ public boolean isBehaviorTranslationEnabled() {
+ return behaviorTranslationEnabled;
+ }
+ /**
+ * Set the behavior translation value
+ *
+ * @param behaviorTranslationEnabled boolean for the state
+ */
+ public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
+ this.behaviorTranslationEnabled = behaviorTranslationEnabled;
+ if (getParent() instanceof CoordinatorLayout) {
+ ViewGroup.LayoutParams params = getLayoutParams();
+ if (bottomNavigationBehavior == null) {
+ bottomNavigationBehavior = new BottomNavigationTabBarBehavior(behaviorTranslationEnabled);
+ } else {
+ bottomNavigationBehavior.setBehaviorTranslationEnabled(behaviorTranslationEnabled);
+ }
+ ((CoordinatorLayout.LayoutParams) params).setBehavior(bottomNavigationBehavior);
+ if (needHideBottomNavigation) {
+ needHideBottomNavigation = false;
+ bottomNavigationBehavior.hideView(this, navBarHeight, hideBottomNavigationWithAnimation);
+ }
+ }
+ }
+
+ /**
+ * Hide Bottom Navigation with animation
+ */
+ public void hideBottomNavigation() {
+ hideBottomNavigation(true);
+ }
+
+ /**
+ * Hide Bottom Navigation with or without animation
+ *
+ * @param withAnimation Boolean
+ */
+ public void hideBottomNavigation(boolean withAnimation) {
+ if (bottomNavigationBehavior != null) {
+ bottomNavigationBehavior.hideView(this, navBarHeight, withAnimation);
+ } else if (getParent() instanceof CoordinatorLayout) {
+ needHideBottomNavigation = true;
+ hideBottomNavigationWithAnimation = withAnimation;
+ } else {
+ scrollDownView(this,withAnimation);
+ if(backgroundView!=null) {
+ scrollDownView(backgroundView,withAnimation);
+ }
+ }
+ }
+
+
+ /**
+ * Restore Bottom Navigation with animation
+ */
+ public void restoreBottomNavigation() {
+ restoreBottomNavigation(true);
+ }
+
+ /**
+ * Restore Bottom Navigation with or without animation
+ *
+ * @param withAnimation Boolean
+ */
+ public void restoreBottomNavigation(boolean withAnimation) {
+ if (bottomNavigationBehavior != null) {
+ bottomNavigationBehavior.resetOffset(this, withAnimation);
+ } else {
+ // Show bottom navigation
+ scrollUpView(this,withAnimation);
+ if(backgroundView!=null) {
+ scrollUpView(backgroundView,withAnimation);
+ }
+ }
+ }
+
+ private void scrollDownView(View view,boolean withAnimation) {
+ int HIDE_ANIM_DURATION=300;
+ // Hide bottom navigation
+ ViewCompat.animate(view)
+ .translationY(navBarHeight)
+ .setInterpolator(new LinearOutSlowInInterpolator())
+ .setDuration(withAnimation ? HIDE_ANIM_DURATION : 0)
+ .start();
+ }
+ private void scrollUpView(View view,boolean withAnimation) {
+ int SHOW_ANIM_DURATION=300;
+ ViewCompat.animate(view)
+ .translationY(0)
+ .setInterpolator(new LinearOutSlowInInterpolator())
+ .setDuration(withAnimation ? SHOW_ANIM_DURATION : 0)
+ .start();
+ }
+
}
diff --git a/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java b/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
new file mode 100644
index 0000000..c4bb460
--- /dev/null
+++ b/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
@@ -0,0 +1,146 @@
+package com.gigamole.library;
+
+
+import android.content.Context;
+import android.os.Parcelable;
+import android.support.annotation.IntDef;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.v4.view.WindowInsetsCompat;
+import android.util.AttributeSet;
+import android.view.View;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Created by Nikola on 11/22/2015.
+ */
+public abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
+
+ private int mTotalDyUnconsumed = 0;
+ private int mTotalDy = 0;
+ @ScrollDirection
+ private int mOverScrollDirection = ScrollDirection.SCROLL_NONE;
+ @ScrollDirection
+ private int mScrollDirection = ScrollDirection.SCROLL_NONE;
+
+ public VerticalScrollingBehavior(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public VerticalScrollingBehavior() {
+ super();
+ }
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({ScrollDirection.SCROLL_DIRECTION_UP, ScrollDirection.SCROLL_DIRECTION_DOWN})
+ public @interface ScrollDirection {
+ int SCROLL_DIRECTION_UP = 1;
+ int SCROLL_DIRECTION_DOWN = -1;
+ int SCROLL_NONE = 0;
+ }
+
+
+ /*
+ @return Overscroll direction: SCROLL_DIRECTION_UP, CROLL_DIRECTION_DOWN, SCROLL_NONE
+ */
+ @ScrollDirection
+ public int getOverScrollDirection() {
+ return mOverScrollDirection;
+ }
+
+
+ /**
+ * @return Scroll direction: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN, SCROLL_NONE
+ */
+
+ @ScrollDirection
+ public int getScrollDirection() {
+ return mScrollDirection;
+ }
+
+
+ /**
+ * @param coordinatorLayout
+ * @param child
+ * @param direction Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ * @param currentOverScroll Unconsumed value, negative or positive based on the direction;
+ * @param totalOverScroll Cumulative value for current direction
+ */
+ public abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll);
+
+ /**
+ * @param scrollDirection Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ */
+ public abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection);
+
+ @Override
+ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
+ return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0;
+ }
+
+ @Override
+ public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
+ super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
+ }
+
+ @Override
+ public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
+ super.onStopNestedScroll(coordinatorLayout, child, target);
+ }
+
+ @Override
+ public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
+ super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
+ if (dyUnconsumed > 0 && mTotalDyUnconsumed < 0) {
+ mTotalDyUnconsumed = 0;
+ mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
+ } else if (dyUnconsumed < 0 && mTotalDyUnconsumed > 0) {
+ mTotalDyUnconsumed = 0;
+ mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
+ }
+ mTotalDyUnconsumed += dyUnconsumed;
+ onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed);
+ }
+
+ @Override
+ public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
+ super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
+ if (dy > 0 && mTotalDy < 0) {
+ mTotalDy = 0;
+ mScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
+ } else if (dy < 0 && mTotalDy > 0) {
+ mTotalDy = 0;
+ mScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
+ }
+ mTotalDy += dy;
+ onDirectionNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, mScrollDirection);
+ }
+
+
+ @Override
+ public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, boolean consumed) {
+ super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
+ mScrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
+ return onNestedDirectionFling(coordinatorLayout, child, target, velocityX, velocityY, mScrollDirection);
+ }
+
+ protected abstract boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection);
+
+ @Override
+ public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
+ return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
+ }
+
+ @Override
+ public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout coordinatorLayout, V child, WindowInsetsCompat insets) {
+
+ return super.onApplyWindowInsets(coordinatorLayout, child, insets);
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) {
+ return super.onSaveInstanceState(parent, child);
+ }
+
+}
\ No newline at end of file
From 981fe72522d755c0d3b207cbad4a683b282e2671 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 4 Jun 2016 16:55:09 +0300
Subject: [PATCH 17/64] Fixes Optimizations Code refactor Tint mode support
---
README.md | 6 +
.../res/layout/activity_horizontal_ntb.xml | 1 +
.../gigamole/library/NavigationTabBar.java | 150 +++++++++++++-----
library/src/main/res/values/attrs.xml | 1 +
4 files changed, 114 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index ab94d99..aee2763 100644
--- a/README.md
+++ b/README.md
@@ -91,6 +91,10 @@ For NTB you can set such parameters as:
allows you to handle mode of the model icon and title scale.
+ - tint mode:
+
+ allows you to enable or disable icon tinting.
+
- badge position:
allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).
@@ -201,6 +205,7 @@ navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.CENTER);
navigationTabBar.setTypeface("fonts/custom_font.ttf");
navigationTabBar.setIsBadged(true);
navigationTabBar.setIsTitled(true);
+navigationTabBar.setIsTinted(true);
navigationTabBar.setIsBadgeUseTypeface(true);
navigationTabBar.setBadgeBgColor(Color.RED);
navigationTabBar.setBadgeTitleColor(Color.WHITE);
@@ -246,6 +251,7 @@ And XML init:
app:ntb_badged="true"
app:ntb_titled="true"
app:ntb_scaled="true"
+ app:ntb_tinted="true"
app:ntb_title_mode="all"
app:ntb_badge_position="right"
app:ntb_badge_gravity="top"
diff --git a/app/src/main/res/layout/activity_horizontal_ntb.xml b/app/src/main/res/layout/activity_horizontal_ntb.xml
index 701b0f8..478b2eb 100644
--- a/app/src/main/res/layout/activity_horizontal_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_ntb.xml
@@ -34,6 +34,7 @@
app:ntb_badge_position="right"
app:ntb_badged="true"
app:ntb_scaled="true"
+ app:ntb_tinted="false"
app:ntb_title_mode="all"
app:ntb_titled="true"/>
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
index 3da5054..0e63660 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/NavigationTabBar.java
@@ -85,6 +85,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static float TITLE_ACTIVE_SCALE_BY = 0.2f;
private final static float TITLE_SIZE_FRACTION = 0.2f;
private final static float TITLE_MARGIN_FRACTION = 0.15f;
+ private final static float TITLE_MARGIN_SCALE_FRACTION = 0.25f;
private final static float BADGE_HORIZONTAL_FRACTION = 0.5f;
private final static float BADGE_VERTICAL_FRACTION = 0.75f;
@@ -116,15 +117,19 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Canvas, where all of other canvas will be merged
private Bitmap mBitmap;
- private Canvas mCanvas;
+ private final Canvas mCanvas = new Canvas();
// Canvas with icons
private Bitmap mIconsBitmap;
- private Canvas mIconsCanvas;
+ private final Canvas mIconsCanvas = new Canvas();
+
+ // Canvas with titles
+ private Bitmap mTitlesBitmap;
+ private final Canvas mTitlesCanvas = new Canvas();
// Canvas for our rect pointer
private Bitmap mPointerBitmap;
- private Canvas mPointerCanvas;
+ private final Canvas mPointerCanvas = new Canvas();
// Main paint
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
@@ -186,7 +191,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private int mAnimationDuration;
// NTP models
- private List mModels = new ArrayList<>();
+ private final List mModels = new ArrayList<>();
// Variables for ViewPager
private ViewPager mViewPager;
@@ -199,7 +204,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Variables for sizes
private float mModelSize;
- private int mIconSize;
+ private float mIconSize;
// Corners radius for rect mode
private float mCornersRadius;
@@ -242,6 +247,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private boolean mIsBadged;
// Detect if model icon scaled
private boolean mIsScaled;
+ // Detect if model icon tinted
+ private boolean mIsTinted;
// Detect if model badge have custom typeface
private boolean mIsBadgeUseTypeface;
// Detect if is bar mode or indicator pager mode
@@ -286,6 +293,7 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
+ setIsTinted(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_tinted, true));
setIsBadgeUseTypeface(
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
);
@@ -385,7 +393,7 @@ public void onAnimationUpdate(final ValueAnimator animation) {
}
mModels.clear();
- mModels = models;
+ mModels.addAll(models);
requestLayout();
}
@@ -416,6 +424,15 @@ public void setIsScaled(final boolean isScaled) {
requestLayout();
}
+ public boolean isTinted() {
+ return mIsTinted;
+ }
+
+ public void setIsTinted(final boolean isTinted) {
+ mIsTinted = isTinted;
+ updateTint();
+ }
+
public boolean isBadgeUseTypeface() {
return mIsBadgeUseTypeface;
}
@@ -542,8 +559,10 @@ public int getActiveColor() {
public void setActiveColor(final int activeColor) {
mActiveColor = activeColor;
- mIconPointerPaint.setColor(activeColor);
- postInvalidate();
+
+ // Set icon pointer active color
+ mIconPointerPaint.setColor(mActiveColor);
+ updateTint();
}
public int getInactiveColor() {
@@ -553,11 +572,9 @@ public int getInactiveColor() {
public void setInactiveColor(final int inactiveColor) {
mInactiveColor = inactiveColor;
- // Set color filter to wrap icons with inactive color
- mIconPaint.setColorFilter(new PorterDuffColorFilter(inactiveColor, PorterDuff.Mode.SRC_IN));
- mSelectedIconPaint.setColorFilter(new PorterDuffColorFilter(inactiveColor, PorterDuff.Mode.SRC_IN));
+ // Set inactive color to title
mModelTitlePaint.setColor(mInactiveColor);
- postInvalidate();
+ updateTint();
}
public float getCornersRadius() {
@@ -698,7 +715,8 @@ public void setModelIndex(int index, boolean force) {
mViewPager.setCurrentItem(index, true);
}
- // Set startX and endX for animation, where we animate two sides of rect with different interpolation
+ // Set startX and endX for animation,
+ // where we animate two sides of rect with different interpolation
mStartPointerX = mPointerLeftTop;
mEndPointerX = mIndex * mModelSize;
@@ -729,6 +747,7 @@ private void updateIndicatorPosition(final float fraction) {
// Update NTP
private void notifyDataSetChanged() {
+ requestLayout();
postInvalidate();
}
@@ -792,13 +811,14 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
if (width > height) {
mIsHorizontalOrientation = true;
+ // Get model size
+ mModelSize = (float) width / (float) mModels.size();
+
// Get smaller side
float side = mModelSize > height ? height : mModelSize;
if (mIsBadged) side -= side * TITLE_SIZE_FRACTION;
- mModelSize = (float) width / (float) mModels.size();
- mIconSize = (int) (side * (mIsTitled ? TITLE_ICON_SIZE_FRACTION : ICON_SIZE_FRACTION));
-
+ mIconSize = side * (mIsTitled ? TITLE_ICON_SIZE_FRACTION : ICON_SIZE_FRACTION);
mModelTitleSize = side * TITLE_SIZE_FRACTION;
mTitleMargin = side * TITLE_MARGIN_FRACTION;
@@ -826,21 +846,27 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
// Set main bitmap
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mCanvas = new Canvas(mBitmap);
+ mCanvas.setBitmap(mBitmap);
// Set pointer canvas
mPointerBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mPointerCanvas = new Canvas(mPointerBitmap);
+ mPointerCanvas.setBitmap(mPointerBitmap);
// Set icons canvas
mIconsBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mIconsCanvas = new Canvas(mIconsBitmap);
+ mIconsCanvas.setBitmap(mIconsBitmap);
+
+ // Set titles canvas
+ if (mIsTitled) {
+ mTitlesBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ mTitlesCanvas.setBitmap(mTitlesBitmap);
+ } else mTitlesBitmap = null;
// Set scale fraction for icons
for (Model model : mModels) {
final float originalIconSize = model.mIcon.getWidth() > model.mIcon.getHeight() ?
model.mIcon.getWidth() : model.mIcon.getHeight();
- model.mInactiveIconScale = (float) mIconSize / originalIconSize;
+ model.mInactiveIconScale = mIconSize / originalIconSize;
model.mActiveIconScaleBy = model.mInactiveIconScale *
(mIsTitled ? TITLE_ACTIVE_ICON_SCALE_BY : ACTIVE_ICON_SCALE_BY);
}
@@ -875,12 +901,15 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
@Override
protected void onDraw(final Canvas canvas) {
- if (mCanvas == null || mPointerCanvas == null || mIconsCanvas == null) return;
+ if (mCanvas == null || mPointerCanvas == null ||
+ mIconsCanvas == null || mTitlesCanvas == null)
+ return;
// Reset and clear canvases
mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
mPointerCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
mIconsCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
+ if (mIsTitled) mTitlesCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
// Get pointer badge margin for gravity
final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0f;
@@ -917,6 +946,9 @@ protected void onDraw(final Canvas canvas) {
// Draw pointer into main canvas
mCanvas.drawBitmap(mPointerBitmap, 0.0f, 0.0f, mPointerPaint);
+ // Set vars for icon when model with title or without
+ final float iconMarginTitleHeight = mIconSize + mTitleMargin + mModelTitleSize;
+
// Draw model icons
for (int i = 0; i < mModels.size(); i++) {
final Model model = mModels.get(i);
@@ -927,8 +959,7 @@ protected void onDraw(final Canvas canvas) {
final float matrixCenterX;
final float matrixCenterY;
- // Set vars for icon when model with title or without
- final float iconMarginTitleHeight = mIconSize + mTitleMargin + mModelTitleSize;
+ // Set offset to titles
final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5f);
final float topTitleOffset =
mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5f;
@@ -936,20 +967,17 @@ protected void onDraw(final Canvas canvas) {
if (mIsHorizontalOrientation) {
leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5f;
topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5f;
-
- matrixCenterX = leftOffset + model.mIcon.getWidth() * 0.5f;
- matrixCenterY = topOffset + model.mIcon.getHeight() * 0.5f +
- (mIsTitled && mTitleMode == TitleMode.ALL ? mTitleMargin * 0.5f : 0.0f);
} else {
- leftOffset = (mBounds.width() - model.mIcon.getWidth()) * 0.5f;
- topOffset = (mModelSize * i) + (mModelSize - model.mIcon.getHeight()) * 0.5f;
-
- matrixCenterX = leftOffset + model.mIcon.getWidth() * 0.5f;
- matrixCenterY = topOffset + model.mIcon.getHeight() * 0.5f;
+ leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5f;
+ topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5f;
}
+ matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5f;
+ matrixCenterY = topOffset + (float) model.mIcon.getHeight() * 0.5f;
+
// Title translate position
- final float titleTranslate = -model.mIcon.getHeight() + topTitleOffset - mTitleMargin * 0.5f;
+ final float titleTranslate =
+ topOffset - model.mIcon.getHeight() * TITLE_MARGIN_SCALE_FRACTION;
// Translate icon to model center
model.mIconMatrix.setTranslate(
@@ -980,7 +1008,8 @@ protected void onDraw(final Canvas canvas) {
if (model.mSelectedIcon != null) mSelectedIconPaint.setAlpha(MAX_ALPHA);
// Check if we handle models from touch on NTP or from ViewPager
- // There is a strange logic of ViewPager onPageScrolled method, so it is
+ // There is a strange logic
+ // of ViewPager onPageScrolled method, so it is
if (mIsSetIndexFromTabBar) {
if (mIndex == i)
updateCurrentModel(
@@ -1025,24 +1054,43 @@ else if (i == mIndex)
}
// Draw selected icon when exist and visible
if (model.mSelectedIcon != null && mSelectedIconPaint.getAlpha() != MIN_ALPHA)
- mIconsCanvas.drawBitmap(model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint);
+ mIconsCanvas.drawBitmap(
+ model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint
+ );
if (mIsTitled)
- mIconsCanvas.drawText(
+ mTitlesCanvas.drawText(
isInEditMode() ? PREVIEW_TITLE : model.getTitle(),
leftTitleOffset, topTitleOffset, mModelTitlePaint
);
}
- // Draw pointer with active color to wrap out active icon
- if (mCornersRadius == 0) mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
- else
- mIconsCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
+ // Reset pointer bounds for icons and titles
+ if (mIsHorizontalOrientation)
+ mPointerBounds.set(
+ mPointerLeftTop, 0.0F,
+ mPointerRightBottom, mBounds.height()
+ );
+ if (mCornersRadius == 0) {
+ if (mIsTinted) mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
+ if (mIsTitled) mTitlesCanvas.drawRect(mPointerBounds, mIconPointerPaint);
+ } else {
+ if (mIsTinted)
+ mIconsCanvas.drawRoundRect(
+ mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
+ );
+ if (mIsTitled)
+ mTitlesCanvas.drawRoundRect(
+ mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
+ );
+ }
// Draw general bitmap
canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
// Draw icons bitmap on top
canvas.drawBitmap(mIconsBitmap, 0.0f, pointerBadgeMargin, null);
+ // Draw titles bitmap on top
+ if (mIsTitled) canvas.drawBitmap(mTitlesBitmap, 0.0f, pointerBadgeMargin, null);
// If is not badged, exit
if (!mIsBadged) return;
@@ -1135,8 +1183,7 @@ private void updateCurrentModel(
model.mIconMatrix.postScale(
model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
- matrixCenterX, matrixCenterY + (mIsTitled && mTitleMode == TitleMode.ACTIVE ?
- mTitleMargin * 0.5f * interpolation : 0.0f)
+ matrixCenterX, matrixCenterY
);
mModelTitlePaint.setTextSize(mModelTitleSize * textScale);
@@ -1191,8 +1238,7 @@ private void updateLastModel(
model.mIconMatrix.postScale(
model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
- matrixCenterX, matrixCenterY + (mIsTitled && mTitleMode == TitleMode.ACTIVE ?
- mTitleMargin * 0.5f - (mTitleMargin * 0.5f * lastInterpolation) : 0.0f)
+ matrixCenterX, matrixCenterY
);
mModelTitlePaint.setTextSize(mModelTitleSize * textLastScale);
@@ -1260,6 +1306,22 @@ private void updateInactiveModel(
mSelectedIconPaint.setAlpha(MIN_ALPHA);
}
+ private void updateTint() {
+ if (mIsTinted) {
+ // Set color filter to wrap icons with inactive color
+ final PorterDuffColorFilter colorFilter =
+ new PorterDuffColorFilter(mInactiveColor, PorterDuff.Mode.SRC_IN);
+ mIconPaint.setColorFilter(colorFilter);
+ mSelectedIconPaint.setColorFilter(colorFilter);
+ } else {
+ // Reset active and inactive colors
+ mIconPaint.reset();
+ mSelectedIconPaint.reset();
+ }
+
+ postInvalidate();
+ }
+
@Override
public void onPageScrolled(int position, float positionOffset, final int positionOffsetPixels) {
// If we animate, don`t call this
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index f12c014..13ca302 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -5,6 +5,7 @@
+
From e6bbbea8106eb8423532eb27e04e210d39e35bef Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sun, 5 Jun 2016 02:46:20 +0300
Subject: [PATCH 18/64] BottomBehavior support Fixes Optimizations Code
refactor
---
README.md | 44 +-
.../HorizontalCoordinatorNtbActivity.java | 42 +-
.../HorizontalNtbActivity.java | 19 +-
.../navigationtabbar/SamplesNtbActivity.java | 2 +-
.../TopHorizontalNtbActivity.java | 6 +-
.../navigationtabbar/VerticalNtbActivity.java | 2 +-
.../activity_horizontal_coordinator_ntb.xml | 76 ++-
.../res/layout/activity_horizontal_ntb.xml | 44 +-
.../layout/activity_horizontal_top_ntb.xml | 10 +-
.../main/res/layout/activity_samples_ntb.xml | 12 +-
.../main/res/layout/activity_vertical_ntb.xml | 2 +-
app/src/main/res/values/dimens.xml | 4 -
library/build.gradle | 5 +-
.../BottomNavigationTabBarBehavior.java | 406 ----------------
.../library/VerticalScrollingBehavior.java | 146 ------
.../behavior/NavigationTabBarBehavior.java | 293 ++++++++++++
.../behavior/VerticalScrollingBehavior.java | 128 +++++
.../library/{ => ntb}/NavigationTabBar.java | 445 +++++++++---------
18 files changed, 758 insertions(+), 928 deletions(-)
delete mode 100644 app/src/main/res/values/dimens.xml
delete mode 100644 library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
delete mode 100644 library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
create mode 100644 library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
create mode 100644 library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
rename library/src/main/java/com/gigamole/library/{ => ntb}/NavigationTabBar.java (87%)
diff --git a/README.md b/README.md
index cf7972d..1d78ee4 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,9 @@ NavigationTabBar
Navigation tab bar with colorful interactions.
-Horizontal NTB|NTB with selected icons |NTB with CoordinatorLayout|Vertical NTB|NTB Samples|
-:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
-||||
-
+Horizontal NTB | NTB with bottom behavior | NTB with selected icons | NTB with CoordinatorLayout | Vertical NTB | NTB Samples |
+:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
+|||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
Download
@@ -33,7 +32,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.1.8'
+compile 'com.github.devlight.navigationtabbar:library:1.2.0'
```
Or Maven:
@@ -42,7 +41,7 @@ Or Maven:
com.github.devlight.navigationtabbar
library
- 1.1.8
+ 1.2.0
aar
```
@@ -63,9 +62,17 @@ For NTB you can set such parameters as:
allows you to set NTB models, where you set icon and color. Can be set up only via code.
+ - behavior:
+
+ allows you to set bottom translation behavior.
+
- view pager:
- allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
+ allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
+
+ - background:
+
+ allows you to set background to NTB which automatically set with offset relative to badge gravity.
- model selected icon:
@@ -149,6 +156,9 @@ By default badge bg color is the active model color and badge title color is the
If your set ViewPager you can action down on active pointer and do like drag.
+If you want to set the background to NTB, just set background via XML or code and its automatically set relative to badge gravity.
+
+
Init
Check out in code init:
@@ -211,21 +221,7 @@ navigationTabBar.setBadgeBgColor(Color.RED);
navigationTabBar.setBadgeTitleColor(Color.WHITE);
```
-If you want to set the background to NTB, you need to create some view at he bottom of NTB in layout and then set height of your background view like this:
-
-```java
-navigationTabBar.post(new Runnable() {
- @Override
- public void run() {
- final View background = findViewById(R.id.background);
- background.getLayoutParams().height = (int) navigationTabBar.getBarHeight();
- background.requestLayout();
- }
-});
-```
-
If your models is in badge mode you can set title, hide, show, toggle and update badge title like this:
-
```java
model.setTitle("Here some title to model");
model.hideBadge();
@@ -234,9 +230,9 @@ model.toggleBadge();
model.updateBadgeTitle("Here some title like NEW or some integer value");
```
-To enable translation inside CoordinatorLayout when at bottom of screen:
+To enable behavior translation inside CoordinatorLayout when at bottom of screen:
```java
-bottomNavigation.setBehaviorTranslationEnabled(true);
+bottomNavigation.setBehaviorEnabled(true);
```
Other methods check out in sample.
@@ -244,7 +240,7 @@ Other methods check out in sample.
And XML init:
```xml
- {
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
index bd91aa0..11eb430 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.NavigationTabBar;
+import com.gigamole.library.ntb.NavigationTabBar;
import java.util.ArrayList;
@@ -26,14 +26,6 @@ protected void onCreate(final Bundle savedInstanceState) {
initUI();
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- System.runFinalization();
- Runtime.getRuntime().gc();
- System.gc();
- }
-
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(new PagerAdapter() {
@@ -134,15 +126,6 @@ public void onPageScrollStateChanged(final int state) {
}
});
- navigationTabBar.post(new Runnable() {
- @Override
- public void run() {
- final View bgNavigationTabBar = findViewById(R.id.bg_ntb_horizontal);
- bgNavigationTabBar.getLayoutParams().height = (int) navigationTabBar.getBarHeight();
- bgNavigationTabBar.requestLayout();
- }
- });
-
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
index 097263f..74e2f16 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
@@ -6,7 +6,7 @@
import android.support.v4.graphics.ColorUtils;
import android.widget.Toast;
-import com.gigamole.library.NavigationTabBar;
+import com.gigamole.library.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
index 6f32fc8..2c8ccaf 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
@@ -12,7 +12,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.NavigationTabBar;
+import com.gigamole.library.ntb.NavigationTabBar;
import java.util.ArrayList;
import java.util.Random;
@@ -110,10 +110,6 @@ public Object instantiateItem(final ViewGroup container, final int position) {
navigationTabBar.post(new Runnable() {
@Override
public void run() {
- final View bgNavigationTabBar = findViewById(R.id.bg_ntb_horizontal);
- bgNavigationTabBar.getLayoutParams().height = (int) navigationTabBar.getBarHeight();
- bgNavigationTabBar.requestLayout();
-
final View viewPager = findViewById(R.id.vp_horizontal_ntb);
((ViewGroup.MarginLayoutParams) viewPager.getLayoutParams()).topMargin =
(int) -navigationTabBar.getBadgeMargin();
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
index 53275a7..2fbb075 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.NavigationTabBar;
+import com.gigamole.library.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
index 4894b16..3bed374 100644
--- a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -2,6 +2,7 @@
+
+ android:tint="#9f90af"
+ android:padding="32dp"
+ app:layout_collapseMode="pin"/>
+ app:title="@string/app_name"
+ app:popupTheme="@style/AppTheme.AppBarOverlay"/>
@@ -46,45 +53,30 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
-
-
-
+ android:layout_marginEnd="16dp"
+ android:tint="#9f90af"
+ android:src="http://github.com/@drawable/ic_first"
+ app:backgroundTint="#605271"/>
-
-
-
-
+
diff --git a/app/src/main/res/layout/activity_horizontal_ntb.xml b/app/src/main/res/layout/activity_horizontal_ntb.xml
index 478b2eb..5dd7f64 100644
--- a/app/src/main/res/layout/activity_horizontal_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_ntb.xml
@@ -1,5 +1,5 @@
-
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
-
+ android:layout_height="60dp"
+ android:background="#605271"
+ app:ntb_badge_gravity="top"
+ app:ntb_badge_position="right"
+ app:ntb_badged="true"
+ app:ntb_scaled="true"
+ app:ntb_tinted="true"
+ app:ntb_title_mode="all"
+ app:ntb_titled="true"/>
-
-
-
-
-
-
-
+
diff --git a/app/src/main/res/layout/activity_horizontal_top_ntb.xml b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
index ef221b7..961ee00 100644
--- a/app/src/main/res/layout/activity_horizontal_top_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
@@ -24,17 +24,11 @@
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
-
-
-
-
-
-
-
-
-
-
-
- 180dp
-
\ No newline at end of file
diff --git a/library/build.gradle b/library/build.gradle
index 4d16b87..f8f0bbb 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.1.8"
+version = "1.2.0"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.1.8"
+ versionName "1.2.0"
}
buildTypes {
release {
@@ -42,7 +42,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:23.4.0'
-// compile 'org.jsoup:jsoup:+'
}
def siteUrl = 'https://github.com/DevLight-Mobile-Agency/NavigationTabBar'
diff --git a/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java b/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
deleted file mode 100644
index 81bc4cb..0000000
--- a/library/src/main/java/com/gigamole/library/BottomNavigationTabBarBehavior.java
+++ /dev/null
@@ -1,406 +0,0 @@
-package com.gigamole.library;
-
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.support.design.widget.CoordinatorLayout;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorUpdateListener;
-import android.support.v4.view.animation.LinearOutSlowInInterpolator;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Interpolator;
-
-/**
- *
- */
-public class BottomNavigationTabBarBehavior extends VerticalScrollingBehavior {
- private static final class ViewPropertyAnimatorCompat2 {
- private ViewPropertyAnimatorCompat va1;
- private ViewPropertyAnimatorCompat va2;
-
- public ViewPropertyAnimatorCompat2(NavigationTabBar ntb) {
- va1 = ViewCompat.animate(ntb);
- va2 = null;
- View bg = ntb.getBackgroundView();
- if (bg != null) {
- va2 = ViewCompat.animate(bg);
- }
- }
-
- public void setDuration(long d) {
- va1.setDuration(d);
- if(va2!=null) va2.setDuration(d);
- }
-
- public void setUpdateListener(ViewPropertyAnimatorUpdateListener viewPropertyAnimatorUpdateListener) {
- va1.setUpdateListener(viewPropertyAnimatorUpdateListener);
- //DON'T SET listener for va2!! we just need one updatelistener!
- }
-
- public void setInterpolator(Interpolator interpolator) {
- va1.setInterpolator(interpolator);
- if(va2!=null) va2.setInterpolator(interpolator);
- }
-
- public void cancel() {
- va1.cancel();
- if(va2!=null) va2.cancel();
- }
-
-
- public void translationY_start(int offset) {
- va1.translationY(offset).start();
- if(va2!=null) va2.translationY(offset).start();
- }
- }
- private static final class ObjectAnimator2 {
- private ObjectAnimator va1;
- private ObjectAnimator va2;
- public ObjectAnimator2(ObjectAnimator va1,ObjectAnimator va2) {
- this.va1=va1;
- this.va2=va2;
- }
-
- public void cancel() {
- va1.cancel();
- if(va2!=null) va2.cancel();
- }
-
- public void start() {
- va1.start();
- if(va2!=null) va2.start();
- }
-
- public void setDuration(int d) {
- va1.setDuration(d);
- if(va2!=null) va2.setDuration(d);
- }
-
- public void setInterpolator(Interpolator interpolator) {
- va1.setInterpolator(interpolator);
- if(va2!=null) va2.setInterpolator(interpolator);
- }
-
- public void addUpdateListener(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
- va1.addUpdateListener(animatorUpdateListener);
- }
- }
-
- private static final Interpolator INTERPOLATOR = new LinearOutSlowInInterpolator();
- private static final int ANIM_DURATION = 300;
-
- private boolean hidden = false;
- private ViewPropertyAnimatorCompat2 translationAnimator;
- private ObjectAnimator2 translationObjectAnimator;
- private Snackbar.SnackbarLayout snackbarLayout;
- private FloatingActionButton floatingActionButton;
- private int mSnackbarHeight = -1;
- private boolean fabBottomMarginInitialized = false;
- private float targetOffset = 0, fabTargetOffset = 0, fabDefaultBottomMargin = 0, snackBarY = 0;
- private boolean behaviorTranslationEnabled = true;
-
- /**
- * Constructor
- */
- public BottomNavigationTabBarBehavior() {
- super();
- }
-
- public BottomNavigationTabBarBehavior(boolean behaviorTranslationEnabled) {
- super();
- this.behaviorTranslationEnabled = behaviorTranslationEnabled;
- }
-
- public BottomNavigationTabBarBehavior(Context context, AttributeSet attrs) {
- super(context, attrs);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
- a.recycle();
- }
-
- @Override
- public boolean onLayoutChild(CoordinatorLayout parent, NavigationTabBar child, int layoutDirection) {
- boolean layoutChild = super.onLayoutChild(parent, child, layoutDirection);
- return layoutChild;
- }
-
-
- @Override
- public boolean onDependentViewChanged(CoordinatorLayout parent,NavigationTabBar child, View dependency) {
- return super.onDependentViewChanged(parent, child, dependency);
- }
-
- @Override
- public void onDependentViewRemoved(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
- super.onDependentViewRemoved(parent, child, dependency);
- }
-
- @Override
- public boolean layoutDependsOn(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
- updateSnackbar(child, dependency);
- updateFloatingActionButton(dependency);
- return super.layoutDependsOn(parent, child, dependency);
- }
-
- @Override
- public void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll) {
- }
-
- @Override
- public void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection) {
- }
-
- @Override
- protected boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection) {
- return false;
- }
-
- @Override
- public void onNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
- super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
- if (dyConsumed < 0) {
- handleDirection(child, ScrollDirection.SCROLL_DIRECTION_DOWN);
- } else if (dyConsumed > 0) {
- handleDirection(child, ScrollDirection.SCROLL_DIRECTION_UP);
- }
- }
-
- @Override
- public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View directTargetChild, View target, int nestedScrollAxes) {
- return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
- }
-
- /**
- * Handle scroll direction
- * @param child
- * @param scrollDirection
- */
- private void handleDirection(NavigationTabBar child, int scrollDirection) {
- if (!behaviorTranslationEnabled) {
- return;
- }
- if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && hidden) {
- hidden = false;
- animateOffset(child, 0, false, true);
- } else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !hidden) {
- hidden = true;
- animateOffset(child, child.getHeight(), false, true);
- }
- }
-
- /**
- * Animate offset
- *
- * @param child
- * @param offset
- */
- private void animateOffset(final NavigationTabBar child, final int offset, boolean forceAnimation, boolean withAnimation) {
- if (!behaviorTranslationEnabled && !forceAnimation) {
- return;
- }
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
- ensureOrCancelObjectAnimation(child, offset, withAnimation);
- translationObjectAnimator.start();
- } else {
- ensureOrCancelAnimator(child, withAnimation);
- translationAnimator.translationY_start(offset);
- }
- }
-
- /**
- * Manage animation for Android >= KITKAT
- *
- * @param child
- */
- private void ensureOrCancelAnimator(NavigationTabBar child, boolean withAnimation) {
- if (translationAnimator == null) {
- translationAnimator = new ViewPropertyAnimatorCompat2(child);
- translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
- translationAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(View view) {
- // Animate snackbar
- if (snackbarLayout != null && snackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- targetOffset = view.getMeasuredHeight() - view.getTranslationY();
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) snackbarLayout.getLayoutParams();
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) targetOffset);
- snackbarLayout.requestLayout();
- }
- // Animate Floating Action Button
- if (floatingActionButton != null && floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
- fabTargetOffset = fabDefaultBottomMargin - view.getTranslationY() + snackBarY;
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
- floatingActionButton.requestLayout();
- }
- }
- });
- translationAnimator.setInterpolator(INTERPOLATOR);
- } else {
- translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
- translationAnimator.cancel();
- }
- }
-
- private static ObjectAnimator objectAnimatorOfTranslationY(View target, int offset) {
- ObjectAnimator res;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- res = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, offset);
- } else {
- res = new ObjectAnimator();
- res.setTarget(target);
- res.setPropertyName("translationY");
- res.setFloatValues(offset);
- }
- return res;
- }
-
-
- /**
- * Manage animation for Android < KITKAT
- *
- * @param child
- */
- private void ensureOrCancelObjectAnimation(final NavigationTabBar child, final int offset, boolean withAnimation) {
-
- if (translationObjectAnimator != null) {
- translationObjectAnimator.cancel();
- }
-
- ObjectAnimator ta1= objectAnimatorOfTranslationY(child,offset);
- ObjectAnimator ta2=null;
- View bg= child.getBackgroundView();
- if(bg!=null) {
- ta2= objectAnimatorOfTranslationY(bg,offset);
- }
- translationObjectAnimator=new ObjectAnimator2(ta1,ta2);
- translationObjectAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
- translationObjectAnimator.setInterpolator(INTERPOLATOR);
- translationObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- if (snackbarLayout != null && snackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- targetOffset = child.getMeasuredHeight() - child.getTranslationY();
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) snackbarLayout.getLayoutParams();
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) targetOffset);
- snackbarLayout.requestLayout();
- }
- // Animate Floating Action Button
- if (floatingActionButton != null && floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
- fabTargetOffset = fabDefaultBottomMargin - child.getTranslationY() + snackBarY;
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
- floatingActionButton.requestLayout();
- }
- }
- });
- }
-
-
- public static BottomNavigationTabBarBehavior from(NavigationTabBar view) {
- ViewGroup.LayoutParams params = view.getLayoutParams();
- if (!(params instanceof CoordinatorLayout.LayoutParams)) {
- throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
- }
- CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params)
- .getBehavior();
- if (!(behavior instanceof BottomNavigationTabBarBehavior)) {
- throw new IllegalArgumentException(
- "The view is not associated with BottomNavigationTabBarBehavior");
- }
- return (BottomNavigationTabBarBehavior) behavior;
- }
-
- /**
- * Enable or not the behavior translation
- * @param behaviorTranslationEnabled
- */
- public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
- this.behaviorTranslationEnabled = behaviorTranslationEnabled;
- }
-
- /**
- * Hide AHBottomNavigation with animation
- * @param view
- * @param offset
- */
- public void hideView(NavigationTabBar view, int offset, boolean withAnimation) {
- if (!hidden) {
- hidden = true;
- animateOffset(view, offset, true, withAnimation);
- }
- }
-
- /**
- * Reset AHBottomNavigation position with animation
- * @param view
- */
- public void resetOffset(NavigationTabBar view, boolean withAnimation) {
- if (hidden) {
- hidden = false;
- animateOffset(view, 0, true, withAnimation);
- }
- }
-
- /**
- * Update Snackbar bottom margin
- */
- public void updateSnackbar(final View child, View dependency) {
-
- if (dependency != null && dependency instanceof Snackbar.SnackbarLayout) {
-
- snackbarLayout = (Snackbar.SnackbarLayout) dependency;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- snackbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- if (floatingActionButton != null &&
- floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams();
- snackBarY = bottom - v.getY();
- fabTargetOffset = fabDefaultBottomMargin - child.getTranslationY() + snackBarY;
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset);
- floatingActionButton.requestLayout();
- }
- }
- });
- }
-
- if (mSnackbarHeight == -1) {
- mSnackbarHeight = dependency.getHeight();
- }
-
- int targetMargin = (int) (child.getMeasuredHeight() - child.getTranslationY());
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- child.bringToFront();
- }
-
- if (dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
- p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, targetMargin);
- dependency.requestLayout();
- }
- }
- }
-
- /**
- * Update floating action button bottom margin
- */
- public void updateFloatingActionButton(View dependency) {
- if (dependency != null && dependency instanceof FloatingActionButton) {
- floatingActionButton = (FloatingActionButton) dependency;
- if (!fabBottomMarginInitialized && dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
- fabBottomMarginInitialized = true;
- ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
- fabDefaultBottomMargin = p.bottomMargin;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java b/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
deleted file mode 100644
index c4bb460..0000000
--- a/library/src/main/java/com/gigamole/library/VerticalScrollingBehavior.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.gigamole.library;
-
-
-import android.content.Context;
-import android.os.Parcelable;
-import android.support.annotation.IntDef;
-import android.support.design.widget.CoordinatorLayout;
-import android.support.v4.view.WindowInsetsCompat;
-import android.util.AttributeSet;
-import android.view.View;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Created by Nikola on 11/22/2015.
- */
-public abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
-
- private int mTotalDyUnconsumed = 0;
- private int mTotalDy = 0;
- @ScrollDirection
- private int mOverScrollDirection = ScrollDirection.SCROLL_NONE;
- @ScrollDirection
- private int mScrollDirection = ScrollDirection.SCROLL_NONE;
-
- public VerticalScrollingBehavior(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public VerticalScrollingBehavior() {
- super();
- }
-
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({ScrollDirection.SCROLL_DIRECTION_UP, ScrollDirection.SCROLL_DIRECTION_DOWN})
- public @interface ScrollDirection {
- int SCROLL_DIRECTION_UP = 1;
- int SCROLL_DIRECTION_DOWN = -1;
- int SCROLL_NONE = 0;
- }
-
-
- /*
- @return Overscroll direction: SCROLL_DIRECTION_UP, CROLL_DIRECTION_DOWN, SCROLL_NONE
- */
- @ScrollDirection
- public int getOverScrollDirection() {
- return mOverScrollDirection;
- }
-
-
- /**
- * @return Scroll direction: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN, SCROLL_NONE
- */
-
- @ScrollDirection
- public int getScrollDirection() {
- return mScrollDirection;
- }
-
-
- /**
- * @param coordinatorLayout
- * @param child
- * @param direction Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
- * @param currentOverScroll Unconsumed value, negative or positive based on the direction;
- * @param totalOverScroll Cumulative value for current direction
- */
- public abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll);
-
- /**
- * @param scrollDirection Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
- */
- public abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection);
-
- @Override
- public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
- return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0;
- }
-
- @Override
- public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
- super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
- }
-
- @Override
- public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
- super.onStopNestedScroll(coordinatorLayout, child, target);
- }
-
- @Override
- public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
- super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
- if (dyUnconsumed > 0 && mTotalDyUnconsumed < 0) {
- mTotalDyUnconsumed = 0;
- mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
- } else if (dyUnconsumed < 0 && mTotalDyUnconsumed > 0) {
- mTotalDyUnconsumed = 0;
- mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
- }
- mTotalDyUnconsumed += dyUnconsumed;
- onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed);
- }
-
- @Override
- public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
- super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
- if (dy > 0 && mTotalDy < 0) {
- mTotalDy = 0;
- mScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
- } else if (dy < 0 && mTotalDy > 0) {
- mTotalDy = 0;
- mScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
- }
- mTotalDy += dy;
- onDirectionNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, mScrollDirection);
- }
-
-
- @Override
- public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, boolean consumed) {
- super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
- mScrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
- return onNestedDirectionFling(coordinatorLayout, child, target, velocityX, velocityY, mScrollDirection);
- }
-
- protected abstract boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection);
-
- @Override
- public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
- return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
- }
-
- @Override
- public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout coordinatorLayout, V child, WindowInsetsCompat insets) {
-
- return super.onApplyWindowInsets(coordinatorLayout, child, insets);
- }
-
- @Override
- public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) {
- return super.onSaveInstanceState(parent, child);
- }
-
-}
\ No newline at end of file
diff --git a/library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java b/library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
new file mode 100644
index 0000000..9d2ae82
--- /dev/null
+++ b/library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
@@ -0,0 +1,293 @@
+package com.gigamole.library.behavior;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v4.view.ViewCompat;
+import android.support.v4.view.ViewPropertyAnimatorCompat;
+import android.support.v4.view.ViewPropertyAnimatorUpdateListener;
+import android.support.v4.view.animation.LinearOutSlowInInterpolator;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Interpolator;
+
+import com.gigamole.library.R;
+import com.gigamole.library.ntb.NavigationTabBar;
+
+public class NavigationTabBarBehavior extends VerticalScrollingBehavior {
+
+ private final static Interpolator INTERPOLATOR = new LinearOutSlowInInterpolator();
+ private final static int ANIMATION_DURATION = 300;
+
+ private ViewPropertyAnimatorCompat mTranslationAnimator;
+ private ObjectAnimator mTranslationObjectAnimator;
+ private Snackbar.SnackbarLayout mSnackbarLayout;
+ private FloatingActionButton mFloatingActionButton;
+
+ private int mSnackbarHeight = -1;
+ private float
+ mTargetOffset = 0,
+ mFabTargetOffset = 0,
+ mFabDefaultBottomMargin = 0;
+
+ private boolean mHidden;
+ private boolean mFabBottomMarginInitialized;
+ private boolean mBehaviorTranslationEnabled = true;
+
+ public NavigationTabBarBehavior(final boolean behaviorTranslationEnabled) {
+ super();
+ this.mBehaviorTranslationEnabled = behaviorTranslationEnabled;
+ }
+
+ public NavigationTabBarBehavior(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ final TypedArray typedArray =
+ context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
+ typedArray.recycle();
+ }
+
+ @Override
+ public boolean onLayoutChild(CoordinatorLayout parent, NavigationTabBar child, int layoutDirection) {
+ return super.onLayoutChild(parent, child, layoutDirection);
+ }
+
+
+ @Override
+ public boolean onDependentViewChanged(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
+ return super.onDependentViewChanged(parent, child, dependency);
+ }
+
+ @Override
+ public void onDependentViewRemoved(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
+ super.onDependentViewRemoved(parent, child, dependency);
+ }
+
+ @Override
+ public boolean layoutDependsOn(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
+ updateSnackbar(child, dependency);
+ updateFloatingActionButton(child, dependency);
+ return super.layoutDependsOn(parent, child, dependency);
+ }
+
+ @Override
+ public void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll) {
+ }
+
+ @Override
+ public void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection) {
+ }
+
+ @Override
+ protected boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection) {
+ return false;
+ }
+
+ @Override
+ public void onNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
+ super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
+ if (dyConsumed < 0) handleDirection(child, ScrollDirection.SCROLL_DIRECTION_DOWN);
+ else if (dyConsumed > 0) handleDirection(child, ScrollDirection.SCROLL_DIRECTION_UP);
+ }
+
+ @Override
+ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, NavigationTabBar child, View directTargetChild, View target, int nestedScrollAxes) {
+ return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
+ }
+
+ // Handle scroll direction
+ private void handleDirection(NavigationTabBar child, int scrollDirection) {
+ if (!mBehaviorTranslationEnabled) return;
+ if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && mHidden) {
+ mHidden = false;
+ animateOffset(child, 0, false, true);
+ } else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !mHidden) {
+ mHidden = true;
+ animateOffset(child, child.getHeight(), false, true);
+ }
+ }
+
+ // Animate offset
+ private void animateOffset(final NavigationTabBar child, final int offset, boolean forceAnimation, boolean withAnimation) {
+ if (!mBehaviorTranslationEnabled && !forceAnimation) return;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+ ensureOrCancelObjectAnimation(child, offset, withAnimation);
+ mTranslationObjectAnimator.start();
+ } else {
+ ensureOrCancelAnimator(child, withAnimation);
+ mTranslationAnimator.translationY(offset).start();
+ }
+ }
+
+ // Manage animation for Android >= KITKAT
+ private void ensureOrCancelAnimator(final NavigationTabBar child, boolean withAnimation) {
+ if (mTranslationAnimator == null) {
+ mTranslationAnimator = ViewCompat.animate(child);
+ mTranslationAnimator.setDuration(withAnimation ? ANIMATION_DURATION : 0);
+ mTranslationAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(View view) {
+ // Animate snackbar
+ if (mSnackbarLayout != null && mSnackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ mTargetOffset = child.getBarHeight() - view.getTranslationY();
+
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mSnackbarLayout.getLayoutParams();
+
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mTargetOffset);
+ mSnackbarLayout.requestLayout();
+ }
+ // Animate Floating Action Button
+ if (mFloatingActionButton != null && mFloatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mFloatingActionButton.getLayoutParams();
+
+ mFabTargetOffset = mFabDefaultBottomMargin - view.getTranslationY();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mFabTargetOffset);
+ mFloatingActionButton.requestLayout();
+ }
+ }
+ });
+ mTranslationAnimator.setInterpolator(INTERPOLATOR);
+ } else {
+ mTranslationAnimator.setDuration(withAnimation ? ANIMATION_DURATION : 0);
+ mTranslationAnimator.cancel();
+ }
+ }
+
+ private static ObjectAnimator objectAnimatorOfTranslationY(View target, int offset) {
+ final ObjectAnimator res;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+ res = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, offset);
+ else {
+ res = new ObjectAnimator();
+ res.setTarget(target);
+ res.setPropertyName("translationY");
+ res.setFloatValues(offset);
+ }
+ return res;
+ }
+
+ // Manage animation for Android < KITKAT
+ private void ensureOrCancelObjectAnimation(final NavigationTabBar child, final int offset, boolean withAnimation) {
+ if (mTranslationObjectAnimator != null) mTranslationObjectAnimator.cancel();
+
+ mTranslationObjectAnimator = objectAnimatorOfTranslationY(child, offset);
+ mTranslationObjectAnimator.setDuration(withAnimation ? ANIMATION_DURATION : 0);
+ mTranslationObjectAnimator.setInterpolator(INTERPOLATOR);
+ mTranslationObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ if (mSnackbarLayout != null && mSnackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ mTargetOffset = child.getBarHeight() - child.getTranslationY();
+
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mSnackbarLayout.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mTargetOffset);
+ mSnackbarLayout.requestLayout();
+ }
+ // Animate Floating Action Button
+ if (mFloatingActionButton != null && mFloatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ mFabTargetOffset = mFabDefaultBottomMargin - child.getTranslationY();
+
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mFloatingActionButton.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mFabTargetOffset);
+ mFloatingActionButton.requestLayout();
+ }
+ }
+ });
+ }
+
+ public static NavigationTabBarBehavior from(NavigationTabBar view) {
+ final ViewGroup.LayoutParams params = view.getLayoutParams();
+ if (!(params instanceof CoordinatorLayout.LayoutParams))
+ throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
+
+ final CoordinatorLayout.Behavior behavior =
+ ((CoordinatorLayout.LayoutParams) params).getBehavior();
+ if (!(behavior instanceof NavigationTabBarBehavior))
+ throw new IllegalArgumentException(
+ "The view is not associated with NavigationTabBarBehavior");
+
+ return (NavigationTabBarBehavior) behavior;
+ }
+
+ // Enable or not the behavior translation
+ public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
+ this.mBehaviorTranslationEnabled = behaviorTranslationEnabled;
+ }
+
+ // Hide NTB with animation
+ public void hideView(NavigationTabBar view, int offset, boolean withAnimation) {
+ if (!mHidden) {
+ mHidden = true;
+ animateOffset(view, offset, true, withAnimation);
+ }
+ }
+
+ // Reset NTB position with animation
+ public void resetOffset(NavigationTabBar view, boolean withAnimation) {
+ if (mHidden) {
+ mHidden = false;
+ animateOffset(view, 0, true, withAnimation);
+ }
+ }
+
+ // Update Snackbar bottom margin
+ public void updateSnackbar(final NavigationTabBar child, View dependency) {
+ if (dependency != null && dependency instanceof Snackbar.SnackbarLayout) {
+ mSnackbarLayout = (Snackbar.SnackbarLayout) dependency;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ mSnackbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ if (mFloatingActionButton != null &&
+ mFloatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ mFabTargetOffset = mFabDefaultBottomMargin - child.getTranslationY();
+
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mFloatingActionButton.getLayoutParams();
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mFabTargetOffset);
+ mFloatingActionButton.requestLayout();
+ }
+ }
+ });
+ }
+
+ if (mSnackbarHeight == -1) mSnackbarHeight = dependency.getHeight();
+ final int targetMargin = (int) (child.getBarHeight() - child.getTranslationY());
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) child.bringToFront();
+ if (dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
+
+ p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, targetMargin);
+ dependency.requestLayout();
+ }
+ }
+ }
+
+ // Update floating action button bottom margin
+ public void updateFloatingActionButton(final NavigationTabBar child, final View dependency) {
+ if (dependency != null && dependency instanceof FloatingActionButton) {
+ mFloatingActionButton = (FloatingActionButton) dependency;
+
+ if (!mFabBottomMarginInitialized &&
+ dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
+ mFabBottomMarginInitialized = true;
+
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
+ mFabDefaultBottomMargin = p.bottomMargin;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java b/library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
new file mode 100644
index 0000000..3c0223e
--- /dev/null
+++ b/library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
@@ -0,0 +1,128 @@
+package com.gigamole.library.behavior;
+
+
+import android.content.Context;
+import android.os.Parcelable;
+import android.support.annotation.IntDef;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.v4.view.WindowInsetsCompat;
+import android.util.AttributeSet;
+import android.view.View;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
+
+ private int mTotalDyUnconsumed = 0;
+ private int mTotalDy = 0;
+
+ @ScrollDirection
+ private int mOverScrollDirection = ScrollDirection.SCROLL_NONE;
+ @ScrollDirection
+ private int mScrollDirection = ScrollDirection.SCROLL_NONE;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({ScrollDirection.SCROLL_DIRECTION_UP, ScrollDirection.SCROLL_DIRECTION_DOWN})
+ public @interface ScrollDirection {
+ int SCROLL_DIRECTION_UP = 1;
+ int SCROLL_DIRECTION_DOWN = -1;
+ int SCROLL_NONE = 0;
+ }
+
+ public VerticalScrollingBehavior() {
+ super();
+ }
+
+ public VerticalScrollingBehavior(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @ScrollDirection
+ public int getOverScrollDirection() {
+ return mOverScrollDirection;
+ }
+
+ @ScrollDirection
+ public int getScrollDirection() {
+ return mScrollDirection;
+ }
+
+ // Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ // Unconsumed value, negative or positive based on the direction
+ // Cumulative value for current direction
+ public abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll);
+
+ // Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ public abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection);
+
+ @Override
+ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
+ return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0;
+ }
+
+ @Override
+ public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
+ super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
+ }
+
+ @Override
+ public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
+ super.onStopNestedScroll(coordinatorLayout, child, target);
+ }
+
+ @Override
+ public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
+ super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
+ if (dyUnconsumed > 0 && mTotalDyUnconsumed < 0) {
+ mTotalDyUnconsumed = 0;
+ mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
+ } else if (dyUnconsumed < 0 && mTotalDyUnconsumed > 0) {
+ mTotalDyUnconsumed = 0;
+ mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
+ }
+
+ mTotalDyUnconsumed += dyUnconsumed;
+ onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed);
+ }
+
+ @Override
+ public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
+ super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
+ if (dy > 0 && mTotalDy < 0) {
+ mTotalDy = 0;
+ mScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
+ } else if (dy < 0 && mTotalDy > 0) {
+ mTotalDy = 0;
+ mScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
+ }
+ mTotalDy += dy;
+ onDirectionNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, mScrollDirection);
+ }
+
+ @Override
+ public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, boolean consumed) {
+ super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
+ mScrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
+ return onNestedDirectionFling(coordinatorLayout, child, target, velocityX, velocityY, mScrollDirection);
+ }
+
+ protected abstract boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection);
+
+ @Override
+ public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
+ return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
+ }
+
+ @Override
+ public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout coordinatorLayout, V child, WindowInsetsCompat insets) {
+
+ return super.onApplyWindowInsets(coordinatorLayout, child, insets);
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) {
+ return super.onSaveInstanceState(parent, child);
+ }
+
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/gigamole/library/NavigationTabBar.java b/library/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
similarity index 87%
rename from library/src/main/java/com/gigamole/library/NavigationTabBar.java
rename to library/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
index ea9148e..553884f 100644
--- a/library/src/main/java/com/gigamole/library/NavigationTabBar.java
+++ b/library/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package com.gigamole.library;
+package com.gigamole.library.ntb;
import android.animation.Animator;
import android.animation.ValueAnimator;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
@@ -53,6 +54,9 @@
import android.view.animation.LinearInterpolator;
import android.widget.Scroller;
+import com.gigamole.library.R;
+import com.gigamole.library.behavior.NavigationTabBarBehavior;
+
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -63,7 +67,7 @@
*/
public class NavigationTabBar extends View implements ViewPager.OnPageChangeListener {
- // NTP constants
+ // NTB constants
private final static String PREVIEW_BADGE = "0";
private final static String PREVIEW_TITLE = "Title";
private final static int INVALID_INDEX = -1;
@@ -74,53 +78,47 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static int DEFAULT_INACTIVE_COLOR = Color.parseColor("#9f90af");
private final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
- private final static float MIN_FRACTION = 0.0f;
- private final static float NON_SCALED_FRACTION = 0.35f;
- private final static float MAX_FRACTION = 1.0f;
+ private final static float MIN_FRACTION = 0.0F;
+ private final static float NON_SCALED_FRACTION = 0.35F;
+ private final static float MAX_FRACTION = 1.0F;
private final static int MIN_ALPHA = 0;
private final static int MAX_ALPHA = 255;
- private final static float ACTIVE_ICON_SCALE_BY = 0.3f;
- private final static float ICON_SIZE_FRACTION = 0.45f;
-
- private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2f;
- private final static float TITLE_ICON_SIZE_FRACTION = 0.45f;
- private final static float TITLE_ACTIVE_SCALE_BY = 0.2f;
- private final static float TITLE_SIZE_FRACTION = 0.2f;
- private final static float TITLE_MARGIN_FRACTION = 0.15f;
- private final static float TITLE_MARGIN_SCALE_FRACTION = 0.25f;
-
- private final static float BADGE_HORIZONTAL_FRACTION = 0.5f;
- private final static float BADGE_VERTICAL_FRACTION = 0.75f;
- private final static float BADGE_TITLE_SIZE_FRACTION = 0.9f;
+ private final static float ACTIVE_ICON_SCALE_BY = 0.3F;
+ private final static float ICON_SIZE_FRACTION = 0.45F;
- private final static int ALL_INDEX = 0;
- private final static int ACTIVE_INDEX = 1;
+ private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2F;
+ private final static float TITLE_ICON_SIZE_FRACTION = 0.45F;
+ private final static float TITLE_ACTIVE_SCALE_BY = 0.2F;
+ private final static float TITLE_SIZE_FRACTION = 0.2F;
+ private final static float TITLE_MARGIN_FRACTION = 0.15F;
+ private final static float TITLE_MARGIN_SCALE_FRACTION = 0.25F;
- private final static int LEFT_INDEX = 0;
- private final static int CENTER_INDEX = 1;
- private final static int RIGHT_INDEX = 2;
+ private final static float BADGE_HORIZONTAL_FRACTION = 0.5F;
+ private final static float BADGE_VERTICAL_FRACTION = 0.75F;
+ private final static float BADGE_TITLE_SIZE_FRACTION = 0.9F;
- private final static int TOP_INDEX = 0;
- private final static int BOTTOM_INDEX = 1;
-
- private final static float LEFT_FRACTION = 0.25f;
- private final static float CENTER_FRACTION = 0.5f;
- private final static float RIGHT_FRACTION = 0.75f;
+ public final static float LEFT_FRACTION = 0.25F;
+ public final static float CENTER_FRACTION = 0.5F;
+ public final static float RIGHT_FRACTION = 0.75F;
private final static Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
private final static Interpolator ACCELERATE_INTERPOLATOR = new AccelerateInterpolator();
+ private final static Interpolator OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator();
- // NTP and pointer bounds
+ // NTB and pointer bounds
private final RectF mBounds = new RectF();
private final RectF mPointerBounds = new RectF();
// Badge bounds and bg badge bounds
private final Rect mBadgeBounds = new Rect();
private final RectF mBgBadgeBounds = new RectF();
- //external backgroundView for the tab layout
- private View backgroundView=null;
+ // NTB background
+ private Bitmap mBackground;
+ // Check whether need to reload background
+ private boolean mNeedInvalidateBackground = true;
+
// Canvas, where all of other canvas will be merged
private Bitmap mBitmap;
private final Canvas mCanvas = new Canvas();
@@ -137,13 +135,18 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private Bitmap mPointerBitmap;
private final Canvas mPointerCanvas = new Canvas();
- private int navBarHeight; //updated in OnMeasure()
- private boolean isBehaviorTranslationSet = false;
- private boolean behaviorTranslationEnabled = false;
- private boolean needHideBottomNavigation = false;
- private boolean hideBottomNavigationWithAnimation = false;
- private BottomNavigationTabBarBehavior bottomNavigationBehavior;
+ // External background view for the NTB
+// private View mBackgroundView = null;
+ private NavigationTabBarBehavior mBehavior;
+ // Detect if behavior already set
+ private boolean mIsBehaviorSet;
+ // Detect if behavior enabled
+ private boolean mBehaviorEnabled;
+ // Detect if need to hide NTB
+ private boolean mNeedHide;
+ // Detect if need animate animate or force hide
+ private boolean mAnimateHide;
// Main paint
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
@@ -204,7 +207,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final ResizeInterpolator mResizeInterpolator = new ResizeInterpolator();
private int mAnimationDuration;
- // NTP models
+ // NTB models
private final List mModels = new ArrayList<>();
// Variables for ViewPager
@@ -312,12 +315,20 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
);
- setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
+ setTitleMode(
+ typedArray.getInt(
+ R.styleable.NavigationTabBar_ntb_title_mode, TitleMode.ALL_INDEX
+ )
+ );
setBadgePosition(
- typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX)
+ typedArray.getInt(
+ R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX
+ )
);
setBadgeGravity(
- typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX)
+ typedArray.getInt(
+ R.styleable.NavigationTabBar_ntb_badge_gravity, BadgeGravity.TOP_INDEX
+ )
);
setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, 0));
setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, 0));
@@ -339,7 +350,7 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
)
);
setCornersRadius(
- typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0f)
+ typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0F)
);
// Init animator
@@ -463,10 +474,10 @@ public TitleMode getTitleMode() {
private void setTitleMode(final int index) {
switch (index) {
- case ACTIVE_INDEX:
+ case TitleMode.ACTIVE_INDEX:
setTitleMode(TitleMode.ACTIVE);
break;
- case ALL_INDEX:
+ case TitleMode.ALL_INDEX:
default:
setTitleMode(TitleMode.ALL);
}
@@ -483,13 +494,13 @@ public BadgePosition getBadgePosition() {
private void setBadgePosition(final int index) {
switch (index) {
- case LEFT_INDEX:
+ case BadgePosition.LEFT_INDEX:
setBadgePosition(BadgePosition.LEFT);
break;
- case CENTER_INDEX:
+ case BadgePosition.CENTER_INDEX:
setBadgePosition(BadgePosition.CENTER);
break;
- case RIGHT_INDEX:
+ case BadgePosition.RIGHT_INDEX:
default:
setBadgePosition(BadgePosition.RIGHT);
}
@@ -506,10 +517,10 @@ public BadgeGravity getBadgeGravity() {
private void setBadgeGravity(final int index) {
switch (index) {
- case BOTTOM_INDEX:
+ case BadgeGravity.BOTTOM_INDEX:
setBadgeGravity(BadgeGravity.BOTTOM);
break;
- case TOP_INDEX:
+ case BadgeGravity.TOP_INDEX:
default:
setBadgeGravity(BadgeGravity.TOP);
}
@@ -660,7 +671,8 @@ public void setViewPager(final ViewPager viewPager) {
}
if (mViewPager == viewPager) return;
- if (mViewPager != null) mViewPager.setOnPageChangeListener(null);
+ if (mViewPager != null) //noinspection deprecation
+ mViewPager.setOnPageChangeListener(null);
if (viewPager.getAdapter() == null)
throw new IllegalStateException("ViewPager does not provide adapter instance.");
@@ -697,6 +709,28 @@ public void setOnPageChangeListener(final ViewPager.OnPageChangeListener listene
mOnPageChangeListener = listener;
}
+ // Return if the behavior translation is enabled
+ public boolean isBehaviorEnabled() {
+ return mBehaviorEnabled;
+ }
+
+ // Set the behavior translation value
+ public void setBehaviorEnabled(final boolean enabled) {
+ mBehaviorEnabled = enabled;
+
+ if (getParent() != null && getParent() instanceof CoordinatorLayout) {
+ final ViewGroup.LayoutParams params = getLayoutParams();
+ if (mBehavior == null) mBehavior = new NavigationTabBarBehavior(enabled);
+ else mBehavior.setBehaviorTranslationEnabled(enabled);
+
+ ((CoordinatorLayout.LayoutParams) params).setBehavior(mBehavior);
+ if (mNeedHide) {
+ mNeedHide = false;
+ mBehavior.hideView(this, (int) getBarHeight(), mAnimateHide);
+ }
+ }
+ }
+
public int getModelIndex() {
return mIndex;
}
@@ -759,7 +793,7 @@ private void updateIndicatorPosition(final float fraction) {
postInvalidate();
}
- // Update NTP
+ // Update NTB
private void notifyDataSetChanged() {
requestLayout();
postInvalidate();
@@ -811,15 +845,14 @@ public boolean onTouchEvent(final MotionEvent event) {
return true;
}
+ @SuppressLint("DrawAllocation")
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
// Get measure size
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int height = MeasureSpec.getSize(heightMeasureSpec);
- navBarHeight=height;
if (mModels.isEmpty() || width == 0 || height == 0) return;
@@ -845,12 +878,14 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
final Rect badgeBounds = new Rect();
mBadgePaint.setTextSize(mBadgeTitleSize);
mBadgePaint.getTextBounds(PREVIEW_BADGE, 0, 1, badgeBounds);
- mBadgeMargin = (badgeBounds.height() * 0.5f) +
+ mBadgeMargin = (badgeBounds.height() * 0.5F) +
(mBadgeTitleSize * BADGE_HORIZONTAL_FRACTION * BADGE_VERTICAL_FRACTION);
}
} else {
+ // Disable vertical translation in coordinator layout
+ mBehaviorEnabled = false;
+ // Disable other features
mIsHorizontalOrientation = false;
- behaviorTranslationEnabled=false; //disable vertical translation in coordinator layout
mIsTitled = false;
mIsBadged = false;
@@ -859,7 +894,7 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
}
// Set bounds for NTB
- mBounds.set(0.0f, 0.0f, width, height - mBadgeMargin);
+ mBounds.set(0.0F, 0.0F, width, height - mBadgeMargin);
// Set main bitmap
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
@@ -915,16 +950,56 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
updateIndicatorPosition(MAX_FRACTION);
}
- if (!isBehaviorTranslationSet) {
- //The translation behavior has to be set up after the super.onMeasure has been called.
- setBehaviorTranslationEnabled(behaviorTranslationEnabled);
- isBehaviorTranslationSet = true;
+ //The translation behavior has to be set up after the super.onMeasure has been called
+ if (!mIsBehaviorSet) {
+ setBehaviorEnabled(mBehaviorEnabled);
+ mIsBehaviorSet = true;
}
+ if (mBackground == null || mNeedInvalidateBackground) {
+ if (getBackground() != null) {
+ if (getBackground() instanceof BitmapDrawable)
+ mBackground = ((BitmapDrawable) getBackground()).getBitmap();
+ else {
+ mBackground = Bitmap.createBitmap(
+ (int) mBounds.width(), (int) mBounds.height(), Bitmap.Config.ARGB_8888
+ );
+
+ final Canvas backgroundCanvas = new Canvas(mBackground);
+ getBackground().setBounds(
+ 0, 0, backgroundCanvas.getWidth(), backgroundCanvas.getHeight()
+ );
+ getBackground().draw(backgroundCanvas);
+ }
+
+ setBackgroundDrawable(null);
+ mNeedInvalidateBackground = false;
+ }
+ }
+ }
+
+ @Override
+ public void setBackgroundColor(final int color) {
+ mNeedInvalidateBackground = true;
+ super.setBackgroundColor(color);
}
+ @SuppressWarnings("deprecation")
+ @Override
+ public void setBackgroundDrawable(final Drawable background) {
+ mNeedInvalidateBackground = true;
+ super.setBackgroundDrawable(background);
+ }
+
+ @SuppressWarnings("ConstantConditions")
@Override
protected void onDraw(final Canvas canvas) {
+ if (mBackground != null)
+ canvas.drawBitmap(
+ mBackground, 0.0F,
+ mBadgeGravity == BadgeGravity.TOP ? getBadgeMargin() : 0.0F, null
+ );
+
if (mCanvas == null || mPointerCanvas == null ||
mIconsCanvas == null || mTitlesCanvas == null)
return;
@@ -936,7 +1011,7 @@ protected void onDraw(final Canvas canvas) {
if (mIsTitled) mTitlesCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
// Get pointer badge margin for gravity
- final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0f;
+ final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;
// Draw our model colors
for (int i = 0; i < mModels.size(); i++) {
@@ -951,7 +1026,7 @@ protected void onDraw(final Canvas canvas) {
} else {
final float top = mModelSize * i;
final float bottom = top + mModelSize;
- mCanvas.drawRect(0.0f, top, mBounds.width(), bottom, mPaint);
+ mCanvas.drawRect(0.0F, top, mBounds.width(), bottom, mPaint);
}
}
@@ -961,14 +1036,14 @@ protected void onDraw(final Canvas canvas) {
mPointerLeftTop, pointerBadgeMargin,
mPointerRightBottom, mBounds.height() + pointerBadgeMargin
);
- else mPointerBounds.set(0.0f, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
+ else mPointerBounds.set(0.0F, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
// Draw pointer for model colors
if (mCornersRadius == 0) mPointerCanvas.drawRect(mPointerBounds, mPaint);
else mPointerCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mPaint);
// Draw pointer into main canvas
- mCanvas.drawBitmap(mPointerBitmap, 0.0f, 0.0f, mPointerPaint);
+ mCanvas.drawBitmap(mPointerBitmap, 0.0F, 0.0F, mPointerPaint);
// Set vars for icon when model with title or without
final float iconMarginTitleHeight = mIconSize + mTitleMargin + mModelTitleSize;
@@ -984,20 +1059,20 @@ protected void onDraw(final Canvas canvas) {
final float matrixCenterY;
// Set offset to titles
- final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5f);
+ final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
final float topTitleOffset =
- mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5f;
+ mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;
if (mIsHorizontalOrientation) {
- leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5f;
- topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5f;
+ leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5F;
+ topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5F;
} else {
- leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5f;
- topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5f;
+ leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5F;
+ topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5F;
}
- matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5f;
- matrixCenterY = topOffset + (float) model.mIcon.getHeight() * 0.5f;
+ matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
+ matrixCenterY = topOffset + (float) model.mIcon.getHeight() * 0.5F;
// Title translate position
final float titleTranslate =
@@ -1031,7 +1106,7 @@ protected void onDraw(final Canvas canvas) {
mIconPaint.setAlpha(MAX_ALPHA);
if (model.mSelectedIcon != null) mSelectedIconPaint.setAlpha(MAX_ALPHA);
- // Check if we handle models from touch on NTP or from ViewPager
+ // Check if we handle models from touch on NTB or from ViewPager
// There is a strange logic
// of ViewPager onPageScrolled method, so it is
if (mIsSetIndexFromTabBar) {
@@ -1110,11 +1185,11 @@ else if (i == mIndex)
}
// Draw general bitmap
- canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
+ canvas.drawBitmap(mBitmap, 0.0F, 0.0F, null);
// Draw icons bitmap on top
- canvas.drawBitmap(mIconsBitmap, 0.0f, pointerBadgeMargin, null);
+ canvas.drawBitmap(mIconsBitmap, 0.0F, pointerBadgeMargin, null);
// Draw titles bitmap on top
- if (mIsTitled) canvas.drawBitmap(mTitlesBitmap, 0.0f, pointerBadgeMargin, null);
+ if (mIsTitled) canvas.drawBitmap(mTitlesBitmap, 0.0F, pointerBadgeMargin, null);
// If is not badged, exit
if (!mIsBadged) return;
@@ -1123,7 +1198,7 @@ else if (i == mIndex)
final float modelBadgeMargin =
mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : mBounds.height();
final float modelBadgeOffset =
- mBadgeGravity == BadgeGravity.TOP ? 0.0f : mBounds.height() - mBadgeMargin;
+ mBadgeGravity == BadgeGravity.TOP ? 0.0F : mBounds.height() - mBadgeMargin;
for (int i = 0; i < mModels.size(); i++) {
final Model model = mModels.get(i);
@@ -1147,18 +1222,20 @@ else if (i == mIndex)
(mModelSize * i) + (mModelSize * mBadgePosition.mPositionFraction);
// If is badge title only one char, so create circle else round rect
+ final float badgeMargin = mBadgeMargin * model.mBadgeFraction;
if (model.getBadgeTitle().length() == 1) {
- final float badgeMargin = mBadgeMargin * model.mBadgeFraction;
mBgBadgeBounds.set(
badgeBoundsHorizontalOffset - badgeMargin, modelBadgeMargin - badgeMargin,
badgeBoundsHorizontalOffset + badgeMargin, modelBadgeMargin + badgeMargin
);
} else
mBgBadgeBounds.set(
- badgeBoundsHorizontalOffset - mBadgeBounds.centerX() - horizontalPadding,
- modelBadgeMargin - (mBadgeMargin * model.mBadgeFraction),
- badgeBoundsHorizontalOffset + mBadgeBounds.centerX() + horizontalPadding,
- modelBadgeOffset + (verticalPadding * 2.0f) + mBadgeBounds.height()
+ badgeBoundsHorizontalOffset -
+ Math.max(badgeMargin, mBadgeBounds.centerX() + horizontalPadding),
+ modelBadgeMargin - badgeMargin,
+ badgeBoundsHorizontalOffset +
+ Math.max(badgeMargin, mBadgeBounds.centerX() + horizontalPadding),
+ modelBadgeOffset + (verticalPadding * 2.0F) + mBadgeBounds.height()
);
// Set color and alpha for badge bg
@@ -1167,17 +1244,18 @@ else if (i == mIndex)
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set corners to round rect for badge bg and draw
- final float cornerRadius = mBgBadgeBounds.height() * 0.5f;
+ final float cornerRadius = mBgBadgeBounds.height() * 0.5F;
canvas.drawRoundRect(mBgBadgeBounds, cornerRadius, cornerRadius, mBadgePaint);
// Set color and alpha for badge title
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
- else mBadgePaint.setColor(mBadgeTitleColor == 0 ? model.getColor() : mBadgeTitleColor);
+ else //noinspection ResourceAsColor
+ mBadgePaint.setColor(mBadgeTitleColor == 0 ? model.getColor() : mBadgeTitleColor);
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set badge title center position and draw title
- final float badgeHalfHeight = mBadgeBounds.height() * 0.5f;
- float badgeVerticalOffset = (mBgBadgeBounds.height() * 0.5f) + badgeHalfHeight -
+ final float badgeHalfHeight = mBadgeBounds.height() * 0.5F;
+ float badgeVerticalOffset = (mBgBadgeBounds.height() * 0.5F) + badgeHalfHeight -
mBadgeBounds.bottom + modelBadgeOffset;
canvas.drawText(
model.getBadgeTitle(), badgeBoundsHorizontalOffset, badgeVerticalOffset +
@@ -1318,7 +1396,7 @@ private void updateInactiveModel(
matrixCenterX, matrixCenterY
);
- mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? 1.0f : textScale));
+ mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? 1.0F : textScale));
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(MIN_ALPHA);
// Reset icons alpha
@@ -1408,29 +1486,9 @@ public Parcelable onSaveInstanceState() {
return savedState;
}
- /**
- * set the background view for the tab bar
- * Also make sure that the background view height match the tab bar height
- * you should call this like this:
- *
- * @param bg
- */
- public void setBackgroundView(final View bg) {
- post(new Runnable() {
- @Override
- public void run() {
- bg.getLayoutParams().height = (int) getBarHeight();
- bg.requestLayout();
- backgroundView=bg;
- }
- });
- }
- public View getBackgroundView() {
- return backgroundView;
- }
-
private static class SavedState extends BaseSavedState {
- int index;
+
+ private int index;
public SavedState(Parcelable superState) {
super(superState);
@@ -1483,6 +1541,50 @@ private float clampValue(final float value, final float max, final float min) {
return Math.max(Math.min(value, min), max);
}
+ // Hide NTB with animation
+ public void hide() {
+ hide(true);
+ }
+
+ // Hide NTB with or without animation
+ public void hide(final boolean withAnimation) {
+ if (mBehavior != null) mBehavior.hideView(this, (int) getBarHeight(), withAnimation);
+ else if (getParent() != null && getParent() instanceof CoordinatorLayout) {
+ mNeedHide = true;
+ mAnimateHide = withAnimation;
+ } else scrollDown(withAnimation);
+ }
+
+ // Show NTB with animation
+ public void show() {
+ show(true);
+ }
+
+ // Show NTB with or without animation
+ public void show(final boolean withAnimation) {
+ if (mBehavior != null)
+ mBehavior.resetOffset(this, withAnimation);
+ else scrollUp(withAnimation);
+ }
+
+ // Hide NTB or bg on scroll down
+ private void scrollDown(final boolean withAnimation) {
+ ViewCompat.animate(this)
+ .translationY(getBarHeight())
+ .setInterpolator(new LinearOutSlowInInterpolator())
+ .setDuration(withAnimation ? DEFAULT_ANIMATION_DURATION : 0)
+ .start();
+ }
+
+ // Show NTB or bg on scroll up
+ private void scrollUp(final boolean withAnimation) {
+ ViewCompat.animate(this)
+ .translationY(0.0F)
+ .setInterpolator(OUT_SLOW_IN_INTERPOLATOR)
+ .setDuration(withAnimation ? DEFAULT_ANIMATION_DURATION : 0)
+ .start();
+ }
+
// Model class
public static class Model {
@@ -1708,14 +1810,14 @@ public void startScroll(int startX, int startY, int dx, int dy) {
private class ResizeInterpolator implements Interpolator {
// Spring factor
- private final float mFactor = 1.0f;
+ private final static float FACTOR = 1.0F;
// Check whether side we move
private boolean mResizeIn;
@Override
public float getInterpolation(final float input) {
- if (mResizeIn) return (float) (1.0f - Math.pow((1.0f - input), 2.0f * mFactor));
- else return (float) (Math.pow(input, 2.0f * mFactor));
+ if (mResizeIn) return (float) (1.0F - Math.pow((1.0F - input), 2.0F * FACTOR));
+ else return (float) (Math.pow(input, 2.0F * FACTOR));
}
public float getResizeInterpolation(final float input, final boolean resizeIn) {
@@ -1726,7 +1828,11 @@ public float getResizeInterpolation(final float input, final boolean resizeIn) {
// Model title mode
public enum TitleMode {
- ALL, ACTIVE
+
+ ALL, ACTIVE;
+
+ public final static int ALL_INDEX = 0;
+ public final static int ACTIVE_INDEX = 1;
}
// Model badge position
@@ -1734,6 +1840,10 @@ public enum BadgePosition {
LEFT(LEFT_FRACTION), CENTER(CENTER_FRACTION), RIGHT(RIGHT_FRACTION);
+ public final static int LEFT_INDEX = 0;
+ public final static int CENTER_INDEX = 1;
+ public final static int RIGHT_INDEX = 2;
+
private float mPositionFraction;
BadgePosition() {
@@ -1747,7 +1857,11 @@ public enum BadgePosition {
// Model badge gravity
public enum BadgeGravity {
- TOP, BOTTOM
+
+ TOP, BOTTOM;
+
+ public final static int TOP_INDEX = 0;
+ public final static int BOTTOM_INDEX = 1;
}
// Out listener for selected index
@@ -1756,105 +1870,4 @@ public interface OnTabBarSelectedIndexListener {
void onEndTabSelected(final Model model, final int index);
}
-
-
- /**
- * Return if the behavior translation is enabled
- *
- * @return a boolean value
- */
- public boolean isBehaviorTranslationEnabled() {
- return behaviorTranslationEnabled;
- }
- /**
- * Set the behavior translation value
- *
- * @param behaviorTranslationEnabled boolean for the state
- */
- public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
- this.behaviorTranslationEnabled = behaviorTranslationEnabled;
- if (getParent() instanceof CoordinatorLayout) {
- ViewGroup.LayoutParams params = getLayoutParams();
- if (bottomNavigationBehavior == null) {
- bottomNavigationBehavior = new BottomNavigationTabBarBehavior(behaviorTranslationEnabled);
- } else {
- bottomNavigationBehavior.setBehaviorTranslationEnabled(behaviorTranslationEnabled);
- }
- ((CoordinatorLayout.LayoutParams) params).setBehavior(bottomNavigationBehavior);
- if (needHideBottomNavigation) {
- needHideBottomNavigation = false;
- bottomNavigationBehavior.hideView(this, navBarHeight, hideBottomNavigationWithAnimation);
- }
- }
- }
-
- /**
- * Hide Bottom Navigation with animation
- */
- public void hideBottomNavigation() {
- hideBottomNavigation(true);
- }
-
- /**
- * Hide Bottom Navigation with or without animation
- *
- * @param withAnimation Boolean
- */
- public void hideBottomNavigation(boolean withAnimation) {
- if (bottomNavigationBehavior != null) {
- bottomNavigationBehavior.hideView(this, navBarHeight, withAnimation);
- } else if (getParent() instanceof CoordinatorLayout) {
- needHideBottomNavigation = true;
- hideBottomNavigationWithAnimation = withAnimation;
- } else {
- scrollDownView(this,withAnimation);
- if(backgroundView!=null) {
- scrollDownView(backgroundView,withAnimation);
- }
- }
- }
-
-
- /**
- * Restore Bottom Navigation with animation
- */
- public void restoreBottomNavigation() {
- restoreBottomNavigation(true);
- }
-
- /**
- * Restore Bottom Navigation with or without animation
- *
- * @param withAnimation Boolean
- */
- public void restoreBottomNavigation(boolean withAnimation) {
- if (bottomNavigationBehavior != null) {
- bottomNavigationBehavior.resetOffset(this, withAnimation);
- } else {
- // Show bottom navigation
- scrollUpView(this,withAnimation);
- if(backgroundView!=null) {
- scrollUpView(backgroundView,withAnimation);
- }
- }
- }
-
- private void scrollDownView(View view,boolean withAnimation) {
- int HIDE_ANIM_DURATION=300;
- // Hide bottom navigation
- ViewCompat.animate(view)
- .translationY(navBarHeight)
- .setInterpolator(new LinearOutSlowInInterpolator())
- .setDuration(withAnimation ? HIDE_ANIM_DURATION : 0)
- .start();
- }
- private void scrollUpView(View view,boolean withAnimation) {
- int SHOW_ANIM_DURATION=300;
- ViewCompat.animate(view)
- .translationY(0)
- .setInterpolator(new LinearOutSlowInInterpolator())
- .setDuration(withAnimation ? SHOW_ANIM_DURATION : 0)
- .start();
- }
-
}
From f9f16518b7154d6d546b36517087f83b6ab7abd1 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sun, 5 Jun 2016 02:50:52 +0300
Subject: [PATCH 19/64] Update README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1d78ee4..cc8eebb 100644
--- a/README.md
+++ b/README.md
@@ -277,7 +277,7 @@ Inspiration
TapBar interactions| Circle interactions | Title interactions
:-------------------------:|:-------------------------:|:-------------------------:
-||
+||
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
From a0330353cfa0020395f024f353c88994378f35e2 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 18 Jun 2016 23:28:41 +0300
Subject: [PATCH 20/64] Update compile path. Update badge.
---
README.md | 9 +++++----
app/build.gradle | 2 +-
app/src/main/AndroidManifest.xml | 5 +++++
{library => navigationtabbar}/.gitignore | 0
{library => navigationtabbar}/build.gradle | 4 ++--
{library => navigationtabbar}/proguard-rules.pro | 0
.../java/com/gigamole/library/ApplicationTest.java | 0
.../src/main/AndroidManifest.xml | 0
.../library/behavior/NavigationTabBarBehavior.java | 0
.../library/behavior/VerticalScrollingBehavior.java | 0
.../java/com/gigamole/library/ntb/NavigationTabBar.java | 0
.../src/main/res/values/arrays.xml | 0
.../src/main/res/values/attrs.xml | 0
.../src/main/res/values/strings.xml | 0
settings.gradle | 2 +-
15 files changed, 14 insertions(+), 8 deletions(-)
rename {library => navigationtabbar}/.gitignore (100%)
rename {library => navigationtabbar}/build.gradle (98%)
rename {library => navigationtabbar}/proguard-rules.pro (100%)
rename {library => navigationtabbar}/src/androidTest/java/com/gigamole/library/ApplicationTest.java (100%)
rename {library => navigationtabbar}/src/main/AndroidManifest.xml (100%)
rename {library => navigationtabbar}/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java (100%)
rename {library => navigationtabbar}/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java (100%)
rename {library => navigationtabbar}/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java (100%)
rename {library => navigationtabbar}/src/main/res/values/arrays.xml (100%)
rename {library => navigationtabbar}/src/main/res/values/attrs.xml (100%)
rename {library => navigationtabbar}/src/main/res/values/strings.xml (100%)
diff --git a/README.md b/README.md
index cc8eebb..ff29363 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
[](http://android-arsenal.com/details/1/3382)
+[ ](https://bintray.com/gigamole/maven/navigationtabstrip/_latestVersion)
NavigationTabBar
===================
@@ -25,14 +26,14 @@ dependencies {
url 'http://dl.bintray.com/gigamole/maven/'
}
}
- compile 'com.github.devlight.navigationtabbar:library:+'
+ compile 'com.github.devlight.navigationtabbar:navigationtabbar:+'
}
```
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:library:1.2.0'
+compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.1'
```
Or Maven:
@@ -40,8 +41,8 @@ Or Maven:
```groovy
com.github.devlight.navigationtabbar
- library
- 1.2.0
+ navigationtabbar
+ 1.2.1
aar
```
diff --git a/app/build.gradle b/app/build.gradle
index 7a55400..f3d6bf2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -21,7 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile project(':library')
+ compile project(':navigationtabbar')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 36bb73b..bcc63bf 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -9,6 +9,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
+
@@ -19,9 +20,13 @@
+
+
+
+
diff --git a/library/.gitignore b/navigationtabbar/.gitignore
similarity index 100%
rename from library/.gitignore
rename to navigationtabbar/.gitignore
diff --git a/library/build.gradle b/navigationtabbar/build.gradle
similarity index 98%
rename from library/build.gradle
rename to navigationtabbar/build.gradle
index f8f0bbb..cbfb72e 100644
--- a/library/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.2.0"
+version = "1.2.1"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.2.0"
+ versionName "1.2.1"
}
buildTypes {
release {
diff --git a/library/proguard-rules.pro b/navigationtabbar/proguard-rules.pro
similarity index 100%
rename from library/proguard-rules.pro
rename to navigationtabbar/proguard-rules.pro
diff --git a/library/src/androidTest/java/com/gigamole/library/ApplicationTest.java b/navigationtabbar/src/androidTest/java/com/gigamole/library/ApplicationTest.java
similarity index 100%
rename from library/src/androidTest/java/com/gigamole/library/ApplicationTest.java
rename to navigationtabbar/src/androidTest/java/com/gigamole/library/ApplicationTest.java
diff --git a/library/src/main/AndroidManifest.xml b/navigationtabbar/src/main/AndroidManifest.xml
similarity index 100%
rename from library/src/main/AndroidManifest.xml
rename to navigationtabbar/src/main/AndroidManifest.xml
diff --git a/library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java b/navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
similarity index 100%
rename from library/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
rename to navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
diff --git a/library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java b/navigationtabbar/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
similarity index 100%
rename from library/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
rename to navigationtabbar/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
diff --git a/library/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
similarity index 100%
rename from library/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
rename to navigationtabbar/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
diff --git a/library/src/main/res/values/arrays.xml b/navigationtabbar/src/main/res/values/arrays.xml
similarity index 100%
rename from library/src/main/res/values/arrays.xml
rename to navigationtabbar/src/main/res/values/arrays.xml
diff --git a/library/src/main/res/values/attrs.xml b/navigationtabbar/src/main/res/values/attrs.xml
similarity index 100%
rename from library/src/main/res/values/attrs.xml
rename to navigationtabbar/src/main/res/values/attrs.xml
diff --git a/library/src/main/res/values/strings.xml b/navigationtabbar/src/main/res/values/strings.xml
similarity index 100%
rename from library/src/main/res/values/strings.xml
rename to navigationtabbar/src/main/res/values/strings.xml
diff --git a/settings.gradle b/settings.gradle
index 3306997..ee9857b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':library'
+include ':app', ':navigationtabbar'
From 6d7ddf238ea872e4e6930db21518948c572c3a02 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 18 Jun 2016 23:31:57 +0300
Subject: [PATCH 21/64] Update badge.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ff29363..1bf1eea 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
[](http://android-arsenal.com/details/1/3382)
-[ ](https://bintray.com/gigamole/maven/navigationtabstrip/_latestVersion)
+[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
NavigationTabBar
===================
From 2cd3d9d4341aa36f784136c77b3b4eacc6659860 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sun, 19 Jun 2016 01:49:00 +0300
Subject: [PATCH 22/64] Update 1.2.2
---
README.md | 4 ++--
app/build.gradle | 6 ++---
.../HorizontalCoordinatorNtbActivity.java | 2 +-
.../activity_horizontal_coordinator_ntb.xml | 24 +++++++++----------
navigationtabbar/build.gradle | 6 ++---
.../behavior/NavigationTabBarBehavior.java | 11 ++++++---
6 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
index 1bf1eea..fe077cb 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.1'
+compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.2'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
navigationtabbar
- 1.2.1
+ 1.2.2
aar
```
diff --git a/app/build.gradle b/app/build.gradle
index f3d6bf2..197f286 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':navigationtabbar')
- compile 'com.android.support:appcompat-v7:23.3.0'
- compile 'com.android.support:design:23.3.0'
- compile 'com.android.support:support-v4:23.3.0'
+ compile 'com.android.support:appcompat-v7:23.2.1'
+ compile 'com.android.support:design:23.2.1'
+ compile 'com.android.support:support-v4:23.2.1'
}
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
index 46d679c..00eeae4 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
+++ b/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
@@ -147,7 +147,7 @@ public void run() {
coordinatorLayout.postDelayed(new Runnable() {
@Override
public void run() {
- final Snackbar snackbar = Snackbar.make(coordinatorLayout, "Coordinator NTB", Snackbar.LENGTH_SHORT);
+ final Snackbar snackbar = Snackbar.make(navigationTabBar, "Coordinator NTB", Snackbar.LENGTH_SHORT);
snackbar.getView().setBackgroundColor(Color.parseColor("#9b92b3"));
((TextView) snackbar.getView().findViewById(R.id.snackbar_text))
.setTextColor(Color.parseColor("#423752"));
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
index 3bed374..715c48f 100644
--- a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -53,18 +53,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
-
-
+
+
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index cbfb72e..1313156 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.2.1"
+version = "1.2.2"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.2.1"
+ versionName "1.2.2"
}
buildTypes {
release {
@@ -41,7 +41,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:design:23.4.0'
+ compile 'com.android.support:design:23.2.1'
}
def siteUrl = 'https://github.com/DevLight-Mobile-Agency/NavigationTabBar'
diff --git a/navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java b/navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
index 9d2ae82..e745cd1 100644
--- a/navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
+++ b/navigationtabbar/src/main/java/com/gigamole/library/behavior/NavigationTabBarBehavior.java
@@ -71,7 +71,7 @@ public void onDependentViewRemoved(CoordinatorLayout parent, NavigationTabBar ch
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, NavigationTabBar child, View dependency) {
updateSnackbar(child, dependency);
- updateFloatingActionButton(child, dependency);
+ updateFloatingActionButton(dependency);
return super.layoutDependsOn(parent, child, dependency);
}
@@ -264,7 +264,12 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
if (mSnackbarHeight == -1) mSnackbarHeight = dependency.getHeight();
final int targetMargin = (int) (child.getBarHeight() - child.getTranslationY());
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) child.bringToFront();
+ child.bringToFront();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ dependency.setStateListAnimator(null);
+ dependency.setElevation(0.0F);
+ }
+
if (dependency.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams p =
(ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
@@ -276,7 +281,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
}
// Update floating action button bottom margin
- public void updateFloatingActionButton(final NavigationTabBar child, final View dependency) {
+ public void updateFloatingActionButton(final View dependency) {
if (dependency != null && dependency instanceof FloatingActionButton) {
mFloatingActionButton = (FloatingActionButton) dependency;
From 46c21595e38371b49a628d7a4703929dff8f0ff0 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sun, 19 Jun 2016 20:49:08 +0300
Subject: [PATCH 23/64] Update.
---
README.md | 2 +-
.../java/com/gigamole/sample}/ApplicationTest.java | 2 +-
app/src/main/AndroidManifest.xml | 14 +++++++-------
.../HorizontalCoordinatorNtbActivity.java | 4 ++--
.../HorizontalNtbActivity.java | 4 ++--
.../{navigationtabbar => sample}/MainActivity.java | 2 +-
.../SamplesNtbActivity.java | 4 ++--
.../TopHorizontalNtbActivity.java | 4 ++--
.../VerticalNtbActivity.java | 4 ++--
.../layout/activity_horizontal_coordinator_ntb.xml | 2 +-
.../main/res/layout/activity_horizontal_ntb.xml | 2 +-
app/src/main/res/layout/activity_samples_ntb.xml | 12 ++++++------
app/src/main/res/layout/activity_vertical_ntb.xml | 2 +-
.../gigamole/navigationtabbar/ApplicationTest.java | 0
navigationtabbar/src/main/AndroidManifest.xml | 2 +-
.../behavior/NavigationTabBarBehavior.java | 6 +++---
.../behavior/VerticalScrollingBehavior.java | 2 +-
.../ntb/NavigationTabBar.java | 6 +++---
18 files changed, 37 insertions(+), 37 deletions(-)
rename {navigationtabbar/src/androidTest/java/com/gigamole/library => app/src/androidTest/java/com/gigamole/sample}/ApplicationTest.java (91%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/HorizontalCoordinatorNtbActivity.java (98%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/HorizontalNtbActivity.java (98%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/MainActivity.java (98%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/SamplesNtbActivity.java (98%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/TopHorizontalNtbActivity.java (98%)
rename app/src/main/java/com/gigamole/{navigationtabbar => sample}/VerticalNtbActivity.java (98%)
rename {app => navigationtabbar}/src/androidTest/java/com/gigamole/navigationtabbar/ApplicationTest.java (100%)
rename navigationtabbar/src/main/java/com/gigamole/{library => navigationtabbar}/behavior/NavigationTabBarBehavior.java (98%)
rename navigationtabbar/src/main/java/com/gigamole/{library => navigationtabbar}/behavior/VerticalScrollingBehavior.java (99%)
rename navigationtabbar/src/main/java/com/gigamole/{library => navigationtabbar}/ntb/NavigationTabBar.java (99%)
diff --git a/README.md b/README.md
index fe077cb..536d7f5 100644
--- a/README.md
+++ b/README.md
@@ -241,7 +241,7 @@ Other methods check out in sample.
And XML init:
```xml
-
-
+
@@ -18,16 +18,16 @@
-
-
+
-
+
-
+
-
+
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
rename to app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
index 00eeae4..99d5277 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalCoordinatorNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -15,7 +15,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.ntb.NavigationTabBar;
+import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
import java.util.ArrayList;
import java.util.Random;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java b/app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
rename to app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java
index 11eb430..7065be0 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/HorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.ntb.NavigationTabBar;
+import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java b/app/src/main/java/com/gigamole/sample/MainActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
rename to app/src/main/java/com/gigamole/sample/MainActivity.java
index d0fc224..ac1daad 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/MainActivity.java
+++ b/app/src/main/java/com/gigamole/sample/MainActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.content.Intent;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java b/app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
rename to app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java
index 74e2f16..cd19566 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/SamplesNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -6,7 +6,7 @@
import android.support.v4.graphics.ColorUtils;
import android.widget.Toast;
-import com.gigamole.library.ntb.NavigationTabBar;
+import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java b/app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
rename to app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java
index 2c8ccaf..c793a5e 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -12,7 +12,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.ntb.NavigationTabBar;
+import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
import java.util.ArrayList;
import java.util.Random;
diff --git a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java b/app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
rename to app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java
index 2fbb075..b1f6d1b 100644
--- a/app/src/main/java/com/gigamole/navigationtabbar/VerticalNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar;
+package com.gigamole.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.library.ntb.NavigationTabBar;
+import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
index 715c48f..46245b3 100644
--- a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -53,7 +53,7 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
-
-
-
-
-
-
-
-
-
-
{
diff --git a/navigationtabbar/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
similarity index 99%
rename from navigationtabbar/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
rename to navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
index 3c0223e..39886f6 100644
--- a/navigationtabbar/src/main/java/com/gigamole/library/behavior/VerticalScrollingBehavior.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
@@ -1,4 +1,4 @@
-package com.gigamole.library.behavior;
+package com.gigamole.navigationtabbar.behavior;
import android.content.Context;
diff --git a/navigationtabbar/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
similarity index 99%
rename from navigationtabbar/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
rename to navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 553884f..ad17d47 100644
--- a/navigationtabbar/src/main/java/com/gigamole/library/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.gigamole.library.ntb;
+package com.gigamole.navigationtabbar.ntb;
import android.animation.Animator;
import android.animation.ValueAnimator;
@@ -54,8 +54,8 @@
import android.view.animation.LinearInterpolator;
import android.widget.Scroller;
-import com.gigamole.library.R;
-import com.gigamole.library.behavior.NavigationTabBarBehavior;
+import com.gigamole.navigationtabbar.R;
+import com.gigamole.navigationtabbar.behavior.NavigationTabBarBehavior;
import java.lang.reflect.Field;
import java.util.ArrayList;
From bb6db54b2cc23f233d4770cc8bd05b430d42931f Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 28 Jun 2016 12:47:09 +0300
Subject: [PATCH 24/64] Update 1.2.3. Major and minor fixes. Scrolling and
swipe issues fixes. Fix wrong index and fraction at the end of animation and
page scroll. Pre 17 API fixes. Layer type fixes. Background draw fix. New
methods to set: background color, title size, badge size, swipe.
---
README.md | 42 ++-
app/build.gradle | 2 +
.../HorizontalCoordinatorNtbActivity.java | 16 +
app/src/main/res/drawable/bg_round_circle.xml | 9 -
.../activity_horizontal_coordinator_ntb.xml | 2 +-
.../res/layout/activity_horizontal_ntb.xml | 5 +-
.../layout/activity_horizontal_top_ntb.xml | 5 +-
.../main/res/layout/activity_samples_ntb.xml | 14 +-
.../main/res/layout/activity_vertical_ntb.xml | 1 -
navigationtabbar/build.gradle | 4 +-
.../ntb/NavigationTabBar.java | 278 ++++++++++--------
.../src/main/res/values/attrs.xml | 5 +
12 files changed, 229 insertions(+), 154 deletions(-)
delete mode 100644 app/src/main/res/drawable/bg_round_circle.xml
diff --git a/README.md b/README.md
index 536d7f5..8df1eb7 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.2'
+compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.3'
```
Or Maven:
@@ -42,7 +42,7 @@ Or Maven:
com.github.devlight.navigationtabbar
navigationtabbar
- 1.2.2
+ 1.2.3
aar
```
@@ -71,9 +71,9 @@ For NTB you can set such parameters as:
allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
- - background:
+ - background color:
- allows you to set background to NTB which automatically set with offset relative to badge gravity.
+ allows you to set background to NTB which automatically set with offset relative to badge gravity and corners radius.
- model selected icon:
@@ -95,13 +95,21 @@ For NTB you can set such parameters as:
allows you to handle mode of the model title show. Can show all or only active.
+ - title size:
+
+ allows you to set titles size.
+
- scale mode:
allows you to handle mode of the model icon and title scale.
- tint mode:
- allows you to enable or disable icon tinting.
+ allows you to enable or disable icon tinting.
+
+ - badge size:
+
+ allows you to set badges size.
- badge position:
@@ -153,12 +161,11 @@ You can set selected icon. Resize and scale of selected icon equals to original
Orientation automatically detected according to view size.
-By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set badge bg and title color to 0.
+By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set AUTO_COLOR value to badge bg and title color.
-If your set ViewPager you can action down on active pointer and do like drag.
-
-If you want to set the background to NTB, just set background via XML or code and its automatically set relative to badge gravity.
+By default badge sizes and title sizes is auto fit. To reset calculation just set AUTO_SIZE value to badge size and title size.
+If your set ViewPager and enable swipe you can action down on active pointer and do like drag.
Init
@@ -220,6 +227,10 @@ navigationTabBar.setIsTinted(true);
navigationTabBar.setIsBadgeUseTypeface(true);
navigationTabBar.setBadgeBgColor(Color.RED);
navigationTabBar.setBadgeTitleColor(Color.WHITE);
+navigationTabBar.setIsSwiped(true);
+navigationTabBar.setBgColor(Color.BLACK);
+navigationTabBar.setBadgeSize(10);
+navigationTabBar.setTitleSize(10);
```
If your models is in badge mode you can set title, hide, show, toggle and update badge title like this:
@@ -233,7 +244,12 @@ model.updateBadgeTitle("Here some title like NEW or some integer value");
To enable behavior translation inside CoordinatorLayout when at bottom of screen:
```java
-bottomNavigation.setBehaviorEnabled(true);
+navigationTabBar.setBehaviorEnabled(true);
+```
+
+To deselect active index and reset pointer:
+```java
+navigationTabBar.deselect();
```
Other methods check out in sample.
@@ -260,7 +276,11 @@ And XML init:
app:ntb_badge_bg_color="#ffff0000"
app:ntb_badge_title_color="#ffffffff"
app:ntb_typeface="fonts/custom_typeface.ttf"
- app:ntb_badge_use_typeface="true"/>
+ app:ntb_badge_use_typeface="true"
+ app:ntb_swiped="true"
+ app:ntb_bg_color="#000"
+ app:ntb_badge_size="10sp"
+ app:ntb_title_size="10sp"/>
```
Getting Help
diff --git a/app/build.gradle b/app/build.gradle
index 197f286..bbb740b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,6 +22,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':navigationtabbar')
+// compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.2'
+
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
diff --git a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
index 99d5277..e30618c 100644
--- a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
@@ -125,6 +125,22 @@ public void onEndTabSelected(final NavigationTabBar.Model model, final int index
model.hideBadge();
}
});
+ navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+ @Override
+ public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageSelected(final int position) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(final int state) {
+
+ }
+ });
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.parent);
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
diff --git a/app/src/main/res/drawable/bg_round_circle.xml b/app/src/main/res/drawable/bg_round_circle.xml
deleted file mode 100644
index 5e40942..0000000
--- a/app/src/main/res/drawable/bg_round_circle.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
index 46245b3..38aa002 100644
--- a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -58,7 +58,7 @@
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
- android:background="#605271"
+ app:ntb_badge_size="12sp"
app:ntb_badge_bg_color="#ffff0000"
app:ntb_badge_gravity="top"
app:ntb_badge_position="left"
diff --git a/app/src/main/res/layout/activity_horizontal_ntb.xml b/app/src/main/res/layout/activity_horizontal_ntb.xml
index 9ee8419..1e719fa 100644
--- a/app/src/main/res/layout/activity_horizontal_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_ntb.xml
@@ -4,6 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ xmlns:tools="http://schemas.android.com/tools"
android:background="#423752"
android:orientation="vertical">
@@ -17,13 +18,13 @@
android:id="@+id/ntb_horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
- android:background="#605271"
app:ntb_badge_gravity="top"
app:ntb_badge_position="right"
app:ntb_badged="true"
app:ntb_scaled="true"
app:ntb_tinted="true"
app:ntb_title_mode="all"
- app:ntb_titled="true"/>
+ app:ntb_titled="true"
+ app:ntb_swiped="true"/>
diff --git a/app/src/main/res/layout/activity_horizontal_top_ntb.xml b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
index 961ee00..ee6339e 100644
--- a/app/src/main/res/layout/activity_horizontal_top_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_top_ntb.xml
@@ -24,11 +24,12 @@
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
-
@@ -62,6 +62,7 @@
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_gravity="center"
+ app:ntb_bg_color="#00000000"
app:ntb_corners_radius="10dp"
app:ntb_inactive_color="#000"
app:ntb_preview_colors="@array/red_wine"/>
@@ -88,6 +89,7 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="center"
+ app:ntb_bg_color="#00FFFFFF"
app:ntb_active_color="#be7818"
app:ntb_inactive_color="#be7818"
app:ntb_animation_duration="1000"/>
@@ -105,13 +107,13 @@
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
- android:background="@drawable/bg_round_circle"
app:ntb_animation_duration="400"
app:ntb_preview_colors="@array/red_wine"
- app:ntb_corners_radius="50dp"
+ app:ntb_corners_radius="25dp"
app:ntb_scaled="false"
app:ntb_active_color="#8d88e4"
- app:ntb_inactive_color="#dddfec"/>
+ app:ntb_inactive_color="#dddfec"
+ app:ntb_bg_color="#8d88e4"/>
@@ -126,7 +128,7 @@
android:layout_width="240dp"
android:layout_height="60dp"
android:layout_gravity="center"
- android:background="@drawable/bg_round_rect"
+ app:ntb_bg_color="#4b405c"
app:ntb_corners_radius="4dp"
app:ntb_preview_colors="@array/polluted_waves"/>
diff --git a/app/src/main/res/layout/activity_vertical_ntb.xml b/app/src/main/res/layout/activity_vertical_ntb.xml
index 7005fed..01bc3f0 100644
--- a/app/src/main/res/layout/activity_vertical_ntb.xml
+++ b/app/src/main/res/layout/activity_vertical_ntb.xml
@@ -10,7 +10,6 @@
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index 1313156..787c9da 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.2.2"
+version = "1.2.3"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.2.2"
+ versionName "1.2.3"
}
buildTypes {
release {
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index ad17d47..371f27b 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -45,6 +45,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -68,15 +69,23 @@
public class NavigationTabBar extends View implements ViewPager.OnPageChangeListener {
// NTB constants
+ private final static int FLAGS =
+ Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG;
+
private final static String PREVIEW_BADGE = "0";
private final static String PREVIEW_TITLE = "Title";
+
private final static int INVALID_INDEX = -1;
+ public final static int AUTO_SIZE = -2;
+ public final static int AUTO_COLOR = -3;
private final static int DEFAULT_BADGE_ANIMATION_DURATION = 200;
private final static int DEFAULT_BADGE_REFRESH_ANIMATION_DURATION = 100;
private final static int DEFAULT_ANIMATION_DURATION = 300;
+
private final static int DEFAULT_INACTIVE_COLOR = Color.parseColor("#9f90af");
private final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
+ private final static int DEFAULT_BG_COLOR = Color.parseColor("#605271");
private final static float MIN_FRACTION = 0.0F;
private final static float NON_SCALED_FRACTION = 0.35F;
@@ -109,16 +118,12 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// NTB and pointer bounds
private final RectF mBounds = new RectF();
+ private final RectF mBgBounds = new RectF();
private final RectF mPointerBounds = new RectF();
// Badge bounds and bg badge bounds
private final Rect mBadgeBounds = new Rect();
private final RectF mBgBadgeBounds = new RectF();
- // NTB background
- private Bitmap mBackground;
- // Check whether need to reload background
- private boolean mNeedInvalidateBackground = true;
-
// Canvas, where all of other canvas will be merged
private Bitmap mBitmap;
private final Canvas mCanvas = new Canvas();
@@ -136,7 +141,6 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final Canvas mPointerCanvas = new Canvas();
// External background view for the NTB
-// private View mBackgroundView = null;
private NavigationTabBarBehavior mBehavior;
// Detect if behavior already set
@@ -149,35 +153,30 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private boolean mAnimateHide;
// Main paint
- private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mPaint = new Paint(FLAGS) {
+ {
+ setStyle(Style.FILL);
+ }
+ };
+ // Background color paint
+ private final Paint mBgPaint = new Paint(FLAGS) {
{
- setDither(true);
setStyle(Style.FILL);
}
};
-
// Pointer paint
- private final Paint mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mPointerPaint = new Paint(FLAGS) {
{
- setDither(true);
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
}
};
// Icons paint
- private final Paint mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
- {
- setDither(true);
- }
- };
- private final Paint mSelectedIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
- {
- setDither(true);
- }
- };
+ private final Paint mIconPaint = new Paint(FLAGS);
+ private final Paint mSelectedIconPaint = new Paint(FLAGS);
// Paint for icon mask pointer
- private final Paint mIconPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mIconPointerPaint = new Paint(FLAGS) {
{
setStyle(Style.FILL);
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
@@ -185,18 +184,16 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for model title
- private final Paint mModelTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mModelTitlePaint = new TextPaint(FLAGS) {
{
- setDither(true);
setColor(Color.WHITE);
setTextAlign(Align.CENTER);
}
};
// Paint for badge
- private final Paint mBadgePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG) {
+ private final Paint mBadgePaint = new TextPaint(FLAGS) {
{
- setDither(true);
setTextAlign(Align.CENTER);
setFakeBoldText(true);
}
@@ -226,12 +223,12 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private float mCornersRadius;
// Model title size and margin
- private float mModelTitleSize;
+ private float mModelTitleSize = AUTO_SIZE;
private float mTitleMargin;
// Model badge title size and margin
private float mBadgeMargin;
- private float mBadgeTitleSize;
+ private float mBadgeTitleSize = AUTO_SIZE;
// Model title mode: active ar all
private TitleMode mTitleMode;
@@ -242,9 +239,9 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Model badge bg and title color.
// By default badge bg color is the active model color and badge title color is the model bg color
- // To reset colors just set bg and title color to 0
- private int mBadgeTitleColor;
- private int mBadgeBgColor;
+ // To reset colors just set bg and title color to AUTO_COLOR
+ private int mBadgeTitleColor = AUTO_COLOR;
+ private int mBadgeBgColor = AUTO_COLOR;
// Indexes
private int mLastIndex = INVALID_INDEX;
@@ -266,6 +263,8 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private boolean mIsScaled;
// Detect if model icon tinted
private boolean mIsTinted;
+ // Detect if model can swiped
+ private boolean mIsSwiped;
// Detect if model badge have custom typeface
private boolean mIsBadgeUseTypeface;
// Detect if is bar mode or indicator pager mode
@@ -284,6 +283,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Color variables
private int mInactiveColor;
private int mActiveColor;
+ private int mBgColor;
// Custom typeface
private Typeface mTypeface;
@@ -296,14 +296,16 @@ public NavigationTabBar(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
+ @SuppressWarnings("ResourceAsColor")
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
//Init NTB
// Always draw
setWillNotDraw(false);
- // More speed!
- setLayerType(LAYER_TYPE_HARDWARE, null);
+ // Speed and fix for pre 17 API
+ ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
+ setLayerType(LAYER_TYPE_SOFTWARE, null);
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
try {
@@ -311,6 +313,10 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
setIsTinted(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_tinted, true));
+ setIsSwiped(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_swiped, true));
+ setTitleSize(
+ typedArray.getDimension(R.styleable.NavigationTabBar_ntb_title_size, AUTO_SIZE)
+ );
setIsBadgeUseTypeface(
typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
);
@@ -320,6 +326,9 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
R.styleable.NavigationTabBar_ntb_title_mode, TitleMode.ALL_INDEX
)
);
+ setBadgeSize(
+ typedArray.getDimension(R.styleable.NavigationTabBar_ntb_badge_size, AUTO_SIZE)
+ );
setBadgePosition(
typedArray.getInt(
R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX
@@ -330,8 +339,12 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
R.styleable.NavigationTabBar_ntb_badge_gravity, BadgeGravity.TOP_INDEX
)
);
- setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, 0));
- setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, 0));
+ setBadgeBgColor(
+ typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, AUTO_COLOR)
+ );
+ setBadgeTitleColor(
+ typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR)
+ );
setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
setInactiveColor(
@@ -344,6 +357,11 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR
)
);
+ setBgColor(
+ typedArray.getColor(
+ R.styleable.NavigationTabBar_ntb_bg_color, DEFAULT_BG_COLOR
+ )
+ );
setAnimationDuration(
typedArray.getInteger(
R.styleable.NavigationTabBar_ntb_animation_duration, DEFAULT_ANIMATION_DURATION
@@ -458,6 +476,24 @@ public void setIsTinted(final boolean isTinted) {
updateTint();
}
+ public boolean isSwiped() {
+ return mIsSwiped;
+ }
+
+ public void setIsSwiped(final boolean swiped) {
+ mIsSwiped = swiped;
+ }
+
+ public float getTitleSize() {
+ return mModelTitleSize;
+ }
+
+ // To reset title size to automatic just put in method AUTO_SIZE value
+ public void setTitleSize(final float modelTitleSize) {
+ mModelTitleSize = modelTitleSize;
+ if (modelTitleSize == AUTO_SIZE) requestLayout();
+ }
+
public boolean isBadgeUseTypeface() {
return mIsBadgeUseTypeface;
}
@@ -547,6 +583,16 @@ public void setBadgeTitleColor(final int badgeTitleColor) {
mBadgeTitleColor = badgeTitleColor;
}
+ public float getBadgeSize() {
+ return mBadgeTitleSize;
+ }
+
+ // To reset badge title size to automatic just put in method AUTO_SIZE value
+ public void setBadgeSize(final float badgeTitleSize) {
+ mBadgeTitleSize = badgeTitleSize;
+ if (mBadgeTitleSize == AUTO_SIZE) requestLayout();
+ }
+
public Typeface getTypeface() {
return mTypeface;
}
@@ -602,6 +648,16 @@ public void setInactiveColor(final int inactiveColor) {
updateTint();
}
+ public int getBgColor() {
+ return mBgColor;
+ }
+
+ public void setBgColor(final int bgColor) {
+ mBgColor = bgColor;
+ mBgPaint.setColor(mBgColor);
+ postInvalidate();
+ }
+
public float getCornersRadius() {
return mCornersRadius;
}
@@ -678,6 +734,7 @@ public void setViewPager(final ViewPager viewPager) {
mIsViewPagerMode = true;
mViewPager = viewPager;
+ mViewPager.removeOnPageChangeListener(this);
mViewPager.addOnPageChangeListener(this);
resetScroller();
@@ -746,10 +803,8 @@ public void setModelIndex(int index, boolean force) {
// This check gives us opportunity to have an non selected model
if (mIndex == INVALID_INDEX) force = true;
-
// Detect if last is the same
- if (index == mIndex) return;
-
+ if (index == mIndex) force = true;
// Snap index to models size
index = Math.max(0, Math.min(index, mModels.size() - 1));
@@ -760,19 +815,40 @@ public void setModelIndex(int index, boolean force) {
mIsSetIndexFromTabBar = true;
if (mIsViewPagerMode) {
if (mViewPager == null) throw new IllegalStateException("ViewPager is null.");
- mViewPager.setCurrentItem(index, true);
+ mViewPager.setCurrentItem(index, !force);
}
// Set startX and endX for animation,
// where we animate two sides of rect with different interpolation
- mStartPointerX = mPointerLeftTop;
- mEndPointerX = mIndex * mModelSize;
+ if (force) {
+ mStartPointerX = mIndex * mModelSize;
+ mEndPointerX = mStartPointerX;
+ } else {
+ mStartPointerX = mPointerLeftTop;
+ mEndPointerX = mIndex * mModelSize;
+ }
// If it force, so update immediately, else animate
// This happens if we set index onCreate or something like this
// You can use force param or call this method in some post()
- if (force) updateIndicatorPosition(MAX_FRACTION);
- else mAnimator.start();
+ if (force) {
+ updateIndicatorPosition(MAX_FRACTION);
+ // Force onPageScrolled listener and refresh VP
+ if (mIsViewPagerMode) {
+ if (!mViewPager.isFakeDragging()) mViewPager.beginFakeDrag();
+ if (mViewPager.isFakeDragging()) mViewPager.fakeDragBy(0.0F);
+ if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
+ }
+ } else mAnimator.start();
+ }
+
+ // Deselect active index and reset pointer
+ public void deselect() {
+ mLastIndex = INVALID_INDEX;
+ mIndex = INVALID_INDEX;
+ mStartPointerX = INVALID_INDEX * mModelSize;
+ mEndPointerX = mStartPointerX;
+ updateIndicatorPosition(MIN_FRACTION);
}
private void updateIndicatorPosition(final float fraction) {
@@ -811,6 +887,7 @@ public boolean onTouchEvent(final MotionEvent event) {
// Action down touch
mIsActionDown = true;
if (!mIsViewPagerMode) break;
+ if (!mIsSwiped) break;
// Detect if we touch down on pointer, later to move
if (mIsHorizontalOrientation)
mIsPointerActionDown = (int) (event.getX() / mModelSize) == mIndex;
@@ -830,6 +907,7 @@ public boolean onTouchEvent(final MotionEvent event) {
case MotionEvent.ACTION_UP:
// Press up and set model index relative to current coordinate
if (mIsActionDown) {
+ playSoundEffect(SoundEffectConstants.CLICK);
if (mIsHorizontalOrientation) setModelIndex((int) (event.getX() / mModelSize));
else setModelIndex((int) (event.getY() / mModelSize));
}
@@ -868,12 +946,13 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
if (mIsBadged) side -= side * TITLE_SIZE_FRACTION;
mIconSize = side * (mIsTitled ? TITLE_ICON_SIZE_FRACTION : ICON_SIZE_FRACTION);
- mModelTitleSize = side * TITLE_SIZE_FRACTION;
+ if (mModelTitleSize == AUTO_SIZE) mModelTitleSize = side * TITLE_SIZE_FRACTION;
mTitleMargin = side * TITLE_MARGIN_FRACTION;
// If is badged mode, so get vars and set paint with default bounds
if (mIsBadged) {
- mBadgeTitleSize = mModelTitleSize * BADGE_TITLE_SIZE_FRACTION;
+ if (mBadgeTitleSize == AUTO_SIZE)
+ mBadgeTitleSize = (side * TITLE_SIZE_FRACTION) * BADGE_TITLE_SIZE_FRACTION;
final Rect badgeBounds = new Rect();
mBadgePaint.setTextSize(mBadgeTitleSize);
@@ -896,6 +975,9 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
// Set bounds for NTB
mBounds.set(0.0F, 0.0F, width, height - mBadgeMargin);
+ final float barBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;
+ mBgBounds.set(0.0F, barBadgeMargin, mBounds.width(), mBounds.height() + barBadgeMargin);
+
// Set main bitmap
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mCanvas.setBitmap(mBitmap);
@@ -955,51 +1037,11 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
setBehaviorEnabled(mBehaviorEnabled);
mIsBehaviorSet = true;
}
-
- if (mBackground == null || mNeedInvalidateBackground) {
- if (getBackground() != null) {
- if (getBackground() instanceof BitmapDrawable)
- mBackground = ((BitmapDrawable) getBackground()).getBitmap();
- else {
- mBackground = Bitmap.createBitmap(
- (int) mBounds.width(), (int) mBounds.height(), Bitmap.Config.ARGB_8888
- );
-
- final Canvas backgroundCanvas = new Canvas(mBackground);
- getBackground().setBounds(
- 0, 0, backgroundCanvas.getWidth(), backgroundCanvas.getHeight()
- );
- getBackground().draw(backgroundCanvas);
- }
-
- setBackgroundDrawable(null);
- mNeedInvalidateBackground = false;
- }
- }
- }
-
- @Override
- public void setBackgroundColor(final int color) {
- mNeedInvalidateBackground = true;
- super.setBackgroundColor(color);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void setBackgroundDrawable(final Drawable background) {
- mNeedInvalidateBackground = true;
- super.setBackgroundDrawable(background);
}
@SuppressWarnings("ConstantConditions")
@Override
protected void onDraw(final Canvas canvas) {
- if (mBackground != null)
- canvas.drawBitmap(
- mBackground, 0.0F,
- mBadgeGravity == BadgeGravity.TOP ? getBadgeMargin() : 0.0F, null
- );
-
if (mCanvas == null || mPointerCanvas == null ||
mIconsCanvas == null || mTitlesCanvas == null)
return;
@@ -1010,8 +1052,11 @@ protected void onDraw(final Canvas canvas) {
mIconsCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
if (mIsTitled) mTitlesCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
+ if (mCornersRadius == 0) canvas.drawRect(mBgBounds, mBgPaint);
+ else canvas.drawRoundRect(mBgBounds, mCornersRadius, mCornersRadius, mBgPaint);
+
// Get pointer badge margin for gravity
- final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;
+ final float barBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;
// Draw our model colors
for (int i = 0; i < mModels.size(); i++) {
@@ -1021,7 +1066,7 @@ protected void onDraw(final Canvas canvas) {
final float left = mModelSize * i;
final float right = left + mModelSize;
mCanvas.drawRect(
- left, pointerBadgeMargin, right, mBounds.height() + pointerBadgeMargin, mPaint
+ left, barBadgeMargin, right, mBounds.height() + barBadgeMargin, mPaint
);
} else {
final float top = mModelSize * i;
@@ -1033,8 +1078,8 @@ protected void onDraw(final Canvas canvas) {
// Set bound of pointer
if (mIsHorizontalOrientation)
mPointerBounds.set(
- mPointerLeftTop, pointerBadgeMargin,
- mPointerRightBottom, mBounds.height() + pointerBadgeMargin
+ mPointerLeftTop, barBadgeMargin,
+ mPointerRightBottom, mBounds.height() + barBadgeMargin
);
else mPointerBounds.set(0.0F, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
@@ -1126,12 +1171,7 @@ else if (mLastIndex == i)
matrixScale, matrixCenterX, matrixCenterY
);
} else {
- if (i != mIndex && i != mIndex + 1)
- updateInactiveModel(
- model, leftOffset, topOffset, titleScale,
- matrixScale, matrixCenterX, matrixCenterY
- );
- else if (i == mIndex + 1)
+ if (i == mIndex + 1)
updateCurrentModel(
model, leftOffset, topOffset, titleTranslate, interpolation,
matrixCenterX, matrixCenterY, matrixScale, titleScale, titleAlpha
@@ -1141,6 +1181,11 @@ else if (i == mIndex)
model, leftOffset, topOffset, titleTranslate, lastInterpolation,
matrixCenterX, matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha
);
+ else
+ updateInactiveModel(
+ model, leftOffset, topOffset, titleScale,
+ matrixScale, matrixCenterX, matrixCenterY
+ );
}
// Draw original model icon
@@ -1187,9 +1232,9 @@ else if (i == mIndex)
// Draw general bitmap
canvas.drawBitmap(mBitmap, 0.0F, 0.0F, null);
// Draw icons bitmap on top
- canvas.drawBitmap(mIconsBitmap, 0.0F, pointerBadgeMargin, null);
+ canvas.drawBitmap(mIconsBitmap, 0.0F, barBadgeMargin, null);
// Draw titles bitmap on top
- if (mIsTitled) canvas.drawBitmap(mTitlesBitmap, 0.0F, pointerBadgeMargin, null);
+ if (mIsTitled) canvas.drawBitmap(mTitlesBitmap, 0.0F, barBadgeMargin, null);
// If is not badged, exit
if (!mIsBadged) return;
@@ -1240,7 +1285,7 @@ else if (i == mIndex)
// Set color and alpha for badge bg
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
- else mBadgePaint.setColor(mBadgeBgColor == 0 ? mActiveColor : mBadgeBgColor);
+ else mBadgePaint.setColor(mBadgeBgColor == AUTO_COLOR ? mActiveColor : mBadgeBgColor);
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set corners to round rect for badge bg and draw
@@ -1250,7 +1295,7 @@ else if (i == mIndex)
// Set color and alpha for badge title
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
else //noinspection ResourceAsColor
- mBadgePaint.setColor(mBadgeTitleColor == 0 ? model.getColor() : mBadgeTitleColor);
+ mBadgePaint.setColor(mBadgeTitleColor == AUTO_COLOR ? model.getColor() : mBadgeTitleColor);
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set badge title center position and draw title
@@ -1426,6 +1471,11 @@ private void updateTint() {
@Override
public void onPageScrolled(int position, float positionOffset, final int positionOffsetPixels) {
+ //Fix the wrong position problem for some devices
+ position = position + (int) positionOffset;
+ if (mOnPageChangeListener != null)
+ mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
+
// If we animate, don`t call this
if (!mIsSetIndexFromTabBar) {
mIsResizeIn = position < mIndex;
@@ -1437,35 +1487,26 @@ public void onPageScrolled(int position, float positionOffset, final int positio
updateIndicatorPosition(positionOffset);
}
- if (mOnPageChangeListener != null)
- mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
+ // Stop scrolling on animation end and reset values
+ if (!mAnimator.isRunning() && mIsSetIndexFromTabBar) {
+ mFraction = MIN_FRACTION;
+ mIsSetIndexFromTabBar = false;
+ }
}
@Override
public void onPageSelected(final int position) {
- // If VP idle, so update
- if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
- mIsResizeIn = position < mIndex;
- mLastIndex = mIndex;
- mIndex = position;
- postInvalidate();
- }
}
@Override
public void onPageScrollStateChanged(final int state) {
// If VP idle, reset to MIN_FRACTION
+ mScrollState = state;
if (state == ViewPager.SCROLL_STATE_IDLE) {
- mFraction = MIN_FRACTION;
- mIsSetIndexFromTabBar = false;
-
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageSelected(mIndex);
- else {
- if (mOnTabBarSelectedIndexListener != null)
- mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
- }
+ if (mIsViewPagerMode && mOnTabBarSelectedIndexListener != null)
+ mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
}
- mScrollState = state;
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageScrollStateChanged(state);
}
@@ -1527,7 +1568,7 @@ protected void onConfigurationChanged(final Configuration newConfig) {
// Refresh pointer and state after config changed to current
final int tempIndex = mIndex;
- setModelIndex(INVALID_INDEX, true);
+ deselect();
post(new Runnable() {
@Override
public void run() {
@@ -1828,7 +1869,6 @@ public float getResizeInterpolation(final float input, final boolean resizeIn) {
// Model title mode
public enum TitleMode {
-
ALL, ACTIVE;
public final static int ALL_INDEX = 0;
@@ -1837,7 +1877,6 @@ public enum TitleMode {
// Model badge position
public enum BadgePosition {
-
LEFT(LEFT_FRACTION), CENTER(CENTER_FRACTION), RIGHT(RIGHT_FRACTION);
public final static int LEFT_INDEX = 0;
@@ -1857,7 +1896,6 @@ public enum BadgePosition {
// Model badge gravity
public enum BadgeGravity {
-
TOP, BOTTOM;
public final static int TOP_INDEX = 0;
diff --git a/navigationtabbar/src/main/res/values/attrs.xml b/navigationtabbar/src/main/res/values/attrs.xml
index 13ca302..f59d52f 100644
--- a/navigationtabbar/src/main/res/values/attrs.xml
+++ b/navigationtabbar/src/main/res/values/attrs.xml
@@ -6,12 +6,16 @@
+
+
+
+
@@ -30,6 +34,7 @@
+
From 001625ad5f3500026d3e0e73db3aaac90ff8f948 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 28 Jun 2016 12:51:45 +0300
Subject: [PATCH 25/64] Update.
---
app/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/build.gradle b/app/build.gradle
index bbb740b..4417fea 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':navigationtabbar')
-// compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.2'
+// compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.3'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
From 4d6ecee38dc417c8a2fc7cf0507b585f2afa6a61 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 5 Jul 2016 15:55:52 +0300
Subject: [PATCH 26/64] Lint analyze check. Code refactoring. Code cleanup.
Update readme.
---
README.md | 7 +-
navigationtabbar/build.gradle | 11 +-
.../behavior/NavigationTabBarBehavior.java | 53 ++++----
.../behavior/VerticalScrollingBehavior.java | 31 +++--
.../ntb/NavigationTabBar.java | 126 ++++++------------
5 files changed, 94 insertions(+), 134 deletions(-)
diff --git a/README.md b/README.md
index 8df1eb7..75a887f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
[](http://android-arsenal.com/details/1/3382)
[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
+[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
NavigationTabBar
===================
@@ -296,9 +297,9 @@ Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/Navi
Inspiration
======
-TapBar interactions| Circle interactions | Title interactions
-:-------------------------:|:-------------------------:|:-------------------------:
-||
+TapBar interactions| Circle interactions | Title interactions | Player interactions
+:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
+|||
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index 787c9da..c3a2660 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -23,7 +23,7 @@ version = "1.2.3"
android {
compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 11
@@ -41,6 +41,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
+ //noinspection GradleDependency
compile 'com.android.support:design:23.2.1'
}
@@ -52,10 +53,12 @@ install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
+ //noinspection GroovyAssignabilityCheck
project {
packaging 'aar'
// Add your description here
+ //noinspection GroovyAssignabilityCheck
name 'NavigationTabBar'
description = 'Navigation tab bar with colorful interactions.'
url siteUrl
@@ -63,6 +66,7 @@ install {
// Set your license
licenses {
license {
+ //noinspection GroovyAssignabilityCheck
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
@@ -70,6 +74,7 @@ install {
developers {
developer {
id 'gigamole'
+ //noinspection GroovyAssignabilityCheck
name 'Basil Miller'
email 'gigamole53@gmail.com'
}
@@ -85,17 +90,20 @@ install {
}
task sourcesJar(type: Jar) {
+ //noinspection GroovyAssignabilityCheck
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
+ //noinspection GroovyAssignabilityCheck
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
+ //noinspection GrUnresolvedAccess
from javadoc.destinationDir
}
artifacts {
@@ -119,6 +127,7 @@ bintray {
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
+ //noinspection GroovyAssignabilityCheck
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java
index f1cd394..9f9795d 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java
@@ -2,8 +2,6 @@
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
-import android.content.Context;
-import android.content.res.TypedArray;
import android.os.Build;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
@@ -12,12 +10,10 @@
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorUpdateListener;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
-import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
-import com.gigamole.navigationtabbar.R;
import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
public class NavigationTabBarBehavior extends VerticalScrollingBehavior {
@@ -27,10 +23,10 @@ public class NavigationTabBarBehavior extends VerticalScrollingBehavior= Build.VERSION_CODES.KITKAT) {
- mSnackbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ mSnackBarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
@@ -261,7 +254,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
});
}
- if (mSnackbarHeight == -1) mSnackbarHeight = dependency.getHeight();
+ if (mSnackBarHeight == -1) mSnackBarHeight = dependency.getHeight();
final int targetMargin = (int) (child.getBarHeight() - child.getTranslationY());
child.bringToFront();
@@ -281,7 +274,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
}
// Update floating action button bottom margin
- public void updateFloatingActionButton(final View dependency) {
+ private void updateFloatingActionButton(final View dependency) {
if (dependency != null && dependency instanceof FloatingActionButton) {
mFloatingActionButton = (FloatingActionButton) dependency;
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
index 39886f6..fef5396 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
@@ -1,18 +1,19 @@
package com.gigamole.navigationtabbar.behavior;
-import android.content.Context;
+import android.annotation.TargetApi;
+import android.os.Build;
import android.os.Parcelable;
import android.support.annotation.IntDef;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.view.WindowInsetsCompat;
-import android.util.AttributeSet;
import android.view.View;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-public abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
+@SuppressWarnings({"unused", "EmptyMethod"})
+abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
private int mTotalDyUnconsumed = 0;
private int mTotalDy = 0;
@@ -30,14 +31,10 @@ public abstract class VerticalScrollingBehavior extends Coordina
int SCROLL_NONE = 0;
}
- public VerticalScrollingBehavior() {
+ VerticalScrollingBehavior() {
super();
}
- public VerticalScrollingBehavior(final Context context, final AttributeSet attrs) {
- super(context, attrs);
- }
-
@ScrollDirection
public int getOverScrollDirection() {
return mOverScrollDirection;
@@ -48,14 +45,15 @@ public int getScrollDirection() {
return mScrollDirection;
}
- // Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ // Direction of the over scroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
// Unconsumed value, negative or positive based on the direction
// Cumulative value for current direction
- public abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll);
+ protected abstract void onNestedVerticalOverScroll();
- // Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
- public abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection);
+ // Direction of the over scroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
+ protected abstract void onDirectionNestedPreScroll();
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0;
@@ -83,7 +81,7 @@ public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View ta
}
mTotalDyUnconsumed += dyUnconsumed;
- onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed);
+ onNestedVerticalOverScroll();
}
@Override
@@ -97,17 +95,18 @@ public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View
mScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
}
mTotalDy += dy;
- onDirectionNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, mScrollDirection);
+ onDirectionNestedPreScroll();
}
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, boolean consumed) {
super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
mScrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
- return onNestedDirectionFling(coordinatorLayout, child, target, velocityX, velocityY, mScrollDirection);
+ return onNestedDirectionFling();
}
- protected abstract boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection);
+ @SuppressWarnings("SameReturnValue")
+ protected abstract boolean onNestedDirectionFling();
@Override
public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 371f27b..48049da 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -17,6 +17,7 @@
package com.gigamole.navigationtabbar.ntb;
import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -66,7 +67,9 @@
/**
* Created by GIGAMOLE on 24.03.2016.
*/
-public class NavigationTabBar extends View implements ViewPager.OnPageChangeListener {
+@SuppressWarnings({"unused", "DefaultFileTemplate"})
+public class NavigationTabBar extends View implements
+ ViewPager.OnPageChangeListener {
// NTB constants
private final static int FLAGS =
@@ -108,9 +111,9 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static float BADGE_VERTICAL_FRACTION = 0.75F;
private final static float BADGE_TITLE_SIZE_FRACTION = 0.9F;
- public final static float LEFT_FRACTION = 0.25F;
- public final static float CENTER_FRACTION = 0.5F;
- public final static float RIGHT_FRACTION = 0.75F;
+ private final static float LEFT_FRACTION = 0.25F;
+ private final static float CENTER_FRACTION = 0.5F;
+ private final static float RIGHT_FRACTION = 0.75F;
private final static Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
private final static Interpolator ACCELERATE_INTERPOLATOR = new AccelerateInterpolator();
@@ -516,6 +519,7 @@ private void setTitleMode(final int index) {
case TitleMode.ALL_INDEX:
default:
setTitleMode(TitleMode.ALL);
+ break;
}
}
@@ -539,6 +543,7 @@ private void setBadgePosition(final int index) {
case BadgePosition.RIGHT_INDEX:
default:
setBadgePosition(BadgePosition.RIGHT);
+ break;
}
}
@@ -559,6 +564,7 @@ private void setBadgeGravity(final int index) {
case BadgeGravity.TOP_INDEX:
default:
setBadgeGravity(BadgeGravity.TOP);
+ break;
}
}
@@ -684,7 +690,7 @@ public void setOnTabBarSelectedIndexListener(final OnTabBarSelectedIndexListener
mOnTabBarSelectedIndexListener = onTabBarSelectedIndexListener;
if (mAnimatorListener == null)
- mAnimatorListener = new Animator.AnimatorListener() {
+ mAnimatorListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(final Animator animation) {
if (mOnTabBarSelectedIndexListener != null)
@@ -704,16 +710,6 @@ public void onAnimationEnd(final Animator animation) {
if (mOnTabBarSelectedIndexListener != null)
mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
}
-
- @Override
- public void onAnimationCancel(final Animator animation) {
-
- }
-
- @Override
- public void onAnimationRepeat(final Animator animation) {
-
- }
};
mAnimator.removeListener(mAnimatorListener);
mAnimator.addListener(mAnimatorListener);
@@ -726,7 +722,7 @@ public void setViewPager(final ViewPager viewPager) {
return;
}
- if (mViewPager == viewPager) return;
+ if (viewPager.equals(mViewPager)) return;
if (mViewPager != null) //noinspection deprecation
mViewPager.setOnPageChangeListener(null);
if (viewPager.getAdapter() == null)
@@ -1312,16 +1308,9 @@ else if (i == mIndex)
// Method to transform current fraction of NTB and position
private void updateCurrentModel(
- final Model model,
- final float leftOffset,
- final float topOffset,
- final float titleTranslate,
- final float interpolation,
- final float matrixCenterX,
- final float matrixCenterY,
- final float matrixScale,
- final float textScale,
- final int textAlpha
+ final Model model, final float leftOffset, final float topOffset, final float titleTranslate,
+ final float interpolation, final float matrixCenterX, final float matrixCenterY,
+ final float matrixScale, final float textScale, final int textAlpha
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(
@@ -1356,26 +1345,19 @@ private void updateCurrentModel(
}
mIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(iconAlpha, MIN_FRACTION, MAX_FRACTION))
+ (int) (MAX_ALPHA * clampValue(iconAlpha))
);
mSelectedIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(selectedIconAlpha, MIN_FRACTION, MAX_FRACTION))
+ (int) (MAX_ALPHA * clampValue(selectedIconAlpha))
);
}
// Method to transform last fraction of NTB and position
private void updateLastModel(
- final Model model,
- final float leftOffset,
- final float topOffset,
- final float titleTranslate,
- final float lastInterpolation,
- final float matrixCenterX,
- final float matrixCenterY,
- final float matrixLastScale,
- final float textLastScale,
- final int textLastAlpha
+ final Model model, final float leftOffset, final float topOffset, final float titleTranslate,
+ final float lastInterpolation, final float matrixCenterX, final float matrixCenterY,
+ final float matrixLastScale, final float textLastScale, final int textLastAlpha
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(
@@ -1411,22 +1393,17 @@ private void updateLastModel(
}
mIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(iconAlpha, MIN_FRACTION, MAX_FRACTION))
+ (int) (MAX_ALPHA * clampValue(iconAlpha))
);
mSelectedIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(selectedIconAlpha, MIN_FRACTION, MAX_FRACTION))
+ (int) (MAX_ALPHA * clampValue(selectedIconAlpha))
);
}
// Method to transform others fraction of NTB and position
private void updateInactiveModel(
- final Model model,
- final float leftOffset,
- final float topOffset,
- final float textScale,
- final float matrixScale,
- final float matrixCenterX,
- final float matrixCenterY
+ final Model model, final float leftOffset, final float topOffset, final float textScale,
+ final float matrixScale, final float matrixCenterX, final float matrixCenterY
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(leftOffset, topOffset);
@@ -1496,6 +1473,7 @@ public void onPageScrolled(int position, float positionOffset, final int positio
@Override
public void onPageSelected(final int position) {
+ // This method is empty, because we call onPageSelected() when scroll state is idle
}
@Override
@@ -1578,51 +1556,40 @@ public void run() {
}
// Clamp value to max and min bounds
- private float clampValue(final float value, final float max, final float min) {
- return Math.max(Math.min(value, min), max);
+ private float clampValue(final float value) {
+ return Math.max(Math.min(value, NavigationTabBar.MAX_FRACTION), NavigationTabBar.MIN_FRACTION);
}
// Hide NTB with animation
public void hide() {
- hide(true);
- }
-
- // Hide NTB with or without animation
- public void hide(final boolean withAnimation) {
- if (mBehavior != null) mBehavior.hideView(this, (int) getBarHeight(), withAnimation);
+ if (mBehavior != null) mBehavior.hideView(this, (int) getBarHeight(), true);
else if (getParent() != null && getParent() instanceof CoordinatorLayout) {
mNeedHide = true;
- mAnimateHide = withAnimation;
- } else scrollDown(withAnimation);
+ mAnimateHide = true;
+ } else scrollDown();
}
// Show NTB with animation
public void show() {
- show(true);
- }
-
- // Show NTB with or without animation
- public void show(final boolean withAnimation) {
- if (mBehavior != null)
- mBehavior.resetOffset(this, withAnimation);
- else scrollUp(withAnimation);
+ if (mBehavior != null) mBehavior.resetOffset(this, true);
+ else scrollUp();
}
// Hide NTB or bg on scroll down
- private void scrollDown(final boolean withAnimation) {
+ private void scrollDown() {
ViewCompat.animate(this)
.translationY(getBarHeight())
.setInterpolator(new LinearOutSlowInInterpolator())
- .setDuration(withAnimation ? DEFAULT_ANIMATION_DURATION : 0)
+ .setDuration(DEFAULT_ANIMATION_DURATION)
.start();
}
// Show NTB or bg on scroll up
- private void scrollUp(final boolean withAnimation) {
+ private void scrollUp() {
ViewCompat.animate(this)
.translationY(0.0F)
.setInterpolator(OUT_SLOW_IN_INTERPOLATOR)
- .setDuration(withAnimation ? DEFAULT_ANIMATION_DURATION : 0)
+ .setDuration(DEFAULT_ANIMATION_DURATION)
.start();
}
@@ -1631,8 +1598,8 @@ public static class Model {
private int mColor;
- private Bitmap mIcon;
- private Bitmap mSelectedIcon;
+ private final Bitmap mIcon;
+ private final Bitmap mSelectedIcon;
private final Matrix mIconMatrix = new Matrix();
private String mTitle = "";
@@ -1655,7 +1622,7 @@ public Model(final Builder builder) {
mTitle = builder.mTitle;
mBadgeTitle = builder.mBadgeTitle;
- mBadgeAnimator.addListener(new Animator.AnimatorListener() {
+ mBadgeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(final Animator animation) {
@@ -1673,11 +1640,6 @@ public void onAnimationEnd(final Animator animation) {
else mIsBadgeUpdated = false;
}
- @Override
- public void onAnimationCancel(final Animator animation) {
-
- }
-
@Override
public void onAnimationRepeat(final Animator animation) {
// Change title when we update and don`t see the title
@@ -1765,9 +1727,9 @@ public void hideBadge() {
public static class Builder {
- private int mColor;
+ private final int mColor;
- private Bitmap mIcon;
+ private final Bitmap mIcon;
private Bitmap mSelectedIcon;
private String mTitle;
@@ -1883,11 +1845,7 @@ public enum BadgePosition {
public final static int CENTER_INDEX = 1;
public final static int RIGHT_INDEX = 2;
- private float mPositionFraction;
-
- BadgePosition() {
- mPositionFraction = RIGHT_FRACTION;
- }
+ private final float mPositionFraction;
BadgePosition(final float positionFraction) {
mPositionFraction = positionFraction;
From de2738afda75d24f00443823071576bc1737138e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 5 Jul 2016 16:04:23 +0300
Subject: [PATCH 27/64] Code cleanup.
---
.../ntb/NavigationTabBar.java | 38 ++++++++++++++-----
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 48049da..6e0a9b2 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -68,8 +68,7 @@
* Created by GIGAMOLE on 24.03.2016.
*/
@SuppressWarnings({"unused", "DefaultFileTemplate"})
-public class NavigationTabBar extends View implements
- ViewPager.OnPageChangeListener {
+public class NavigationTabBar extends View implements ViewPager.OnPageChangeListener {
// NTB constants
private final static int FLAGS =
@@ -1308,9 +1307,16 @@ else if (i == mIndex)
// Method to transform current fraction of NTB and position
private void updateCurrentModel(
- final Model model, final float leftOffset, final float topOffset, final float titleTranslate,
- final float interpolation, final float matrixCenterX, final float matrixCenterY,
- final float matrixScale, final float textScale, final int textAlpha
+ final Model model,
+ final float leftOffset,
+ final float topOffset,
+ final float titleTranslate,
+ final float interpolation,
+ final float matrixCenterX,
+ final float matrixCenterY,
+ final float matrixScale,
+ final float textScale,
+ final int textAlpha
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(
@@ -1355,9 +1361,16 @@ private void updateCurrentModel(
// Method to transform last fraction of NTB and position
private void updateLastModel(
- final Model model, final float leftOffset, final float topOffset, final float titleTranslate,
- final float lastInterpolation, final float matrixCenterX, final float matrixCenterY,
- final float matrixLastScale, final float textLastScale, final int textLastAlpha
+ final Model model,
+ final float leftOffset,
+ final float topOffset,
+ final float titleTranslate,
+ final float lastInterpolation,
+ final float matrixCenterX,
+ final float matrixCenterY,
+ final float matrixLastScale,
+ final float textLastScale,
+ final int textLastAlpha
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(
@@ -1402,8 +1415,13 @@ private void updateLastModel(
// Method to transform others fraction of NTB and position
private void updateInactiveModel(
- final Model model, final float leftOffset, final float topOffset, final float textScale,
- final float matrixScale, final float matrixCenterX, final float matrixCenterY
+ final Model model,
+ final float leftOffset,
+ final float topOffset,
+ final float textScale,
+ final float matrixScale,
+ final float matrixCenterX,
+ final float matrixCenterY
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(leftOffset, topOffset);
From 026c72f5e83f13da30b696042c3f83b5677a563e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 5 Jul 2016 16:10:16 +0300
Subject: [PATCH 28/64] Code cleanup.
---
.../gigamole/navigationtabbar/ntb/NavigationTabBar.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 6e0a9b2..e4d2307 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -792,10 +792,13 @@ public void setModelIndex(int index) {
}
// Set model index from touch or programmatically
- public void setModelIndex(int index, boolean force) {
+ public void setModelIndex(final int modelIndex, final boolean isForce) {
if (mAnimator.isRunning()) return;
if (mModels.isEmpty()) return;
+ int index = modelIndex;
+ boolean force = isForce;
+
// This check gives us opportunity to have an non selected model
if (mIndex == INVALID_INDEX) force = true;
// Detect if last is the same
@@ -1466,8 +1469,6 @@ private void updateTint() {
@Override
public void onPageScrolled(int position, float positionOffset, final int positionOffsetPixels) {
- //Fix the wrong position problem for some devices
- position = position + (int) positionOffset;
if (mOnPageChangeListener != null)
mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
From bf180980b97a45175fc0a21caff014d1438ffb6f Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 9 Jul 2016 23:13:51 +0300
Subject: [PATCH 29/64] Update 1.2.4. Icon size fraction feature. Fixed random
crash of bitmap.
---
README.md | 8 ++
build.gradle | 2 +-
navigationtabbar/build.gradle | 4 +-
.../ntb/NavigationTabBar.java | 98 +++++++++++++------
.../src/main/res/values/attrs.xml | 1 +
5 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/README.md b/README.md
index 75a887f..119b2d4 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,10 @@ For NTB you can set such parameters as:
allows you to set corners radius of pointer.
+ - icon size fraction:
+
+ allows you to set icon size fraction relative to smaller model side.
+
- animation duration:
allows you to set animation duration.
@@ -166,6 +170,8 @@ By default badge bg color is the active model color and badge title color is the
By default badge sizes and title sizes is auto fit. To reset calculation just set AUTO_SIZE value to badge size and title size.
+By default icon size fraction is 0.5 (half of smaller side of NTB model). To reset scale fraction of icon to automatic just put in method AUTO_SCALE value.
+
If your set ViewPager and enable swipe you can action down on active pointer and do like drag.
Init
@@ -232,6 +238,7 @@ navigationTabBar.setIsSwiped(true);
navigationTabBar.setBgColor(Color.BLACK);
navigationTabBar.setBadgeSize(10);
navigationTabBar.setTitleSize(10);
+navigationTabBar.setIconSizeFraction(0.5);
```
If your models is in badge mode you can set title, hide, show, toggle and update badge title like this:
@@ -280,6 +287,7 @@ And XML init:
app:ntb_badge_use_typeface="true"
app:ntb_swiped="true"
app:ntb_bg_color="#000"
+ app:ntb_icon_size_fraction="http://github.com/0.5"
app:ntb_badge_size="10sp"
app:ntb_title_size="10sp"/>
```
diff --git a/build.gradle b/build.gradle
index cd70ee5..c618080 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
}
}
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index c3a2660..d28d0f2 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.2.3"
+version = "1.2.4"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.2.3"
+ versionName "1.2.4"
}
buildTypes {
release {
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index e4d2307..42ced03 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -80,10 +80,13 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static int INVALID_INDEX = -1;
public final static int AUTO_SIZE = -2;
public final static int AUTO_COLOR = -3;
+ public final static int AUTO_SCALE = -4;
private final static int DEFAULT_BADGE_ANIMATION_DURATION = 200;
private final static int DEFAULT_BADGE_REFRESH_ANIMATION_DURATION = 100;
private final static int DEFAULT_ANIMATION_DURATION = 300;
+ private final static float DEFAULT_ICON_SIZE_FRACTION = 0.5F;
+ private final static float DEFAULT_TITLE_ICON_SIZE_FRACTION = 0.5F;
private final static int DEFAULT_INACTIVE_COLOR = Color.parseColor("#9f90af");
private final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
@@ -97,10 +100,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
private final static int MAX_ALPHA = 255;
private final static float ACTIVE_ICON_SCALE_BY = 0.3F;
- private final static float ICON_SIZE_FRACTION = 0.45F;
-
private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2F;
- private final static float TITLE_ICON_SIZE_FRACTION = 0.45F;
private final static float TITLE_ACTIVE_SCALE_BY = 0.2F;
private final static float TITLE_SIZE_FRACTION = 0.2F;
private final static float TITLE_MARGIN_FRACTION = 0.15F;
@@ -221,6 +221,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
// Variables for sizes
private float mModelSize;
private float mIconSize;
+ private float mIconSizeFraction;
// Corners radius for rect mode
private float mCornersRadius;
@@ -372,6 +373,12 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
setCornersRadius(
typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0F)
);
+ setIconSizeFraction(
+ typedArray.getFloat(
+ R.styleable.NavigationTabBar_ntb_icon_size_fraction,
+ AUTO_SCALE
+ )
+ );
// Init animator
mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
@@ -672,6 +679,16 @@ public void setCornersRadius(final float cornersRadius) {
postInvalidate();
}
+ public float getIconSizeFraction() {
+ return mIconSizeFraction;
+ }
+
+ // To reset scale fraction of icon to automatic just put in method AUTO_SCALE value
+ public void setIconSizeFraction(final float iconSizeFraction) {
+ mIconSizeFraction = iconSizeFraction;
+ requestLayout();
+ }
+
public float getBadgeMargin() {
return mBadgeMargin;
}
@@ -943,7 +960,8 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
float side = mModelSize > height ? height : mModelSize;
if (mIsBadged) side -= side * TITLE_SIZE_FRACTION;
- mIconSize = side * (mIsTitled ? TITLE_ICON_SIZE_FRACTION : ICON_SIZE_FRACTION);
+ mIconSize = side * (mIconSizeFraction != AUTO_SCALE ? mIconSizeFraction :
+ (mIsTitled ? DEFAULT_TITLE_ICON_SIZE_FRACTION : DEFAULT_ICON_SIZE_FRACTION));
if (mModelTitleSize == AUTO_SIZE) mModelTitleSize = side * TITLE_SIZE_FRACTION;
mTitleMargin = side * TITLE_MARGIN_FRACTION;
@@ -967,7 +985,8 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
mIsBadged = false;
mModelSize = (float) height / (float) mModels.size();
- mIconSize = (int) ((mModelSize > width ? width : mModelSize) * ICON_SIZE_FRACTION);
+ mIconSize = (int) ((mModelSize > width ? width : mModelSize) *
+ (mIconSizeFraction == AUTO_SCALE ? DEFAULT_ICON_SIZE_FRACTION : mIconSizeFraction));
}
// Set bounds for NTB
@@ -976,24 +995,6 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
final float barBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;
mBgBounds.set(0.0F, barBadgeMargin, mBounds.width(), mBounds.height() + barBadgeMargin);
- // Set main bitmap
- mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mCanvas.setBitmap(mBitmap);
-
- // Set pointer canvas
- mPointerBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mPointerCanvas.setBitmap(mPointerBitmap);
-
- // Set icons canvas
- mIconsBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mIconsCanvas.setBitmap(mIconsBitmap);
-
- // Set titles canvas
- if (mIsTitled) {
- mTitlesBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- mTitlesCanvas.setBitmap(mTitlesBitmap);
- } else mTitlesBitmap = null;
-
// Set scale fraction for icons
for (Model model : mModels) {
final float originalIconSize = model.mIcon.getWidth() > model.mIcon.getHeight() ?
@@ -1003,6 +1004,12 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
(mIsTitled ? TITLE_ACTIVE_ICON_SCALE_BY : ACTIVE_ICON_SCALE_BY);
}
+ // Reset bitmap to init it onDraw()
+ mBitmap = null;
+ mPointerBitmap = null;
+ mIconsBitmap = null;
+ if (mIsTitled) mTitlesBitmap = null;
+
// Set start position of pointer for preview or on start
if (isInEditMode() || !mIsViewPagerMode) {
mIsSetIndexFromTabBar = true;
@@ -1040,9 +1047,39 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
@SuppressWarnings("ConstantConditions")
@Override
protected void onDraw(final Canvas canvas) {
- if (mCanvas == null || mPointerCanvas == null ||
- mIconsCanvas == null || mTitlesCanvas == null)
- return;
+ // Get height of NTB with badge on nor
+ final int mBadgedHeight = (int) (mBounds.height() + mBadgeMargin);
+
+ // Set main canvas
+ if (mBitmap == null || mBitmap.isRecycled()) {
+ mBitmap = Bitmap.createBitmap(
+ (int) mBounds.width(), mBadgedHeight, Bitmap.Config.ARGB_8888
+ );
+ mCanvas.setBitmap(mBitmap);
+ }
+ // Set pointer canvas
+ if (mPointerBitmap == null || mPointerBitmap.isRecycled()) {
+ mPointerBitmap = Bitmap.createBitmap(
+ (int) mBounds.width(), mBadgedHeight, Bitmap.Config.ARGB_8888
+ );
+ mPointerCanvas.setBitmap(mPointerBitmap);
+ }
+ // Set icons canvas
+ if (mIconsBitmap == null || mIconsBitmap.isRecycled()) {
+ mIconsBitmap = Bitmap.createBitmap(
+ (int) mBounds.width(), mBadgedHeight, Bitmap.Config.ARGB_8888
+ );
+ mIconsCanvas.setBitmap(mIconsBitmap);
+ }
+ // Set titles canvas
+ if (mIsTitled) {
+ if (mTitlesBitmap == null || mTitlesBitmap.isRecycled()) {
+ mTitlesBitmap = Bitmap.createBitmap(
+ (int) mBounds.width(), mBadgedHeight, Bitmap.Config.ARGB_8888
+ );
+ mTitlesCanvas.setBitmap(mTitlesBitmap);
+ }
+ } else mTitlesBitmap = null;
// Reset and clear canvases
mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
@@ -1188,14 +1225,17 @@ else if (i == mIndex)
// Draw original model icon
if (model.mSelectedIcon == null) {
- mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
+ if (model.mIcon != null && !model.mIcon.isRecycled())
+ mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
} else {
- if (mIconPaint.getAlpha() != MIN_ALPHA)
+ if (mIconPaint.getAlpha() != MIN_ALPHA
+ && model.mIcon != null && !model.mIcon.isRecycled())
// Draw original icon when is visible
mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
}
// Draw selected icon when exist and visible
- if (model.mSelectedIcon != null && mSelectedIconPaint.getAlpha() != MIN_ALPHA)
+ if (mSelectedIconPaint.getAlpha() != MIN_ALPHA
+ && model.mSelectedIcon != null && !model.mSelectedIcon.isRecycled())
mIconsCanvas.drawBitmap(
model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint
);
diff --git a/navigationtabbar/src/main/res/values/attrs.xml b/navigationtabbar/src/main/res/values/attrs.xml
index f59d52f..0b39aa9 100644
--- a/navigationtabbar/src/main/res/values/attrs.xml
+++ b/navigationtabbar/src/main/res/values/attrs.xml
@@ -30,6 +30,7 @@
+
From 8d46986209b02426c8f5f2e1c8632ce108c811f2 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Mon, 25 Jul 2016 18:50:20 +0300
Subject: [PATCH 30/64] New badge.
---
README.md | 2 +-
app/build.gradle | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 119b2d4..3e687d5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[](http://android-arsenal.com/details/1/3382)
+[](http://android-arsenal.com/details/1/3382)
[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
diff --git a/app/build.gradle b/app/build.gradle
index 4417fea..c7ecffe 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,6 +17,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+ compileOptions {
+ targetCompatibility 1.7
+ sourceCompatibility 1.7
+ }
}
dependencies {
From e187e49ac917c0a160fe9b0a6749715f09ba4aa7 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:38:49 +0300
Subject: [PATCH 31/64] New badge.
---
README.md | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 3e687d5..b4289d5 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,16 @@
-[](http://android-arsenal.com/details/1/3382)
-[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
-[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-
NavigationTabBar
===================
Navigation tab bar with colorful interactions.
+[](http://devlight.com.ua)
+
+[](http://android-arsenal.com/details/1/3382)
+
+[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
+[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
+[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
+
Horizontal NTB | NTB with bottom behavior | NTB with selected icons | NTB with CoordinatorLayout | Vertical NTB | NTB Samples |
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||||
From fac5a7b891d05cd24195d7d725ef6815a2828aae Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:40:06 +0300
Subject: [PATCH 32/64] Readme update.
---
README.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README.md b/README.md
index b4289d5..d7e8a88 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-Horizontal NTB | NTB with bottom behavior | NTB with selected icons | NTB with CoordinatorLayout | Vertical NTB | NTB Samples |
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -307,9 +306,8 @@ License
Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/LICENSE.txt) file for details.
Inspiration
-======
+===========
-TapBar interactions| Circle interactions | Title interactions | Player interactions
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||
From 4458d7a47d865cb147470b7976fdc025babd2c37 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:49:05 +0300
Subject: [PATCH 33/64] Readme update.
---
README.md | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index d7e8a88..aaa4442 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
-|||||
+|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|
+|||||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
Download
@@ -307,7 +307,6 @@ Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/Navi
Inspiration
===========
-
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||
From fce6b354c667b0c227029f07469943708b077f7f Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:51:36 +0300
Subject: [PATCH 34/64] Readme update.
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index aaa4442..93799d4 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,10 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|
-|||||||
+| | | | |
+:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
+|||||
+
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
Download
From a9e4e5f652ab51834f0d16de356d99a16cdefc3e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:51:52 +0300
Subject: [PATCH 35/64] Readme update.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 93799d4..526bd3e 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-| | | | |
+
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||||
From e91b20be044f5960a39bcd343b0202092967a085 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:52:11 +0300
Subject: [PATCH 36/64] Readme update.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 526bd3e..93799d4 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-
+| | | | |
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
|||||
From 789b222ac825a337018a49f21201eafc3e5a394f Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 11:57:24 +0300
Subject: [PATCH 37/64] Readme update.
---
README.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 93799d4..6f1d589 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-| | | | |
-:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
+| | | | | | |
+|:-: |:-: |:-: |:-: |:-: |:-: |
|||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -309,7 +309,9 @@ Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/Navi
Inspiration
===========
-:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
+
+| | | | |
+|:-: |:-: |:-: |:-: |
|||
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
From 2dbf468d392cf6cc138e5a15a7ffaecfb63ea991 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 12:08:02 +0300
Subject: [PATCH 38/64] Readme update.
---
README.md | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 6f1d589..d3410c6 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
NavigationTabBar
-===================
+================
Navigation tab bar with colorful interactions.
@@ -11,9 +11,10 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-| | | | | | |
-|:-: |:-: |:-: |:-: |:-: |:-: |
-|||||
+|---|
+||
+
+|:-  -:|||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
From f67d6ae167e2bc050b2626206e32f2579f347de9 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 12:12:57 +0300
Subject: [PATCH 39/64] Readme update.
---
README.md | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index d3410c6..d818bd4 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,9 @@ Navigation tab bar with colorful interactions.
[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-|---|
-||
-
-|:-  -:|||||
+| | | | | | |
+|:-: |:-: |:-: |:-: |:-: |:-: |
+|||||
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
From e3ff551a3e5e76415169c1b3350ae8ae9177ffc0 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 13:02:32 +0300
Subject: [PATCH 40/64] Code highlight.
---
README.md | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index d818bd4..84b3704 100644
--- a/README.md
+++ b/README.md
@@ -56,18 +56,18 @@ Or Maven:
Android SDK Version
=========
-NavigationTabBar requires a minimum SDK version of 11.
+`NavigationTabBar` requires a minimum SDK version of 11.
Sample
========
Parameters
-For NTB you can set such parameters as:
+For `NTB` you can set such parameters as:
- models:
- allows you to set NTB models, where you set icon and color. Can be set up only via code.
+ allows you to set `NTB` models, where you set icon and color. Can be set up only via code.
- behavior:
@@ -75,11 +75,11 @@ For NTB you can set such parameters as:
- view pager:
- allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.
+ allows you to connect `NTB` with `ViewPager`. If you want your can also set `OnPageChangeListener`.
- background color:
- allows you to set background to NTB which automatically set with offset relative to badge gravity and corners radius.
+ allows you to set background to `NTB` which automatically set with offset relative to badge gravity and corners radius.
- model selected icon:
@@ -163,21 +163,21 @@ For NTB you can set such parameters as:
Tips
-Creation of models occurs through Builder pattern.
+Creation of models occurs through `Builder` pattern.
-ModelBuilder requires two fields: icon and color. Title, badge title and selected icon is optional.
+`ModelBuilder` requires two fields: icon and color. Title, badge title and selected icon is optional.
You can set selected icon. Resize and scale of selected icon equals to original icon.
-Orientation automatically detected according to view size.
+Orientation automatically detected according to `View` size.
-By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set AUTO_COLOR value to badge bg and title color.
+By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set `AUTO_COLOR` value to badge bg and title color.
-By default badge sizes and title sizes is auto fit. To reset calculation just set AUTO_SIZE value to badge size and title size.
+By default badge sizes and title sizes is auto fit. To reset calculation just set `AUTO_SIZE` value to badge size and title size.
-By default icon size fraction is 0.5 (half of smaller side of NTB model). To reset scale fraction of icon to automatic just put in method AUTO_SCALE value.
+By default icon size fraction is `0.5F` (half of smaller side of `NTB` model). To reset scale fraction of icon to automatic just put in method `AUTO_SCALE` value.
-If your set ViewPager and enable swipe you can action down on active pointer and do like drag.
+If your set `ViewPager` and enable swipe you can action down on active pointer and do like drag.
Init
@@ -255,7 +255,7 @@ model.toggleBadge();
model.updateBadgeTitle("Here some title like NEW or some integer value");
```
-To enable behavior translation inside CoordinatorLayout when at bottom of screen:
+To enable behavior translation inside `CoordinatorLayout` when at bottom of screen:
```java
navigationTabBar.setBehaviorEnabled(true);
```
From fe18866f4e9c9cdd9996df4242431c492a523993 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Tue, 26 Jul 2016 17:47:02 +0300
Subject: [PATCH 41/64] Code highlight.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 84b3704..a019461 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,9 @@ Navigation tab bar with colorful interactions.
[](http://devlight.com.ua)
[](http://android-arsenal.com/details/1/3382)
-
+[](https://github.com/DevLight-Mobile-Agency)
[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
-[](https://github.com/DevLight-Mobile-Agency/NavigationTabStrip/blob/master/LICENSE.txt)
+[](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/LICENSE.txt)
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
| | | | | | |
From ad36d75dbf296278a7c7873868ee6e860ab2eca9 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Mon, 1 Aug 2016 12:53:46 +0300
Subject: [PATCH 42/64] Add Beerpay's badge
---
README.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a019461..31884b8 100644
--- a/README.md
+++ b/README.md
@@ -321,4 +321,8 @@ Author
Made in [DevLight Mobile Agency](https://github.com/DevLight-Mobile-Agency)
-Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
\ No newline at end of file
+Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
+## Support on Beerpay
+Hey dude! Help me out for a couple of :beers:!
+
+[](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar) [](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar?focus=wish)
\ No newline at end of file
From f196bb6e8bb359d0bad399171cc7330a94e34fe4 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Mon, 1 Aug 2016 16:46:02 +0300
Subject: [PATCH 43/64] Code highlight.
---
README.md | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 31884b8..646af09 100644
--- a/README.md
+++ b/README.md
@@ -322,7 +322,16 @@ Author
Made in [DevLight Mobile Agency](https://github.com/DevLight-Mobile-Agency)
Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
-## Support on Beerpay
-Hey dude! Help me out for a couple of :beers:!
-[](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar) [](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar?focus=wish)
\ No newline at end of file
+Support
+=======
+
+If you'd like to support future development and new product features, please make a payments on Gratipay and Beerpay or become a patron on Patreon.
+
+[](https://gratipay.com/~GIGAMOLE/)
+[](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar)
+[](https://www.patreon.com/gigamole)
+
+Also, if you use this library in applications that are available on Google Play, please report it to us or author.
+
+Thanks in advance.
\ No newline at end of file
From 255c8cfc23d2c9f213fe293a27a174ffce11763e Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Sat, 13 Aug 2016 21:39:58 +0300
Subject: [PATCH 44/64] Update 1.2.5.
---
README.md | 4 ++--
.../gigamole/sample/HorizontalCoordinatorNtbActivity.java | 1 -
navigationtabbar/build.gradle | 4 ++--
.../gigamole/navigationtabbar/ntb/NavigationTabBar.java | 7 +++++++
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 646af09..cd48861 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ dependencies {
Or Gradle Maven Central:
```groovy
-compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.3'
+compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.5'
```
Or Maven:
@@ -48,7 +48,7 @@ Or Maven:
com.github.devlight.navigationtabbar
navigationtabbar
- 1.2.3
+ 1.2.5
aar
```
diff --git a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
index e30618c..dd313ae 100644
--- a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
+++ b/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
@@ -117,7 +117,6 @@ public Object instantiateItem(final ViewGroup container, final int position) {
navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@Override
public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
-
}
@Override
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index d28d0f2..0b788cc 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -19,7 +19,7 @@ apply plugin: "com.jfrog.bintray"
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven'
-version = "1.2.4"
+version = "1.2.5"
android {
compileSdkVersion 23
@@ -29,7 +29,7 @@ android {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
- versionName "1.2.4"
+ versionName "1.2.5"
}
buildTypes {
release {
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 42ced03..6bf91fe 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -848,11 +848,18 @@ public void setModelIndex(final int modelIndex, final boolean isForce) {
// You can use force param or call this method in some post()
if (force) {
updateIndicatorPosition(MAX_FRACTION);
+
+ if (mOnTabBarSelectedIndexListener != null)
+ mOnTabBarSelectedIndexListener.onStartTabSelected(mModels.get(mIndex), mIndex);
+
// Force onPageScrolled listener and refresh VP
if (mIsViewPagerMode) {
if (!mViewPager.isFakeDragging()) mViewPager.beginFakeDrag();
if (mViewPager.isFakeDragging()) mViewPager.fakeDragBy(0.0F);
if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
+ } else {
+ if (mOnTabBarSelectedIndexListener != null)
+ mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
}
} else mAnimator.start();
}
From f5a388a110b6472e9d0170476ed4bb1abeeab04c Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Wed, 14 Sep 2016 15:29:56 +0300
Subject: [PATCH 45/64] Readme update.
---
README.md | 53 +++++++++----------
build.gradle | 4 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
.../ntb/NavigationTabBar.java | 9 ++--
4 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/README.md b/README.md
index cd48861..461cd3c 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,36 @@
+
+
+
+
+
+
+
+
NavigationTabBar
================
Navigation tab bar with colorful interactions.
-[](http://devlight.com.ua)
+[](http://android-arsenal.com/details/1/3382)
+
+[](https://github.com/DevLight-Mobile-Agency)
+
+[](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
+
+[](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/LICENSE.txt)
+
+[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-[](http://android-arsenal.com/details/1/3382)
-[](https://github.com/DevLight-Mobile-Agency)
-[ ](https://bintray.com/gigamole/maven/navigationtabbar/_latestVersion)
-[](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/LICENSE.txt)
-[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
+
| | | | | | |
|:-: |:-: |:-: |:-: |:-: |:-: |
-|||||
+|
+|
+|
+|
+|
+
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -302,11 +319,6 @@ Getting Help
To report a specific problem or feature request, [open a new issue on Github](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/issues/new).
-License
-======
-
-Apache 2.0 and MIT. See [LICENSE](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/LICENSE.txt) file for details.
-
Inspiration
===========
@@ -319,19 +331,4 @@ Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge des
Author
=======
-Made in [DevLight Mobile Agency](https://github.com/DevLight-Mobile-Agency)
-
-Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
-
-Support
-=======
-
-If you'd like to support future development and new product features, please make a payments on Gratipay and Beerpay or become a patron on Patreon.
-
-[](https://gratipay.com/~GIGAMOLE/)
-[](https://beerpay.io/DevLight-Mobile-Agency/NavigationTabBar)
-[](https://www.patreon.com/gigamole)
-
-Also, if you use this library in applications that are available on Google Play, please report it to us or author.
-
-Thanks in advance.
\ No newline at end of file
+Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index c618080..5f66515 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:2.1.2'
+ classpath 'com.android.tools.build:gradle:2.1.3'
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 05ac656..5414252 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat May 07 12:59:05 EEST 2016
+#Wed Sep 14 15:10:23 EEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
index 6bf91fe..0c52090 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
@@ -1478,15 +1478,16 @@ private void updateInactiveModel(
if (mIsScaled)
model.mIconMatrix.postScale(
- model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
+ model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
+ matrixCenterX, matrixCenterY
);
else
model.mIconMatrix.postScale(
- model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
- matrixCenterX, matrixCenterY
+ model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
);
- mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? 1.0F : textScale));
+
+ mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? textScale : 1.0F));
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(MIN_ALPHA);
// Reset icons alpha
From ff8f7dedec0785bb7da8445ca051860d4da7dfac Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Wed, 14 Sep 2016 22:11:14 +0300
Subject: [PATCH 46/64] Readme update.
---
README.md | 133 +++++++++++------------
gradle/wrapper/gradle-wrapper.properties | 2 +-
2 files changed, 65 insertions(+), 70 deletions(-)
diff --git a/README.md b/README.md
index 461cd3c..24c35e2 100644
--- a/README.md
+++ b/README.md
@@ -23,14 +23,21 @@ Navigation tab bar with colorful interactions.
-| | | | | | |
-|:-: |:-: |:-: |:-: |:-: |:-: |
-|
-|
-|
-|
-|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -40,7 +47,6 @@ Download
You can download a .aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/releases).
Or use Gradle jCenter:
-
```groovy
dependencies {
repositories {
@@ -54,13 +60,11 @@ dependencies {
```
Or Gradle Maven Central:
-
```groovy
compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.5'
```
Or Maven:
-
```groovy
com.github.devlight.navigationtabbar
@@ -82,116 +86,88 @@ Sample
For `NTB` you can set such parameters as:
- - models:
-
+ - models:
allows you to set `NTB` models, where you set icon and color. Can be set up only via code.
- - behavior:
-
+ - behavior:
allows you to set bottom translation behavior.
- - view pager:
-
+ - view pager:
allows you to connect `NTB` with `ViewPager`. If you want your can also set `OnPageChangeListener`.
- - background color:
-
+ - background color:
allows you to set background to `NTB` which automatically set with offset relative to badge gravity and corners radius.
- - model selected icon:
-
+ - model selected icon:
allows you to set selected icon when current model is active.
- - model title:
-
+ - model title:
allows you to enable title in you model.
- - model badge:
-
+ - model badge:
allows you to enable badge in you model.
- - use custom typeface on badge:
-
+ - use custom typeface on badge:
allows you to handle set of custom typeface in your badge.
- - title mode:
-
+ - title mode:
allows you to handle mode of the model title show. Can show all or only active.
- - title size:
-
+ - title size:
allows you to set titles size.
- - scale mode:
-
+ - scale mode:
allows you to handle mode of the model icon and title scale.
- - tint mode:
-
+ - tint mode:
allows you to enable or disable icon tinting.
- - badge size:
-
+ - badge size:
allows you to set badges size.
- - badge position:
-
+ - badge position:
allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).
- - badge gravity:
-
+ - badge gravity:
allows you to set the badge gravity in NTB. Can be top or bottom.
- - badge colors:
-
- allows you to set the badge bg and title colors.
+ - badge colors:
+ allows you to set the badge bg and title colors.
- - typeface:
-
+ - typeface:
allows you to set custom typeface to your title.
- - corners radius:
-
+ - corners radius:
allows you to set corners radius of pointer.
- - icon size fraction:
-
+ - icon size fraction:
allows you to set icon size fraction relative to smaller model side.
- - animation duration:
-
+ - animation duration:
allows you to set animation duration.
- - inactive color:
-
+ - inactive color:
allows you to set inactive icon color.
- - active color:
-
+ - active color:
allows you to set active icon color.
- - tab bar listener:
-
+ - tab bar listener:
allows you to set listener which triggering on start or on end when you set model index.
- - preview colors:
-
+ - preview colors:
allows you to set preview colors, which generate count of models equals to count of colors.
Tips
-Creation of models occurs through `Builder` pattern.
-
+Creation of models occurs through `Builder` pattern.
`ModelBuilder` requires two fields: icon and color. Title, badge title and selected icon is optional.
-You can set selected icon. Resize and scale of selected icon equals to original icon.
-
+You can set selected icon. Resize and scale of selected icon equals to original icon.
Orientation automatically detected according to `View` size.
-By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set `AUTO_COLOR` value to badge bg and title color.
-
-By default badge sizes and title sizes is auto fit. To reset calculation just set `AUTO_SIZE` value to badge size and title size.
-
+By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set `AUTO_COLOR` value to badge bg and title color.
+By default badge sizes and title sizes is auto fit. To reset calculation just set `AUTO_SIZE` value to badge size and title size.
By default icon size fraction is `0.5F` (half of smaller side of `NTB` model). To reset scale fraction of icon to automatic just put in method `AUTO_SCALE` value.
If your set `ViewPager` and enable swipe you can action down on active pointer and do like drag.
@@ -331,4 +307,23 @@ Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge des
Author
=======
-Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
\ No newline at end of file
+Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
+
+Company
+=======
+
+[Here](https://github.com/DevLight-Mobile-Agency) you can see open source work developed by Devlight LLC.
+This and another works is an exclusive property of Devlight LLC.
+
+If you want to use this library in applications which will be available on Google Play, please report about it to us or to the author of the library.
+
+Also you can find us on: [Facebook](https://www.facebook.com/devlightagency), [Twitter](https://twitter.com/DevLightIO), [LinkedIn](https://www.linkedin.com/company/devlight).
+
+Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.
+
+You can contact us via info@devlight.io or opensource@devlight.io.
+
+Thanks in advance.
+
+Devlight LLC, 2016
+[devlight.io](http://devlight.io)
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5414252..7f777ee 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,4 +1,4 @@
-#Wed Sep 14 15:10:23 EEST 2016
+#Wed Sep 14 21:51:46 EEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
From bc870b8ae73e4856429126cf3a1a200b6cb182ac Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Wed, 14 Sep 2016 23:24:51 +0300
Subject: [PATCH 47/64] Readme update.
---
README.md | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index 24c35e2..6a0a807 100644
--- a/README.md
+++ b/README.md
@@ -23,21 +23,17 @@ Navigation tab bar with colorful interactions.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
@@ -298,9 +294,9 @@ To report a specific problem or feature request, [open a new issue on Github](ht
Inspiration
===========
-| | | | |
-|:-: |:-: |:-: |:-: |
-|||
+|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
+|:--------------------------------------------------:|
+|[](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions)|
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
From f8c8923f065ea29ed8fad0e9b707c6ec7f511c9d Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Wed, 14 Sep 2016 23:25:47 +0300
Subject: [PATCH 48/64] Readme update.
---
README.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/README.md b/README.md
index 6a0a807..dd31ccb 100644
--- a/README.md
+++ b/README.md
@@ -21,8 +21,6 @@ Navigation tab bar with colorful interactions.
[](https://www.codacy.com/app/gigamole53/NavigationTabBar?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/NavigationTabBar&utm_campaign=Badge_Grade)
-
-
 |
From a25c7ebd45ea987b4f87e7841f53ac8aac5da2ee Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Thu, 15 Sep 2016 08:57:25 +0300
Subject: [PATCH 49/64] Readme update.
---
README.md | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index dd31ccb..93dff0c 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ Navigation tab bar with colorful interactions.
U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
Download
-------------
+========
You can download a .aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/releases).
@@ -69,12 +69,12 @@ Or Maven:
```
Android SDK Version
-=========
+===================
`NavigationTabBar` requires a minimum SDK version of 11.
Sample
-========
+======
Parameters
@@ -285,12 +285,18 @@ And XML init:
```
Getting Help
-======
+============
To report a specific problem or feature request, [open a new issue on Github](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/issues/new).
-Inspiration
-===========
+Xamarin
+=======
+
+Thanks to [Martijn van Dijk](https://github.com/martijn00) for developing Xamarin bindings library for [NavigationTabBar](https://github.com/martijn00/NavigationTabBarXamarin).
+Plugin is available on [Nuget](https://www.nuget.org/packages/Xam.Plugins.Android.InfiniteCycleViewPager/).
+
+Credits
+=======
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
@@ -299,7 +305,7 @@ Inspiration
Thanks to [Valery Nuzhniy](https://www.pinterest.com/hevbolt/) for NTB badge design.
Author
-=======
+======
Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:gigamole53@gmail.com)
@@ -311,12 +317,12 @@ This and another works is an exclusive property of Devlight LLC.
If you want to use this library in applications which will be available on Google Play, please report about it to us or to the author of the library.
-Also you can find us on: [Facebook](https://www.facebook.com/devlightagency), [Twitter](https://twitter.com/DevLightIO), [LinkedIn](https://www.linkedin.com/company/devlight).
-
Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.
You can contact us via info@devlight.io or opensource@devlight.io.
+[](https://www.facebook.com/devlightagency) [](https://twitter.com/DevLightIO) [](https://www.linkedin.com/company/devlight)
+
Thanks in advance.
Devlight LLC, 2016
From 212969f2ca4d77845d3796a1508fb4e1d7f57a52 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Thu, 15 Sep 2016 09:21:02 +0300
Subject: [PATCH 50/64] Readme update.
---
README.md | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 93dff0c..fa5fce5 100644
--- a/README.md
+++ b/README.md
@@ -312,17 +312,16 @@ Created by [Basil Miller](https://github.com/GIGAMOLE) - [@gigamole](mailto:giga
Company
=======
+[](https://www.facebook.com/devlightagency) [](https://twitter.com/DevLightIO) [](https://www.linkedin.com/company/devlight)
+
[Here](https://github.com/DevLight-Mobile-Agency) you can see open source work developed by Devlight LLC.
This and another works is an exclusive property of Devlight LLC.
-If you want to use this library in applications which will be available on Google Play, please report about it to us or to the author of the library.
+If you want to use this library in applications which will be available on Google Play, please report us about it or author of the library.
Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.
-You can contact us via info@devlight.io or opensource@devlight.io.
-
-[](https://www.facebook.com/devlightagency) [](https://twitter.com/DevLightIO) [](https://www.linkedin.com/company/devlight)
-
+You can contact us via info@devlight.io or opensource@devlight.io.
Thanks in advance.
Devlight LLC, 2016
From 3c73f1d38ea77a66bef6acb12a373400b18a1dcf Mon Sep 17 00:00:00 2001
From: Lzh <1172361058@qq.com>
Date: Fri, 4 Nov 2016 11:06:45 +0800
Subject: [PATCH 51/64] =?UTF-8?q?=E6=B7=BB=E5=8A=A0XML=E5=B1=9E=E6=80=A7?=
=?UTF-8?q?=E4=B8=AD=E6=96=87=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add XML attributes in Chinese explanation
---
README.md | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fa5fce5..f298cad 100644
--- a/README.md
+++ b/README.md
@@ -284,6 +284,41 @@ And XML init:
app:ntb_title_size="10sp"/>
```
+XML属性中文详解:
+============
+
+```xml
+
+```
+
Getting Help
============
@@ -325,4 +360,4 @@ You can contact us via info@devlight.io or opensource@devlight.io.
Thanks in advance.
Devlight LLC, 2016
-[devlight.io](http://devlight.io)
\ No newline at end of file
+[devlight.io](http://devlight.io)
From 0edb4e7d9c92d88604f32464f850a302075e2652 Mon Sep 17 00:00:00 2001
From: Lzh <1172361058@qq.com>
Date: Fri, 4 Nov 2016 11:16:31 +0800
Subject: [PATCH 52/64] Add XML attributes in Chinese explanation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
添加XML属性中文详解
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f298cad..647a3d0 100644
--- a/README.md
+++ b/README.md
@@ -299,14 +299,14 @@ XML属性中文详解:
app:ntb_icon_size_fraction="http://github.com/1" 图标所占的大小比例 最佳值:0.5
标题相关:
app:ntb_titled="true" 是否显示图标所对应的标题 默认为false
- app:ntb_title_mode="active" 图片所对应的标题显示模式 active:活动时才显示 all:总是显示 ps:app:ntb_titled属性值为 true 时才可用
+ app:ntb_title_mode="active" 图片所对应的标题显示模式 active:活动时才显示 all:总是显示 PS:app:ntb_titled属性值为 true 时才可用
app:ntb_title_size="10sp" 设置图标所对应的标题文字大小 请自定义
勋章相关:
app:ntb_badged="false" 是否显示勋章 默认为false
app:ntb_badge_gravity="top" 勋章的上下位置 top|bottom
app:ntb_badge_position="right" 勋章的左右位置 left(25%), center(50%) and right(75%)
app:ntb_badge_bg_color="#ffff0000" 勋章的背景颜色 可自定义
- app:ntb_badge_title_color="#000000" 勋章的标题文字颜色 可自定义
+ app:ntb_badge_title_color="#000000" 勋章的标题文字颜色 可自定义 PS:不设置的话默认为切换动画的背景色
app:ntb_badge_size="12sp" 勋章的标题文字大小 可自定义
字体相关:
app:ntb_badge_use_typeface="false" 是否使用自定义字体 默认为false
From c92d6014073174c023c5dc0315720b6b960f94d6 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 11 Nov 2016 16:07:23 +0200
Subject: [PATCH 53/64] Fixed scaling issue. Set protected modifiers according
to this issue:
https://github.com/DevLight-Mobile-Agency/NavigationTabBar/issues/42 Package
renames to Devlight.io
---
README.md | 4 +-
app/build.gradle | 2 +-
.../io}/sample/ApplicationTest.java | 2 +-
app/src/main/AndroidManifest.xml | 14 +-
.../HorizontalCoordinatorNtbActivity.java | 4 +-
.../io}/sample/HorizontalNtbActivity.java | 4 +-
.../io}/sample/MainActivity.java | 2 +-
.../io}/sample/SamplesNtbActivity.java | 4 +-
.../io}/sample/TopHorizontalNtbActivity.java | 4 +-
.../io}/sample/VerticalNtbActivity.java | 4 +-
.../activity_horizontal_coordinator_ntb.xml | 2 +-
.../res/layout/activity_horizontal_ntb.xml | 2 +-
.../layout/activity_horizontal_top_ntb.xml | 4 +-
.../main/res/layout/activity_samples_ntb.xml | 12 +-
.../main/res/layout/activity_vertical_ntb.xml | 2 +-
build.gradle | 2 +-
navigationtabbar/build.gradle | 4 +-
.../io}/navigationtabbar/ApplicationTest.java | 2 +-
navigationtabbar/src/main/AndroidManifest.xml | 5 +-
.../behavior/NavigationTabBarBehavior.java | 4 +-
.../behavior/VerticalScrollingBehavior.java | 4 +-
.../io/library}/ntb/NavigationTabBar.java | 576 +++++++++---------
22 files changed, 346 insertions(+), 317 deletions(-)
rename app/src/androidTest/java/{com/gigamole => devlight/io}/sample/ApplicationTest.java (91%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/HorizontalCoordinatorNtbActivity.java (98%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/HorizontalNtbActivity.java (98%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/MainActivity.java (99%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/SamplesNtbActivity.java (98%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/TopHorizontalNtbActivity.java (98%)
rename app/src/main/java/{com/gigamole => devlight/io}/sample/VerticalNtbActivity.java (98%)
rename navigationtabbar/src/androidTest/java/{com/gigamole => devlight/io}/navigationtabbar/ApplicationTest.java (89%)
rename navigationtabbar/src/main/java/{com/gigamole/navigationtabbar => devlight/io/library}/behavior/NavigationTabBarBehavior.java (99%)
rename navigationtabbar/src/main/java/{com/gigamole/navigationtabbar => devlight/io/library}/behavior/VerticalScrollingBehavior.java (98%)
rename navigationtabbar/src/main/java/{com/gigamole/navigationtabbar => devlight/io/library}/ntb/NavigationTabBar.java (79%)
diff --git a/README.md b/README.md
index fa5fce5..154ab81 100644
--- a/README.md
+++ b/README.md
@@ -33,12 +33,12 @@ Navigation tab bar with colorful interactions.
-U can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
+You can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
Download
========
-You can download a .aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/releases).
+You can download a `.aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/releases).
Or use Gradle jCenter:
```groovy
diff --git a/app/build.gradle b/app/build.gradle
index c7ecffe..8abc04e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,7 +5,7 @@ android {
buildToolsVersion "23.0.2"
defaultConfig {
- applicationId "com.gigamole.navigationtabbar"
+ applicationId "devlight.io.navigationtabbar"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
diff --git a/app/src/androidTest/java/com/gigamole/sample/ApplicationTest.java b/app/src/androidTest/java/devlight/io/sample/ApplicationTest.java
similarity index 91%
rename from app/src/androidTest/java/com/gigamole/sample/ApplicationTest.java
rename to app/src/androidTest/java/devlight/io/sample/ApplicationTest.java
index d203b20..3d59832 100644
--- a/app/src/androidTest/java/com/gigamole/sample/ApplicationTest.java
+++ b/app/src/androidTest/java/devlight/io/sample/ApplicationTest.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Application;
import android.test.ApplicationTestCase;
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b6fa65b..68997ed 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
+
@@ -18,16 +18,16 @@
-
-
+
-
+
-
+
-
+
diff --git a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java b/app/src/main/java/devlight/io/sample/HorizontalCoordinatorNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
rename to app/src/main/java/devlight/io/sample/HorizontalCoordinatorNtbActivity.java
index dd313ae..50fbc83 100644
--- a/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/HorizontalCoordinatorNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -15,7 +15,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
import java.util.ArrayList;
import java.util.Random;
diff --git a/app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java b/app/src/main/java/devlight/io/sample/HorizontalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java
rename to app/src/main/java/devlight/io/sample/HorizontalNtbActivity.java
index 7065be0..5d72919 100644
--- a/app/src/main/java/com/gigamole/sample/HorizontalNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/HorizontalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/gigamole/sample/MainActivity.java b/app/src/main/java/devlight/io/sample/MainActivity.java
similarity index 99%
rename from app/src/main/java/com/gigamole/sample/MainActivity.java
rename to app/src/main/java/devlight/io/sample/MainActivity.java
index ac1daad..927295d 100644
--- a/app/src/main/java/com/gigamole/sample/MainActivity.java
+++ b/app/src/main/java/devlight/io/sample/MainActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.content.Intent;
diff --git a/app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java b/app/src/main/java/devlight/io/sample/SamplesNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java
rename to app/src/main/java/devlight/io/sample/SamplesNtbActivity.java
index cd19566..9e16a66 100644
--- a/app/src/main/java/com/gigamole/sample/SamplesNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/SamplesNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -6,7 +6,7 @@
import android.support.v4.graphics.ColorUtils;
import android.widget.Toast;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java b/app/src/main/java/devlight/io/sample/TopHorizontalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java
rename to app/src/main/java/devlight/io/sample/TopHorizontalNtbActivity.java
index c793a5e..c12ca21 100644
--- a/app/src/main/java/com/gigamole/sample/TopHorizontalNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/TopHorizontalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -12,7 +12,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
import java.util.ArrayList;
import java.util.Random;
diff --git a/app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java b/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
similarity index 98%
rename from app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java
rename to app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
index b1f6d1b..2186791 100644
--- a/app/src/main/java/com/gigamole/sample/VerticalNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
@@ -1,4 +1,4 @@
-package com.gigamole.sample;
+package devlight.io.sample;
import android.app.Activity;
import android.graphics.Color;
@@ -10,7 +10,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
import java.util.ArrayList;
diff --git a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
index 38aa002..3655967 100644
--- a/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
+++ b/app/src/main/res/layout/activity_horizontal_coordinator_ntb.xml
@@ -53,7 +53,7 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
-
-
-
-
-
-
-
-
-
-
-
-
+ android:supportsRtl="true"/>
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java b/navigationtabbar/src/main/java/devlight/io/library/behavior/NavigationTabBarBehavior.java
similarity index 99%
rename from navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java
rename to navigationtabbar/src/main/java/devlight/io/library/behavior/NavigationTabBarBehavior.java
index 9f9795d..58b66e9 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/NavigationTabBarBehavior.java
+++ b/navigationtabbar/src/main/java/devlight/io/library/behavior/NavigationTabBarBehavior.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar.behavior;
+package devlight.io.library.behavior;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
@@ -14,7 +14,7 @@
import android.view.ViewGroup;
import android.view.animation.Interpolator;
-import com.gigamole.navigationtabbar.ntb.NavigationTabBar;
+import devlight.io.library.ntb.NavigationTabBar;
public class NavigationTabBarBehavior extends VerticalScrollingBehavior {
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java b/navigationtabbar/src/main/java/devlight/io/library/behavior/VerticalScrollingBehavior.java
similarity index 98%
rename from navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
rename to navigationtabbar/src/main/java/devlight/io/library/behavior/VerticalScrollingBehavior.java
index fef5396..e27b134 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/behavior/VerticalScrollingBehavior.java
+++ b/navigationtabbar/src/main/java/devlight/io/library/behavior/VerticalScrollingBehavior.java
@@ -1,4 +1,4 @@
-package com.gigamole.navigationtabbar.behavior;
+package devlight.io.library.behavior;
import android.annotation.TargetApi;
@@ -25,7 +25,7 @@ abstract class VerticalScrollingBehavior extends CoordinatorLayo
@Retention(RetentionPolicy.SOURCE)
@IntDef({ScrollDirection.SCROLL_DIRECTION_UP, ScrollDirection.SCROLL_DIRECTION_DOWN})
- public @interface ScrollDirection {
+ @interface ScrollDirection {
int SCROLL_DIRECTION_UP = 1;
int SCROLL_DIRECTION_DOWN = -1;
int SCROLL_NONE = 0;
diff --git a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
similarity index 79%
rename from navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
rename to navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
index 0c52090..ac8d5e3 100644
--- a/navigationtabbar/src/main/java/com/gigamole/navigationtabbar/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.gigamole.navigationtabbar.ntb;
+package devlight.io.library.ntb;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -57,13 +57,14 @@
import android.widget.Scroller;
import com.gigamole.navigationtabbar.R;
-import com.gigamole.navigationtabbar.behavior.NavigationTabBarBehavior;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import devlight.io.library.behavior.NavigationTabBarBehavior;
+
/**
* Created by GIGAMOLE on 24.03.2016.
*/
@@ -71,114 +72,113 @@
public class NavigationTabBar extends View implements ViewPager.OnPageChangeListener {
// NTB constants
- private final static int FLAGS =
+ protected final static int FLAGS =
Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG;
- private final static String PREVIEW_BADGE = "0";
- private final static String PREVIEW_TITLE = "Title";
+ protected final static String PREVIEW_BADGE = "0";
+ protected final static String PREVIEW_TITLE = "Title";
- private final static int INVALID_INDEX = -1;
+ protected final static int INVALID_INDEX = -1;
public final static int AUTO_SIZE = -2;
public final static int AUTO_COLOR = -3;
public final static int AUTO_SCALE = -4;
- private final static int DEFAULT_BADGE_ANIMATION_DURATION = 200;
- private final static int DEFAULT_BADGE_REFRESH_ANIMATION_DURATION = 100;
- private final static int DEFAULT_ANIMATION_DURATION = 300;
- private final static float DEFAULT_ICON_SIZE_FRACTION = 0.5F;
- private final static float DEFAULT_TITLE_ICON_SIZE_FRACTION = 0.5F;
+ protected final static int DEFAULT_BADGE_ANIMATION_DURATION = 200;
+ protected final static int DEFAULT_BADGE_REFRESH_ANIMATION_DURATION = 100;
+ protected final static int DEFAULT_ANIMATION_DURATION = 300;
+ protected final static float DEFAULT_ICON_SIZE_FRACTION = 0.5F;
+ protected final static float DEFAULT_TITLE_ICON_SIZE_FRACTION = 0.5F;
- private final static int DEFAULT_INACTIVE_COLOR = Color.parseColor("#9f90af");
- private final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
- private final static int DEFAULT_BG_COLOR = Color.parseColor("#605271");
+ protected final static int DEFAULT_INACTIVE_COLOR = Color.parseColor("#9f90af");
+ protected final static int DEFAULT_ACTIVE_COLOR = Color.WHITE;
+ protected final static int DEFAULT_BG_COLOR = Color.parseColor("#605271");
- private final static float MIN_FRACTION = 0.0F;
- private final static float NON_SCALED_FRACTION = 0.35F;
- private final static float MAX_FRACTION = 1.0F;
+ protected final static float MIN_FRACTION = 0.0F;
+ protected final static float MAX_FRACTION = 1.0F;
- private final static int MIN_ALPHA = 0;
- private final static int MAX_ALPHA = 255;
+ protected final static int MIN_ALPHA = 0;
+ protected final static int MAX_ALPHA = 255;
- private final static float ACTIVE_ICON_SCALE_BY = 0.3F;
- private final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2F;
- private final static float TITLE_ACTIVE_SCALE_BY = 0.2F;
- private final static float TITLE_SIZE_FRACTION = 0.2F;
- private final static float TITLE_MARGIN_FRACTION = 0.15F;
- private final static float TITLE_MARGIN_SCALE_FRACTION = 0.25F;
+ protected final static float SCALED_FRACTION = 0.3F;
+ protected final static float TITLE_ACTIVE_ICON_SCALE_BY = 0.2F;
+ protected final static float TITLE_ACTIVE_SCALE_BY = 0.2F;
+ protected final static float TITLE_SIZE_FRACTION = 0.2F;
+ protected final static float TITLE_MARGIN_FRACTION = 0.15F;
+ protected final static float TITLE_MARGIN_SCALE_FRACTION = 0.25F;
- private final static float BADGE_HORIZONTAL_FRACTION = 0.5F;
- private final static float BADGE_VERTICAL_FRACTION = 0.75F;
- private final static float BADGE_TITLE_SIZE_FRACTION = 0.9F;
+ protected final static float BADGE_HORIZONTAL_FRACTION = 0.5F;
+ protected final static float BADGE_VERTICAL_FRACTION = 0.75F;
+ protected final static float BADGE_TITLE_SIZE_FRACTION = 0.9F;
- private final static float LEFT_FRACTION = 0.25F;
- private final static float CENTER_FRACTION = 0.5F;
- private final static float RIGHT_FRACTION = 0.75F;
+ protected final static float LEFT_FRACTION = 0.25F;
+ protected final static float CENTER_FRACTION = 0.5F;
+ protected final static float RIGHT_FRACTION = 0.75F;
- private final static Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
- private final static Interpolator ACCELERATE_INTERPOLATOR = new AccelerateInterpolator();
- private final static Interpolator OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator();
+ protected final static Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
+ protected final static Interpolator ACCELERATE_INTERPOLATOR = new AccelerateInterpolator();
+ protected final static Interpolator OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator();
// NTB and pointer bounds
- private final RectF mBounds = new RectF();
- private final RectF mBgBounds = new RectF();
- private final RectF mPointerBounds = new RectF();
+ protected final RectF mBounds = new RectF();
+ protected final RectF mBgBounds = new RectF();
+ protected final RectF mPointerBounds = new RectF();
// Badge bounds and bg badge bounds
- private final Rect mBadgeBounds = new Rect();
- private final RectF mBgBadgeBounds = new RectF();
+ protected final Rect mBadgeBounds = new Rect();
+ protected final RectF mBgBadgeBounds = new RectF();
// Canvas, where all of other canvas will be merged
- private Bitmap mBitmap;
- private final Canvas mCanvas = new Canvas();
+ protected Bitmap mBitmap;
+ protected final Canvas mCanvas = new Canvas();
// Canvas with icons
- private Bitmap mIconsBitmap;
- private final Canvas mIconsCanvas = new Canvas();
+ protected Bitmap mIconsBitmap;
+ protected final Canvas mIconsCanvas = new Canvas();
// Canvas with titles
- private Bitmap mTitlesBitmap;
- private final Canvas mTitlesCanvas = new Canvas();
+ protected Bitmap mTitlesBitmap;
+ protected final Canvas mTitlesCanvas = new Canvas();
// Canvas for our rect pointer
- private Bitmap mPointerBitmap;
- private final Canvas mPointerCanvas = new Canvas();
+ protected Bitmap mPointerBitmap;
+ protected final Canvas mPointerCanvas = new Canvas();
// External background view for the NTB
- private NavigationTabBarBehavior mBehavior;
+ protected NavigationTabBarBehavior mBehavior;
// Detect if behavior already set
- private boolean mIsBehaviorSet;
+ protected boolean mIsBehaviorSet;
// Detect if behavior enabled
- private boolean mBehaviorEnabled;
+ protected boolean mBehaviorEnabled;
// Detect if need to hide NTB
- private boolean mNeedHide;
+ protected boolean mNeedHide;
// Detect if need animate animate or force hide
- private boolean mAnimateHide;
+ protected boolean mAnimateHide;
// Main paint
- private final Paint mPaint = new Paint(FLAGS) {
+ protected final Paint mPaint = new Paint(FLAGS) {
{
setStyle(Style.FILL);
}
};
// Background color paint
- private final Paint mBgPaint = new Paint(FLAGS) {
+ protected final Paint mBgPaint = new Paint(FLAGS) {
{
setStyle(Style.FILL);
}
};
// Pointer paint
- private final Paint mPointerPaint = new Paint(FLAGS) {
+ protected final Paint mPointerPaint = new Paint(FLAGS) {
{
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
}
};
// Icons paint
- private final Paint mIconPaint = new Paint(FLAGS);
- private final Paint mSelectedIconPaint = new Paint(FLAGS);
+ protected final Paint mIconPaint = new Paint(FLAGS);
+ protected final Paint mSelectedIconPaint = new Paint(FLAGS);
// Paint for icon mask pointer
- private final Paint mIconPointerPaint = new Paint(FLAGS) {
+ protected final Paint mIconPointerPaint = new Paint(FLAGS) {
{
setStyle(Style.FILL);
setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
@@ -186,7 +186,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for model title
- private final Paint mModelTitlePaint = new TextPaint(FLAGS) {
+ protected final Paint mModelTitlePaint = new TextPaint(FLAGS) {
{
setColor(Color.WHITE);
setTextAlign(Align.CENTER);
@@ -194,7 +194,7 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Paint for badge
- private final Paint mBadgePaint = new TextPaint(FLAGS) {
+ protected final Paint mBadgePaint = new TextPaint(FLAGS) {
{
setTextAlign(Align.CENTER);
setFakeBoldText(true);
@@ -202,94 +202,94 @@ public class NavigationTabBar extends View implements ViewPager.OnPageChangeList
};
// Variables for animator
- private final ValueAnimator mAnimator = new ValueAnimator();
- private final ResizeInterpolator mResizeInterpolator = new ResizeInterpolator();
- private int mAnimationDuration;
+ protected final ValueAnimator mAnimator = new ValueAnimator();
+ protected final ResizeInterpolator mResizeInterpolator = new ResizeInterpolator();
+ protected int mAnimationDuration;
// NTB models
- private final List mModels = new ArrayList<>();
+ protected final List mModels = new ArrayList<>();
// Variables for ViewPager
- private ViewPager mViewPager;
- private ViewPager.OnPageChangeListener mOnPageChangeListener;
- private int mScrollState;
+ protected ViewPager mViewPager;
+ protected ViewPager.OnPageChangeListener mOnPageChangeListener;
+ protected int mScrollState;
// Tab listener
- private OnTabBarSelectedIndexListener mOnTabBarSelectedIndexListener;
- private ValueAnimator.AnimatorListener mAnimatorListener;
+ protected OnTabBarSelectedIndexListener mOnTabBarSelectedIndexListener;
+ protected ValueAnimator.AnimatorListener mAnimatorListener;
// Variables for sizes
- private float mModelSize;
- private float mIconSize;
- private float mIconSizeFraction;
+ protected float mModelSize;
+ protected float mIconSize;
+ protected float mIconSizeFraction;
// Corners radius for rect mode
- private float mCornersRadius;
+ protected float mCornersRadius;
// Model title size and margin
- private float mModelTitleSize = AUTO_SIZE;
- private float mTitleMargin;
+ protected float mModelTitleSize = AUTO_SIZE;
+ protected float mTitleMargin;
// Model badge title size and margin
- private float mBadgeMargin;
- private float mBadgeTitleSize = AUTO_SIZE;
+ protected float mBadgeMargin;
+ protected float mBadgeTitleSize = AUTO_SIZE;
// Model title mode: active ar all
- private TitleMode mTitleMode;
+ protected TitleMode mTitleMode;
// Model badge position: left, center or right
- private BadgePosition mBadgePosition;
+ protected BadgePosition mBadgePosition;
// Model badge gravity: top or bottom
- private BadgeGravity mBadgeGravity;
+ protected BadgeGravity mBadgeGravity;
// Model badge bg and title color.
// By default badge bg color is the active model color and badge title color is the model bg color
// To reset colors just set bg and title color to AUTO_COLOR
- private int mBadgeTitleColor = AUTO_COLOR;
- private int mBadgeBgColor = AUTO_COLOR;
+ protected int mBadgeTitleColor = AUTO_COLOR;
+ protected int mBadgeBgColor = AUTO_COLOR;
// Indexes
- private int mLastIndex = INVALID_INDEX;
- private int mIndex = INVALID_INDEX;
+ protected int mLastIndex = INVALID_INDEX;
+ protected int mIndex = INVALID_INDEX;
// General fraction value
- private float mFraction;
+ protected float mFraction;
// Coordinates of pointer
- private float mStartPointerX;
- private float mEndPointerX;
- private float mPointerLeftTop;
- private float mPointerRightBottom;
+ protected float mStartPointerX;
+ protected float mEndPointerX;
+ protected float mPointerLeftTop;
+ protected float mPointerRightBottom;
// Detect if model has title
- private boolean mIsTitled;
+ protected boolean mIsTitled;
// Detect if model has badge
- private boolean mIsBadged;
+ protected boolean mIsBadged;
// Detect if model icon scaled
- private boolean mIsScaled;
+ protected boolean mIsScaled;
// Detect if model icon tinted
- private boolean mIsTinted;
+ protected boolean mIsTinted;
// Detect if model can swiped
- private boolean mIsSwiped;
+ protected boolean mIsSwiped;
// Detect if model badge have custom typeface
- private boolean mIsBadgeUseTypeface;
+ protected boolean mIsBadgeUseTypeface;
// Detect if is bar mode or indicator pager mode
- private boolean mIsViewPagerMode;
+ protected boolean mIsViewPagerMode;
// Detect whether the horizontal orientation
- private boolean mIsHorizontalOrientation;
+ protected boolean mIsHorizontalOrientation;
// Detect if we move from left to right
- private boolean mIsResizeIn;
+ protected boolean mIsResizeIn;
// Detect if we get action down event
- private boolean mIsActionDown;
+ protected boolean mIsActionDown;
// Detect if we get action down event on pointer
- private boolean mIsPointerActionDown;
+ protected boolean mIsPointerActionDown;
// Detect when we set index from tab bar nor from ViewPager
- private boolean mIsSetIndexFromTabBar;
+ protected boolean mIsSetIndexFromTabBar;
// Color variables
- private int mInactiveColor;
- private int mActiveColor;
- private int mBgColor;
+ protected int mInactiveColor;
+ protected int mActiveColor;
+ protected int mBgColor;
// Custom typeface
- private Typeface mTypeface;
+ protected Typeface mTypeface;
public NavigationTabBar(final Context context) {
this(context, null);
@@ -299,7 +299,7 @@ public NavigationTabBar(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
- @SuppressWarnings("ResourceAsColor")
+ @SuppressWarnings({"ResourceAsColor", "ResourceType"})
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
//Init NTB
@@ -310,7 +310,8 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
setLayerType(LAYER_TYPE_SOFTWARE, null);
- final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
+ final TypedArray typedArray =
+ context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
try {
setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
@@ -321,7 +322,10 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
typedArray.getDimension(R.styleable.NavigationTabBar_ntb_title_size, AUTO_SIZE)
);
setIsBadgeUseTypeface(
- typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false)
+ typedArray.getBoolean(
+ R.styleable.NavigationTabBar_ntb_badge_use_typeface,
+ false
+ )
);
setTitleMode(
@@ -334,7 +338,8 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
);
setBadgePosition(
typedArray.getInt(
- R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX
+ R.styleable.NavigationTabBar_ntb_badge_position,
+ BadgePosition.RIGHT_INDEX
)
);
setBadgeGravity(
@@ -346,7 +351,9 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, AUTO_COLOR)
);
setBadgeTitleColor(
- typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR)
+ typedArray.getColor(
+ R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR
+ )
);
setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
@@ -367,7 +374,8 @@ public NavigationTabBar(final Context context, final AttributeSet attrs, final i
);
setAnimationDuration(
typedArray.getInteger(
- R.styleable.NavigationTabBar_ntb_animation_duration, DEFAULT_ANIMATION_DURATION
+ R.styleable.NavigationTabBar_ntb_animation_duration,
+ DEFAULT_ANIMATION_DURATION
)
);
setCornersRadius(
@@ -405,7 +413,8 @@ public void onAnimationUpdate(final ValueAnimator animation) {
exception.printStackTrace();
} finally {
if (previewColors == null)
- previewColors = typedArray.getResources().getStringArray(R.array.default_preview);
+ previewColors =
+ typedArray.getResources().getStringArray(R.array.default_preview);
for (String previewColor : previewColors)
mModels.add(new Model.Builder(null, Color.parseColor(previewColor)).build());
@@ -517,7 +526,7 @@ public TitleMode getTitleMode() {
return mTitleMode;
}
- private void setTitleMode(final int index) {
+ protected void setTitleMode(final int index) {
switch (index) {
case TitleMode.ACTIVE_INDEX:
setTitleMode(TitleMode.ACTIVE);
@@ -538,7 +547,7 @@ public BadgePosition getBadgePosition() {
return mBadgePosition;
}
- private void setBadgePosition(final int index) {
+ protected void setBadgePosition(final int index) {
switch (index) {
case BadgePosition.LEFT_INDEX:
setBadgePosition(BadgePosition.LEFT);
@@ -562,7 +571,7 @@ public BadgeGravity getBadgeGravity() {
return mBadgeGravity;
}
- private void setBadgeGravity(final int index) {
+ protected void setBadgeGravity(final int index) {
switch (index) {
case BadgeGravity.BOTTOM_INDEX:
setBadgeGravity(BadgeGravity.BOTTOM);
@@ -630,7 +639,7 @@ public void setTypeface(final Typeface typeface) {
postInvalidate();
}
- private void setBadgeTypeface() {
+ protected void setBadgeTypeface() {
mBadgePaint.setTypeface(
mIsBadgeUseTypeface ? mTypeface : Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)
);
@@ -702,7 +711,9 @@ public OnTabBarSelectedIndexListener getOnTabBarSelectedIndexListener() {
}
// Set on tab bar selected index listener where you can trigger action onStart or onEnd
- public void setOnTabBarSelectedIndexListener(final OnTabBarSelectedIndexListener onTabBarSelectedIndexListener) {
+ public void setOnTabBarSelectedIndexListener(
+ final OnTabBarSelectedIndexListener onTabBarSelectedIndexListener
+ ) {
mOnTabBarSelectedIndexListener = onTabBarSelectedIndexListener;
if (mAnimatorListener == null)
@@ -710,7 +721,9 @@ public void setOnTabBarSelectedIndexListener(final OnTabBarSelectedIndexListener
@Override
public void onAnimationStart(final Animator animation) {
if (mOnTabBarSelectedIndexListener != null)
- mOnTabBarSelectedIndexListener.onStartTabSelected(mModels.get(mIndex), mIndex);
+ mOnTabBarSelectedIndexListener.onStartTabSelected(
+ mModels.get(mIndex), mIndex
+ );
animation.removeListener(this);
animation.addListener(this);
@@ -724,7 +737,9 @@ public void onAnimationEnd(final Animator animation) {
animation.addListener(this);
if (mOnTabBarSelectedIndexListener != null)
- mOnTabBarSelectedIndexListener.onEndTabSelected(mModels.get(mIndex), mIndex);
+ mOnTabBarSelectedIndexListener.onEndTabSelected(
+ mModels.get(mIndex), mIndex
+ );
}
};
mAnimator.removeListener(mAnimatorListener);
@@ -762,7 +777,7 @@ public void setViewPager(final ViewPager viewPager, int index) {
}
// Reset scroller and reset scroll duration equals to animation duration
- private void resetScroller() {
+ protected void resetScroller() {
if (mViewPager == null) return;
try {
final Field scrollerField = ViewPager.class.getDeclaredField("mScroller");
@@ -873,26 +888,25 @@ public void deselect() {
updateIndicatorPosition(MIN_FRACTION);
}
- private void updateIndicatorPosition(final float fraction) {
+ protected void updateIndicatorPosition(final float fraction) {
// Update general fraction
mFraction = fraction;
// Set the pointer left top side coordinate
- mPointerLeftTop =
- mStartPointerX + (mResizeInterpolator.getResizeInterpolation(fraction, mIsResizeIn) *
+ mPointerLeftTop = mStartPointerX +
+ (mResizeInterpolator.getResizeInterpolation(fraction, mIsResizeIn) *
(mEndPointerX - mStartPointerX));
// Set the pointer right bottom side coordinate
- mPointerRightBottom =
- (mStartPointerX + mModelSize) +
- (mResizeInterpolator.getResizeInterpolation(fraction, !mIsResizeIn) *
- (mEndPointerX - mStartPointerX));
+ mPointerRightBottom = (mStartPointerX + mModelSize) +
+ (mResizeInterpolator.getResizeInterpolation(fraction, !mIsResizeIn) *
+ (mEndPointerX - mStartPointerX));
// Update pointer
postInvalidate();
}
// Update NTB
- private void notifyDataSetChanged() {
+ protected void notifyDataSetChanged() {
requestLayout();
postInvalidate();
}
@@ -993,7 +1007,8 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
mModelSize = (float) height / (float) mModels.size();
mIconSize = (int) ((mModelSize > width ? width : mModelSize) *
- (mIconSizeFraction == AUTO_SCALE ? DEFAULT_ICON_SIZE_FRACTION : mIconSizeFraction));
+ (mIconSizeFraction == AUTO_SCALE ?
+ DEFAULT_ICON_SIZE_FRACTION : mIconSizeFraction));
}
// Set bounds for NTB
@@ -1008,7 +1023,7 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
model.mIcon.getWidth() : model.mIcon.getHeight();
model.mInactiveIconScale = mIconSize / originalIconSize;
model.mActiveIconScaleBy = model.mInactiveIconScale *
- (mIsTitled ? TITLE_ACTIVE_ICON_SCALE_BY : ACTIVE_ICON_SCALE_BY);
+ (mIsTitled ? TITLE_ACTIVE_ICON_SCALE_BY : SCALED_FRACTION);
}
// Reset bitmap to init it onDraw()
@@ -1120,8 +1135,10 @@ protected void onDraw(final Canvas canvas) {
// Set bound of pointer
if (mIsHorizontalOrientation)
mPointerBounds.set(
- mPointerLeftTop, barBadgeMargin,
- mPointerRightBottom, mBounds.height() + barBadgeMargin
+ mPointerLeftTop,
+ barBadgeMargin,
+ mPointerRightBottom,
+ mBounds.height() + barBadgeMargin
);
else mPointerBounds.set(0.0F, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
@@ -1172,21 +1189,21 @@ protected void onDraw(final Canvas canvas) {
);
// Get interpolated fraction for left last and current models
- final float interpolation = mResizeInterpolator.getResizeInterpolation(mFraction, true);
- final float lastInterpolation = mResizeInterpolator.getResizeInterpolation(mFraction, false);
+ final float interpolation =
+ mResizeInterpolator.getResizeInterpolation(mFraction, true);
+ final float lastInterpolation =
+ mResizeInterpolator.getResizeInterpolation(mFraction, false);
// Scale value relative to interpolation
- final float matrixScale = model.mActiveIconScaleBy *
- (mIsScaled ? interpolation : NON_SCALED_FRACTION);
- final float matrixLastScale = model.mActiveIconScaleBy *
- (mIsScaled ? lastInterpolation : (MAX_FRACTION - NON_SCALED_FRACTION));
+ final float matrixScale = model.mActiveIconScaleBy * interpolation;
+ final float matrixLastScale = model.mActiveIconScaleBy * lastInterpolation;
// Get title alpha relative to interpolation
final int titleAlpha = (int) (MAX_ALPHA * interpolation);
final int titleLastAlpha = MAX_ALPHA - (int) (MAX_ALPHA * lastInterpolation);
// Get title scale relative to interpolation
- final float titleScale = MAX_FRACTION +
- ((mIsScaled ? interpolation : NON_SCALED_FRACTION) * TITLE_ACTIVE_SCALE_BY);
+ final float titleScale = mIsScaled ?
+ MAX_FRACTION + interpolation * TITLE_ACTIVE_SCALE_BY : MAX_FRACTION;
final float titleLastScale = mIsScaled ? (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY) -
(lastInterpolation * TITLE_ACTIVE_SCALE_BY) : titleScale;
@@ -1199,34 +1216,75 @@ protected void onDraw(final Canvas canvas) {
if (mIsSetIndexFromTabBar) {
if (mIndex == i)
updateCurrentModel(
- model, leftOffset, topOffset, titleTranslate, interpolation,
- matrixCenterX, matrixCenterY, matrixScale, titleScale, titleAlpha
+ model,
+ leftOffset,
+ topOffset,
+ titleTranslate,
+ interpolation,
+ matrixCenterX,
+ matrixCenterY,
+ matrixScale,
+ titleScale,
+ titleAlpha
);
else if (mLastIndex == i)
updateLastModel(
- model, leftOffset, topOffset, titleTranslate, lastInterpolation,
- matrixCenterX, matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha
+ model,
+ leftOffset,
+ topOffset,
+ titleTranslate,
+ lastInterpolation,
+ matrixCenterX,
+ matrixCenterY,
+ matrixLastScale,
+ titleLastScale,
+ titleLastAlpha
);
else
updateInactiveModel(
- model, leftOffset, topOffset, titleScale,
- matrixScale, matrixCenterX, matrixCenterY
+ model,
+ leftOffset,
+ topOffset,
+ titleScale,
+ matrixScale,
+ matrixCenterX,
+ matrixCenterY
);
} else {
if (i == mIndex + 1)
updateCurrentModel(
- model, leftOffset, topOffset, titleTranslate, interpolation,
- matrixCenterX, matrixCenterY, matrixScale, titleScale, titleAlpha
+ model,
+ leftOffset,
+ topOffset,
+ titleTranslate,
+ interpolation,
+ matrixCenterX,
+ matrixCenterY,
+ matrixScale,
+ titleScale,
+ titleAlpha
);
else if (i == mIndex)
updateLastModel(
- model, leftOffset, topOffset, titleTranslate, lastInterpolation,
- matrixCenterX, matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha
+ model,
+ leftOffset,
+ topOffset,
+ titleTranslate,
+ lastInterpolation,
+ matrixCenterX,
+ matrixCenterY,
+ matrixLastScale,
+ titleLastScale,
+ titleLastAlpha
);
- else
- updateInactiveModel(
- model, leftOffset, topOffset, titleScale,
- matrixScale, matrixCenterX, matrixCenterY
+ else updateInactiveModel(
+ model,
+ leftOffset,
+ topOffset,
+ titleScale,
+ matrixScale,
+ matrixCenterX,
+ matrixCenterY
);
}
@@ -1234,44 +1292,35 @@ else if (i == mIndex)
if (model.mSelectedIcon == null) {
if (model.mIcon != null && !model.mIcon.isRecycled())
mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
- } else {
- if (mIconPaint.getAlpha() != MIN_ALPHA
- && model.mIcon != null && !model.mIcon.isRecycled())
- // Draw original icon when is visible
- mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
- }
+ } else if (mIconPaint.getAlpha() != MIN_ALPHA &&
+ model.mIcon != null && !model.mIcon.isRecycled())
+ // Draw original icon when is visible
+ mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
// Draw selected icon when exist and visible
- if (mSelectedIconPaint.getAlpha() != MIN_ALPHA
- && model.mSelectedIcon != null && !model.mSelectedIcon.isRecycled())
- mIconsCanvas.drawBitmap(
- model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint
- );
-
- if (mIsTitled)
- mTitlesCanvas.drawText(
- isInEditMode() ? PREVIEW_TITLE : model.getTitle(),
- leftTitleOffset, topTitleOffset, mModelTitlePaint
- );
+ if (mSelectedIconPaint.getAlpha() != MIN_ALPHA &&
+ model.mSelectedIcon != null && !model.mSelectedIcon.isRecycled())
+ mIconsCanvas.drawBitmap(model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint);
+ if (mIsTitled) mTitlesCanvas.drawText(
+ isInEditMode() ? PREVIEW_TITLE : model.getTitle(),
+ leftTitleOffset,
+ topTitleOffset,
+ mModelTitlePaint
+ );
}
// Reset pointer bounds for icons and titles
if (mIsHorizontalOrientation)
- mPointerBounds.set(
- mPointerLeftTop, 0.0F,
- mPointerRightBottom, mBounds.height()
- );
+ mPointerBounds.set(mPointerLeftTop, 0.0F, mPointerRightBottom, mBounds.height());
if (mCornersRadius == 0) {
if (mIsTinted) mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
if (mIsTitled) mTitlesCanvas.drawRect(mPointerBounds, mIconPointerPaint);
} else {
- if (mIsTinted)
- mIconsCanvas.drawRoundRect(
- mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
- );
- if (mIsTitled)
- mTitlesCanvas.drawRoundRect(
- mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
- );
+ if (mIsTinted) mIconsCanvas.drawRoundRect(
+ mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
+ );
+ if (mIsTitled) mTitlesCanvas.drawRoundRect(
+ mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint
+ );
}
// Draw general bitmap
@@ -1315,8 +1364,10 @@ else if (i == mIndex)
final float badgeMargin = mBadgeMargin * model.mBadgeFraction;
if (model.getBadgeTitle().length() == 1) {
mBgBadgeBounds.set(
- badgeBoundsHorizontalOffset - badgeMargin, modelBadgeMargin - badgeMargin,
- badgeBoundsHorizontalOffset + badgeMargin, modelBadgeMargin + badgeMargin
+ badgeBoundsHorizontalOffset - badgeMargin,
+ modelBadgeMargin - badgeMargin,
+ badgeBoundsHorizontalOffset + badgeMargin,
+ modelBadgeMargin + badgeMargin
);
} else
mBgBadgeBounds.set(
@@ -1340,7 +1391,9 @@ else if (i == mIndex)
// Set color and alpha for badge title
if (model.mBadgeFraction == MIN_FRACTION) mBadgePaint.setColor(Color.TRANSPARENT);
else //noinspection ResourceAsColor
- mBadgePaint.setColor(mBadgeTitleColor == AUTO_COLOR ? model.getColor() : mBadgeTitleColor);
+ mBadgePaint.setColor(
+ mBadgeTitleColor == AUTO_COLOR ? model.getColor() : mBadgeTitleColor
+ );
mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));
// Set badge title center position and draw title
@@ -1356,7 +1409,7 @@ else if (i == mIndex)
}
// Method to transform current fraction of NTB and position
- private void updateCurrentModel(
+ protected void updateCurrentModel(
final Model model,
final float leftOffset,
final float topOffset,
@@ -1365,21 +1418,18 @@ private void updateCurrentModel(
final float matrixCenterX,
final float matrixCenterY,
final float matrixScale,
- final float textScale,
- final int textAlpha
+ final float titleScale,
+ final int titleAlpha
) {
- if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
- model.mIconMatrix.setTranslate(
- leftOffset, topOffset - (interpolation * (topOffset - titleTranslate))
- );
-
- model.mIconMatrix.postScale(
- model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
- matrixCenterX, matrixCenterY
+ if (mIsTitled && mTitleMode == TitleMode.ACTIVE) model.mIconMatrix.setTranslate(
+ leftOffset, topOffset - (interpolation * (topOffset - titleTranslate))
);
- mModelTitlePaint.setTextSize(mModelTitleSize * textScale);
- if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(textAlpha);
+ final float scale = model.mInactiveIconScale + (mIsScaled ? matrixScale : 0.0F);
+ model.mIconMatrix.postScale(scale, scale, matrixCenterX, matrixCenterY);
+
+ mModelTitlePaint.setTextSize(mModelTitleSize * titleScale);
+ if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(titleAlpha);
if (model.mSelectedIcon == null) {
mIconPaint.setAlpha(MAX_ALPHA);
@@ -1400,17 +1450,12 @@ private void updateCurrentModel(
selectedIconAlpha = MIN_FRACTION;
}
- mIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(iconAlpha))
- );
- mSelectedIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(selectedIconAlpha))
- );
-
+ mIconPaint.setAlpha((int) (MAX_ALPHA * clampValue(iconAlpha)));
+ mSelectedIconPaint.setAlpha((int) (MAX_ALPHA * clampValue(selectedIconAlpha)));
}
// Method to transform last fraction of NTB and position
- private void updateLastModel(
+ protected void updateLastModel(
final Model model,
final float leftOffset,
final float topOffset,
@@ -1419,22 +1464,19 @@ private void updateLastModel(
final float matrixCenterX,
final float matrixCenterY,
final float matrixLastScale,
- final float textLastScale,
- final int textLastAlpha
+ final float titleLastScale,
+ final int titleLastAlpha
) {
- if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
- model.mIconMatrix.setTranslate(
- leftOffset, titleTranslate + (lastInterpolation * (topOffset - titleTranslate))
- );
-
- model.mIconMatrix.postScale(
- model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
- model.mInactiveIconScale + model.mActiveIconScaleBy - matrixLastScale,
- matrixCenterX, matrixCenterY
+ if (mIsTitled && mTitleMode == TitleMode.ACTIVE) model.mIconMatrix.setTranslate(
+ leftOffset, titleTranslate + (lastInterpolation * (topOffset - titleTranslate))
);
- mModelTitlePaint.setTextSize(mModelTitleSize * textLastScale);
- if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(textLastAlpha);
+ final float scale = model.mInactiveIconScale +
+ (mIsScaled ? model.mActiveIconScaleBy - matrixLastScale : 0.0F);
+ model.mIconMatrix.postScale(scale, scale, matrixCenterX, matrixCenterY);
+
+ mModelTitlePaint.setTextSize(mModelTitleSize * titleLastScale);
+ if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(titleLastAlpha);
if (model.mSelectedIcon == null) {
mIconPaint.setAlpha(MAX_ALPHA);
@@ -1455,16 +1497,12 @@ private void updateLastModel(
selectedIconAlpha = MIN_FRACTION;
}
- mIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(iconAlpha))
- );
- mSelectedIconPaint.setAlpha(
- (int) (MAX_ALPHA * clampValue(selectedIconAlpha))
- );
+ mIconPaint.setAlpha((int) (MAX_ALPHA * clampValue(iconAlpha)));
+ mSelectedIconPaint.setAlpha((int) (MAX_ALPHA * clampValue(selectedIconAlpha)));
}
// Method to transform others fraction of NTB and position
- private void updateInactiveModel(
+ protected void updateInactiveModel(
final Model model,
final float leftOffset,
final float topOffset,
@@ -1475,19 +1513,11 @@ private void updateInactiveModel(
) {
if (mIsTitled && mTitleMode == TitleMode.ACTIVE)
model.mIconMatrix.setTranslate(leftOffset, topOffset);
+ model.mIconMatrix.postScale(
+ model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
+ );
- if (mIsScaled)
- model.mIconMatrix.postScale(
- model.mInactiveIconScale + matrixScale, model.mInactiveIconScale + matrixScale,
- matrixCenterX, matrixCenterY
- );
- else
- model.mIconMatrix.postScale(
- model.mInactiveIconScale, model.mInactiveIconScale, matrixCenterX, matrixCenterY
- );
-
-
- mModelTitlePaint.setTextSize(mModelTitleSize * (mIsScaled ? textScale : 1.0F));
+ mModelTitlePaint.setTextSize(mModelTitleSize);
if (mTitleMode == TitleMode.ACTIVE) mModelTitlePaint.setAlpha(MIN_ALPHA);
// Reset icons alpha
@@ -1499,7 +1529,7 @@ private void updateInactiveModel(
mSelectedIconPaint.setAlpha(MIN_ALPHA);
}
- private void updateTint() {
+ protected void updateTint() {
if (mIsTinted) {
// Set color filter to wrap icons with inactive color
final PorterDuffColorFilter colorFilter =
@@ -1572,11 +1602,11 @@ public Parcelable onSaveInstanceState() {
return savedState;
}
- private static class SavedState extends BaseSavedState {
+ protected static class SavedState extends BaseSavedState {
private int index;
- public SavedState(Parcelable superState) {
+ SavedState(Parcelable superState) {
super(superState);
}
@@ -1623,8 +1653,10 @@ public void run() {
}
// Clamp value to max and min bounds
- private float clampValue(final float value) {
- return Math.max(Math.min(value, NavigationTabBar.MAX_FRACTION), NavigationTabBar.MIN_FRACTION);
+ protected float clampValue(final float value) {
+ return Math.max(
+ Math.min(value, NavigationTabBar.MAX_FRACTION), NavigationTabBar.MIN_FRACTION
+ );
}
// Hide NTB with animation
@@ -1643,7 +1675,7 @@ public void show() {
}
// Hide NTB or bg on scroll down
- private void scrollDown() {
+ protected void scrollDown() {
ViewCompat.animate(this)
.translationY(getBarHeight())
.setInterpolator(new LinearOutSlowInInterpolator())
@@ -1652,7 +1684,7 @@ private void scrollDown() {
}
// Show NTB or bg on scroll up
- private void scrollUp() {
+ protected void scrollUp() {
ViewCompat.animate(this)
.translationY(0.0F)
.setInterpolator(OUT_SLOW_IN_INTERPOLATOR)
@@ -1663,26 +1695,26 @@ private void scrollUp() {
// Model class
public static class Model {
- private int mColor;
+ int mColor;
- private final Bitmap mIcon;
- private final Bitmap mSelectedIcon;
- private final Matrix mIconMatrix = new Matrix();
+ final Bitmap mIcon;
+ final Bitmap mSelectedIcon;
+ final Matrix mIconMatrix = new Matrix();
- private String mTitle = "";
- private String mBadgeTitle = "";
- private String mTempBadgeTitle = "";
- private float mBadgeFraction;
+ String mTitle = "";
+ String mBadgeTitle = "";
+ String mTempBadgeTitle = "";
+ float mBadgeFraction;
- private boolean mIsBadgeShowed;
- private boolean mIsBadgeUpdated;
+ boolean mIsBadgeShowed;
+ boolean mIsBadgeUpdated;
- private final ValueAnimator mBadgeAnimator = new ValueAnimator();
+ final ValueAnimator mBadgeAnimator = new ValueAnimator();
- private float mInactiveIconScale;
- private float mActiveIconScaleBy;
+ float mInactiveIconScale;
+ float mActiveIconScaleBy;
- public Model(final Builder builder) {
+ Model(final Builder builder) {
mColor = builder.mColor;
mIcon = builder.mIcon;
mSelectedIcon = builder.mSelectedIcon;
@@ -1794,13 +1826,13 @@ public void hideBadge() {
public static class Builder {
- private final int mColor;
+ final int mColor;
- private final Bitmap mIcon;
- private Bitmap mSelectedIcon;
+ final Bitmap mIcon;
+ Bitmap mSelectedIcon;
- private String mTitle;
- private String mBadgeTitle;
+ String mTitle;
+ String mBadgeTitle;
public Builder(final Drawable icon, final int color) {
mColor = color;
@@ -1858,9 +1890,9 @@ public Model build() {
}
// Custom scroller with custom scroll duration
- private class ResizeViewPagerScroller extends Scroller {
+ protected class ResizeViewPagerScroller extends Scroller {
- public ResizeViewPagerScroller(Context context) {
+ ResizeViewPagerScroller(Context context) {
super(context, new AccelerateDecelerateInterpolator());
}
@@ -1877,12 +1909,12 @@ public void startScroll(int startX, int startY, int dx, int dy) {
// Resize interpolator to create smooth effect on pointer according to inspiration design
// This is like improved accelerated and decelerated interpolator
- private class ResizeInterpolator implements Interpolator {
+ protected class ResizeInterpolator implements Interpolator {
// Spring factor
- private final static float FACTOR = 1.0F;
+ final static float FACTOR = 1.0F;
// Check whether side we move
- private boolean mResizeIn;
+ boolean mResizeIn;
@Override
public float getInterpolation(final float input) {
@@ -1890,7 +1922,7 @@ public float getInterpolation(final float input) {
else return (float) (Math.pow(input, 2.0F * FACTOR));
}
- public float getResizeInterpolation(final float input, final boolean resizeIn) {
+ float getResizeInterpolation(final float input, final boolean resizeIn) {
mResizeIn = resizeIn;
return getInterpolation(input);
}
@@ -1912,7 +1944,7 @@ public enum BadgePosition {
public final static int CENTER_INDEX = 1;
public final static int RIGHT_INDEX = 2;
- private final float mPositionFraction;
+ protected final float mPositionFraction;
BadgePosition(final float positionFraction) {
mPositionFraction = positionFraction;
From 9c1f824f3018b21cfd8f556cceaa290067f65b24 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 11 Nov 2016 16:35:00 +0200
Subject: [PATCH 54/64] Fixes with modifiers.
---
.../io/library/ntb/NavigationTabBar.java | 55 +++++++++----------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
index ac8d5e3..5c824ed 100644
--- a/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
@@ -1133,13 +1133,12 @@ protected void onDraw(final Canvas canvas) {
}
// Set bound of pointer
- if (mIsHorizontalOrientation)
- mPointerBounds.set(
- mPointerLeftTop,
- barBadgeMargin,
- mPointerRightBottom,
- mBounds.height() + barBadgeMargin
- );
+ if (mIsHorizontalOrientation) mPointerBounds.set(
+ mPointerLeftTop,
+ barBadgeMargin,
+ mPointerRightBottom,
+ mBounds.height() + barBadgeMargin
+ );
else mPointerBounds.set(0.0F, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
// Draw pointer for model colors
@@ -1695,24 +1694,24 @@ protected void scrollUp() {
// Model class
public static class Model {
- int mColor;
+ private int mColor;
- final Bitmap mIcon;
- final Bitmap mSelectedIcon;
- final Matrix mIconMatrix = new Matrix();
+ private final Bitmap mIcon;
+ private final Bitmap mSelectedIcon;
+ private final Matrix mIconMatrix = new Matrix();
- String mTitle = "";
- String mBadgeTitle = "";
- String mTempBadgeTitle = "";
- float mBadgeFraction;
+ private String mTitle = "";
+ private String mBadgeTitle = "";
+ private String mTempBadgeTitle = "";
+ private float mBadgeFraction;
- boolean mIsBadgeShowed;
- boolean mIsBadgeUpdated;
+ private boolean mIsBadgeShowed;
+ private boolean mIsBadgeUpdated;
- final ValueAnimator mBadgeAnimator = new ValueAnimator();
+ private final ValueAnimator mBadgeAnimator = new ValueAnimator();
- float mInactiveIconScale;
- float mActiveIconScaleBy;
+ private float mInactiveIconScale;
+ private float mActiveIconScaleBy;
Model(final Builder builder) {
mColor = builder.mColor;
@@ -1826,13 +1825,13 @@ public void hideBadge() {
public static class Builder {
- final int mColor;
+ private final int mColor;
- final Bitmap mIcon;
- Bitmap mSelectedIcon;
+ private final Bitmap mIcon;
+ private Bitmap mSelectedIcon;
- String mTitle;
- String mBadgeTitle;
+ private String mTitle;
+ private String mBadgeTitle;
public Builder(final Drawable icon, final int color) {
mColor = color;
@@ -1912,9 +1911,9 @@ public void startScroll(int startX, int startY, int dx, int dy) {
protected class ResizeInterpolator implements Interpolator {
// Spring factor
- final static float FACTOR = 1.0F;
+ private final static float FACTOR = 1.0F;
// Check whether side we move
- boolean mResizeIn;
+ private boolean mResizeIn;
@Override
public float getInterpolation(final float input) {
@@ -1944,7 +1943,7 @@ public enum BadgePosition {
public final static int CENTER_INDEX = 1;
public final static int RIGHT_INDEX = 2;
- protected final float mPositionFraction;
+ private final float mPositionFraction;
BadgePosition(final float positionFraction) {
mPositionFraction = positionFraction;
From b2a25e5f9fe80c306106bc6592333cee38d91887 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 11 Nov 2016 16:58:16 +0200
Subject: [PATCH 55/64] Fixes for new version.
---
README.md | 89 +++++++++----------
build.gradle | 2 +-
.../io/library/ntb/NavigationTabBar.java | 2 +-
3 files changed, 42 insertions(+), 51 deletions(-)
diff --git a/README.md b/README.md
index 7e11950..93b2bb6 100644
--- a/README.md
+++ b/README.md
@@ -40,34 +40,28 @@ Download
You can download a `.aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/releases).
-Or use Gradle jCenter:
+You can use Gradle:
```groovy
-dependencies {
- repositories {
- mavenCentral()
- maven {
- url 'http://dl.bintray.com/gigamole/maven/'
- }
- }
- compile 'com.github.devlight.navigationtabbar:navigationtabbar:+'
-}
-```
-
-Or Gradle Maven Central:
-```groovy
-compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.5'
+compile 'devlight.io:navigationtabbar:1.2.5'
```
Or Maven:
```groovy
- com.github.devlight.navigationtabbar
+ devlight.io
navigationtabbar
1.2.5
aar
```
+Or Ivy:
+```groovy
+
+
+
+```
+
Android SDK Version
===================
@@ -134,7 +128,7 @@ For `NTB` you can set such parameters as:
- corners radius:
allows you to set corners radius of pointer.
- - icon size fraction:
+ - icon size fraction:
allows you to set icon size fraction relative to smaller model side.
- animation duration:
@@ -257,7 +251,7 @@ Other methods check out in sample.
And XML init:
```xml
-
+
```
Getting Help
diff --git a/build.gradle b/build.gradle
index e2a3028..5f66515 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:2.2.0'
+ classpath 'com.android.tools.build:gradle:2.1.3'
}
}
diff --git a/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
index 5c824ed..934232f 100644
--- a/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
+++ b/navigationtabbar/src/main/java/devlight/io/library/ntb/NavigationTabBar.java
@@ -1921,7 +1921,7 @@ public float getInterpolation(final float input) {
else return (float) (Math.pow(input, 2.0F * FACTOR));
}
- float getResizeInterpolation(final float input, final boolean resizeIn) {
+ private float getResizeInterpolation(final float input, final boolean resizeIn) {
mResizeIn = resizeIn;
return getInterpolation(input);
}
From b0f9fc1cc935f8929e5f3a1d535ba713e9673110 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 9 Dec 2016 10:50:20 +0200
Subject: [PATCH 56/64] Fixed readme.
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 93b2bb6..bde64df 100644
--- a/README.md
+++ b/README.md
@@ -319,11 +319,14 @@ Xamarin
=======
Thanks to [Martijn van Dijk](https://github.com/martijn00) for developing Xamarin bindings library for [NavigationTabBar](https://github.com/martijn00/NavigationTabBarXamarin).
-Plugin is available on [Nuget](https://www.nuget.org/packages/Xam.Plugins.Android.InfiniteCycleViewPager/).
+Plugin is available on [Nuget](https://www.nuget.org/packages/Xam.Plugins.Android.NavigationTabBar/).
Credits
=======
+Sincere thanks, to portal [FAnDroid.info](http://www.fandroid.info) [(StartAndroid)](https://www.youtube.com/channel/UCzE7HcbvyEiS5ea1rVRbPLQ) who released the review of this library in detail. If you understand the Russian language, then feel free to see the video or read the [text version](http://www.fandroid.info/obzor-biblioteki-navigationtabbar-dlya-android-ot-komandy-devlight/) of its great post.
+[](https://youtu.be/nGikO-tbSsg)
+
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
|[](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions)|
From bb4ecdd0bfcf4513670215e6902b55f41aa813e8 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 9 Dec 2016 10:57:42 +0200
Subject: [PATCH 57/64] Fixed readme.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index bde64df..66d9fff 100644
--- a/README.md
+++ b/README.md
@@ -325,7 +325,7 @@ Credits
=======
Sincere thanks, to portal [FAnDroid.info](http://www.fandroid.info) [(StartAndroid)](https://www.youtube.com/channel/UCzE7HcbvyEiS5ea1rVRbPLQ) who released the review of this library in detail. If you understand the Russian language, then feel free to see the video or read the [text version](http://www.fandroid.info/obzor-biblioteki-navigationtabbar-dlya-android-ot-komandy-devlight/) of its great post.
-[](https://youtu.be/nGikO-tbSsg)
+[](https://youtu.be/nGikO-tbSsg)
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
From 80f37b97eb87314c6c14a77f6364e0b8056d50fb Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 9 Dec 2016 11:01:46 +0200
Subject: [PATCH 58/64] Fixed readme.
---
README.md | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 66d9fff..c7c8e54 100644
--- a/README.md
+++ b/README.md
@@ -325,8 +325,13 @@ Credits
=======
Sincere thanks, to portal [FAnDroid.info](http://www.fandroid.info) [(StartAndroid)](https://www.youtube.com/channel/UCzE7HcbvyEiS5ea1rVRbPLQ) who released the review of this library in detail. If you understand the Russian language, then feel free to see the video or read the [text version](http://www.fandroid.info/obzor-biblioteki-navigationtabbar-dlya-android-ot-komandy-devlight/) of its great post.
-[](https://youtu.be/nGikO-tbSsg)
+
+
+
+
+
+Inspired by:
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
|[](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions)|
From e76790e0807c95233e7a5263732eaf9671badf26 Mon Sep 17 00:00:00 2001
From: GIGAMOLE
Date: Fri, 9 Dec 2016 11:02:33 +0200
Subject: [PATCH 59/64] Fixed readme.
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index c7c8e54..ff7346b 100644
--- a/README.md
+++ b/README.md
@@ -332,6 +332,7 @@ Sincere thanks, to portal [FAnDroid.info](http://www.fandroid.info) [(StartAndro
Inspired by:
+
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
|[](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions)|
From 6f68f4a905873906fec87e6a7e7dc8d7c99cc831 Mon Sep 17 00:00:00 2001
From: HaoYin
Date: Fri, 9 Dec 2016 11:02:33 +0200
Subject: [PATCH 60/64] =?UTF-8?q?The=20title=20function=20is=20displayed?=
=?UTF-8?q?=20when=20the=20vertical=20layout=20is=20added=E3=80=82=20?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=BD=93=E4=B8=BA=E5=9E=82=E7=9B=B4?=
=?UTF-8?q?=E5=B8=83=E5=B1=80=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=A0=87?=
=?UTF-8?q?=E9=A2=98=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8E=9F=E5=9B=A0=E6=98=AF?=
=?UTF-8?q?=E5=9E=82=E7=9B=B4=E6=96=B9=E5=90=91=E6=9C=AA=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E6=AD=A4=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8F=A6=E5=A4=96=E6=9C=AA?=
=?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=9A=84=E8=BF=98=E6=9C=89=E8=A7=92=E6=A0=87?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=B6=88=E6=81=AF=E5=8A=9F=E8=83=BD=EF=BC=88?=
=?UTF-8?q?=E6=9C=AC=E6=AC=A1=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=89=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 1 +
.../io/sample/VerticalNtbActivity.java | 8 ++++++
.../main/res/layout/activity_vertical_ntb.xml | 3 +++
.../io/library/ntb/NavigationTabBar.java | 26 ++++++++++++++-----
4 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index c7c8e54..ff7346b 100644
--- a/README.md
+++ b/README.md
@@ -332,6 +332,7 @@ Sincere thanks, to portal [FAnDroid.info](http://www.fandroid.info) [(StartAndro
Inspired by:
+
|[Sergey Valiukh](https://dribbble.com/SergeyValiukh)|
|:--------------------------------------------------:|
|[](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions)|
diff --git a/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java b/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
index 2186791..29f3fb5 100644
--- a/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
+++ b/app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
@@ -65,6 +65,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_first),
Color.parseColor(colors[0]))
+ .title("ic_first")
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.build()
);
@@ -73,6 +74,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_second),
Color.parseColor(colors[1]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_second")
.build()
);
models.add(
@@ -80,6 +82,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_third),
Color.parseColor(colors[2]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_third")
.build()
);
models.add(
@@ -87,6 +90,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_fourth),
Color.parseColor(colors[3]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_fourth")
.build()
);
models.add(
@@ -94,6 +98,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_fifth),
Color.parseColor(colors[4]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_fifth")
.build()
);
models.add(
@@ -101,6 +106,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_sixth),
Color.parseColor(colors[5]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_sixth")
.build()
);
models.add(
@@ -108,6 +114,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_seventh),
Color.parseColor(colors[6]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_seventh")
.build()
);
models.add(
@@ -115,6 +122,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_eighth),
Color.parseColor(colors[7]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
+ .title("ic_eighth")
.build()
);
diff --git a/app/src/main/res/layout/activity_vertical_ntb.xml b/app/src/main/res/layout/activity_vertical_ntb.xml
index f05b25a..d6187b7 100644
--- a/app/src/main/res/layout/activity_vertical_ntb.xml
+++ b/app/src/main/res/layout/activity_vertical_ntb.xml
@@ -8,6 +8,9 @@
android:background="#423752">
width ? width : mModelSize) *
+ // Get smaller side
+ float side = mModelSize > width ? width : mModelSize;
+
+ mIconSize = (int) (side *
(mIconSizeFraction == AUTO_SCALE ?
DEFAULT_ICON_SIZE_FRACTION : mIconSizeFraction));
+
+ if (mModelTitleSize == AUTO_SIZE) mModelTitleSize = side * TITLE_SIZE_FRACTION;
+ mTitleMargin = side * TITLE_MARGIN_FRACTION;
}
// Set bounds for NTB
@@ -1162,16 +1168,24 @@ protected void onDraw(final Canvas canvas) {
final float matrixCenterY;
// Set offset to titles
- final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
- final float topTitleOffset =
- mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;
-
+ final float leftTitleOffset;
+ final float topTitleOffset;
if (mIsHorizontalOrientation) {
leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5F;
topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5F;
+
+ // Set offset to titles
+ leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
+ topTitleOffset =
+ mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;
+
} else {
leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5F;
topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5F;
+
+ // Set offset to titles
+ leftTitleOffset = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
+ topTitleOffset = topOffset + (model.mIcon.getHeight() + iconMarginTitleHeight) * 0.5f;
}
matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
From 5a35719ce4edc6529d40a91200c842a5867725fc Mon Sep 17 00:00:00 2001
From: Serhii Pokrovskyi
Date: Thu, 1 Jun 2017 22:46:57 +0300
Subject: [PATCH 61/64] support lib, target sdk and gradle update to latest
version
---
app/build.gradle | 12 ++++++------
build.gradle | 2 +-
gradle/wrapper/gradle-wrapper.properties | 4 ++--
navigationtabbar/build.gradle | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 8abc04e..e7df12d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
defaultConfig {
applicationId "devlight.io.navigationtabbar"
minSdkVersion 11
- targetSdkVersion 23
+ targetSdkVersion 25
versionCode 1
versionName "1.0"
}
@@ -28,7 +28,7 @@ dependencies {
compile project(':navigationtabbar')
// compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.3'
- compile 'com.android.support:appcompat-v7:23.2.1'
- compile 'com.android.support:design:23.2.1'
- compile 'com.android.support:support-v4:23.2.1'
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ compile 'com.android.support:design:25.3.1'
+ compile 'com.android.support:support-v4:25.3.1'
}
diff --git a/build.gradle b/build.gradle
index 5f66515..ea0055f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:2.1.3'
+ classpath 'com.android.tools.build:gradle:2.3.2'
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 7f777ee..a73d6cf 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Sep 14 21:51:46 EEST 2016
+#Thu Jun 01 22:46:13 EEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index 67ac75b..c8d6fdf 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -22,12 +22,12 @@ apply plugin: 'maven'
version = "1.2.5"
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 11
- targetSdkVersion 23
+ targetSdkVersion 25
versionCode 1
versionName "1.2.5"
}
@@ -42,7 +42,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDependency
- compile 'com.android.support:design:23.2.1'
+ compile 'com.android.support:design:25.3.1'
}
def siteUrl = 'https://github.com/DevLight-Mobile-Agency/NavigationTabBar'
From 2cc582ebbdc76bad08f924d4d541bcfee45584a9 Mon Sep 17 00:00:00 2001
From: Arthur Melo
Date: Fri, 27 Apr 2018 03:24:35 -0300
Subject: [PATCH 62/64] updated android gradle compatibility with 3.1.2
---
app/build.gradle | 18 +++++++++---------
build.gradle | 6 ++++--
gradle/wrapper/gradle-wrapper.properties | 4 ++--
navigationtabbar/build.gradle | 12 ++++++------
4 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index e7df12d..146f017 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.3"
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
defaultConfig {
applicationId "devlight.io.navigationtabbar"
- minSdkVersion 11
- targetSdkVersion 25
+ minSdkVersion 14
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
}
@@ -24,11 +24,11 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile project(':navigationtabbar')
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation project(':navigationtabbar')
// compile 'com.github.devlight.navigationtabbar:navigationtabbar:1.2.3'
- compile 'com.android.support:appcompat-v7:25.3.1'
- compile 'com.android.support:design:25.3.1'
- compile 'com.android.support:support-v4:25.3.1'
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support:design:27.1.1'
+ implementation 'com.android.support:support-v4:27.1.1'
}
diff --git a/build.gradle b/build.gradle
index ea0055f..69bfa21 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,16 +3,18 @@
buildscript {
repositories {
jcenter()
+ google()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
- classpath 'com.android.tools.build:gradle:2.3.2'
+ classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
+ classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
+ google()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a73d6cf..9072f5b 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Thu Jun 01 22:46:13 EEST 2017
+#Fri Apr 27 03:13:54 BRT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/navigationtabbar/build.gradle b/navigationtabbar/build.gradle
index c8d6fdf..04d0b47 100644
--- a/navigationtabbar/build.gradle
+++ b/navigationtabbar/build.gradle
@@ -22,12 +22,12 @@ apply plugin: 'maven'
version = "1.2.5"
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.3"
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
defaultConfig {
- minSdkVersion 11
- targetSdkVersion 25
+ minSdkVersion 14
+ targetSdkVersion 27
versionCode 1
versionName "1.2.5"
}
@@ -40,9 +40,9 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDependency
- compile 'com.android.support:design:25.3.1'
+ implementation 'com.android.support:design:27.1.1'
}
def siteUrl = 'https://github.com/DevLight-Mobile-Agency/NavigationTabBar'
From a9a5881c5fac2fd86f2bcb8c2cb8d2f02d701ee5 Mon Sep 17 00:00:00 2001
From: Basil Miller
Date: Tue, 22 May 2018 00:34:30 +0300
Subject: [PATCH 63/64] Not more supported warn
---
README.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/README.md b/README.md
index ff7346b..4c58168 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,16 @@ Navigation tab bar with colorful interactions.
You can check the sample app [here](https://github.com/DevLight-Mobile-Agency/NavigationTabBar/tree/master/app).
+Warn
+====
+```
+This library is not more supported.
+If you want to add new feature or fix a bug, grab source code and do it.
+If you think your fix or feature would be useful to other developers,
+I can add link of your repository to this README file.
+Thank you for using our libraries.
+```
+
Download
========
From 11a041316dae4a19bdca802ec008f9980268e8fe Mon Sep 17 00:00:00 2001
From: Paras gupta <43930565+parasgupta0018@users.noreply.github.com>
Date: Thu, 3 Oct 2019 14:18:12 +0530
Subject: [PATCH 64/64] Update with "Using materialize css for navbar"
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 4c58168..86fdb58 100644
--- a/README.md
+++ b/README.md
@@ -331,6 +331,10 @@ Xamarin
Thanks to [Martijn van Dijk](https://github.com/martijn00) for developing Xamarin bindings library for [NavigationTabBar](https://github.com/martijn00/NavigationTabBarXamarin).
Plugin is available on [Nuget](https://www.nuget.org/packages/Xam.Plugins.Android.NavigationTabBar/).
+## use navbar using materialize css
+navbar using materialize css is really easy and would take just assigning right classes to the html tags and it would create a navigation tab bar using its prewritten css and js files. This can be easily used in html pages using downloaded files or cdn links...
+https://materializecss.com/navbar.html
+
Credits
=======