public class BrandedFragment extends Fragment
TitleViewAdapter.Provider
.Fragment.InstantiationException, Fragment.SavedState
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
BrandedFragment() |
Modifier and Type | Method and Description |
---|---|
Drawable |
getBadgeDrawable()
Returns the badge drawable used in the fragment title.
|
int |
getSearchAffordanceColor()
Returns the color used to draw the search affordance.
|
SearchOrbView.Colors |
getSearchAffordanceColors()
Returns the
SearchOrbView.Colors
used to draw the search affordance. |
CharSequence |
getTitle()
Returns the title text for the fragment.
|
View |
getTitleView()
Returns the view that implements
TitleViewAdapter.Provider . |
TitleViewAdapter |
getTitleViewAdapter()
Returns the
TitleViewAdapter implemented by title view. |
void |
installTitleView(LayoutInflater inflater,
ViewGroup parent,
Bundle savedInstanceState)
Inflate title view and add to parent.
|
boolean |
isShowingTitle()
Returns true/false to indicate the visibility of TitleView.
|
void |
onDestroyView()
Called when the view previously created by
Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) has
been detached from the fragment. |
View |
onInflateTitleView(LayoutInflater inflater,
ViewGroup parent,
Bundle savedInstanceState)
Called by
installTitleView(LayoutInflater, ViewGroup, Bundle) to inflate
title view. |
void |
onPause()
Called when the Fragment is no longer resumed.
|
void |
onResume()
Called when the fragment is visible to the user and actively running.
|
void |
onSaveInstanceState(Bundle outState)
Called to ask the fragment to save its current dynamic state, so it
can later be reconstructed in a new instance of its process is
restarted.
|
void |
onStart()
Called when the Fragment is visible to the user.
|
void |
onViewCreated(View view,
Bundle savedInstanceState)
Called immediately after
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
has returned, but before any saved state has been restored in to the view. |
void |
setBadgeDrawable(Drawable drawable)
Sets the drawable displayed in the fragment title.
|
void |
setOnSearchClickedListener(View.OnClickListener listener)
Sets a click listener for the search affordance.
|
void |
setSearchAffordanceColor(int color)
Sets the color used to draw the search affordance.
|
void |
setSearchAffordanceColors(SearchOrbView.Colors colors)
Sets the
SearchOrbView.Colors used to draw the
search affordance. |
void |
setTitle(CharSequence title)
Sets title text for the fragment.
|
void |
setTitleView(View titleView)
Sets the view that implemented
TitleViewAdapter . |
void |
showTitle(boolean show)
Shows or hides the title view.
|
void |
showTitle(int flags)
Changes title view's components visibility and shows title.
|
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onDetach, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onStop, onTrimMemory, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterSharedElementTransitionCallback, setEnterTransition, setExitSharedElementCallback, setExitSharedElementTransitionCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenu
public View onInflateTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
installTitleView(LayoutInflater, ViewGroup, Bundle)
to inflate
title view. Default implementation uses layout file lb_browse_title.
Subclass may override and use its own layout, the layout must have a descendant with id
browse_title_group that implements TitleViewAdapter.Provider
. Subclass may return
null if no title is needed.inflater
- The LayoutInflater object that can be used to inflate
any views in the fragment,parent
- Parent of title view.savedInstanceState
- If non-null, this fragment is being re-constructed
from a previous saved state as given here.TitleViewAdapter.Provider
, or null for no title view.public void installTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
.inflater
- The LayoutInflater object that can be used to inflate
any views in the fragment,parent
- Parent of title view.savedInstanceState
- If non-null, this fragment is being re-constructed
from a previous saved state as given here.public void setTitleView(View titleView)
TitleViewAdapter
.titleView
- The view that implemented TitleViewAdapter.Provider
.public View getTitleView()
TitleViewAdapter.Provider
.TitleViewAdapter.Provider
.public TitleViewAdapter getTitleViewAdapter()
TitleViewAdapter
implemented by title view.TitleViewAdapter
implemented by title view.public void onSaveInstanceState(Bundle outState)
Fragment
Fragment.onCreate(Bundle)
,
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, and
Fragment.onActivityCreated(Bundle)
.
This corresponds to Activity.onSaveInstanceState(Bundle)
and most of the discussion there
applies here as well. Note however: this method may be called
at any time before Fragment.onDestroy()
. There are many situations
where a fragment may be mostly torn down (such as when placed on the
back stack with no UI showing), but its state will not be saved until
its owning activity actually needs to save its state.
onSaveInstanceState
in class Fragment
outState
- Bundle in which to place your saved state.public void onViewCreated(View view, Bundle savedInstanceState)
Fragment
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
has returned, but before any saved state has been restored in to the view.
This gives subclasses a chance to initialize themselves once
they know their view hierarchy has been completely created. The fragment's
view hierarchy is not however attached to its parent at this point.onViewCreated
in class Fragment
view
- The View returned by Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
.savedInstanceState
- If non-null, this fragment is being re-constructed
from a previous saved state as given here.public void onDestroyView()
Fragment
Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
has
been detached from the fragment. The next time the fragment needs
to be displayed, a new view will be created. This is called
after Fragment.onStop()
and before Fragment.onDestroy()
. It is called
regardless of whether Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
returned a
non-null view. Internally it is called after the view's state has
been saved but before it has been removed from its parent.onDestroyView
in class Fragment
public void showTitle(boolean show)
show
- True to show title view, false to hide title view.public void showTitle(int flags)
flags
- Flags representing the visibility of components inside title view.TitleViewAdapter.SEARCH_VIEW_VISIBLE
,
TitleViewAdapter.BRANDING_VIEW_VISIBLE
,
TitleViewAdapter.FULL_VIEW_VISIBLE
,
TitleViewAdapter.updateComponentsVisibility(int)
public void setBadgeDrawable(Drawable drawable)
drawable
- The Drawable to display in the fragment title.public Drawable getBadgeDrawable()
public void setTitle(CharSequence title)
title
- The title text of the fragment.public CharSequence getTitle()
public void setOnSearchClickedListener(View.OnClickListener listener)
The presence of a listener will change the visibility of the search affordance in the fragment title. When set to non-null, the title will contain an element that a user may click to begin a search.
The listener's onClick
method
will be invoked when the user clicks on the search element.
listener
- The listener to call when the search element is clicked.public void setSearchAffordanceColors(SearchOrbView.Colors colors)
SearchOrbView.Colors
used to draw the
search affordance.colors
- Colors used to draw search affordance.public SearchOrbView.Colors getSearchAffordanceColors()
SearchOrbView.Colors
used to draw the search affordance.public void setSearchAffordanceColor(int color)
color
- The color to use for the search affordance.public int getSearchAffordanceColor()
public void onStart()
Fragment
Activity.onStart
of the containing
Activity's lifecycle.public void onPause()
Fragment
Activity.onPause
of the containing
Activity's lifecycle.public void onResume()
Fragment
Activity.onResume
of the containing
Activity's lifecycle.public final boolean isShowingTitle()