public class DirectoryFragment extends Fragment implements LoaderManager.LoaderCallbacks<DirectoryResult>
Modifier and Type | Class and Description |
---|---|
static interface |
DirectoryFragment.RequestCode |
static interface |
DirectoryFragment.ResultType |
Fragment.InstantiationException, Fragment.SavedState
Modifier and Type | Field and Description |
---|---|
static int |
REQUEST_COPY_DESTINATION |
static int |
TYPE_NORMAL |
static int |
TYPE_RECENT_OPEN |
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 |
---|
DirectoryFragment() |
Modifier and Type | Method and Description |
---|---|
void |
copySelectedToClipboard() |
static void |
create(FragmentManager fm,
int type,
RootInfo root,
DocumentInfo doc,
String query,
int anim) |
static DirectoryFragment |
get(FragmentManager fm) |
int |
getColumnCount() |
Context |
getContext() |
State |
getDisplayState() |
Model |
getModel() |
void |
initDocumentHolder(DocumentHolder holder) |
boolean |
isDocumentEnabled(String docMimeType,
int docFlags) |
boolean |
isSelected(String modelId) |
void |
onActivityCreated(Bundle savedInstanceState)
Called when the fragment's activity has been created and this
fragment's view hierarchy instantiated.
|
void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
Receive the result from a previous call to
Fragment.startActivityForResult(Intent, int) . |
boolean |
onBackPressed() |
void |
onBindDocumentHolder(DocumentHolder holder,
Cursor cursor) |
Loader<DirectoryResult> |
onCreateLoader(int id,
Bundle args)
Instantiate and return a new Loader for the given ID.
|
View |
onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view.
|
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. |
void |
onDisplayStateChanged() |
protected boolean |
onDoubleTap(MotionEvent e) |
void |
onLoaderReset(Loader<DirectoryResult> loader)
Called when a previously created loader is being reset, and thus
making its data unavailable.
|
void |
onLoadFinished(Loader<DirectoryResult> loader,
DirectoryResult result)
Called when a previously created loader has finished its load.
|
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 |
onSortOrderChanged() |
void |
onStop()
Called when the Fragment is no longer started.
|
void |
onViewModeChanged() |
void |
pasteFromClipboard() |
static void |
reload(FragmentManager fm,
int type,
RootInfo root,
DocumentInfo doc,
String query) |
static void |
reloadSearch(FragmentManager fm,
RootInfo root,
DocumentInfo doc,
String query) |
void |
requestFocus()
Attempts to restore focus on the directory listing.
|
void |
selectAllFiles() |
static void |
showDirectory(FragmentManager fm,
RootInfo root,
DocumentInfo doc,
int anim) |
static void |
showRecentsOpen(FragmentManager fm,
int anim) |
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, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDetach, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onResume, onStart, onTrimMemory, onViewCreated, 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 static final int TYPE_NORMAL
public static final int TYPE_RECENT_OPEN
public static final int REQUEST_COPY_DESTINATION
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Fragment
Fragment.onCreate(Bundle)
and Fragment.onActivityCreated(Bundle)
.
If you return a View from here, you will later be called in
Fragment.onDestroyView()
when the view is being released.
onCreateView
in class Fragment
inflater
- The LayoutInflater object that can be used to inflate
any views in the fragment,container
- If non-null, this is the parent view that the fragment's
UI should be attached to. The fragment should not add the view itself,
but this can be used to generate the LayoutParams of the view.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 onActivityCreated(Bundle savedInstanceState)
Fragment
Fragment.setRetainInstance(boolean)
to retain their instance,
as this callback tells the fragment when it is fully associated with
the new activity instance. This is called after Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
and before Fragment.onViewStateRestored(Bundle)
.onActivityCreated
in class Fragment
savedInstanceState
- If the fragment is being re-created from
a previous saved state, this is the state.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 onActivityResult(int requestCode, int resultCode, Intent data)
Fragment
Fragment.startActivityForResult(Intent, int)
. This follows the
related Activity API as described there in
Activity.onActivityResult(int, int, Intent)
.onActivityResult
in class Fragment
requestCode
- The integer request code originally supplied to
startActivityForResult(), allowing you to identify who this
result came from.resultCode
- The integer result code returned by the child activity
through its setResult().data
- An Intent, which can return result data to the caller
(various data can be attached to Intent "extras").protected boolean onDoubleTap(MotionEvent e)
public void onStop()
Fragment
Activity.onStop
of the containing
Activity's lifecycle.public void onDisplayStateChanged()
public void onSortOrderChanged()
public void onViewModeChanged()
public int getColumnCount()
public final boolean onBackPressed()
public void initDocumentHolder(DocumentHolder holder)
public void onBindDocumentHolder(DocumentHolder holder, Cursor cursor)
public State getDisplayState()
public Model getModel()
public boolean isDocumentEnabled(String docMimeType, int docFlags)
public void copySelectedToClipboard()
public void pasteFromClipboard()
public void selectAllFiles()
public void requestFocus()
public boolean isSelected(String modelId)
public static void showDirectory(FragmentManager fm, RootInfo root, DocumentInfo doc, int anim)
public static void showRecentsOpen(FragmentManager fm, int anim)
public static void reloadSearch(FragmentManager fm, RootInfo root, DocumentInfo doc, String query)
public static void reload(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query)
public static void create(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query, int anim)
@Nullable public static DirectoryFragment get(FragmentManager fm)
public Loader<DirectoryResult> onCreateLoader(int id, Bundle args)
LoaderManager.LoaderCallbacks
onCreateLoader
in interface LoaderManager.LoaderCallbacks<DirectoryResult>
id
- The ID whose loader is to be created.args
- Any arguments supplied by the caller.public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result)
LoaderManager.LoaderCallbacks
FragmentManager.openTransaction()
for further discussion on this.
This function is guaranteed to be called prior to the release of the last data that was supplied for this Loader. At this point you should remove all use of the old data (since it will be released soon), but should not do your own release of the data since its Loader owns it and will take care of that. The Loader will take care of management of its data so you don't have to. In particular:
The Loader will monitor for changes to the data, and report
them to you through new calls here. You should not monitor the
data yourself. For example, if the data is a Cursor
and you place it in a CursorAdapter
, use
the CursorAdapter.CursorAdapter(android.content.Context,
android.database.Cursor, int)
constructor without passing
in either CursorAdapter.FLAG_AUTO_REQUERY
or CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER
(that is, use 0 for the flags argument). This prevents the CursorAdapter
from doing its own observing of the Cursor, which is not needed since
when a change happens you will get a new Cursor throw another call
here.
Cursor
from a CursorLoader
,
you should not call close() on it yourself. If the Cursor is being placed in a
CursorAdapter
, you should use the
CursorAdapter.swapCursor(android.database.Cursor)
method so that the old Cursor is not closed.
onLoadFinished
in interface LoaderManager.LoaderCallbacks<DirectoryResult>
loader
- The Loader that has finished.result
- The data generated by the Loader.public void onLoaderReset(Loader<DirectoryResult> loader)
LoaderManager.LoaderCallbacks
onLoaderReset
in interface LoaderManager.LoaderCallbacks<DirectoryResult>
loader
- The Loader that is being reset.public Context getContext()