From e64001a130bd2e2a3ef7d412b6be4bd777408e29 Mon Sep 17 00:00:00 2001
From: Davide Steduto
Date: Sat, 16 Dec 2017 14:30:51 +0100
Subject: [PATCH] Resolved #501 - Moved some common classes to UI package
---
.../common/FlexibleItemAnimator.java | 0
.../common/FlexibleItemDecoration.java | 0
.../common/SmoothScrollGridLayoutManager.java | 0
.../SmoothScrollLinearLayoutManager.java | 0
.../SmoothScrollStaggeredLayoutManager.java | 0
.../common/TopSnappedSmoothScroller.java | 0
.../flexibleadapter/AnimatorAdapter.java | 42 ++++++++++---------
.../flexibleadapter/FlexibleAdapter.java | 8 ++--
.../viewholders/AnimatedViewHolder.java | 14 +++----
.../viewholders/FlexibleViewHolder.java | 2 +-
10 files changed, 31 insertions(+), 35 deletions(-)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemAnimator.java (100%)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemDecoration.java (100%)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollGridLayoutManager.java (100%)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollLinearLayoutManager.java (100%)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollStaggeredLayoutManager.java (100%)
rename {flexible-adapter => flexible-adapter-ui}/src/main/java/eu/davidea/flexibleadapter/common/TopSnappedSmoothScroller.java (100%)
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemAnimator.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemAnimator.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemAnimator.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemAnimator.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemDecoration.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemDecoration.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemDecoration.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/FlexibleItemDecoration.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollGridLayoutManager.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollGridLayoutManager.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollGridLayoutManager.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollGridLayoutManager.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollLinearLayoutManager.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollLinearLayoutManager.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollLinearLayoutManager.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollLinearLayoutManager.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollStaggeredLayoutManager.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollStaggeredLayoutManager.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollStaggeredLayoutManager.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/SmoothScrollStaggeredLayoutManager.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/TopSnappedSmoothScroller.java b/flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/TopSnappedSmoothScroller.java
similarity index 100%
rename from flexible-adapter/src/main/java/eu/davidea/flexibleadapter/common/TopSnappedSmoothScroller.java
rename to flexible-adapter-ui/src/main/java/eu/davidea/flexibleadapter/common/TopSnappedSmoothScroller.java
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/AnimatorAdapter.java b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/AnimatorAdapter.java
index 5740d695..9fc6977a 100644
--- a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/AnimatorAdapter.java
+++ b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/AnimatorAdapter.java
@@ -285,9 +285,9 @@ public boolean isOnlyEntryAnimation() {
return onlyEntryAnimation;
}
- /*--------------*/
+ /*--------------*/
/* MAIN METHODS */
- /*--------------*/
+ /*--------------*/
/**
* Cancels any existing animations for given View. Useful when fling.
@@ -328,10 +328,10 @@ protected final void animateView(final RecyclerView.ViewHolder holder, final int
isForwardEnabled = false;
}
int lastVisiblePosition = getFlexibleLayoutManager().findLastVisibleItemPosition();
-// log.v("isForwardEnabled=%s isFastScroll=%s isNotified=%s isReverseEnabled=%s mLastAnimatedPosition=%s %s mMaxChildViews=%s",
-// isForwardEnabled, isFastScroll, mAnimatorNotifierObserver.isPositionNotified(), isReverseEnabled, mLastAnimatedPosition,
-// (!isReverseEnabled ? " Pos>LasVisPos=" + (position > lastVisiblePosition) : ""), mMaxChildViews
-// );
+ log.v("isForwardEnabled=%s isReverseEnabled=%s isFastScroll=%s isNotified=%s mLastAnimatedPosition=%s mMaxChildViews=%s %s",
+ isForwardEnabled, isReverseEnabled, isFastScroll, mAnimatorNotifierObserver.isPositionNotified(), mLastAnimatedPosition,
+ mMaxChildViews, (!isReverseEnabled ? " Pos>LasVisPos=" + (position > lastVisiblePosition) : "")
+ );
if ((isForwardEnabled || isReverseEnabled)
&& !isFastScroll && holder instanceof FlexibleViewHolder
&& !mAnimatorNotifierObserver.isPositionNotified()
@@ -360,7 +360,7 @@ protected final void animateView(final RecyclerView.ViewHolder holder, final int
duration = animator.getDuration();
}
}
- //log.v("duration=%s", duration);
+ log.v("duration=%s", duration);
set.setDuration(duration);
set.addListener(new HelperAnimatorListener(hashCode));
if (mEntryStep) {
@@ -369,7 +369,7 @@ protected final void animateView(final RecyclerView.ViewHolder holder, final int
}
set.start();
mAnimators.put(hashCode, set);
- //log.v("animateView Scroll animation on position %s", position);
+ log.v("animateView Scroll animation on position %s", position);
}
mAnimatorNotifierObserver.clearNotified();
// Update last animated position
@@ -396,9 +396,12 @@ private long calculateAnimationDelay(int position) {
int visibleItems = lastVisiblePosition - firstVisiblePosition;
int numberOfAnimatedItems = position - 1;
- if (mMaxChildViews == 0 || visibleItems < numberOfAnimatedItems || //Normal Forward scrolling after max itemOnScreen is reached
- (firstVisiblePosition > 1 && firstVisiblePosition <= mMaxChildViews) || //Reverse scrolling
- (position > mMaxChildViews && firstVisiblePosition == -1 && mRecyclerView.getChildCount() == 0)) { //Reverse scrolling and click on FastScroller
+ // Normal Forward scrolling after max itemOnScreen is reached
+ if (mMaxChildViews == 0 || visibleItems < numberOfAnimatedItems ||
+ // Reverse scrolling
+ (firstVisiblePosition > 1 && firstVisiblePosition <= mMaxChildViews) ||
+ // Reverse scrolling and click on FastScroller
+ (position > mMaxChildViews && firstVisiblePosition == -1 && mRecyclerView.getChildCount() == 0)) {
// Base delay is step delay
delay = mStepDelay;
@@ -415,20 +418,20 @@ private long calculateAnimationDelay(int position) {
delay = mInitialDelay + mStepDelay * (position % numColumns);
}
- } else { //forward scrolling before max itemOnScreen is reached
+ } else { // Forward scrolling before max itemOnScreen is reached
delay = mInitialDelay + (position * mStepDelay);
}
-// log.v("Delay[%s]=%s FirstVisible=%s LastVisible=%s LastAnimated=%s VisibleItems=%s ChildCount=%s MaxChildCount=%s",
-// position, delay, firstVisiblePosition, lastVisiblePosition, numberOfAnimatedItems,
-// visibleItems, mRecyclerView.getChildCount(), mMaxChildViews);
+ log.v("Delay[%s]=%s FirstVisible=%s LastVisible=%s LastAnimated=%s VisibleItems=%s ChildCount=%s MaxChildCount=%s",
+ position, delay, firstVisiblePosition, lastVisiblePosition, numberOfAnimatedItems,
+ visibleItems, mRecyclerView.getChildCount(), mMaxChildViews);
return delay;
}
- /*---------------*/
- /* INNER CLASSES */
- /*---------------*/
+ /*---------------*/
+ /* INNER CLASSES */
+ /*---------------*/
/**
* Observer Class responsible to skip animation when items are notified to avoid
@@ -458,8 +461,7 @@ public void clearNotified() {
private void markNotified() {
notified = !animateFromObserver;
-// if (DEBUG)
-// log.v(TAG, "animateFromObserver=" + animateFromObserver + " notified=" + notified);
+ //log.v(TAG, "animateFromObserver=" + animateFromObserver + " notified=" + notified);
}
@Override
diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java
index 2725fd48..3c4e15c6 100644
--- a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java
+++ b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java
@@ -43,8 +43,6 @@
import java.util.Map;
import java.util.Set;
-import eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager;
-import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
import eu.davidea.flexibleadapter.helpers.ItemTouchHelperCallback;
import eu.davidea.flexibleadapter.helpers.StickyHeaderHelper;
import eu.davidea.flexibleadapter.items.IExpandable;
@@ -2164,8 +2162,8 @@ public boolean isAutoScrollOnExpand() {
/**
* Automatically scroll the clicked expandable item to the first visible position.
* Default value is {@code false} (disabled).
- * Note: This works ONLY in combination with {@link SmoothScrollLinearLayoutManager}
- * or with {@link SmoothScrollGridLayoutManager}.
+ * Note: This works ONLY in combination with {@code SmoothScrollLinearLayoutManager}
+ * or with {@code SmoothScrollGridLayoutManager} available in UI extension.
*
* @param scrollOnExpand true to enable automatic scroll, false to disable
* @return this Adapter, so the call can be chained
@@ -3770,7 +3768,7 @@ public String getSearchText() {
/**
* Sets the new search text.
* Note: Text is always trimmed and lowercase.
- * Tip: You can highlight filtered Text or Words using {@code FlexibleUtils} from UI package:
+ *
Tip: You can highlight filtered Text or Words using {@code FlexibleUtils} from UI extension:
*
- {@code FlexibleUtils#highlightText(TextView, String, String)}
* - {@code FlexibleUtils#highlightWords(TextView, String, String)}
*
diff --git a/flexible-adapter/src/main/java/eu/davidea/viewholders/AnimatedViewHolder.java b/flexible-adapter/src/main/java/eu/davidea/viewholders/AnimatedViewHolder.java
index 26f3a9ef..f04a36a1 100644
--- a/flexible-adapter/src/main/java/eu/davidea/viewholders/AnimatedViewHolder.java
+++ b/flexible-adapter/src/main/java/eu/davidea/viewholders/AnimatedViewHolder.java
@@ -16,18 +16,14 @@
package eu.davidea.viewholders;
import android.support.v4.view.ViewPropertyAnimatorListener;
-import android.support.v7.widget.RecyclerView;
-
-import eu.davidea.flexibleadapter.common.FlexibleItemAnimator;
/**
* Interface for {@code itemView} addition/removal animation.
- * Used by {@link FlexibleItemAnimator} when notify events occur. If any of these methods
+ *
Used by {@code FlexibleItemAnimator} when notify events occur. If any of these methods
* are implemented, the ItemAnimator extending FlexibleItemAnimator is skipped in favour of this
* ViewHolder implementation.
*
* @author Davide Steduto
- * @see FlexibleItemAnimator
* @since 26/08/2016 Created
*/
public interface AnimatedViewHolder {
@@ -35,7 +31,7 @@ public interface AnimatedViewHolder {
/**
* Prepares the View for Add Animation. If this method is implemented and returns
* {@code true}, then this method is performed against
- * {@link FlexibleItemAnimator#preAnimateAddImpl(RecyclerView.ViewHolder)} which will be ignored.
+ * {@code FlexibleItemAnimator#preAnimateAddImpl(RecyclerView.ViewHolder)} which will be ignored.
* Default value is {@code false}.
*
* @return {@code true} to confirm the execution of {@link #animateAddImpl(ViewPropertyAnimatorListener, long, int)},
@@ -47,7 +43,7 @@ public interface AnimatedViewHolder {
/**
* Prepares the View for Remove Animation. If this method is implemented and returns
* {@code true}, then this method is performed against
- * {@link FlexibleItemAnimator#preAnimateRemoveImpl(RecyclerView.ViewHolder)} which will be ignored.
+ * {@code FlexibleItemAnimator#preAnimateRemoveImpl(RecyclerView.ViewHolder)} which will be ignored.
* Default value is {@code false}.
*
* @return {@code true} to confirm the execution of {@link #animateRemoveImpl(ViewPropertyAnimatorListener, long, int)},
@@ -77,8 +73,8 @@ public interface AnimatedViewHolder {
*
* @param listener should assign to {@code ViewCompat.animate().setListener(listener)}
* @param removeDuration duration of remove animation
- * @param index order of execution, starts with 0 @return {@code true} to animate with this implementation, {@code false} to use the generic
- * animation.
+ * @param index order of execution, starts with 0 @return {@code true} to animate with this
+ * implementation, {@code false} to use the generic animation.
* @since 5.0.0-b8
*/
boolean animateRemoveImpl(ViewPropertyAnimatorListener listener, long removeDuration, int index);
diff --git a/flexible-adapter/src/main/java/eu/davidea/viewholders/FlexibleViewHolder.java b/flexible-adapter/src/main/java/eu/davidea/viewholders/FlexibleViewHolder.java
index e112f71b..8a67dc03 100644
--- a/flexible-adapter/src/main/java/eu/davidea/viewholders/FlexibleViewHolder.java
+++ b/flexible-adapter/src/main/java/eu/davidea/viewholders/FlexibleViewHolder.java
@@ -205,7 +205,7 @@ protected void setDragHandleView(@NonNull View view) {
* Important note! the selected background is visible if you added
* {@code android:background="?attr/selectableItemBackground"} in the item layout AND
* customized the file {@code style.xml}.
- * Alternatively, to set a background at runtime, you can use the new {@code DrawableUtils} from UI package.
+ * Alternatively, to set a background at runtime, you can use the new {@code DrawableUtils} from UI extension.
* Note: This method must be called every time we want the activation state visible
* on the itemView, for instance: after a Click (to add the item to the selection list) or
* after a LongClick (to activate the ActionMode) or during dragging (to show that we enabled