Class DownloadProgressFragment
-
- All Implemented Interfaces:
-
android.content.ComponentCallbacks
,android.content.DialogInterface.OnCancelListener
,android.content.DialogInterface.OnDismissListener
,android.view.View.OnCreateContextMenuListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
public class DownloadProgressFragment extends DialogFragment
A fragment for retaining a DownloadJob and showing its progress. Create the fragment via its constructor and call setJob. This is a retained fragment and can't be used as nested fragment.
-
-
Field Summary
Fields Modifier and Type Field Description public DownloadJob
job
-
Constructor Summary
Constructors Constructor Description DownloadProgressFragment()
-
Method Summary
Modifier and Type Method Description DownloadJob
getJob()
Returns the set DownloadJob (if any). void
setJob(@NonNull() DownloadJob job)
Sets a DownloadJob. Dialog
getDialog()
Returns the ProgressDialog that is used by this fragment. void
onCreate(@Nullable() Bundle savedInstanceState)
final Dialog
onCreateDialog(Bundle savedInstanceState)
void
onCancel(DialogInterface dialog)
void
onDestroyView()
void
setDialogOnCancelListener(@Nullable() DialogInterface.OnCancelListener dialogCancelListener)
Sets a DialogInterface.OnCancelListener that will be informed when the progress dialog was cancelled by the user. -
-
Method Detail
-
getJob
DownloadJob getJob()
Returns the set DownloadJob (if any). This can be used to retrieve the retained job after a configuration change happened.
- Returns:
The DownloadJob that was previously set via setJob or
null
if no job was set.
-
setJob
void setJob(@NonNull() DownloadJob job)
Sets a DownloadJob. The fragment will retain the job across configuration changes (if added to the activity) and show its progress via a dialog.
- Parameters:
job
- The DownloadJob to retain and visualize.
-
getDialog
Dialog getDialog()
Returns the ProgressDialog that is used by this fragment.
- Returns:
The ProgressDialog instance used by this fragment, or
null
if it's not yet initialized.
-
onCreateDialog
@NonNull() final Dialog onCreateDialog(Bundle savedInstanceState)
-
onCancel
void onCancel(DialogInterface dialog)
-
onDestroyView
void onDestroyView()
-
setDialogOnCancelListener
void setDialogOnCancelListener(@Nullable() DialogInterface.OnCancelListener dialogCancelListener)
Sets a DialogInterface.OnCancelListener that will be informed when the progress dialog was cancelled by the user. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
dialogCancelListener
- DialogInterface.OnCancelListener that should be notified, ornull
to clear the listener.
-
-
-
-