当前位置: 首页>>代码示例>>Java>>正文


Java StaggeredGridLayoutManager.getSpanCount方法代码示例

本文整理汇总了Java中android.support.v7.widget.StaggeredGridLayoutManager.getSpanCount方法的典型用法代码示例。如果您正苦于以下问题:Java StaggeredGridLayoutManager.getSpanCount方法的具体用法?Java StaggeredGridLayoutManager.getSpanCount怎么用?Java StaggeredGridLayoutManager.getSpanCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.StaggeredGridLayoutManager的用法示例。


在下文中一共展示了StaggeredGridLayoutManager.getSpanCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reLayout

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
private void reLayout(  ) {
    int orientation = this.activity.getResources().getConfiguration().orientation;
    int newCountItem = adapter.getItemCount();
    int spanCount;

    if( newCountItem <= 1) {
        spanCount = 1;
    }else if(newCountItem >= 3 && orientation == Configuration.ORIENTATION_LANDSCAPE ){
        spanCount = 3;
    }else spanCount = 2;

    StaggeredGridLayoutManager current = (StaggeredGridLayoutManager) this.recyclerView.getLayoutManager();
    if( current.getSpanCount() != spanCount ){
        current.setSpanCount( spanCount );
    }
}
 
开发者ID:tec-ustp,项目名称:SIIEScanner,代码行数:17,代码来源:LoginBuilderView.java

示例2: reLayout

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
private void reLayout(  ) {
    int orientation = this.context.getResources().getConfiguration().orientation;
    int newCountItem = adapter.getItemCount();
    int spanCount;

    if( newCountItem <= 1) {
        spanCount = 1;
    }else if(newCountItem >= 3 && orientation == Configuration.ORIENTATION_LANDSCAPE ){
        spanCount = 3;
    }else spanCount = 2;

    StaggeredGridLayoutManager current = (StaggeredGridLayoutManager) this.recyclerView.getLayoutManager();
    if( current.getSpanCount() != spanCount ){
        current.setSpanCount( spanCount );
    }
}
 
开发者ID:tec-ustp,项目名称:SIIEScanner,代码行数:17,代码来源:ScannerSenderFragment.java

