@Override
 public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
   final View view =
       LayoutInflater.from(context).inflate(R.layout.item_photo_profile, parent, false);
   StaggeredGridLayoutManager.LayoutParams layoutParams =
       (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
   layoutParams.height = cellSize;
   layoutParams.width = cellSize;
   layoutParams.setFullSpan(false);
   view.setLayoutParams(layoutParams);
   return new PhotoViewHolder(view);
 }
 @Override
 public void onViewAttachedToWindow(BaseViewHolder holder) {
   super.onViewAttachedToWindow(holder);
   int position = holder.getLayoutPosition();
   int type = getItemViewType(position);
   if (isFullSpanType(type)) {
     ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
     if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams) {
       StaggeredGridLayoutManager.LayoutParams lp =
           (StaggeredGridLayoutManager.LayoutParams) layoutParams;
       lp.setFullSpan(true);
     }
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onBindViewHolder(BindingHolder holder, final int position) {
    try {
      try {
        holder
            .getBinding()
            .setVariable(
                getBRClass().getDeclaredField("data").getInt(getBRClass().newInstance()),
                deals.get(position));
        ;
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InstantiationException e) {
        e.printStackTrace();
      }
    } catch (NoSuchFieldException e) {
      e.printStackTrace();
    }

    holder.getBinding().executePendingBindings();

    // add footer
    if (holder.getBinding() instanceof LceLoadingFooterBinding && recycle != null) {
      RecyclerView.LayoutManager manager = recycle.getLayoutManager();
      if (manager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager.LayoutParams layoutParams =
            new StaggeredGridLayoutManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams.setFullSpan(true);
        holder.getBinding().getRoot().setLayoutParams(layoutParams);
      } else if (manager instanceof LinearLayoutManager) {
      } else if (manager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) manager;
        final GridLayoutManager.SpanSizeLookup lookup = gridLayoutManager.getSpanSizeLookup();
        gridLayoutManager.setSpanSizeLookup(
            new GridLayoutManager.SpanSizeLookup() {
              @Override
              public int getSpanSize(int inner_position) {
                if (position == inner_position) {
                  return gridLayoutManager.getSpanCount();
                } else {
                  return lookup.getSpanSize(inner_position);
                }
              }
            });
      }
    } else {
      onBind(holder, deals.get(position), mv.getModel(getItemViewType(position)), position);
    }
  }
 @Override
 public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
   int headerViewsCountCount = getHeaderViewsCount();
   if (position >= headerViewsCountCount
       && position < headerViewsCountCount + mInnerAdapter.getItemCount()) {
     mInnerAdapter.onBindViewHolder(holder, position - headerViewsCountCount);
   } else {
     ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
     if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams) {
       ((StaggeredGridLayoutManager.LayoutParams) layoutParams).setFullSpan(true);
     }
   }
 }
Ejemplo n.º 5
0
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    int type = getItemViewType(position);
    if (type == TYPE_NORMAL_ITEM) {
      onBindNormalViewHolder(holder, position);
    } else {

      if (mFirstEnter) {
        mLoadingViewHolder.tvLoading.setText("已加载完");
        mLoadingViewHolder.progressBar.setVisibility(View.GONE);

        setScrollListener(mRecyclerView);
      }

      if (mStaggeredGridLayoutManager != null) {
        StaggeredGridLayoutManager.LayoutParams layoutParams =
            new StaggeredGridLayoutManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.setFullSpan(true);

        mLoadingViewHolder.llyLoading.setLayoutParams(layoutParams);
      }
    }
  }