本文整理汇总了Java中android.support.v7.widget.StaggeredGridLayoutManager.setGapStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java StaggeredGridLayoutManager.setGapStrategy方法的具体用法?Java StaggeredGridLayoutManager.setGapStrategy怎么用?Java StaggeredGridLayoutManager.setGapStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.StaggeredGridLayoutManager
的用法示例。
在下文中一共展示了StaggeredGridLayoutManager.setGapStrategy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
ActivityCompat.setExitSharedElementCallback(this, exitTransitionCallback);
super.onCreate(savedInstanceState);
int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
setContentView(R.layout.activity_gallery);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
ArrayList<String> imagesList = new ArrayList<>();
for (int i = 1; i <= 23; i++)
imagesList.add("http://ssninstincts.org.in/img/gallery/big/" + i + ".jpg");
galleryAdapter = new GalleryAdapter(this, imagesList);
StaggeredGridLayoutManager gridLayoutManager =
new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
galleryRecyclerView.setHasFixedSize(true);
galleryRecyclerView.setLayoutManager(gridLayoutManager);
galleryRecyclerView.setAdapter(galleryAdapter);
}
示例2: onCreateView
import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=View.inflate(UIUtils.getContext(), R.layout.talking_pager,null);
mRecycler = (RecyclerView) view.findViewById(R.id.icon_recycler);
layoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
mRecycler.setLayoutManager(layoutManager);
initData();
initListener();
return view;
}
示例3: initEventAndData
import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
protected void initEventAndData() {
mList = new ArrayList<>();
mAdapter = new GirlAdapter(mContext, mList);
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(SPAN_COUNT,StaggeredGridLayoutManager.VERTICAL);
mStaggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
//fix issue #52 https://github.com/codeestX/GeekNews/issues/52
mStaggeredGridLayoutManager.setItemPrefetchEnabled(false);
rvGirlContent.setLayoutManager(mStaggeredGridLayoutManager);
rvGirlContent.setAdapter(mAdapter);
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getGirlData();
}
});
rvGirlContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int[] visibleItems = mStaggeredGridLayoutManager.findLastVisibleItemPositions(null);
int lastItem = Math.max(visibleItems[0],visibleItems[1]);
if (lastItem > mAdapter.getItemCount() - 5 && !isLoadingMore && dy > 0 ) {
isLoadingMore = true;
mPresenter.getMoreGirlData();
}
}
});
mAdapter.setOnItemClickListener(new GirlAdapter.OnItemClickListener() {
@Override
public void onItemClickListener(int position, View shareView) {
Intent intent = new Intent();
intent.setClass(mContext, GirlDetailActivity.class);
intent.putExtra("url",mList.get(position).getUrl());
intent.putExtra("id",mList.get(position).get_id());
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
mContext.startActivity(intent,options.toBundle());
}
});
ivProgress.start();
mPresenter.getGirlData();
}
示例4: initEventAndData
import android.support.v7.widget.StaggeredGridLayoutManager; //导入方法依赖的package包/类
@Override
protected void initEventAndData() {
mList = new ArrayList<>();
mAdapter = new GirlAdapter(mContext, mList);
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(SPAN_COUNT,StaggeredGridLayoutManager.VERTICAL);
mStaggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
//fix issue #52 https://github.com/codeestX/GeekNews/issues/52
mStaggeredGridLayoutManager.setItemPrefetchEnabled(false);
rvGirlContent.setLayoutManager(mStaggeredGridLayoutManager);
rvGirlContent.setAdapter(mAdapter);
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getGirlData();
}
});
rvGirlContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int[] visibleItems = mStaggeredGridLayoutManager.findLastVisibleItemPositions(null);
int lastItem = Math.max(visibleItems[0],visibleItems[1]);
if (lastItem > mAdapter.getItemCount() - 5 && !isLoadingMore && dy > 0 ) {
isLoadingMore = true;
mPresenter.getMoreGirlData();
}
}
});
mAdapter.setOnItemClickListener(new GirlAdapter.OnItemClickListener() {
@Override
public void onItemClickListener(int position, View shareView) {
Intent intent = new Intent();
intent.setClass(mContext, GirlDetailActivity.class);
intent.putExtra(Constants.IT_GANK_GRIL_URL, mList.get(position).getUrl());
intent.putExtra(Constants.IT_GANK_GRIL_ID, mList.get(position).get_id());
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
mContext.startActivity(intent,options.toBundle());
}
});
stateLoading();
mPresenter.getGirlData();
}