示例3: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    LayoutManager layoutManager = recyclerView.getLayoutManager();

    if (layoutManager instanceof GridLayoutManager) {
        lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
    } else if (layoutManager instanceof LinearLayoutManager) {
        lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
        if (lastPositions == null) {
            lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
        }
        staggeredGridLayoutManager.findLastVisibleItemPositions(lastPositions);
        lastVisibleItemPosition = findMax(lastPositions);
    } else {
        throw new RuntimeException(
                "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
    }
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:23,代码来源:RecyclerViewFinal.java

示例4: findFirstCompletelyVisibleItemPosition

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
public static int findFirstCompletelyVisibleItemPosition(RecyclerView recyclerView) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    int firstPosition;
    if (layoutManager instanceof LinearLayoutManager) {
        firstPosition = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
    } else if (layoutManager instanceof GridLayoutManager) {
        firstPosition = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
        int[] lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
        staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(lastPositions);
        firstPosition = findMin(lastPositions);
    } else {
        throw new RuntimeException(
                "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
    }
    return firstPosition;
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:19,代码来源:Utils.java

示例5: isAtLastElementOfStaggedGridLayoutManager

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
private boolean isAtLastElementOfStaggedGridLayoutManager(StaggeredGridLayoutManager staggeredGridLayoutManager) {
    visibleItemCount = staggeredGridLayoutManager.getChildCount();
    totalItemCount = staggeredGridLayoutManager.getItemCount();
    int[] firstVisibleItems = new int[staggeredGridLayoutManager.getSpanCount()];
    firstVisibleItems = staggeredGridLayoutManager.findFirstVisibleItemPositions(firstVisibleItems);

    if (firstVisibleItems != null && firstVisibleItems.length > 0) {
        pastVisibleItems = firstVisibleItems[0];
    }

    return (visibleItemCount + pastVisibleItems) >= totalItemCount - VISIBILITY_THRESHOLD;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:13,代码来源:EndlessRecyclerOnScrollListener.java

示例6: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    //  int lastVisibleItemPosition = -1;
    if (layoutManagerType == null) {
        if (layoutManager instanceof LinearLayoutManager) {
            layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
        } else if (layoutManager instanceof GridLayoutManager) {
            layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
        } else {
            throw new RuntimeException(
                    "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
        }
    }

    switch (layoutManagerType) {
        case LINEAR:
            lastVisibleItemPosition = ((LinearLayoutManager) layoutManager)
                    .findLastVisibleItemPosition();
            break;
        case GRID:
            lastVisibleItemPosition = ((GridLayoutManager) layoutManager)
                    .findLastVisibleItemPosition();
            break;
        case STAGGERED_GRID:
            StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            if (lastPositions == null) {
                lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
            }
            staggeredGridLayoutManager.findLastVisibleItemPositions(lastPositions);
            lastVisibleItemPosition = findMax(lastPositions);
            break;
    }

}
 
开发者ID:fiepi,项目名称:moebooru-android,代码行数:40,代码来源:OnRcvScrollListener.java

示例7: isLastItem

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
private boolean isLastItem(RecyclerView.LayoutManager layoutManager) {
    int totalItemCount = layoutManager.getItemCount();
    if (layoutManager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager)
                layoutManager;
        if (null == mPositions) {
            mPositions = new int[staggeredGridLayoutManager.getSpanCount()];
        }
        staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(mPositions);
        return totalItemCount == getLast(mPositions) + 1;
    } else if (layoutManager instanceof LinearLayoutManager){
        return totalItemCount - 1 == ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
    }
    return false;
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:16,代码来源:LoadMoreScrollerListener.java

示例8: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

    if (layoutManagerType == null) {
        if (layoutManager instanceof LinearLayoutManager) {
            layoutManagerType = LayoutManagerType.LinearLayout;
        } else if (layoutManager instanceof GridLayoutManager) {
            layoutManagerType = LayoutManagerType.GridLayout;
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            layoutManagerType = LayoutManagerType.StaggeredGridLayout;
        } else {
            throw new RuntimeException(
                    "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
        }
    }

    switch (layoutManagerType) {
        case LinearLayout:
            lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
            break;
        case GridLayout:
            lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
            break;
        case StaggeredGridLayout:
            StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            if (lastPositions == null) {
                lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
            }
            staggeredGridLayoutManager.findLastVisibleItemPositions(lastPositions);
            lastVisibleItemPosition = findMax(lastPositions);
            break;
    }
}
 
开发者ID:yinyiliang,项目名称:RabbitCloud,代码行数:37,代码来源:EndlessRecyclerOnScrollListener.java

示例9: scroll_load_more_detection

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
private void scroll_load_more_detection(RecyclerView recyclerView) {

        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

        if (layoutManagerType == null) {
            if (layoutManager instanceof GridLayoutManager) {
                layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
            } else if (layoutManager instanceof StaggeredGridLayoutManager) {
                layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
            } else if (layoutManager instanceof LinearLayoutManager) {
                layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
            } else {
                throw new RuntimeException("Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
            }
        }

        mTotalItemCount = layoutManager.getItemCount();
        mVisibleItemCount = layoutManager.getChildCount();

        switch (layoutManagerType) {
            case LINEAR:
                mFirstVisibleItem = mRecyclerViewHelper.findFirstVisibleItemPosition();
                lastVisibleItemPosition = mRecyclerViewHelper.findLastVisibleItemPosition();
                break;
            case GRID:
                if (layoutManager instanceof GridLayoutManager) {
                    GridLayoutManager ly = (GridLayoutManager) layoutManager;
                    lastVisibleItemPosition = ly.findLastVisibleItemPosition();
                    mFirstVisibleItem = ly.findFirstVisibleItemPosition();
                }
                break;
            case STAGGERED_GRID:
                if (layoutManager instanceof StaggeredGridLayoutManager) {
                    StaggeredGridLayoutManager sy = (StaggeredGridLayoutManager) layoutManager;

                    if (mlastPositionsStaggeredGridLayout == null)
                        mlastPositionsStaggeredGridLayout = new int[sy.getSpanCount()];

                    sy.findLastVisibleItemPositions(mlastPositionsStaggeredGridLayout);
                    lastVisibleItemPosition = findMax(mlastPositionsStaggeredGridLayout);

                    sy.findFirstVisibleItemPositions(mlastPositionsStaggeredGridLayout);
                    mFirstVisibleItem = findMin(mlastPositionsStaggeredGridLayout);
                }
                break;
        }

        if (automaticLoadMoreEnabled) {

            if (mTotalItemCount > previousTotal) {
                automaticLoadMoreEnabled = false;
                previousTotal = mTotalItemCount;
            }
        }

        boolean bottomEdgeHit = (mTotalItemCount - mVisibleItemCount) <= mFirstVisibleItem;

        if (bottomEdgeHit) {
            if (mIsLoadMoreWidgetEnabled) {
                /**auto activate load more**/
                if (!automaticLoadMoreEnabled) {
                    onLoadMoreListener.loadMore(mRecyclerView.getAdapter().getItemCount(), lastVisibleItemPosition);
                    automaticLoadMoreEnabled = true;
                }
            }
            mAdapter.internalExecuteLoadingView();
            previousTotal = mTotalItemCount;
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:UltimateRecyclerView.java

示例10: EndlessRecyclerViewScrollListener

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
public EndlessRecyclerViewScrollListener(StaggeredGridLayoutManager layoutManager) {
    this.mLayoutManager = layoutManager;
    visibleThreshold = visibleThreshold * layoutManager.getSpanCount();
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:5,代码来源:EndlessRecyclerViewScrollListener.java

示例11: EndlessRecyclerViewOnScrollListener

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
public EndlessRecyclerViewOnScrollListener(StaggeredGridLayoutManager layoutManager) {
    mLayoutManager = layoutManager;
    sVisibleThreshold = sVisibleThreshold * layoutManager.getSpanCount();
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:5,代码来源:EndlessRecyclerViewOnScrollListener.java

示例12: RecyclerViewEndlessScrollListener

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
public RecyclerViewEndlessScrollListener(StaggeredGridLayoutManager layoutManager) {
    this.mLayoutManager = layoutManager;
    visibleThreshold = visibleThreshold * layoutManager.getSpanCount();
}
 
开发者ID:pawanchauhan05,项目名称:AndroidUtility,代码行数:5,代码来源:RecyclerViewEndlessScrollListener.java

示例13: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
  super.onScrolled(recyclerView, dx, dy);
  RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
  listener.get().onBeforeScroll(dx,dy);
  //  int lastVisibleItemPosition = -1;
  if (layoutManagerType == null) {
    if (layoutManager instanceof LinearLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
    } else if (layoutManager instanceof GridLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
    } else {
      throw new RuntimeException(
          "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
    }
  }

  switch (layoutManagerType) {
    case LINEAR:
      lastVisibleItemPosition = ((LinearLayoutManager) layoutManager)
          .findLastVisibleItemPosition();
      listener.get().notifyAppearStateChange(((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition()
          ,lastVisibleItemPosition
          ,dx
          ,dy);
      break;
    case GRID:
      lastVisibleItemPosition = ((GridLayoutManager) layoutManager)
          .findLastVisibleItemPosition();
      break;
    case STAGGERED_GRID:
      StaggeredGridLayoutManager staggeredGridLayoutManager
          = (StaggeredGridLayoutManager) layoutManager;
      if (lastPositions == null) {
        lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
      }
      staggeredGridLayoutManager.findLastVisibleItemPositions(lastPositions);
      lastVisibleItemPosition = findMax(lastPositions);
      break;
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:44,代码来源:WXRecyclerViewOnScrollListener.java

示例14: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
  super.onScrolled(recyclerView, dx, dy);
  RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
  if(listener == null){
    return;
  }
  IOnLoadMoreListener iOnLoadMoreListener = listener.get();

  if(iOnLoadMoreListener!=null) {

    iOnLoadMoreListener.onBeforeScroll(dx, dy);

    if (layoutManager instanceof LinearLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
      LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
      mLastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
      int firstVisible = linearLayoutManager.findFirstVisibleItemPosition();
      iOnLoadMoreListener.notifyAppearStateChange(firstVisible
          , mLastVisibleItemPosition
          , dx
          , dy);
    } else if (layoutManager instanceof GridLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
      GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
      mLastVisibleItemPosition = gridLayoutManager.findLastVisibleItemPosition();
      iOnLoadMoreListener.notifyAppearStateChange(gridLayoutManager.findFirstVisibleItemPosition()
          , mLastVisibleItemPosition
          , dx
          , dy);

    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
      layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
      StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
      int newSpanCount = staggeredGridLayoutManager.getSpanCount();
      if (mLastPositions == null || newSpanCount != mLastPositions.length) {
        mLastPositions = new int[newSpanCount];
      }
      if (mFirstPositions == null || newSpanCount != mFirstPositions.length) {
        mFirstPositions = new int[newSpanCount];
      }
      //avoid crash of support-v7 original bug
      try{
        staggeredGridLayoutManager.findFirstVisibleItemPositions(mFirstPositions);
        mFirstVisibleItemPosition = findMin(mFirstPositions);
        staggeredGridLayoutManager.findLastVisibleItemPositions(mLastPositions);
        mLastVisibleItemPosition = findMax(mLastPositions);
        iOnLoadMoreListener.notifyAppearStateChange(
            mFirstVisibleItemPosition
            , mLastVisibleItemPosition
            , dx
            , dy);

      }catch(Exception e){
        e.printStackTrace();
        WXLogUtils.e(e.toString());
      }

    } else {
      throw new RuntimeException(
          "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
    }
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:65,代码来源:WXRecyclerViewOnScrollListener.java

示例15: onScrolled

import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(int dx, int dy) {
    super.onScrolled(dx, dy);
    int firstVisibleItemPosition = 0;
    LayoutManager layoutManager = getLayoutManager();
    if (mLayoutManagerType == null) {
        if (layoutManager instanceof LinearLayoutManager) {
            mLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT;
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            mLayoutManagerType = LayoutManagerType.STAGGERED_GRID_LAYOUT;
        } else if (layoutManager instanceof GridLayoutManager) {
            mLayoutManagerType = LayoutManagerType.GRID_LAYOUT;
        } else {
            throw new RuntimeException("老铁,你没设置布局管理器,还是设置了什么奇怪的类型");
        }
    }

    switch (mLayoutManagerType) {
        case LINEAR_LAYOUT:
            firstVisibleItemPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
            mLastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
            break;
        case STAGGERED_GRID_LAYOUT:
            firstVisibleItemPosition = ((GridLayoutManager) layoutManager).findFirstVisibleItemPosition();
            mLastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
            break;
        case GRID_LAYOUT:
            StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            if (mLastVisibleItemPositions == null) {
                mLastVisibleItemPositions = new int[staggeredGridLayoutManager.getSpanCount()];
            }
            staggeredGridLayoutManager.findLastVisibleItemPositions(mLastVisibleItemPositions);
            mLastVisibleItemPosition = findMax(mLastVisibleItemPositions);
            staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(mLastVisibleItemPositions);
            firstVisibleItemPosition = findMax(mLastVisibleItemPositions);
            break;
        default:
            break;
    }

    calculateScrollUpOrDown(firstVisibleItemPosition, dy);
    mScrolledXDistance += dx;
    mScrolledYDistance += dy;
    mScrolledXDistance = (mScrolledXDistance < 0) ? 0 : mScrolledXDistance;
    mScrolledYDistance = (mScrolledYDistance < 0) ? 0 : mScrolledYDistance;
    if (mIsUpToDown && (dy == 0)) {
        mScrolledYDistance = 0;
    }

    if (mUltimateScrollLister != null) {
        mUltimateScrollLister.onScrolled(mScrolledXDistance, mScrolledYDistance);
    }
}
 
开发者ID:yedashen,项目名称:UltimateRecyclerView,代码行数:54,代码来源:UltimateRecyclerView.java


注:本文中的android.support.v7.widget.StaggeredGridLayoutManager.getSpanCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。