use of android.support.v7.widget.StaggeredGridLayoutManager in project Douya by DreaminginCodeZH.
the class ProfileFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mProfileResource = ProfileResource.attachTo(mUserIdOrUid, mSimpleUser, mUser, this);
mScrollLayout.setListener(new ProfileLayout.Listener() {
@Override
public void onEnterAnimationEnd() {
}
@Override
public void onExitAnimationEnd() {
getActivity().finish();
}
});
if (savedInstanceState == null) {
mScrollLayout.enter();
}
mDismissView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
exit();
}
});
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(mToolbar);
activity.getSupportActionBar().setTitle(null);
if (mProfileResource.hasUser()) {
mHeaderLayout.bindUser(mProfileResource.getUser());
} else if (mProfileResource.hasSimpleUser()) {
mHeaderLayout.bindSimpleUser(mProfileResource.getSimpleUser());
}
mHeaderLayout.setListener(this);
if (ViewUtils.hasSw600Dp(activity)) {
mContentList.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
} else {
mContentList.setLayoutManager(new LinearLayoutManager(activity));
}
mProfileAdapter = new ProfileAdapter(this);
mContentList.setAdapter(mProfileAdapter);
if (mProfileResource.isLoaded()) {
mProfileResource.notifyChangedIfLoaded();
} else {
mContentStateLayout.setLoading();
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.
the class BaseQuickAdapter method disableLoadMoreIfNotFullPage.
/**
* check if full page after {@link #setNewData(List)}, if full, it will enable load more again.
*
* @param recyclerView your recyclerView
* @see #setNewData(List)
*/
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView) {
if (recyclerView == null)
return;
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager == null)
return;
if (manager instanceof LinearLayoutManager) {
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) manager;
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
if ((linearLayoutManager.findLastCompletelyVisibleItemPosition() + 1) != getItemCount()) {
setEnableLoadMore(true);
}
}
}, 50);
} else if (manager instanceof StaggeredGridLayoutManager) {
final StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) manager;
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
final int[] positions = new int[staggeredGridLayoutManager.getSpanCount()];
staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(positions);
int pos = getTheBiggestNumber(positions) + 1;
if (pos != getItemCount()) {
setEnableLoadMore(true);
}
}
}, 50);
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project SwipeToLoadLayout by Aspsine.
the class TwitterRecyclerFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
recyclerView = (RecyclerView) view.findViewById(R.id.swipe_target);
RecyclerView.LayoutManager layoutManager = null;
if (mType == TYPE_LINEAR) {
layoutManager = new LinearLayoutManager(getContext());
} else if (mType == TYPE_GRID) {
layoutManager = new GridLayoutManager(getContext(), 2);
} else if (mType == TYPE_STAGGERED_GRID) {
layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
}
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(mAdapter);
swipeToLoadLayout.setOnRefreshListener(this);
swipeToLoadLayout.setOnLoadMoreListener(this);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (!ViewCompat.canScrollVertically(recyclerView, 1)) {
swipeToLoadLayout.setLoadingMore(true);
}
}
}
});
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project AndroidDevelop by 7449.
the class SearchFragment method initActivityCreated.
@Override
protected void initActivityCreated() {
FloatingActionButton mFAB = (FloatingActionButton) getActivity().findViewById(R.id.fa_btn);
mFAB.setOnClickListener(this);
showExplanation();
mPresenter = new SearchPresenterImpl(this);
mAdapter = new XRecyclerViewAdapter<>();
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(Constant.RECYCLERVIEW_LISTVIEW, StaggeredGridLayoutManager.VERTICAL));
mRecyclerView.setAdapter(mAdapter.setLayoutId(R.layout.item_search).onXBind(this));
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project AndroidDevelop by 7449.
the class MainActivity method initCreate.
@Override
protected void initCreate(Bundle savedInstanceState) {
toolbar.setTitle("推荐");
setSupportActionBar(toolbar);
presenter = new RecommendPresenterImpl(this);
adapter = new RecommendAdapter();
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getBaseContext(), R.color.colorPrimary));
swipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
onRefresh();
}
});
}
Aggregations