本文整理匯總了Java中android.support.v7.widget.RecyclerView.getChildViewHolder方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getChildViewHolder方法的具體用法?Java RecyclerView.getChildViewHolder怎麽用?Java RecyclerView.getChildViewHolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getChildViewHolder方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getItemOffsets
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
final Context context = recyclerView.getContext();
if(!registered) {
MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
registered = true;
}
int headerCells = 1;
//don't work with stagged
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if(layoutManager instanceof GridLayoutManager){
GridLayoutManager gridLayoutManager = (GridLayoutManager)layoutManager;
headerCells = gridLayoutManager.getSpanCount();
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
if (animator != null) {
if (holder.getAdapterPosition() < headerCells) {
outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
}
}
}
示例2: onDrawOver
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override public void onDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int childCount = parent.getChildCount();
if (childCount < 2) return;
RecyclerView.LayoutManager lm = parent.getLayoutManager();
float[] lines = new float[childCount * 4];
boolean hasDividers = false;
for (int i = 0; i < childCount; i++) {
View child = parent.getChildAt(i);
RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child);
if (!(viewHolder instanceof ProgressBarViewHolder)) {
boolean canDivide = toDivide == null || viewHolder.getClass() == toDivide;
if (canDivide) {
int position = parent.getChildAdapterPosition(child);
if (child.isActivated() || (i + 1 < childCount && parent.getChildAt(i + 1).isActivated())) {
continue;
}
if (position != (state.getItemCount() - 1)) {
lines[i * 4] = inset == 0 ? inset : inset + lm.getDecoratedLeft(child);
lines[(i * 4) + 2] = lm.getDecoratedRight(child);
int y = lm.getDecoratedBottom(child) + (int) child.getTranslationY() - height;
lines[(i * 4) + 1] = y;
lines[(i * 4) + 3] = y;
hasDividers = true;
}
}
}
}
if (hasDividers) {
canvas.drawLines(lines, paint);
}
}
示例3: hasDivider
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public boolean hasDivider(RecyclerView parent, View view) {
RecyclerView.ViewHolder holder = parent.getChildViewHolder(view);
int viewType = holder.getItemViewType();
return viewType != TYPE_HEADER && viewType != TYPE_TIP && !(viewType == TYPE_USER_RULE
&& ((RuleHolder) holder).mIsDragged);
}
示例4: releaseAllHolder
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 遍曆所有hodler,釋放他們需要釋放的資源
*
* @param recyclerView
*/
public static void releaseAllHolder(RecyclerView recyclerView) {
if (recyclerView == null) return;
for (int i = recyclerView.getChildCount() - 1; i >= 0; i--) {
final View view = recyclerView.getChildAt(i);
RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view);
if (viewHolder != null && viewHolder instanceof BaseHolder) {
((BaseHolder) viewHolder).onRelease();
}
}
}
示例5: releaseAllHolder
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 遍曆所有hodler,釋放他們需要釋放的資源,需要在super.onDestroy()之前調用
*
* @param recyclerView
*/
public static void releaseAllHolder(RecyclerView recyclerView) {
for (int i = recyclerView.getChildCount() - 1; i >= 0; i--) {
final View view = recyclerView.getChildAt(i);
RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view);
if (viewHolder != null && viewHolder instanceof BaseHolder) {
((BaseHolder) viewHolder).onRelease();
}
}
}
示例6: releaseAllHolder
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 遍曆所有{@link BaseHolder},釋放他們需要釋放的資源
*
* @param recyclerView
*/
public static void releaseAllHolder(RecyclerView recyclerView) {
if (recyclerView == null) return;
for (int i = recyclerView.getChildCount() - 1; i >= 0; i--) {
final View view = recyclerView.getChildAt(i);
RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view);
if (viewHolder != null && viewHolder instanceof BaseHolder) {
((BaseHolder) viewHolder).onRelease();
}
}
}
示例7: isInset
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private boolean isInset(View view, RecyclerView parent) {
ViewHolder viewHolder = (ViewHolder) parent.getChildViewHolder(view);
if (viewHolder.getExtras().containsKey(INSET_TYPE_KEY)) {
return viewHolder.getExtras().get(INSET_TYPE_KEY).equals(INSET);
} else {
return false;
}
}
示例8: getItemOffsets
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int pos = parent.getChildAdapterPosition(view);
int count = parent.getAdapter().getItemCount();
boolean alternativeHeaderAbove = pos > 0 && parent.getAdapter().getItemViewType(pos - 1) == R.id.id_adapter_setting_alternative_header_item;
// Space über jedem Header, falls dieser nicht unter alternativem Header ist und nicht an erster Stelle ist
if (pos > 0 && !alternativeHeaderAbove && parent.getChildViewHolder(view) instanceof SettingsHeaderItem.ViewHolder) {
outRect.top = paddingBeforeHeader;
}
// First and last item padding top
if (pos == 0 && paddingTopBottom != 0) {
outRect.top = paddingBeforeHeader;
}
if (pos == count -1 && paddingTopBottom != 0) {
outRect.bottom = paddingBeforeHeader;
}
// item padding left/right
if (paddingHorizontal != 0) {
outRect.left = paddingHorizontal;
outRect.right = paddingHorizontal;
}
}
示例9: updateRecordsRows
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void updateRecordsRows() {
RecyclerView recyclerView = getRecyclerView();
for (int i = 0, n = recyclerView.getChildCount(); i < n; i++) {
View view = recyclerView.getChildAt(i);
RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
if (holder != null && holder.getItemViewType() == RecordsAdapter.ITEM_VIEW_TYPE) {
Record record = adapter.getItem(holder.getAdapterPosition());
((RecordsAdapter.ItemViewHolder) holder).updatePlayPauseState(record);
}
}
}