List of usage examples for android.app ActivityOptions toBundle
public Bundle toBundle()
From source file:io.plaidapp.ui.FeedAdapter.java
@NonNull private DesignerNewsStoryHolder createDesignerNewsStoryHolder(ViewGroup parent) { final DesignerNewsStoryHolder holder = new DesignerNewsStoryHolder( layoutInflater.inflate(R.layout.designer_news_story_item, parent, false), pocketIsInstalled); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override/*from ww w.j ava 2 s . c o m*/ public void onClick(View v) { final Story story = (Story) getItem(holder.getAdapterPosition()); CustomTabActivityHelper.openCustomTab(host, DesignerNewsStory.getCustomTabIntent(host, story, null).build(), Uri.parse(story.url)); } }); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View commentsView) { final Intent intent = new Intent(); intent.setClass(host, DesignerNewsStory.class); intent.putExtra(DesignerNewsStory.EXTRA_STORY, (Story) getItem(holder.getAdapterPosition())); setGridItemContentTransitions(holder.itemView); final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(holder.itemView, host.getString(R.string.transition_story_title_background)), Pair.create(holder.itemView, host.getString(R.string.transition_story_background))); host.startActivity(intent, options.toBundle()); } }); if (pocketIsInstalled) { holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble... holder.pocket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { PocketUtils.addToPocket(host, ((Story) getItem(holder.getAdapterPosition())).url); // notify changed with a payload asking RV to run the anim notifyItemChanged(holder.getAdapterPosition(), HomeGridItemAnimator.ANIMATE_ADD_POCKET); } }); } return holder; }
From source file:com.hannesdorfmann.FeedAdapter.java
private void bindDesignerNewsStory(final Story story, final DesignerNewsStoryHolder holder) { holder.title.setText(story.title);//from w w w . j a va2 s . c o m holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomTabActivityHelper.openCustomTab(host, DesignerNewsStory.getCustomTabIntent(host, story, null).build(), Uri.parse(story.url)); } }); holder.comments.setText(String.valueOf(story.comment_count)); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View commentsView) { final Intent intent = new Intent(); intent.setClass(host, DesignerNewsStory.class); intent.putExtra(DesignerNewsStory.EXTRA_STORY, story); final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(holder.itemView, host.getString(R.string.transition_story_title_background)), Pair.create(holder.itemView, host.getString(R.string.transition_story_background))); host.startActivity(intent, options.toBundle()); } }); if (pocketIsInstalled) { holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble... holder.pocket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final ImageButton pocketButton = (ImageButton) view; // actually add to pocket PocketUtils.addToPocket(host, story.url); // setup for anim holder.itemView.setHasTransientState(true); ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(false); final int initialLeft = pocketButton.getLeft(); final int initialTop = pocketButton.getTop(); final int translatedLeft = (holder.itemView.getWidth() - pocketButton.getWidth()) / 2; final int translatedTop = initialTop - ((holder.itemView.getHeight() - pocketButton.getHeight()) / 2); final ArcMotion arc = new ArcMotion(); // animate the title & pocket icon up, scale the pocket icon up PropertyValuesHolder pvhTitleUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -(holder.itemView.getHeight() / 5)); PropertyValuesHolder pvhTitleFade = PropertyValuesHolder.ofFloat(View.ALPHA, 0.54f); Animator titleMoveFadeOut = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleUp, pvhTitleFade); Animator pocketMoveUp = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(initialLeft, initialTop, translatedLeft, translatedTop)); PropertyValuesHolder pvhPocketScaleUpX = PropertyValuesHolder.ofFloat(View.SCALE_X, 3f); PropertyValuesHolder pvhPocketScaleUpY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 3f); Animator pocketScaleUp = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleUpX, pvhPocketScaleUpY); ObjectAnimator pocketFadeUp = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 255); AnimatorSet up = new AnimatorSet(); up.playTogether(titleMoveFadeOut, pocketMoveUp, pocketScaleUp, pocketFadeUp); up.setDuration(300); up.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); // animate everything back into place PropertyValuesHolder pvhTitleMoveUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f); PropertyValuesHolder pvhTitleFadeUp = PropertyValuesHolder.ofFloat(View.ALPHA, 1f); Animator titleMoveFadeIn = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleMoveUp, pvhTitleFadeUp); Animator pocketMoveDown = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(translatedLeft, translatedTop, 0, 0)); PropertyValuesHolder pvhPocketScaleDownX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f); PropertyValuesHolder pvhPocketScaleDownY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f); Animator pvhPocketScaleDown = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleDownX, pvhPocketScaleDownY); ObjectAnimator pocketFadeDown = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 138); AnimatorSet down = new AnimatorSet(); down.playTogether(titleMoveFadeIn, pocketMoveDown, pvhPocketScaleDown, pocketFadeDown); down.setDuration(300); down.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); down.setStartDelay(500); // play it AnimatorSet upDown = new AnimatorSet(); upDown.playSequentially(up, down); // clean up upDown.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(true); holder.itemView.setHasTransientState(false); } }); upDown.start(); } }); } }
From source file:org.y20k.transistor.CollectionAdapter.java
public void handleSingleClick(int position, CollectionAdapterViewHolder theHolder) { Station station = mStationList.get(position); if (mTwoPane) { Bundle args = new Bundle(); args.putParcelable(TransistorKeys.ARG_STATION, station); args.putInt(TransistorKeys.ARG_STATION_ID, position); args.putBoolean(TransistorKeys.ARG_TWO_PANE, mTwoPane); PlayerActivityFragment playerActivityFragment = new PlayerActivityFragment(); playerActivityFragment.setArguments(args); mActivity.getFragmentManager().beginTransaction() .replace(R.id.player_container, playerActivityFragment, TransistorKeys.PLAYER_FRAGMENT_TAG) .commit();//from ww w. j av a 2 s . co m } else { // add ID of station to intent and start activity Intent intent = new Intent(mActivity, PlayerActivity.class); intent.setAction(TransistorKeys.ACTION_SHOW_PLAYER); intent.putExtra(TransistorKeys.EXTRA_STATION, station); intent.putExtra(TransistorKeys.EXTRA_STATION_Position_ID, position); if (theHolder != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { //for Motion (transaction) between activities View sharedView = theHolder.getStationImageView(); String transitionName = mActivity.getString(R.string.mainImageForSation); ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(mActivity, sharedView, transitionName); mActivity.startActivity(intent, transitionActivityOptions.toBundle()); } else { mActivity.startActivity(intent); } } }
From source file:io.plaidapp.ui.HomeActivity.java
@OnClick(R.id.fab) protected void fabClick() { if (designerNewsPrefs.isLoggedIn()) { Intent intent = new Intent(this, PostNewDesignerNewsStory.class); FabTransform.addExtras(intent, ContextCompat.getColor(this, R.color.accent), R.drawable.ic_add_dark); intent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT, true); registerPostStoryResultListener(); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, fab, getString(R.string.transition_new_designer_news_post)); startActivityForResult(intent, RC_NEW_DESIGNER_NEWS_STORY, options.toBundle()); } else {/*ww w . ja v a2 s . c om*/ Intent intent = new Intent(this, DesignerNewsLogin.class); FabTransform.addExtras(intent, ContextCompat.getColor(this, R.color.accent), R.drawable.ic_add_dark); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, fab, getString(R.string.transition_designer_news_login)); startActivityForResult(intent, RC_NEW_DESIGNER_NEWS_LOGIN, options.toBundle()); } }
From source file:io.plaidapp.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); ButterKnife.bind(this); drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); //toolbar.inflateMenu(R.menu.main); setActionBar(toolbar);//w w w .ja v a2 s .c o m if (savedInstanceState == null) { animateToolbar(); } dribbblePrefs = DribbblePrefs.get(this); designerNewsPrefs = DesignerNewsPrefs.get(this); filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this), new FilterAdapter.FilterAuthoriser() { @Override public void requestDribbbleAuthorisation(View sharedElemeent, Source forSource) { Intent login = new Intent(HomeActivity.this, DribbbleLogin.class); login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, ContextCompat.getColor(HomeActivity.this, R.color.background_dark)); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this, sharedElemeent, getString(R.string.transition_dribbble_login)); startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle()); } }); dataManager = new DataManager(this, filtersAdapter) { @Override public void onDataLoaded(List<? extends PlaidItem> data) { adapter.addAndResort(data); checkEmptyState(); } }; adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this)); grid.setAdapter(adapter); layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); grid.setLayoutManager(layoutManager); grid.addOnScrollListener(gridScroll); grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadAllDataSources(); } }); grid.setHasFixedSize(true); grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this, R.dimen.divider_height, R.color.divider)); grid.setItemAnimator(new HomeGridItemAnimator()); // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // inset the toolbar down by the status bar height ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); lpToolbar.topMargin += insets.getSystemWindowInsetTop(); lpToolbar.rightMargin += insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(lpToolbar); // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip) grid.setPadding(grid.getPaddingLeft(), insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this), grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape grid.getPaddingBottom()); // inset the fab for the navbar ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams(); lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape fab.setLayoutParams(lpFab); // we place a background behind the status bar to combine with it's semi-transparent // color to get the desired appearance. Set it's height to the status bar height View statusBarBackground = findViewById(R.id.status_bar_background); FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground .getLayoutParams(); lpStatus.height = insets.getSystemWindowInsetTop(); statusBarBackground.setLayoutParams(lpStatus); // inset the filters list for the status bar / navbar // need to set the padding end for landscape case final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; filtersList.setPaddingRelative(filtersList.getPaddingStart(), filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(), filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0), filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied drawer.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } }); setupTaskDescription(); filtersList.setAdapter(filtersAdapter); filtersAdapter.addFilterChangedListener(filtersChangedListener); filtersAdapter.addFilterChangedListener(dataManager); dataManager.loadAllDataSources(); ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback); itemTouchHelper.attachToRecyclerView(filtersList); checkEmptyState(); checkConnectivity(); }
From source file:io.plaidapp.core.ui.FeedAdapter.java
@NonNull private DribbbleShotHolder createDribbbleShotHolder(ViewGroup parent) { final DribbbleShotHolder holder = new DribbbleShotHolder( layoutInflater.inflate(R.layout.dribbble_shot_item, parent, false)); holder.image.setBadgeColor(initialGifBadgeColor); holder.image.setOnClickListener(view -> { Intent intent = ActivityHelper.intentTo(Activities.Dribbble.Shot.INSTANCE); intent.putExtra(Activities.Dribbble.Shot.EXTRA_SHOT_ID, getItem(holder.getAdapterPosition()).getId()); setGridItemContentTransitions(holder.image); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_shot)), Pair.create(view, host.getString(R.string.transition_shot_background))); host.startActivityForResult(intent, REQUEST_CODE_VIEW_SHOT, options.toBundle()); });/* www. j a v a2 s . c o m*/ // play animated GIFs whilst touched holder.image.setOnTouchListener((v, event) -> { // check if it's an event we care about, else bail fast final int action = event.getAction(); if (!(action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL)) { return false; } // get the image and check if it's an animated GIF final Drawable drawable = holder.image.getDrawable(); if (drawable == null) return false; GifDrawable gif = null; if (drawable instanceof GifDrawable) { gif = (GifDrawable) drawable; } else if (drawable instanceof TransitionDrawable) { // we fade in images on load which uses a TransitionDrawable; check its layers TransitionDrawable fadingIn = (TransitionDrawable) drawable; for (int i = 0; i < fadingIn.getNumberOfLayers(); i++) { if (fadingIn.getDrawable(i) instanceof GifDrawable) { gif = (GifDrawable) fadingIn.getDrawable(i); break; } } } if (gif == null) return false; // GIF found, start/stop it on press/lift switch (action) { case MotionEvent.ACTION_DOWN: gif.start(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: gif.stop(); break; } return false; }); return holder; }
From source file:io.plaidapp.ui.FeedAdapter.java
@NonNull private DribbbleShotHolder createDribbbleShotHolder(ViewGroup parent) { final DribbbleShotHolder holder = new DribbbleShotHolder( layoutInflater.inflate(R.layout.dribbble_shot_item, parent, false)); holder.image.setBadgeColor(initialGifBadgeColor); holder.image.setOnClickListener(new View.OnClickListener() { @Override//w w w .ja v a 2 s . c o m public void onClick(View view) { Intent intent = new Intent(); intent.setClass(host, DribbbleShot.class); intent.putExtra(DribbbleShot.EXTRA_SHOT, (Shot) getItem(holder.getAdapterPosition())); setGridItemContentTransitions(holder.image); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_shot)), Pair.create(view, host.getString(R.string.transition_shot_background))); host.startActivityForResult(intent, REQUEST_CODE_VIEW_SHOT, options.toBundle()); } }); // play animated GIFs whilst touched holder.image.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // check if it's an event we care about, else bail fast final int action = event.getAction(); if (!(action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL)) return false; // get the image and check if it's an animated GIF final Drawable drawable = holder.image.getDrawable(); if (drawable == null) return false; GifDrawable gif = null; if (drawable instanceof GifDrawable) { gif = (GifDrawable) drawable; } else if (drawable instanceof TransitionDrawable) { // we fade in images on load which uses a TransitionDrawable; check its layers TransitionDrawable fadingIn = (TransitionDrawable) drawable; for (int i = 0; i < fadingIn.getNumberOfLayers(); i++) { if (fadingIn.getDrawable(i) instanceof GifDrawable) { gif = (GifDrawable) fadingIn.getDrawable(i); break; } } } if (gif == null) return false; // GIF found, start/stop it on press/lift switch (action) { case MotionEvent.ACTION_DOWN: gif.start(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: gif.stop(); break; } return false; } }); return holder; }
From source file:org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity.java
private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); // create the transition animation - the images in the layouts // of both activities are defined with android:transitionName="qr_code" Bundle opts = null;//from www. j av a 2 s.c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, mQrCodeLayout, "qr_code"); opts = options.toBundle(); } qrCodeIntent.setData(mDataUri); ActivityCompat.startActivity(this, qrCodeIntent, opts); }
From source file:com.cm.android.beercellar.ui.ImageGridFragment.java
@TargetApi(VERSION_CODES.JELLY_BEAN) @Override/*from w ww . j a v a 2 s. c o m*/ public void onItemClick(AdapterView<?> parent, View v, int position, long id) { final Intent i = new Intent(getActivity(), ImageDetailActivity.class); i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id); if (Utils.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(i, options.toBundle()); } else { startActivity(i); } }
From source file:io.plaidapp.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); ButterKnife.bind(this); drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); setActionBar(toolbar);//from www . jav a 2 s . c om if (savedInstanceState == null) { animateToolbar(); } setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this)); dribbblePrefs = DribbblePrefs.get(this); designerNewsPrefs = DesignerNewsPrefs.get(this); filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this), new FilterAdapter.FilterAuthoriser() { @Override public void requestDribbbleAuthorisation(View sharedElement, Source forSource) { Intent login = new Intent(HomeActivity.this, DribbbleLogin.class); MorphTransform.addExtras(login, ContextCompat.getColor(HomeActivity.this, R.color.background_dark), sharedElement.getHeight() / 2); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this, sharedElement, getString(R.string.transition_dribbble_login)); startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle()); } }); dataManager = new DataManager(this, filtersAdapter) { @Override public void onDataLoaded(List<? extends PlaidItem> data) { adapter.addAndResort(data); checkEmptyState(); } }; adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this)); grid.setAdapter(adapter); layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); grid.setLayoutManager(layoutManager); grid.addOnScrollListener(toolbarElevation); grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadAllDataSources(); } }); grid.setHasFixedSize(true); grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this, R.dimen.divider_height, R.color.divider)); grid.setItemAnimator(new HomeGridItemAnimator()); // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // inset the toolbar down by the status bar height ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); lpToolbar.topMargin += insets.getSystemWindowInsetTop(); lpToolbar.leftMargin += insets.getSystemWindowInsetLeft(); lpToolbar.rightMargin += insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(lpToolbar); // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip) grid.setPadding(grid.getPaddingLeft() + insets.getSystemWindowInsetLeft(), // landscape insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this), grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape grid.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // inset the fab for the navbar ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams(); lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape fab.setLayoutParams(lpFab); View postingStub = findViewById(R.id.stub_posting_progress); ViewGroup.MarginLayoutParams lpPosting = (ViewGroup.MarginLayoutParams) postingStub .getLayoutParams(); lpPosting.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait lpPosting.rightMargin += insets.getSystemWindowInsetRight(); // landscape postingStub.setLayoutParams(lpPosting); // we place a background behind the status bar to combine with it's semi-transparent // color to get the desired appearance. Set it's height to the status bar height View statusBarBackground = findViewById(R.id.status_bar_background); FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground .getLayoutParams(); lpStatus.height = insets.getSystemWindowInsetTop(); statusBarBackground.setLayoutParams(lpStatus); // inset the filters list for the status bar / navbar // need to set the padding end for landscape case final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; filtersList.setPaddingRelative(filtersList.getPaddingStart(), filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(), filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0), filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied drawer.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } }); setupTaskDescription(); filtersList.setAdapter(filtersAdapter); filtersList.setItemAnimator(new FilterAdapter.FilterAnimator()); filtersAdapter.registerFilterChangedCallback(filtersChangedCallbacks); dataManager.loadAllDataSources(); ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback); itemTouchHelper.attachToRecyclerView(filtersList); checkEmptyState(); }