Package eltos.simpledialogfragment
Class SimpleProgressDialog
java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<SimpleProgressDialog>
eltos.simpledialogfragment.SimpleProgressDialog
- 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
A dialog that displays a progress
Created by eltos on 27.05.21.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum for various progress bar types.Nested classes/interfaces inherited from class eltos.simpledialogfragment.SimpleDialog
SimpleDialog.OnDialogResultListener
Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Result type if dialog was auto-dismissed due a to completed taskprotected android.widget.TextView
protected android.widget.ProgressBar
protected android.widget.TextView
protected SimpleProgressTask<?,
?, ?> static final String
Fields inherited from class eltos.simpledialogfragment.SimpleDialog
BUNDLE, CANCELABLE, FULLSCREEN, HTML, ICON_RESOURCE, MESSAGE, NEGATIVE_BUTTON_TEXT, NEUTRAL_BUTTON_TEXT, POSITIVE_BUTTON_TEXT, THEME, TITLE
Fields inherited from class androidx.fragment.app.DialogFragment
STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleProgressDialog
bar()
Deprecated.static SimpleProgressDialog
build()
Generic static method to build this dialogstatic SimpleProgressDialog
buildBar()
Static method to build a progress dialog ofSimpleProgressDialog.Type.BAR
Shows the percentage by default.static SimpleProgressDialog
Static method to build an indeterminate progress dialog ofSimpleProgressDialog.Type.CIRCLE
protected boolean
callResultListener
(int which, android.os.Bundle extras) static SimpleProgressDialog
Deprecated.void
onCreate
(android.os.Bundle savedInstanceState) protected android.view.View
onCreateContentView
(android.os.Bundle savedInstanceState) Inflate your custom view here.void
onSaveInstanceState
(android.os.Bundle outState) percentage
(boolean visible) Whether to show the percentage text or nottask
(SimpleProgressTask<?, ?, ?> task, boolean cancelable, boolean autoDismiss) Connect an AsyncTask with this dialog.Set the progress bar type to any ofSimpleProgressDialog.Type
Please note that some features might not be available depending on the chosen typevoid
Set or update the progress to be finished, i.e. 100% If a task is linked to this dialog, the "cancel" button is disabled, the positive one enabled, and the dialog dismissed if autoDismiss was setvoid
Set or update the progress to be indeterminate before or while the dialog is shown.void
updateInfoText
(String text) Set or update the info text at the end of the bar / next to the circlevoid
updateMax
(int max) Set or update the progress before or while the dialog is shown.void
updateProgress
(int progress) Set or update the progress before or while the dialog is shown.void
updateProgress
(int progress, int max) Set or update the progress before or while the dialog is shown.void
updateProgress
(Boolean indeterminate, Integer progress, Integer secondaryProgress, Integer max) Set or update the progress before or while the dialog is shown.void
updateProgressText
(String text) Set or update the progress text at the start of the progress bar / in the center of the circlevoid
updateSecondaryProgress
(int progress) Set or update the progress before or while the dialog is shown.Methods inherited from class eltos.simpledialogfragment.CustomViewDialog
acceptsPositiveButtonPress, extractContentView, inflate, inflate, onCreateDialog, onDialogShown, onNegativeButtonClick, onNeutralButtonClick, onPositiveButtonClick, onResult, pressPositiveButton, setNegativeButtonEnabled, setNeutralButtonEnabled, setPositiveButtonEnabled
Methods inherited from class eltos.simpledialogfragment.SimpleDialog
cancelable, extra, fullscreen, fullscreen, getArgs, getArgString, getContext, getExtras, getMessage, getTitle, icon, isCancelable, msg, msg, msgHtml, msgHtml, neg, neg, neg, neut, neut, neut, onCancel, onDestroyView, pos, pos, setArg, setArg, setArg, setArg, setButtonClickListener, setButtonEnabled, show, show, show, show, show, show, show, show, showKeyboard, theme, title, title
Methods inherited from class androidx.fragment.app.DialogFragment
dismiss, dismissAllowingStateLoss, getDialog, getShowsDialog, getTheme, onAttach, onDetach, onDismiss, onGetLayoutInflater, onStart, onStop, onViewStateRestored, requireDialog, setCancelable, setShowsDialog, setStyle, setupDialog, showNow
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onViewCreated, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface androidx.lifecycle.HasDefaultViewModelProviderFactory
getDefaultViewModelCreationExtras
-
Field Details
-
TAG
- See Also:
-
COMPLETED
public static final int COMPLETEDResult type if dialog was auto-dismissed due a to completed task- See Also:
-
mProgressBar
protected android.widget.ProgressBar mProgressBar -
mProgressText
protected android.widget.TextView mProgressText -
mInfoText
protected android.widget.TextView mInfoText -
mTask
-
-
Constructor Details
-
SimpleProgressDialog
public SimpleProgressDialog()
-
-
Method Details
-
build
Generic static method to build this dialog- Returns:
- a new instance of a
SimpleProgressDialog
-
buildBar
Static method to build a progress dialog ofSimpleProgressDialog.Type.BAR
Shows the percentage by default.- Returns:
- a new instance of a
SimpleProgressDialog
-
bar
Deprecated. -
buildIndeterminateCircle
Static method to build an indeterminate progress dialog ofSimpleProgressDialog.Type.CIRCLE
- Returns:
- a new instance of a
SimpleProgressDialog
-
indeterminateCircle
Deprecated. -
type
Set the progress bar type to any ofSimpleProgressDialog.Type
Please note that some features might not be available depending on the chosen type- Parameters:
type
- The progress bar typeSimpleProgressDialog.Type
- Returns:
- this instance
-
percentage
Whether to show the percentage text or not- Parameters:
visible
- percentage text visible or not- Returns:
- this instance
-
task
public SimpleProgressDialog task(SimpleProgressTask<?, ?, ?> task, boolean cancelable, boolean autoDismiss) Connect an AsyncTask with this dialog. This will - update the progress dialog based on the progress reported by the task (seeSimpleProgressTask.onProgressUpdate(Progress...)
- if cancelable, add a neutral "cancel" button and disable it once the task finished - prevent the user from dismissing the dialog via the back button or by clicking outside it - if autoDismiss is true, dismiss the dialog after the task has ended - if autoDismiss is false, add a positive button "OK" that is only enabled after the task finished- Parameters:
task
- : TheSimpleProgressTask
associated with this dialogcancelable
- : If a cancel button is shown to allow canceling the taskautoDismiss
- : Whether to dismiss the dialog once the task finishes- Returns:
- this instance
-
updateProgress
public void updateProgress(@Nullable Boolean indeterminate, @Nullable Integer progress, @Nullable Integer secondaryProgress, @Nullable Integer max) Set or update the progress before or while the dialog is shown.- Parameters:
indeterminate
- indeterminate mode (or null to keep the previous value)progress
- primary progress (or null to keep the previous value)secondaryProgress
- secondary progress (if any, or null to keep the previous value)max
- maximum for progress (or null to keep the previous value)
-
updateProgress
public void updateProgress(int progress) Set or update the progress before or while the dialog is shown. This also sets indeterminate to false.- Parameters:
progress
- primary progress
-
updateProgress
public void updateProgress(int progress, int max) Set or update the progress before or while the dialog is shown. This also sets indeterminate to false.- Parameters:
progress
- primary progressmax
- maximum for progress
-
updateMax
public void updateMax(int max) Set or update the progress before or while the dialog is shown.- Parameters:
max
- maximum for progress
-
updateSecondaryProgress
public void updateSecondaryProgress(int progress) Set or update the progress before or while the dialog is shown. This also sets indeterminate to false.- Parameters:
progress
- secondary progress
-
updateIndeterminate
public void updateIndeterminate()Set or update the progress to be indeterminate before or while the dialog is shown. To set indeterminate to false, useupdateProgress(java.lang.Boolean, java.lang.Integer, java.lang.Integer, java.lang.Integer)
-
updateFinished
public void updateFinished()Set or update the progress to be finished, i.e. 100% If a task is linked to this dialog, the "cancel" button is disabled, the positive one enabled, and the dialog dismissed if autoDismiss was set. * -
updateProgressText
Set or update the progress text at the start of the progress bar / in the center of the circle- Parameters:
text
- The text to show
-
updateInfoText
Set or update the info text at the end of the bar / next to the circle- Parameters:
text
- The text to show
-
onCreateContentView
protected android.view.View onCreateContentView(android.os.Bundle savedInstanceState) Description copied from class:CustomViewDialog
Inflate your custom view here.- Specified by:
onCreateContentView
in classCustomViewDialog<SimpleProgressDialog>
- Parameters:
savedInstanceState
- The last saved instance state of the Fragment, or null if this fragment is created for the first time.- Returns:
- Return a new View to be displayed by the Fragment.
-
onCreate
@CallSuper public void onCreate(android.os.Bundle savedInstanceState) - Overrides:
onCreate
in classCustomViewDialog<SimpleProgressDialog>
-
callResultListener
@CallSuper protected boolean callResultListener(int which, android.os.Bundle extras) - Overrides:
callResultListener
in classCustomViewDialog<SimpleProgressDialog>
-
onSaveInstanceState
public void onSaveInstanceState(@NonNull android.os.Bundle outState) - Overrides:
onSaveInstanceState
in classandroidx.fragment.app.DialogFragment
-