Skip to content
Permalink
Browse files

Merge remote-tracking branch 'origin/development'

  • Loading branch information...
yarovoiag-cr committed Aug 9, 2017
2 parents 00228e0 + f6a4216 commit 824af265b43ddff027957935b608c0c187322623
Showing with 496 additions and 85 deletions.
  1. +1 −0 CHANGELOG.md
  2. +0 −1 LoopBar-widget/build.gradle
  3. +2 −2 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/CategoriesAdapter.java
  4. +3 −3 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/ChangeScrollModeAdapter.java
  5. +4 −2 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/IChangeSizeCallback.java
  6. +45 −10 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java
  7. +17 −6 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/Orientation.java
  8. +4 −4 ...leveroad/loopbar/widget/{OrientationStateHorizontal.java → OrientationStateHorizontalBottom.java}
  9. +11 −0 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OrientationStateHorizontalTop.java
  10. +4 −4 .../com/cleveroad/loopbar/widget/{OrientationStateVertical.java → OrientationStateVerticalLeft.java}
  11. +10 −0 LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OrientationStateVerticalRight.java
  12. +74 −0 LoopBar-widget/src/main/res/drawable/enls_bottom_left_shadow.xml
  13. +13 −13 LoopBar-widget/src/main/res/drawable/enls_bottom_right_shadow.xml
  14. +10 −13 ...iew_categories_navigation_horizontal.xml → enls_view_categories_navigation_horizontal_bottom.xml}
  15. +46 −0 LoopBar-widget/src/main/res/layout/enls_view_categories_navigation_horizontal_top.xml
  16. +9 −10 ...enls_view_categories_navigation_vertical.xml → enls_view_categories_navigation_vertical_left.xml}
  17. +49 −0 LoopBar-widget/src/main/res/layout/enls_view_categories_navigation_vertical_right.xml
  18. +4 −2 LoopBar-widget/src/main/res/values/EndlessNavigationViewAttrs.xml
  19. +2 −1 README.md
  20. +4 −4 sample/build.gradle
  21. +1 −1 sample/src/main/java/com/cleveroad/sample/MainActivity.java
  22. +43 −7 sample/src/main/java/com/cleveroad/sample/fragments/AbstractLoopBarFragment.java
  23. +1 −1 ...le/src/main/res/layout/{fragment_loopbar_horizontal.xml → fragment_loopbar_horizontal_bottom.xml}
  24. +69 −0 sample/src/main/res/layout/fragment_loopbar_horizontal_top.xml
  25. +1 −1 sample/src/main/res/layout/{fragment_loopbar_vertical.xml → fragment_loopbar_vertical_left.xml}
  26. +69 −0 sample/src/main/res/layout/fragment_loopbar_vertical_right.xml
@@ -11,5 +11,6 @@ Version | Changes
v.1.1.1 | <ul><li>Added ability to change scroll mode</li><li>Fixed overlay feature</li><li>Updated start position in Infinite scroll mode</li><li>Removed unused dependencies</li><li>Updated versions of dependencies</li><li>unused or old methods were marked as deprecated</li><li>Added auto resize selector logic for different size of items support</li><li>Removed start and end shadows</li></ul>
v.1.1.2 | <ul><li>Added SDK v.15 support</li><ul>
v.1.1.3 | <ul><li>Fixed crashes with empty adapter</li><li>Fixed crashes without adapter</li><ul>
v.1.1.4 | <ul><li>Added loopbar orientation top and right </li><li>Update buildToolsVersion to 25.0.3</li></ul>

