/**
* Returns @R_431_4045@ion about the item that the recycler view is currently scrolled to.
*/
protected void getCurScrollState(ScrollPositionState stateOut) {
stateOut.rowIndex = -1;
stateOut.rowTopOffset = -1;
stateOut.rowHeight = -1;
// Return early if there are no items
int rowCount = getAdapter().getItemCount();
if (rowCount == 0) {
return;
}
View child = getChildAt(0);
if (child == null) {
return;
}
stateOut.rowIndex = getChildPosition(child);
if (getLayoutManager() instanceof GridLayoutManager) {
stateOut.rowIndex = stateOut.rowIndex / ((GridLayoutManager) getLayoutManager()).getSpanCount();
}
if(child != null) {
stateOut.rowTopOffset = getLayoutManager().getDecoratedTop(child);
stateOut.rowHeight = child.getHeight();
}
}
项目:ImitateZHRB
文件:XRecyclerView.java
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager instanceof GridLayoutManager) {
final GridLayoutManager gridManager = ((GridLayoutManager) manager);
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return (isHeader(position) || isFooter(position) || isRefreshHeader(position))
? gridManager.getSpanCount() : 1;
}
});
}
adapter.onAttachedToRecyclerView(recyclerView);
}
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
// Set the adapter
switch (mode) {
case GRID:
binding.list.setLayoutManager(new GridLayoutManager(getActivity(),4));
break;
case LIST:
binding.list.setLayoutManager(new linearlayoutmanager(getActivity()));
break;
case TILE:
binding.list.setLayoutManager(new GridLayoutManager(getActivity(),2));
break;
}
return binding.getRoot();
}
项目:AutoRecycleView
文件:SmartRecycleView.java
public SmartRecycleView setLayoutmanger(LayoutManagerType layoutManagerType,int orientation,int spanCout) {
RecyclerView.LayoutManager layoutManager = null;
if (layoutManagerType == LayoutManagerType.LINEAR_LAYOUT) {
linearlayoutmanager linearlayoutmanager = new linearlayoutmanager(mContext);
linearlayoutmanager.setorientation(orientation);
layoutManager = linearlayoutmanager;
} else if (layoutManagerType == LayoutManagerType.GRID_LAYOUT) {
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext,spanCout);
gridLayoutManager.setorientation(orientation);
layoutManager = gridLayoutManager;
} else if (layoutManagerType == LayoutManagerType.STAGGER_LAYOUT) {
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(spanCout,orientation);
layoutManager = staggeredGridLayoutManager;
}
mRecyclerView.setLayoutManager(layoutManager);
return this;
}
项目:JsoupSample
文件:K567ListFragment.java
@Override
protected void initactivityCreated() {
if (!isPrepared || !isVisible || isLoad) {
return;
}
mAdapter = new XRecyclerViewAdapter<>();
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(),2));
recyclerView.setLoadingMore(this);
recyclerView.setAdapter(
mAdapter.setLayoutId(R.layout.item_k567)
.onXBind((holder,position,movieModel) -> {
holder.setTextView(R.id.k567_item_tv,Html.fromHtml(movieModel.title));
ImageLoaderUtils.display(holder.getimageView(R.id.k567_item_iv),movieModel.url);
})
.setonItemClickListener((view,info) -> K567DetailActivity.startIntent(info.title,info.detailUrl,info.url))
);
swipeRefreshLayout.setonRefreshListener(this);
swipeRefreshLayout.post(this::onRefresh);
setLoad();
}
项目:Watermark
文件:FlexibleDividerdecoration.java
/**
* In the case mShowLastDivider = false,* Returns offset for how many views we don't have to draw a divider for,* for linearlayoutmanager it is as simple as not drawing the last child divider,* but for a GridLayoutManager it needs to take the span count for the last items into account
* until we use the span count configured for the grid.
*
* @param parent RecyclerView
* @return offset for how many views we don't have to draw a divider or 1 if its a
* linearlayoutmanager
*/
private int getLastDividerOffset(RecyclerView parent) {
if (parent.getLayoutManager() instanceof GridLayoutManager) {
GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
int spanCount = layoutManager.getSpanCount();
int itemCount = parent.getAdapter().getItemCount();
for (int i = itemCount - 1; i >= 0; i--) {
if (spanSizeLookup.getSpanIndex(i,spanCount) == 0) {
return itemCount - i;
}
}
}
return 1;
}
项目:TPlayer
文件:FeatureAdapter.java
/**
* 当添加到RecyclerView时获取GridLayoutManager布局管理器,修正header和footer显示整行
*
* @param recyclerView the mRecyclerView
*/
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager instanceof GridLayoutManager) {
final GridLayoutManager gridManager = ((GridLayoutManager) manager);
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return getItemViewType(position) == VIEW_TYPE_HEADER || getItemViewType(position) == VIEW_TYPE_FOOTER
? gridManager.getSpanCount() : 1;
}
});
}
}
项目:CommonFramework
文件:DividerGridItemdecoration.java
private boolean isLastColumn(RecyclerView parent,int pos,int rowCount,int childCount) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
if ((pos + 1) % rowCount == 0) { // 如果是最后一列,则不需要绘制右侧分割线
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int orientation = ((StaggeredGridLayoutManager) layoutManager).getorientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL) {
if ((pos + 1) % rowCount == 0) { // 如果是最后一列,则不需要绘制右侧分割线
return true;
}
} else {
childCount = childCount - childCount % rowCount;
if (pos >= childCount) { // 如果是最后一列,则不需要绘制右侧分割线
return true;
}
}
}
return false;
}
项目:thesis-project
文件:SliderClassFragment.java
public void init() {
new Thread(new Runnable() {
@Override
public void run() {
try {
List<Class> classList = new ClassServiceImpl().getClassListByTeacherId(
new TeacherHelper(getContext()).loadUser().get().getId());
final ClassAdapter classAdapter = new ClassAdapter(getContext(),classList);
final RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getContext(),2);
handler.post(new Runnable() {
@Override
public void run() {
recyclerView.setAdapter(classAdapter);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
progressBar.setVisibility(View.INVISIBLE);
}
});
} catch (ClassException e) {
e.printstacktrace();
}
}
}).start();
}
private boolean isLastColum(RecyclerView parent,int spanCount,int childCount) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getorientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else {
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
return true;
}
}
return false;
}
项目:JueDiQiuSheng
文件:WrapperUtils.java
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter,RecyclerView recyclerView,final SpanSizeCallback callback)
{
innerAdapter.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager)
{
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
{
@Override
public int getSpanSize(int position)
{
return callback.getSpanSize(gridLayoutManager,spanSizeLookup,position);
}
});
gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
}
}
项目:RabbitCloud
文件:ChijiFragment.java
@Override
protected void initData() {
mItemsBeen = new ArrayList<>();
mTypeItemAdapter = new LiveTypeItemAdapter(mMainActivity,LiveTypeItemAdapter.TYPE_CATE);
mHeaderAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter
(mTypeItemAdapter);
mChijiRecyclerView.setAdapter(mHeaderAndFooterRecyclerViewAdapter);
GridLayoutManager manager = new GridLayoutManager(mMainActivity,2);
manager.setSpanSizeLookup(new HeaderSpanSizeLookup((HeaderAndFooterRecyclerViewAdapter)
mChijiRecyclerView.getAdapter(),manager.getSpanCount()));
mChijiRecyclerView.setLayoutManager(manager);
int spacing = ScreenHelper.dp2px(mMainActivity,15);
mChijiRecyclerView.addItemdecoration(new SpaceItemdecoration(2,spacing,false));
mDetailPresenter.attachView(this);
mDetailPresenter.getLiveTypeData(mTypestring,pagerNow,pagerNum);
}
项目:decoy
文件:BaseFetchLoadAdapter.java
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager instanceof GridLayoutManager) {
final GridLayoutManager gridManager = ((GridLayoutManager) manager);
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int type = getItemViewType(position);
if (mSpanSizeLookup == null) {
return (type == EMPTY_VIEW || type == LOADING_VIEW || type == FETCHING_VIEW) ? gridManager.getSpanCount() : 1;
} else {
return (type == EMPTY_VIEW || type == LOADING_VIEW || type == FETCHING_VIEW) ? gridManager
.getSpanCount() : mSpanSizeLookup.getSpanSize(gridManager,position - getFetchMoreViewCount());
}
}
});
}
}
项目:GitHub
文件:DividerGridItemdecoration.java
private boolean isLastColum(RecyclerView parent,int childCount) {
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getorientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else {
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
return true;
}
}
return false;
}
项目:Viajes
文件:HotelsFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
View mRootView = inflater.inflate(R.layout.fragment_hotels,container,false);
hotels = new ArrayList<>();
mHotelsList = (RecyclerView) mRootView.findViewById(R.id.hotels_recycler);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mHotelsList.setLayoutManager(new GridLayoutManager(getActivity(),2));
}
else {
mHotelsList.setLayoutManager(new GridLayoutManager(getActivity(),1));
}
mAdapter = new HotelDataAdapter(getActivity(),hotels);
mAdapter.setActionListner(this);
mHotelsList.setAdapter(mAdapter);
if (mPresenter != null)
mPresenter.loadHotels();
return mRootView;
}
项目:GitHub
文件:SupportGridItemdecoration.java
private boolean isLastColum(RecyclerView parent,int childCount) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getorientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL) {
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else {
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
return true;
}
}
return false;
}
项目:OpenEyesReading-android
文件:NewsActivity.java
private int calculateRecyclerViewFirstPosition() {
RecyclerView.LayoutManager manager = mRecyclerView.getLayoutManager();
if (manager instanceof StaggeredGridLayoutManager) {
if (mVisiblePositions == null)
mVisiblePositions = new int[((StaggeredGridLayoutManager) manager).getSpanCount()];
((StaggeredGridLayoutManager) manager).findLastCompletelyVisibleItemPositions(mVisiblePositions);
int max = -1;
for (int pos : mVisiblePositions) {
max = Math.max(max,pos);
}
return max;
} else if (manager instanceof GridLayoutManager) {
return ((GridLayoutManager) manager).findFirstCompletelyVisibleItemPosition();
} else {
return ((linearlayoutmanager) manager).findLastCompletelyVisibleItemPosition();
}
}
项目:Matisse-Image-and-Video-Selector
文件:MediaSelectionFragment.java
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Album album = getArguments().getParcelable(EXTRA_ALBUM);
mAdapter = new AlbumMediaAdapter(getContext(),mSelectionProvider.provideselectedItemCollection(),mRecyclerView);
mAdapter.registerCheckStateListener(this);
mAdapter.registerOnMediaClickListener(this);
mRecyclerView.setHasFixedSize(true);
int spanCount;
SelectionSpec selectionSpec = SelectionSpec.getInstance();
if (selectionSpec.gridExpectedSize > 0) {
spanCount = UIUtils.spanCount(getContext(),selectionSpec.gridExpectedSize);
} else {
spanCount = selectionSpec.spanCount;
}
mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(),spanCount));
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
mRecyclerView.addItemdecoration(new MediaGridInset(spanCount,false));
mRecyclerView.setAdapter(mAdapter);
mAlbumMediaCollection.onCreate(getActivity(),this);
mAlbumMediaCollection.load(album,selectionSpec.capture);
}
项目:SmartChart
文件:EmptyWrapper.java
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
WrapperUtils.onAttachedToRecyclerView(mInnerAdapter,recyclerView,new WrapperUtils.SpanSizeCallback() {
@Override
public int getSpanSize(GridLayoutManager gridLayoutManager,GridLayoutManager.SpanSizeLookup oldLookup,int position) {
if (isEmpty()) {
return gridLayoutManager.getSpanCount();
}
if (oldLookup != null) {
return oldLookup.getSpanSize(position);
}
return 1;
}
});
}
项目:Mybilibili
文件:ShoucangActivity.java
private void setData() {
mRecyclerView.setLayoutManager(new GridLayoutManager(this,1));
//侧滑删除的根布局是SwipeItemLayout这个自定义view
mRecyclerView.addOnItemTouchListener(new SwipeItemLayout.OnSwipeItemTouchListener(this));
mRecyclerView.setAdapter(mAdapter);
/**
* //这几行是之前只侧滑删除没有按钮的实现方式,涉及到itemtouchhelperAdapter,Rvitemtouchhelper两个类
//此处不调用,那两个类也就没用了,但并不删除,因为那种不带按钮的是很简单,不用添加其他东西的
//这种带按钮的要添加一个800行代码的SwipeItemLayout的自定义view类,这也是操作比较简单的一种实现方式
//但只针对recyclerview,能多种适配的比较麻烦,在build.gradle中也引入了,是张旭童博客的,GitHub有源码
//此处标记是怕以后时间长了忘记,关于这种仿iOS qq侧滑删除的今天在网上下了几个demo,存在E盘以s开头的工程
//有差别,但都很牛逼,其实都是自定义view的延伸,我现在水平还到不了那,但以后要往那个方向努力
//此处注释不能删
*/
// itemtouchhelper.Callback callback = new RVitemtouchhelper(mAdapter);
// itemtouchhelper itemtouchhelper = new itemtouchhelper(callback);
// itemtouchhelper.attachToRecyclerView(mRecyclerView);
}
项目:BaseAdapterRel
文件:WrapperUtils.java
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter,position);
}
});
gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
}
}
项目:CXJPadProject
文件:InquiryDetailsOneFragment.java
private void initsupplierList() {
supplierAdapter = new BRAdapter<SelectedListInfo>(getContext(),R.layout.item_selected_show_list,supplierList) {
@Override
protected void convert(RvHolder holder,final SelectedListInfo selectedListInfo,int position) {
holder.setText(R.id.tv_name,selectedListInfo.name);
holder.setonClickListener(R.id.tv_cancle,new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 0; i < supplierList.size(); i++) {
if ((supplierList.get(i).name).equals(selectedListInfo.name)) {
supplierList.remove(i);
i--;
}
}
supplierAdapter.notifyDataSetChanged();
}
});
}
};
rvsupplier.setAdapter(supplierAdapter);
rvsupplier.setLayoutManager(new GridLayoutManager(getContext(),3));
}
@Override protected void setUpAdapter() {
GridLayoutManager glm = new GridLayoutManager(getApplicationContext(),3);
GridAdapter adapter = new GridAdapter(convertDpToPixel(4,this));
adapter.setSpanCount(3);
recyclerView.addItemdecoration(adapter.getItemdecorationManager());
glm.setSpanSizeLookup(adapter.getSpanSizeLookup());
recyclerView.setLayoutManager(glm);
recyclerView.setAdapter(adapter);
List<BaseModel> data = new ArrayList<>();
for (int i = 0; i < 50; i++) {
if (i % 10 == 0) {
data.add(new Header("Sample header " + i));
} else {
data.add(GridItem.generateGridItem(i));
}
}
adapter.addData(data);
}
项目:Show_Chat
文件:TVFragment.java
@Override
public View onCreateView(LayoutInflater inflater,Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.chat_fragment_group,false);
listGroup = GroupDB.getInstance(getContext()).getListGroups();
recyclerListGroups = (RecyclerView) layout.findViewById(R.id.recycleListGroup);
mSwipeRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setonRefreshListener(this);
GridLayoutManager layoutManager = new GridLayoutManager(getContext(),2);
recyclerListGroups.setLayoutManager(layoutManager);
adapter = new ListMovieAdapter(getContext(),listGroup);
recyclerListGroups.setAdapter(adapter);
if(listGroup.size() == 0){
//Ket noi server hien thi group
mSwipeRefreshLayout.setRefreshing(true);
getListGroup();
}
return layout;
}
项目:GitHub
文件:EmptyWrapper.java
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView)
{
WrapperUtils.onAttachedToRecyclerView(mInnerAdapter,new WrapperUtils.SpanSizeCallback()
{
@Override
public int getSpanSize(GridLayoutManager gridLayoutManager,int position)
{
if (isEmpty())
{
return gridLayoutManager.getSpanCount();
}
if (oldLookup != null)
{
return oldLookup.getSpanSize(position);
}
return 1;
}
});
}
项目:WatchIt
文件:TvSeriesWatchLaterFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tvseries_watch_later,false);
ButterKnife.bind(this,view);
realm = Realm.getDefaultInstance();
GridLayoutManager layoutManager = new GridLayoutManager(getContext(),2);
layoutManager.setorientation(linearlayoutmanager.VERTICAL);
rvTvSeriesWatchLater.setLayoutManager(layoutManager);
rvTvSeriesWatchLater.setAdapter(new TvSeriesWatchLateradapter(realm.where(TvSeries.class)
.equalTo("isWatchLater",true).findAllAsync(),true,this));
return view;
}
项目:OSchina_resources_android
文件:ModifyFieldActivity.java
@Override
protected void initWidget() {
super.initWidget();
mRecyclerField.setLayoutManager(new GridLayoutManager(this,2));
mAdapter = new FieldAdapter(this);
mAdapter.setonItemClickListener(new BaseRecyclerAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position,long itemId) {
Field field = mAdapter.getItem(position);
if (field == null) return;
if (!field.isSelected()) {
List<Field> fields = mAdapter.getSelects();
if (fields.size() >= 3) {
SimplexToast.show(ModifyFieldActivity.this,"最多选择3个");
return;
}
}
field.setSelected(!field.isSelected());
mAdapter.updateItem(position);
}
});
mRecyclerField.setAdapter(mAdapter);
}
项目:LayoutSwitch
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
initItemsData();
gridLayoutManager = new GridLayoutManager(this,SPAN_COUNT_ONE);
itemAdapter = new ItemAdapter(items,gridLayoutManager);
recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setAdapter(itemAdapter);
recyclerView.setLayoutManager(gridLayoutManager);
}
项目:ImitateZHRB
文件:XRecyclerView.java
@Override
public void onScrollStateChanged(int state) {
super.onScrollStateChanged(state);
if (state == RecyclerView.SCROLL_STATE_IDLE && mloadingListener != null && !isLoadingData && loadingMoreEnabled) {
LayoutManager layoutManager = getLayoutManager();
int lastVisibleItemPosition;
if (layoutManager instanceof GridLayoutManager) {
lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int[] into = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(into);
lastVisibleItemPosition = findMax(into);
} else {
lastVisibleItemPosition = ((linearlayoutmanager) layoutManager).findLastVisibleItemPosition();
}
if (layoutManager.getChildCount() > 0
&& lastVisibleItemPosition >= layoutManager.getItemCount() - 1 && !isNoMore && mRefreshHeader.getState() < ArrowRefreshHeader.STATE_REFRESHING) {
isLoadingData = true;
if (mFootView instanceof LoadingMoreFooter) {
((LoadingMoreFooter) mFootView).setState(LoadingMoreFooter.STATE_LOADING);
} else {
mFootView.setVisibility(View.VISIBLE);
}
mloadingListener.onLoadMore();
}
}
}
项目:anitrend-app
文件:ProgressFragment.java
@Override
public View onCreateView(LayoutInflater inflater,Bundle savedInstanceState) {
View views = inflater.inflate(R.layout.fragment_base_view,false);
unbinder = ButterKnife.bind(this,views);
progressLayout.showLoading();
swipeRefreshLayout.setonRefreshListener(this);
recyclerView.setHasFixedSize(true); //originally set to fixed size true
recyclerView.setnestedScrollingEnabled(false);//set to false if somethings fail to work properly
mLayoutManager = new GridLayoutManager(getContext(),getResources().getInteger(R.integer.card_col_size_home));
recyclerView.setLayoutManager(mLayoutManager);
if(savedInstanceState != null)
model_type = savedInstanceState.getString(MODEL_TYPE);
return views;
}
项目:medialibrary
文件:AlbumActivity.java
private void setupAlbum(Path path) {
mPath = path;
mRootObject = getDataManager().getMediaSet(path);
mRootObject.addContentListener(() -> mAdapter.notifyDataSetChanged());
mAdapter = new AlbumSetAdapter(mRootObject,this,this);
mRecyclerView.setLayoutManager(new GridLayoutManager(this,2));
mRecyclerView.setAdapter(mAdapter);
mRootObject.reload();
}
项目:OddLauncher
文件:DefaultAppsActivity.java
public void initUI() {
// searchText = (EditText) findViewById(R.id.search_bar_default);
frameContainer = (LinearLayout) findViewById(R.id.frame_default);
flSearch = (FrameLayout) findViewById(R.id.frame_default_search);
rvDefault = (RecyclerView) findViewById(R.id.list_view_default);
GridLayoutManager gridLayoutManager =
new GridLayoutManager(this,2,GridLayoutManager.VERTICAL,false);
rvDefault.setLayoutManager(gridLayoutManager);
layoutManager = new GridLayoutManager(this,false);
}
项目:HeroVideo-master
文件:HomeBangumiFragment.java
protected void initRecyclerView()
{
mSectionedRecyclerViewAdapter = new SectionedRecyclerViewAdapter();
GridLayoutManager mGridLayoutManager = new GridLayoutManager(getActivity(),3);
mGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
{
@Override
public int getSpanSize(int position)
{
switch (mSectionedRecyclerViewAdapter.getSectionItemViewType(position))
{
case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
return 3;
default:
return 1;
}
}
});
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setnestedScrollingEnabled(true);
mRecyclerView.setLayoutManager(mGridLayoutManager);
mRecyclerView.setAdapter(mSectionedRecyclerViewAdapter);
setRecycleNoScroll();
}
@Override
public View onCreateView(LayoutInflater inflater,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home_lines,false);
// Set the adapter
Context context = view.getContext();
recyclerView = (RecyclerView) view.findViewById(R.id.list);
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new linearlayoutmanager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context,mColumnCount));
}
recyclerView.setVisibility(View.GONE);
progressBar = (ProgressBar) view.findViewById(R.id.loading_indicator);
progressBar.setVisibility(View.VISIBLE);
update@R_431_4045@ionView = (TextView) view.findViewById(R.id.update_@R_431_4045@ion);
// fix scroll fling. less than ideal,but apparently there's still no other solution
recyclerView.setnestedScrollingEnabled(false);
IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_MAIN_SERVICE_BOUND);
filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
filter.addAction(LinestatusCache.ACTION_LINE_STATUS_UPDATE_STARTED);
filter.addAction(LinestatusCache.ACTION_LINE_STATUS_UPDATE_SUCCESS);
filter.addAction(LinestatusCache.ACTION_LINE_STATUS_UPDATE_Failed);
LocalbroadcastManager bm = LocalbroadcastManager.getInstance(context);
bm.registerReceiver(mbroadcastReceiver,filter);
redraw(context);
return view;
}
private void initRecycleView() {
GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(),GRID_COUNT);
gridLayoutManager.setSmoothScrollbarEnabled(true);
mRecycleView.setLayoutManager(gridLayoutManager);
mRecycleView.addItemdecoration(new SpacesItemdecoration(getResources().getDimensionPixelOffset(R.dimen.Boxing_media_margin),GRID_COUNT));
mMediaAdapter.setonCameraClickListener(new OnCameraClickListener());
mMediaAdapter.setonCheckedListener(new OnMediaCheckedListener());
mMediaAdapter.setonMediaClickListener(new OnMediaClickListener());
mRecycleView.setAdapter(mMediaAdapter);
mRecycleView.addOnScrollListener(new ScrollListener());
}
项目:Inflix
文件:EndlessRecyclerViewScrollListener.java
public EndlessRecyclerViewScrollListener(int currentPage,RecyclerView.LayoutManager layoutManager) {
this.mCurrentPage = currentPage;
this.mLayoutManager = layoutManager;
if (layoutManager instanceof GridLayoutManager) {
mVisibleThreshold *= ((GridLayoutManager) layoutManager).getSpanCount();
} else if (layoutManager instanceof linearlayoutmanager) {
mVisibleThreshold = ENDLESS_PAGINATION_THRESHOLD * 2;
}
}
项目:CalendarView_master
文件:MonthRecyclerView.java
public MonthRecyclerView(Context context,@Nullable AttributeSet attrs) {
super(context,attrs);
mAdapter = new MonthAdapter(context);
setLayoutManager(new GridLayoutManager(context,3));
setAdapter(mAdapter);
mAdapter.setonItemClickListener(new BaseRecyclerAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position,long itemId) {
if (mListener != null) {
Month month = mAdapter.getItem(position);
mListener.onMonthSelected(month.getYear(),month.getMonth());
}
}
});
}
项目:aliyun-cloudphotos-android-demo
文件:AssistantFragment.java
@Override
public void onViewCreated(View view,@Nullable Bundle savedInstanceState) {
super.onViewCreated(view,savedInstanceState);
if (adapter == null) {
adapter = new AssistantAdapter(getActivity(),itemPerRow);
adapter.addHeader(new View(getActivity()));
adapter.addFooter(new View(getActivity()));
}
gridLayoutManager = new GridLayoutManager(getActivity(),itemPerRow);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return adapter.getSpanSize(position);
}
});
ItemOffsetdecoration itemdecoration = new ItemOffsetdecoration(getContext(),R.dimen.grid_offset);
recyclerView.addItemdecoration(itemdecoration);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setAdapter(adapter);
if (((MainActivity) getActivity()).positionMap.containsKey(TAG)) {
offset = ((MainActivity) getActivity()).positionMap.get(TAG);
}
}
项目:Calendouer
文件:CelebrityActivity.java
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
if (s != null && !s.equals("")) {
DoubanMovies doubanMovies = new Gson().fromJson(s,DoubanMovies.class);
final List<MovieBean> dataset = Arrays.asList(doubanMovies.getSubjects());
GridLayoutManager gridLayoutMgr = new GridLayoutManager(CelebrityActivity.this,4);
recyclerView.setLayoutManager(gridLayoutMgr);
MovieSubjectAdapter adapter = new MovieSubjectAdapter(dataset) {
@Override
public void onBindViewHolder(MovieSubjectAdapter.ViewHolder holder,int position) {
super.onBindViewHolder(holder,position);
MovieBean movie = dataset.get(position);
holder.title.setText(movie.getTitle() + "\n" + join(movie.getGenres(),"/"));
}
};
recyclerView.setAdapter(adapter);
setSubjectMoreBtn(doubanMovies.getTotal());
} else {
Toast.makeText(
CelebrityActivity.this,getString(R.string.douban_error),Toast.LENGTH_LONG
).show();
}
subjectPB.setVisibility(View.GONE);
subjectMoreBtn.setVisibility(View.VISIBLE);
}
项目:GitHub
文件:DividerGridItemdecoration.java
private boolean isLastColum(RecyclerView parent,int childCount)
{
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager)
{
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager)
{
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getorientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL)
{
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else
{
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
return true;
}
}
return false;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。