use of me.zhanghai.android.douya.ui.AppBarHost in project Douya by DreaminginCodeZH.
the class BaseBroadcastListFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mBroadcastListResource = onAttachBroadcastListResource();
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
onSwipeRefresh();
}
});
mBroadcastList.setHasFixedSize(true);
mBroadcastList.setItemAnimator(new NoChangeAnimationItemAnimator());
// Always use StaggeredGridLayoutManager so that instance state can be saved.
Activity activity = getActivity();
int columnCount = CardUtils.getColumnCount(activity);
mBroadcastList.setLayoutManager(new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL));
mBroadcastAdapter = new BroadcastAdapter(mBroadcastListResource.get(), this);
mAdapter = new LoadMoreAdapter(R.layout.load_more_card_item, mBroadcastAdapter);
mBroadcastList.setAdapter(mAdapter);
final AppBarHost appBarHost = (AppBarHost) getParentFragment();
mBroadcastList.addOnScrollListener(new OnVerticalScrollWithPagingTouchSlopListener(activity) {
@Override
public void onScrolled(int dy) {
if (!RecyclerViewUtils.hasFirstChildReachedTop(mBroadcastList)) {
onShow();
}
}
@Override
public void onScrolledUp() {
onShow();
}
private void onShow() {
appBarHost.showAppBar();
mSendFab.show();
}
@Override
public void onScrolledDown() {
if (RecyclerViewUtils.hasFirstChildReachedTop(mBroadcastList)) {
appBarHost.hideAppBar();
mSendFab.hide();
}
}
@Override
public void onScrolledToBottom() {
mBroadcastListResource.load(true);
}
});
updateRefreshing();
CheatSheetUtils.setup(mSendFab);
mSendFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onSendBroadcast();
}
});
}
Aggregations