use of com.google.android.material.appbar.AppBarLayout in project IITB-App by wncc.
the class EventFragment method setAppBarOffset.
/**
* Set appbar to have an offset
*/
private void setAppBarOffset(int offsetPx) {
if (getView() == null || getActivity() == null)
return;
AppBarLayout mAppBarLayout = getView().findViewById(R.id.appBar);
CoordinatorLayout mCoordinatorLayour = getView().findViewById(R.id.coordinator);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
if (behavior == null)
return;
behavior.onNestedPreScroll(mCoordinatorLayour, mAppBarLayout, null, 0, offsetPx, new int[] { 0, 0 }, 0);
}
use of com.google.android.material.appbar.AppBarLayout in project android by nextcloud.
the class FileDisplayActivity method resetHeaderScrollingState.
private void resetHeaderScrollingState() {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
AppBarLayout appBarLayout = findViewById(R.id.appbar);
if (appBarLayout != null) {
appBarLayout.setExpanded(true);
}
}
use of com.google.android.material.appbar.AppBarLayout in project android_packages_apps_Settings by omnirom.
the class FloatingAppBarScrollingViewBehaviorTest method setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent.
@Test
public void setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent() {
mContext.setTheme(R.style.Theme_Settings_Home);
final AppBarLayout appBarLayout = new AppBarLayout(mContext);
appBarLayout.setBackgroundColor(Color.WHITE);
mScrollingViewBehavior.setAppBarLayoutTransparent(appBarLayout);
assertThat(((ColorDrawable) appBarLayout.getBackground()).getColor()).isEqualTo(Color.TRANSPARENT);
}
use of com.google.android.material.appbar.AppBarLayout in project AmazeFileManager by TeamAmaze.
the class MainActivity method initialiseViews.
void initialiseViews() {
appbar = new AppBar(this, getPrefs(), queue -> {
if (!queue.isEmpty()) {
mainActivityHelper.search(getPrefs(), queue);
}
});
appBarLayout = getAppbar().getAppbarLayout();
setSupportActionBar(getAppbar().getToolbar());
drawer = new Drawer(this);
indicator_layout = findViewById(R.id.indicator_layout);
getSupportActionBar().setDisplayShowTitleEnabled(false);
fabBgView = findViewById(R.id.fabs_overlay_layout);
switch(getAppTheme().getSimpleTheme()) {
case DARK:
fabBgView.setBackgroundResource(R.drawable.fab_shadow_dark);
break;
case BLACK:
fabBgView.setBackgroundResource(R.drawable.fab_shadow_black);
break;
}
fabBgView.setOnClickListener(view -> {
if (getAppbar().getSearchView().isEnabled())
getAppbar().getSearchView().hideSearchView();
});
drawer.setDrawerHeaderBackground();
}
use of com.google.android.material.appbar.AppBarLayout in project AntennaPod by AntennaPod.
the class FeedItemlistFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.feed_item_list_fragment, container, false);
toolbar = root.findViewById(R.id.toolbar);
toolbar.inflateMenu(R.menu.feedlist);
toolbar.setOnMenuItemClickListener(this);
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
}
((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
refreshToolbarState();
recyclerView = root.findViewById(R.id.recyclerView);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
progressBar = root.findViewById(R.id.progLoading);
progressBar.setVisibility(View.VISIBLE);
txtvTitle = root.findViewById(R.id.txtvTitle);
txtvAuthor = root.findViewById(R.id.txtvAuthor);
imgvBackground = root.findViewById(R.id.imgvBackground);
imgvCover = root.findViewById(R.id.imgvCover);
butShowInfo = root.findViewById(R.id.butShowInfo);
butShowSettings = root.findViewById(R.id.butShowSettings);
txtvInformation = root.findViewById(R.id.txtvInformation);
txtvFailure = root.findViewById(R.id.txtvFailure);
txtvUpdatesDisabled = root.findViewById(R.id.txtvUpdatesDisabled);
header = root.findViewById(R.id.headerContainer);
AppBarLayout appBar = root.findViewById(R.id.appBar);
CollapsingToolbarLayout collapsingToolbar = root.findViewById(R.id.collapsing_toolbar);
ToolbarIconTintManager iconTintManager = new ToolbarIconTintManager(getContext(), toolbar, collapsingToolbar) {
@Override
protected void doTint(Context themedContext) {
toolbar.getMenu().findItem(R.id.sort_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_sort));
toolbar.getMenu().findItem(R.id.filter_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_filter));
toolbar.getMenu().findItem(R.id.refresh_item).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_refresh));
toolbar.getMenu().findItem(R.id.action_search).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_search));
}
};
iconTintManager.updateTint();
appBar.addOnOffsetChangedListener(iconTintManager);
nextPageLoader = new MoreContentListFooterUtil(root.findViewById(R.id.more_content_list_footer));
nextPageLoader.setClickListener(() -> {
if (feed != null) {
DBTasks.loadNextPageOfFeed(getActivity(), feed, false);
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView view, int deltaX, int deltaY) {
super.onScrolled(view, deltaX, deltaY);
boolean hasMorePages = feed != null && feed.isPaged() && feed.getNextPageLink() != null;
nextPageLoader.getRoot().setVisibility((recyclerView.isScrolledToBottom() && hasMorePages) ? View.VISIBLE : View.GONE);
}
});
EventBus.getDefault().register(this);
SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
swipeRefreshLayout.setOnRefreshListener(() -> {
DBTasks.forceRefreshFeed(requireContext(), feed, true);
new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
});
loadItems();
// Init action UI (via a FAB Speed Dial)
speedDialView = root.findViewById(R.id.fabSD);
speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay));
speedDialView.inflate(R.menu.episodes_apply_action_speeddial);
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public boolean onMainActionSelected() {
return false;
}
@Override
public void onToggleChanged(boolean open) {
if (open && adapter.getSelectedCount() == 0) {
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected, Snackbar.LENGTH_SHORT);
speedDialView.close();
}
}
});
speedDialView.setOnActionSelectedListener(actionItem -> {
new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), adapter.getSelectedItems()).handleAction(actionItem.getId());
adapter.endSelectMode();
return true;
});
return root;
}
Aggregations