當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.getChildViewHolder方法代碼示例

本文整理匯總了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));
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:MaterialViewPagerHeaderDecorator.java

示例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);
    }
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:32,代碼來源:InsetDividerDecoration.java

示例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);
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:8,代碼來源:NotificationRulesAdapter.java

示例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();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:DefaultAdapter.java

示例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();
        }
    }
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:15,代碼來源:DefaultAdapter.java

示例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();
        }
    }
}
 
開發者ID:Superingxz,項目名稱:MoligyMvpArms,代碼行數:16,代碼來源:DefaultAdapter.java

示例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;
    }
}
 
開發者ID:Genius,項目名稱:genius-groupie,代碼行數:9,代碼來源:InsetItemDecoration.java

示例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;
    }
}
 
開發者ID:MFlisar,項目名稱:RecyclerViewPreferences,代碼行數:28,代碼來源:SettingsSpaceDecorator.java

示例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);
        }
    }
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:12,代碼來源:RecordsActivity.java


注:本文中的android.support.v7.widget.RecyclerView.getChildViewHolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。