<br />
@@ -35,7 +35,6 @@ dependencies {
final SUPPORT_LIB_VERSION = '25.1.1'

compile fileTree(include: ['*.jar'], dir: 'libs')

//noinspection GradleCompatible
compile "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
//noinspection GradleCompatible
@@ -22,7 +22,7 @@
static final int VIEW_TYPE_OTHER = 0;
private static final int VIEW_TYPE_RESERVED_HIDDEN = -1;
@Orientation
private int mOrientation = Orientation.ORIENTATION_VERTICAL;
private int mOrientation = Orientation.ORIENTATION_VERTICAL_LEFT;

private RecyclerView.Adapter<? extends RecyclerView.ViewHolder> mInputAdapter;

@@ -103,7 +103,7 @@ public int getItemViewType(int position) {
RecyclerView.ViewHolder viewHolder = mInputAdapter.createViewHolder(parent, viewType);
CategoriesHolder categoriesHolder = new CategoriesHolder(viewHolder);

if (mOrientation == Orientation.ORIENTATION_VERTICAL) {
if (mOrientation == Orientation.ORIENTATION_VERTICAL_LEFT || mOrientation == Orientation.ORIENTATION_VERTICAL_RIGHT) {
//if mOrientation vertical set layout params to MATCH_PARENT to center item in view
ViewGroup.LayoutParams layoutParams = viewHolder.itemView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
@@ -19,7 +19,7 @@
static final int VIEW_TYPE_CHANGE_SCROLL_MODE = 2;
private static final int VIEW_TYPE_OFFSET = 1;
@Orientation
private int mOrientation = Orientation.ORIENTATION_VERTICAL;
private int mOrientation = Orientation.ORIENTATION_VERTICAL_LEFT;
private CategoriesAdapter mInputAdapter;
private boolean mIsIndeterminate = true;
@LoopBarView.GravityAttr
@@ -160,7 +160,7 @@ int normalizePosition(int position) {


private View createHeaderView(ViewGroup parent) {
@LayoutRes int layoutId = mOrientation == Orientation.ORIENTATION_VERTICAL
@LayoutRes int layoutId = mOrientation == Orientation.ORIENTATION_VERTICAL_LEFT
? R.layout.enls_empty_header_vertical
: R.layout.enls_empty_header_horizontal;
return LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
@@ -181,7 +181,7 @@ protected void onBindItem(IOperationItem item, int position) {
int size = mChangeSizeCallback.getHeaderSize();
if (size > 0) {
ViewGroup.LayoutParams layoutParams = itemView.getLayoutParams();
if (mChangeSizeCallback.getOrientation() == Orientation.ORIENTATION_HORIZONTAL) {
if (mChangeSizeCallback.getOrientation() == Orientation.ORIENTATION_HORIZONTAL_BOTTOM) {
layoutParams.width = size;
} else {
layoutParams.height = size;
@@ -17,8 +17,10 @@
* Returns current orientation state
*
* @return One of {@link Orientation}
* @see Orientation#ORIENTATION_HORIZONTAL
* @see Orientation#ORIENTATION_VERTICAL
* @see Orientation#ORIENTATION_HORIZONTAL_BOTTOM
* @see Orientation#ORIENTATION_HORIZONTAL_TOP
* @see Orientation#ORIENTATION_VERTICAL_LEFT
* @see Orientation#ORIENTATION_VERTICAL_RIGHT
*/
@Orientation
int getOrientation();
@@ -148,6 +148,8 @@
@ScrollAttr
private int mScrollMode;

private int mOrientation;

private IndeterminateOnScrollListener mIndeterminateOnScrollListener = new IndeterminateOnScrollListener(this);

public LoopBarView(Context context) {
@@ -189,8 +191,8 @@ private void init(Context context, @Nullable AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LoopBarView);
mColorCodeSelectionView = typedArray.getColor(R.styleable.LoopBarView_enls_selectionBackground,
ContextCompat.getColor(getContext(), android.R.color.holo_blue_dark));
int orientation = typedArray
.getInteger(R.styleable.LoopBarView_enls_orientation, Orientation.ORIENTATION_HORIZONTAL);
mOrientation = typedArray
.getInteger(R.styleable.LoopBarView_enls_orientation, Orientation.ORIENTATION_HORIZONTAL_BOTTOM);
int selectionAnimatorInId = typedArray
.getResourceId(R.styleable.LoopBarView_enls_selectionInAnimation, R.animator.enls_scale_restore);
int selectionAnimatorOutId = typedArray
@@ -205,7 +207,6 @@ private void init(Context context, @Nullable AttributeSet attrs) {
mInfinite ? SCROLL_MODE_INFINITE : SCROLL_MODE_FINITE);
mScrollMode = scrollMode;


mSelectionMargin = typedArray.getDimensionPixelSize(R.styleable.LoopBarView_enls_selectionMargin,
getResources().getDimensionPixelSize(R.dimen.enls_margin_selected_view));
mOverlaySize = typedArray.getDimensionPixelSize(R.styleable.LoopBarView_enls_overlaySize, 0);
@@ -220,8 +221,8 @@ private void init(Context context, @Nullable AttributeSet attrs) {
mSelectionInAnimator = AnimatorInflater.loadAnimator(getContext(), selectionAnimatorInId);
mSelectionOutAnimator = AnimatorInflater.loadAnimator(getContext(), selectionAnimatorOutId);

//current view has two state : horizontal & vertical. State design pattern
mOrientationState = getOrientationStateFromParam(orientation);
//current view has four state : horizontalBottom, horizontalTop & verticalLeft, verticalRight. State design pattern
mOrientationState = getOrientationStateFromParam(mOrientation);
inflate(mOrientationState, mPlaceHolderId, backgroundResource);
setGravity(selectionGravity);

@@ -247,6 +248,31 @@ private void init(Context context, @Nullable AttributeSet attrs) {
typedArray.recycle();
}

/**
* Sets orientation of loopbar
*
* @param orientation int value of orientation. Must be one of {@link Orientation}
*/
public final void setOrientation(int orientation) {
mOrientation = orientation;
mOrientationState = getOrientationStateFromParam(mOrientation);
invalidate();
if (mOuterAdapter != null) {
mOuterAdapter.setOrientation(mOrientation);
}

}

/**
* Gets current value of orientation
*
* @return int constant representing current orientation of loopbar
* Will be one of {@link Orientation}
*/
public final int getOrientation() {
return mOrientation;
}

/**
* Gets current value of selector gravity
*
@@ -744,7 +770,7 @@ public void setCurrentItem(int currentItemPosition, boolean isInvokeListeners) {
}

/**
* Select item by its' position
* Select item by it's position
*
* @param position int value of item position to select
* @param invokeListeners boolean value for invoking listeners
@@ -784,7 +810,7 @@ public void selectItem(int position, boolean invokeListeners) {
}

/**
* Select item by its' position. Listeners will be invoked
* Select item by it's position. Listeners will be invoked
*
* @param position int value of item position to select
*/
@@ -795,9 +821,18 @@ public void onItemClicked(int position) {

//orientation state factory method
public IOrientationState getOrientationStateFromParam(int orientation) {
return orientation == Orientation.ORIENTATION_VERTICAL
? new OrientationStateVertical()
: new OrientationStateHorizontal();
switch (orientation) {
case Orientation.ORIENTATION_HORIZONTAL_BOTTOM:
return new OrientationStateHorizontalBottom();
case Orientation.ORIENTATION_HORIZONTAL_TOP:
return new OrientationStateHorizontalTop();
case Orientation.ORIENTATION_VERTICAL_LEFT:
return new OrientationStateVerticalLeft();
case Orientation.ORIENTATION_VERTICAL_RIGHT:
return new OrientationStateVerticalRight();
default:
return new OrientationStateHorizontalBottom();
}
}

private void checkAndScroll() {
@@ -8,17 +8,28 @@
/**
* Interface with pre-defined constants for orientation of LoopBar
*/
@IntDef({Orientation.ORIENTATION_VERTICAL, Orientation.ORIENTATION_HORIZONTAL})
@IntDef({Orientation.ORIENTATION_VERTICAL_LEFT, Orientation.ORIENTATION_VERTICAL_RIGHT,
Orientation.ORIENTATION_HORIZONTAL_TOP, Orientation.ORIENTATION_HORIZONTAL_BOTTOM})
@Retention(RetentionPolicy.SOURCE)
public @interface Orientation {


/**
* Constant representing vertical left orientation state of LoopBar
*/
int ORIENTATION_VERTICAL_LEFT = 0;

/**
* Constant representing vertical right orientation state of LoopBar
*/
int ORIENTATION_VERTICAL_RIGHT = 1;

/**
* Constant representing vertical orientation state of LoopBar
* Constant representing horizontal top orientation state of LoopBar
*/
int ORIENTATION_VERTICAL = 0;
int ORIENTATION_HORIZONTAL_TOP = 2;

/**
* Constant representing horizontal orientation state of LoopBar
* Constant representing horizontal bottom orientation state of LoopBar
*/
int ORIENTATION_HORIZONTAL = 1;
int ORIENTATION_HORIZONTAL_BOTTOM = 3;
}
@@ -12,11 +12,11 @@

import java.util.UnknownFormatFlagsException;

class OrientationStateHorizontal extends AbstractOrientationState implements IOrientationState {
class OrientationStateHorizontalBottom extends AbstractOrientationState implements IOrientationState {

private Integer itemWidth;

OrientationStateHorizontal() {
OrientationStateHorizontalBottom() {
}

@Override
@@ -26,7 +26,7 @@ public LinearLayoutManager getLayoutManager(Context context) {

@Override
public int getLayoutId() {
return R.layout.enls_view_categories_navigation_horizontal;
return R.layout.enls_view_categories_navigation_horizontal_bottom;
}

@Override
@@ -74,7 +74,7 @@ public AbstractSpacesItemDecoration getSelectionViewItemDecoration(int margin, i

@Override
public int getOrientation() {
return Orientation.ORIENTATION_HORIZONTAL;
return Orientation.ORIENTATION_HORIZONTAL_BOTTOM;
}

@Override
@@ -0,0 +1,11 @@
package com.cleveroad.loopbar.widget;

import com.cleveroad.loopbar.R;

public class OrientationStateHorizontalTop extends OrientationStateHorizontalBottom {

@Override
public int getLayoutId() {
return R.layout.enls_view_categories_navigation_horizontal_top;
}
}
@@ -12,11 +12,11 @@

import java.util.UnknownFormatFlagsException;

class OrientationStateVertical extends AbstractOrientationState implements IOrientationState {
class OrientationStateVerticalLeft extends AbstractOrientationState implements IOrientationState {

private Integer itemHeight;

OrientationStateVertical() {
OrientationStateVerticalLeft() {
}

@Override
@@ -26,7 +26,7 @@ public LinearLayoutManager getLayoutManager(Context context) {

@Override
public int getLayoutId() {
return R.layout.enls_view_categories_navigation_vertical;
return R.layout.enls_view_categories_navigation_vertical_left;
}

@Override
@@ -90,7 +90,7 @@ private int calcItemHeight(RecyclerView rvCategories) {

@Override
public int getOrientation() {
return Orientation.ORIENTATION_VERTICAL;
return Orientation.ORIENTATION_VERTICAL_LEFT;
}

@Override
@@ -0,0 +1,10 @@
package com.cleveroad.loopbar.widget;

import com.cleveroad.loopbar.R;

public class OrientationStateVerticalRight extends OrientationStateVerticalLeft {
@Override
public int getLayoutId() {
return R.layout.enls_view_categories_navigation_vertical_right;
}
}
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0dp"
android:top="0dp"/>

<solid android:color="#00CCCCCC"/>

</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0dp"
android:top="0dp"/>

<solid android:color="#102A2A2A"/>

</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0dp"
android:top="0dp"/>

<solid android:color="#202A2A2A"/>

</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0dp"
android:top="0dp"/>

<solid android:color="#302A2A2A"/>

</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0dp"
android:top="0dp"/>

<solid android:color="#502A2A2A"/>

</shape>
</item>

<!-- Background -->
<item>
<shape>
<solid android:color="#FFFFFF"/>

</shape>
</item>

</layer-list>
Oops, something went wrong.

0 comments on commit 824af26

Please sign in to comment.
You can’t perform that action at this time.