use of android.support.design.widget.AppBarLayout in project WordPress-Android by wordpress-mobile.
the class ReaderPostListActivity method disableFilteredRecyclerViewToolbar.
/*
* This method hides the FilteredRecyclerView toolbar with spinner so to disable content filtering, for reusability
* */
private void disableFilteredRecyclerViewToolbar() {
// make it invisible - setting height to zero here because setting visibility to View.GONE wouldn't take the
// occupied space, as otherwise expected
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);
if (appBarLayout != null) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
lp.height = 0;
appBarLayout.setLayoutParams(lp);
}
// disabling any CoordinatorLayout behavior for scrolling
Toolbar toolbarWithSpinner = (Toolbar) findViewById(R.id.toolbar_with_spinner);
if (toolbarWithSpinner != null) {
AppBarLayout.LayoutParams p = (AppBarLayout.LayoutParams) toolbarWithSpinner.getLayoutParams();
p.setScrollFlags(0);
toolbarWithSpinner.setLayoutParams(p);
}
}
use of android.support.design.widget.AppBarLayout in project MadMax by deviz92.
the class BarDetailFragment method initCollapsingToolbar.
/* */
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
/*
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}*/
// Initializing collapsing toolbar: it will show and hide the toolbar title on scroll
private void initCollapsingToolbar() {
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) ((BasicActivity) getActivity()).findViewById(R.id.collapsingToolbar);
collapsingToolbar.setTitle(" ");
AppBarLayout appBarLayout = (AppBarLayout) ((BasicActivity) getActivity()).findViewById(R.id.app_bar);
appBarLayout.setExpanded(true);
// hiding & showing the title when toolbar expanded & collapsed
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean isShow = false;
int scrollRange = -1;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (scrollRange == -1) {
scrollRange = appBarLayout.getTotalScrollRange();
}
if (scrollRange + verticalOffset == 0) {
collapsingToolbar.setTitle(nameTextView.getText());
isShow = true;
} else if (isShow) {
collapsingToolbar.setTitle(" ");
isShow = false;
}
}
});
}
use of android.support.design.widget.AppBarLayout in project GeekNews by codeestX.
the class ThemeActivity method initEventAndData.
@Override
protected void initEventAndData() {
Intent intent = getIntent();
id = intent.getExtras().getInt("id");
ivProgress.start();
mList = new ArrayList<>();
mAdapter = new ThemeChildAdapter(mContext, mList);
rvThemeChildList.setLayoutManager(new LinearLayoutManager(mContext));
rvThemeChildList.setAdapter(mAdapter);
mPresenter.getThemeChildData(id);
mAdapter.setOnItemClickListener(new ThemeChildAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position, View shareView) {
mPresenter.insertReadToDB(mList.get(position).getId());
mAdapter.setReadState(position, true);
mAdapter.notifyItemChanged(position);
Intent intent = new Intent();
intent.setClass(mContext, ZhihuDetailActivity.class);
intent.putExtra("id", mList.get(position).getId());
if (shareView != null) {
mContext.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(mContext, shareView, "shareView").toBundle());
} else {
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(mContext).toBundle());
}
}
});
appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset >= 0) {
swipeRefresh.setEnabled(true);
} else {
swipeRefresh.setEnabled(false);
float rate = (float) (SystemUtil.dp2px(mContext, 256) + verticalOffset * 2) / SystemUtil.dp2px(mContext, 256);
if (rate >= 0)
ivOrigin.setAlpha(rate);
}
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getThemeChildData(id);
}
});
}
use of android.support.design.widget.AppBarLayout in project GeekNews by codeestX.
the class TechFragment method initEventAndData.
@Override
protected void initEventAndData() {
mPresenter.getGirlImage();
mList = new ArrayList<>();
tech = getArguments().getString(Constants.IT_GANK_TYPE);
type = getArguments().getInt(Constants.IT_GANK_TYPE_CODE);
mAdapter = new TechAdapter(mContext, mList, tech);
rvTechContent.setLayoutManager(new LinearLayoutManager(mContext));
rvTechContent.setAdapter(mAdapter);
ivProgress.start();
mPresenter.getGankData(tech, type);
mAdapter.setOnItemClickListener(new TechAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position, View shareView) {
TechDetailActivity.launch(new TechDetailActivity.Builder().setContext(mContext).setId(mList.get(position).get_id()).setTitle(mList.get(position).getDesc()).setUrl(mList.get(position).getUrl()).setType(type).setAnimConfig(mActivity, shareView));
}
});
rvTechContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastVisibleItem = ((LinearLayoutManager) rvTechContent.getLayoutManager()).findLastVisibleItemPosition();
int totalItemCount = rvTechContent.getLayoutManager().getItemCount();
if (lastVisibleItem >= totalItemCount - 2 && dy > 0) {
//还剩2个Item时加载更多
if (!isLoadingMore) {
isLoadingMore = true;
mPresenter.getMoreGankData(tech);
}
}
}
});
appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset >= 0) {
swipeRefresh.setEnabled(true);
} else {
swipeRefresh.setEnabled(false);
float rate = (float) (SystemUtil.dp2px(mContext, 256) + verticalOffset * 2) / SystemUtil.dp2px(mContext, 256);
if (rate >= 0)
ivOrigin.setAlpha(rate);
}
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getGankData(tech, type);
}
});
}
use of android.support.design.widget.AppBarLayout in project Meizhi by drakeet.
the class BaseBehavior method dispatchOffsetUpdates.
protected void dispatchOffsetUpdates(AppBarLayout layout, int translationOffset) {
if (layout instanceof SmoothAppBarLayout) {
List listeners = ((SmoothAppBarLayout) layout).mOffsetChangedListeners;
int i = 0;
for (int z = listeners.size(); i < z; ++i) {
WeakReference ref = (WeakReference) listeners.get(i);
AppBarLayout.OnOffsetChangedListener listener = ref != null ? (AppBarLayout.OnOffsetChangedListener) ref.get() : null;
if (listener != null) {
listener.onOffsetChanged(layout, translationOffset);
}
}
}
}
Aggregations