Skip to content

Commit

Permalink
Resolved #501 - Moved some common classes to UI package
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed Dec 16, 2017
1 parent 939f051 commit e64001a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ public boolean isOnlyEntryAnimation() {
return onlyEntryAnimation;
}

/*--------------*/
/*--------------*/
/* MAIN METHODS */
/*--------------*/
/*--------------*/

/**
* Cancels any existing animations for given View. Useful when fling.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2164,8 +2162,8 @@ public boolean isAutoScrollOnExpand() {
/**
* Automatically scroll the clicked expandable item to the first visible position.<br>
* <p>Default value is {@code false} (disabled).</p>
* <b>Note:</b> This works ONLY in combination with {@link SmoothScrollLinearLayoutManager}
* or with {@link SmoothScrollGridLayoutManager}.
* <b>Note:</b> 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
Expand Down Expand Up @@ -3770,7 +3768,7 @@ public String getSearchText() {
/**
* Sets the new search text.
* <p><b>Note:</b> Text is always <b>trimmed</b> and <b>lowercase</b>.</p>
* <p><b>Tip:</b> You can highlight filtered Text or Words using {@code FlexibleUtils} from UI package:
* <p><b>Tip:</b> You can highlight filtered Text or Words using {@code FlexibleUtils} from UI extension:
* <ul><li>{@code FlexibleUtils#highlightText(TextView, String, String)}</li>
* <li>{@code FlexibleUtils#highlightWords(TextView, String, String)}</li></ul></p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,22 @@
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.
* <p>Used by {@link FlexibleItemAnimator} when notify events occur. If any of these methods
* <p>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.</p>
*
* @author Davide Steduto
* @see FlexibleItemAnimator
* @since 26/08/2016 Created
*/
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.
* <p>Default value is {@code false}.</p>
*
* @return {@code true} to confirm the execution of {@link #animateAddImpl(ViewPropertyAnimatorListener, long, int)},
Expand All @@ -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.
* <p>Default value is {@code false}.</p>
*
* @return {@code true} to confirm the execution of {@link #animateRemoveImpl(ViewPropertyAnimatorListener, long, int)},
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected void setDragHandleView(@NonNull View view) {
* <p><b>Important note!</b> the selected background is visible if you added
* {@code android:background="?attr/selectableItemBackground"} in the item layout <u>AND</u>
* customized the file {@code style.xml}.</p>
* 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.
* <p><b>Note:</b> 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
Expand Down

0 comments on commit e64001a

Please sign in to comment.