本文整理汇总了Java中eu.davidea.viewholders.FlexibleViewHolder类的典型用法代码示例。如果您正苦于以下问题:Java FlexibleViewHolder类的具体用法?Java FlexibleViewHolder怎么用?Java FlexibleViewHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlexibleViewHolder类属于eu.davidea.viewholders包,在下文中一共展示了FlexibleViewHolder类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resetHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void resetHeader(FlexibleViewHolder header) {
restoreHeaderItemVisibility();
// Clean the header container
final View view = header.getContentView();
removeViewFromParent(view);
// Reset translation on removed header
view.setTranslationX(0);
view.setTranslationY(0);
if (!header.itemView.equals(view)) {
addViewToParent(((ViewGroup) header.itemView), view);
}
header.setIsRecyclable(true);
// #294 - Expandable header is not resized / redrawn on automatic configuration change when sticky headers are enabled
header.itemView.getLayoutParams().width = view.getLayoutParams().width;
header.itemView.getLayoutParams().height = view.getLayoutParams().height;
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:17,代码来源:StickyHeaderHelper.java
示例2: onBindViewHolder
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
// Bind the correct view elevation
if (holder instanceof FlexibleViewHolder) {
FlexibleViewHolder flexHolder = (FlexibleViewHolder) holder;
flexHolder.getContentView().setActivated(isSelected(position));
if (flexHolder.getContentView().isActivated() && flexHolder.getActivationElevation() > 0)
ViewCompat.setElevation(flexHolder.getContentView(), flexHolder.getActivationElevation());
else if (flexHolder.getActivationElevation() > 0) //Leave unaltered the default elevation
ViewCompat.setElevation(flexHolder.getContentView(), 0);
mBoundViewHolders.add(flexHolder);
} else {
// When user scrolls, this line binds the correct selection status
holder.itemView.setActivated(isSelected(position));
}
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:17,代码来源:SelectableAdapter.java
示例3: updateHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void updateHeader(int headerPosition, boolean updateHeaderContent) {
// Check if there is a new header to be sticky
if (mHeaderPosition != headerPosition) {
// #244 - Don't animate if header is already visible at the first layout position
int firstVisibleItemPosition = Utils.findFirstVisibleItemPosition(mRecyclerView.getLayoutManager());
// Animate if headers were hidden, but don't if configuration changed (rotation)
if (displayWithAnimation && mHeaderPosition == RecyclerView.NO_POSITION &&
headerPosition != firstVisibleItemPosition) {
displayWithAnimation = false;
mStickyHolderLayout.setAlpha(0);
mStickyHolderLayout.animate().alpha(1).start();
} else {
mStickyHolderLayout.setAlpha(1);
}
mHeaderPosition = headerPosition;
FlexibleViewHolder holder = getHeaderViewHolder(headerPosition);
if (FlexibleAdapter.DEBUG)
Log.d(TAG, "swapHeader newHeaderPosition=" + mHeaderPosition);
swapHeader(holder);
} else if (updateHeaderContent) {
// #299 - ClassCastException after click on expanded sticky header when AutoCollapse is enabled
// mStickyHeaderViewHolder = getHeaderViewHolder(headerPosition);
// mStickyHeaderViewHolder.setBackupPosition(headerPosition);
// mAdapter.onBindViewHolder(mStickyHeaderViewHolder, headerPosition);
// ensureHeaderParent();
//FIXME: update viewHolder when sticky
}
translateHeader();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:StickyHeaderHelper.java
示例4: swapHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void swapHeader(FlexibleViewHolder newHeader) {
if (mStickyHeaderViewHolder != null) {
resetHeader(mStickyHeaderViewHolder);
}
mStickyHeaderViewHolder = newHeader;
if (mStickyHeaderViewHolder != null) {
mStickyHeaderViewHolder.setIsRecyclable(false);
ensureHeaderParent();
}
onStickyHeaderChange(mHeaderPosition);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:StickyHeaderHelper.java
示例5: resetHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void resetHeader(FlexibleViewHolder header) {
restoreHeaderItemVisibility();
// Clean the header container
final View view = header.getContentView();
removeViewFromParent(view);
// Reset translation on removed header
view.setTranslationX(0);
view.setTranslationY(0);
if (!header.itemView.equals(view))
((ViewGroup) header.itemView).addView(view);
header.setIsRecyclable(true);
// #294 - Expandable header is not resized / redrawn on automatic configuration change when sticky headers are enabled
header.itemView.getLayoutParams().width = view.getLayoutParams().width;
header.itemView.getLayoutParams().height = view.getLayoutParams().height;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:StickyHeaderHelper.java
示例6: notifySelectionChanged
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void notifySelectionChanged(int positionStart, int itemCount) {
if (itemCount > 0) {
// Avoid to rebind the VH, direct call to the itemView activation
for (FlexibleViewHolder holder : mBoundViewHolders) {
if (isSelectable(holder.getAdapterPosition()))
holder.toggleActivation();
}
// Use classic notification, in case FlexibleViewHolder is not implemented
if (mBoundViewHolders.isEmpty())
notifyItemRangeChanged(positionStart, itemCount, Payload.SELECTION);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:SelectableAdapter.java
示例7: onBindViewHolder
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
// When user scrolls, this line binds the correct selection status
holder.itemView.setActivated(isSelected(position));
// Bind the correct view elevation
if (holder instanceof FlexibleViewHolder) {
FlexibleViewHolder flexHolder = (FlexibleViewHolder) holder;
if (holder.itemView.isActivated() && flexHolder.getActivationElevation() > 0)
ViewCompat.setElevation(holder.itemView, flexHolder.getActivationElevation());
else if (flexHolder.getActivationElevation() > 0) //Leave unaltered the default elevation
ViewCompat.setElevation(holder.itemView, 0);
mBoundViewHolders.add(flexHolder);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SelectableAdapter.java
示例8: updateHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void updateHeader(int headerPosition, boolean updateHeaderContent) {
// Check if there is a new header to be sticky
if (mHeaderPosition != headerPosition && mStickyHolderLayout != null) {
// #244 - Don't animate if header is already visible at the first layout position
int firstVisibleItemPosition = mAdapter.getFlexibleLayoutManager().findFirstVisibleItemPosition();
// Animate if headers were hidden, but don't if configuration changed (rotation)
if (displayWithAnimation && mHeaderPosition == RecyclerView.NO_POSITION &&
headerPosition != firstVisibleItemPosition) {
displayWithAnimation = false;
mStickyHolderLayout.setAlpha(0);
mStickyHolderLayout.animate().alpha(1).start();
} else {
mStickyHolderLayout.setAlpha(1);
}
int oldHeaderPosition = mHeaderPosition;
mHeaderPosition = headerPosition;
FlexibleViewHolder holder = getHeaderViewHolder(headerPosition);
Log.d("swapHeader newHeaderPosition=%s", mHeaderPosition);
swapHeader(holder, oldHeaderPosition);
} else if (updateHeaderContent) {
// #299 - ClassCastException after click on expanded sticky header when AutoCollapse is enabled
// mStickyHeaderViewHolder = getHeaderViewHolder(headerPosition);
// mStickyHeaderViewHolder.setBackupPosition(headerPosition);
mAdapter.onBindViewHolder(mStickyHeaderViewHolder, headerPosition);
ensureHeaderParent();
}
translateHeader();
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:29,代码来源:StickyHeaderHelper.java
示例9: swapHeader
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void swapHeader(FlexibleViewHolder newHeader, int oldHeaderPosition) {
if (mStickyHeaderViewHolder != null) {
resetHeader(mStickyHeaderViewHolder);
}
mStickyHeaderViewHolder = newHeader;
mStickyHeaderViewHolder.setIsRecyclable(false);
ensureHeaderParent();
onStickyHeaderChange(mHeaderPosition, oldHeaderPosition);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:10,代码来源:StickyHeaderHelper.java
示例10: notifySelectionChanged
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
private void notifySelectionChanged(int positionStart, int itemCount) {
if (itemCount > 0) {
// Avoid to rebind the VH, direct call to the itemView activation
for (FlexibleViewHolder flexHolder : mBoundViewHolders) {
flexHolder.toggleActivation();
}
// Use classic notification, in case FlexibleViewHolder is not implemented
if (mBoundViewHolders.isEmpty())
notifyItemRangeChanged(positionStart, itemCount, Payload.SELECTION);
}
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:12,代码来源:SelectableAdapter.java
示例11: onViewRecycled
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
if (holder instanceof FlexibleViewHolder)
mBoundViewHolders.remove(holder);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SelectableAdapter.java
示例12: animateView
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
/**
* Performs checks to scroll animate the itemView and in case, it animates the view.
* <p><b>Note:</b> If you have to change at runtime the LayoutManager <i>and</i> add
* Scrollable Headers too, consider to add them in post, using a {@code delay >= 0},
* otherwise scroll animations on all items will not start correctly.</p>
*
* @param holder the ViewHolder just bound
* @param position the current item position
*/
@SuppressWarnings("ConstantConditions")
protected final void animateView(final RecyclerView.ViewHolder holder, final int position) {
if (mRecyclerView == null) return;
// Use always the max child count reached
if (mMaxChildViews < mRecyclerView.getChildCount()) {
mMaxChildViews = mRecyclerView.getChildCount();
}
// Animate only during initial loading?
if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
shouldAnimate = false;
}
int lastVisiblePosition = Utils.findLastVisibleItemPosition(mRecyclerView.getLayoutManager());
// if (DEBUG) {
// Log.v(TAG, "shouldAnimate=" + shouldAnimate
// + " isFastScroll=" + isFastScroll
// + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified()
// + " isReverseEnabled=" + isReverseEnabled
// + " mLastAnimatedPosition=" + mLastAnimatedPosition
// + (!isReverseEnabled ? " Pos>LasVisPos=" + (position > lastVisiblePosition) : "")
// + " mMaxChildViews=" + mMaxChildViews
// );
// }
if (holder instanceof FlexibleViewHolder && shouldAnimate && !isFastScroll &&
!mAnimatorNotifierObserver.isPositionNotified() &&
(position > lastVisiblePosition || isReverseEnabled || isScrollableHeaderOrFooter(position) || (position == 0 && mMaxChildViews == 0))) {
// Cancel animation is necessary when fling
int hashCode = holder.itemView.hashCode();
cancelExistingAnimation(hashCode);
// User animators
List<Animator> animators = new ArrayList<>();
FlexibleViewHolder flexibleViewHolder = (FlexibleViewHolder) holder;
flexibleViewHolder.scrollAnimators(animators, position, position >= lastVisiblePosition);
// Execute the animations together
AnimatorSet set = new AnimatorSet();
set.playTogether(animators);
set.setInterpolator(mInterpolator);
// Single view duration
long duration = mDuration;
for (Animator animator : animators) {
if (animator.getDuration() != DEFAULT_DURATION) {
duration = animator.getDuration();
}
}
//Log.v(TAG, "duration=" + duration);
set.setDuration(duration);
set.addListener(new HelperAnimatorListener(hashCode));
if (mEntryStep) {
// Stop stepDelay when screen is filled
set.setStartDelay(calculateAnimationDelay(position));
}
set.start();
mAnimators.put(hashCode, set);
if (DEBUG) Log.v(TAG, "animateView Scroll animation on position " + position);
}
mAnimatorNotifierObserver.clearNotified();
// Update last animated position
mLastAnimatedPosition = position;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:72,代码来源:AnimatorAdapter.java
示例13: createViewHolder
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public FlexibleViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
return null;
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:5,代码来源:ItemComparatorTest.java
示例14: onViewRecycled
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
if (holder instanceof FlexibleViewHolder)
mBoundViewHolders.remove(holder);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:6,代码来源:SelectableAdapter.java
示例15: animateView
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
/**
* Performs checks to scroll animate the itemView and in case, it animates the view.
* <p><b>Note:</b> If you have to change at runtime the LayoutManager <i>and</i> add
* Scrollable Headers too, consider to add them in post, using a {@code delay >= 0},
* otherwise scroll animations on all items will not start correctly.</p>
*
* @param holder the ViewHolder just bound
* @param position the current item position
* @since 5.0.0-b1
*/
protected final void animateView(final RecyclerView.ViewHolder holder, final int position) {
if (mRecyclerView == null) return;
// Use always the max child count reached
if (mMaxChildViews < mRecyclerView.getChildCount()) {
mMaxChildViews = mRecyclerView.getChildCount();
}
// Animate only during initial loading?
if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
isForwardEnabled = false;
}
int lastVisiblePosition = getFlexibleLayoutManager().findLastVisibleItemPosition();
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()
&& (isScrollableHeaderOrFooter(position)
|| (isForwardEnabled && position > lastVisiblePosition)
|| (isReverseEnabled && position < lastVisiblePosition)
|| (position == 0 && mMaxChildViews == 0))) {
// Cancel animation is necessary when fling
int hashCode = holder.itemView.hashCode();
cancelExistingAnimation(hashCode);
// User animators
List<Animator> animators = new ArrayList<>();
FlexibleViewHolder flexibleViewHolder = (FlexibleViewHolder) holder;
flexibleViewHolder.scrollAnimators(animators, position, position >= lastVisiblePosition);
// Execute the animations together
AnimatorSet set = new AnimatorSet();
set.playTogether(animators);
set.setInterpolator(mInterpolator);
// Single view duration
long duration = mDuration;
for (Animator animator : animators) {
if (animator.getDuration() != DEFAULT_DURATION) {
duration = animator.getDuration();
}
}
log.v("duration=%s", duration);
set.setDuration(duration);
set.addListener(new HelperAnimatorListener(hashCode));
if (mEntryStep) {
// Stop stepDelay when screen is filled
set.setStartDelay(calculateAnimationDelay(position));
}
set.start();
mAnimators.put(hashCode, set);
log.v("animateView Scroll animation on position %s", position);
}
mAnimatorNotifierObserver.clearNotified();
// Update last animated position
mLastAnimatedPosition = position;
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:70,代码来源:AnimatorAdapter.java
示例16: getAllBoundViewHolders
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
/**
* Usually {@code RecyclerView} binds 3 items more than the visible items.
*
* @return a Set with all bound FlexibleViewHolders
* @since 5.0.0-rc1
*/
public Set<FlexibleViewHolder> getAllBoundViewHolders() {
return Collections.unmodifiableSet(mBoundViewHolders);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SelectableAdapter.java
示例17: bindViewHolder
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
@Override
public void bindViewHolder(FlexibleAdapter adapter, FlexibleViewHolder holder, int position, List payloads) {
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:5,代码来源:ItemComparatorTest.java
示例18: getAllBoundViewHolders
import eu.davidea.viewholders.FlexibleViewHolder; //导入依赖的package包/类
/**
* Usually {@code RecyclerView} binds 3 items more than the visible items.
*
* @return a Set with all bound FlexibleViewHolders
* @since 5.0.0-rc1
*/
public Set<FlexibleViewHolder> getAllBoundViewHolders() {
return Collections.unmodifiableSet(mBoundViewHolders);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:10,代码来源:SelectableAdapter.java
注:本文中的eu.davidea.viewholders.FlexibleViewHolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论