Class SimpleProgressDialog

java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
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 SimpleProgressDialog extends CustomViewDialog<SimpleProgressDialog>
A dialog that displays a progress Created by eltos on 27.05.21.
  • Field Details

    • TAG

      public static final String TAG
      See Also:
    • COMPLETED

      public static final int COMPLETED
      Result 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

      protected SimpleProgressTask<?,?,?> mTask
  • Constructor Details

    • SimpleProgressDialog

      public SimpleProgressDialog()
  • Method Details

    • build

      public static SimpleProgressDialog build()
      Generic static method to build this dialog
      Returns:
      a new instance of a SimpleProgressDialog
    • buildBar

      public static SimpleProgressDialog buildBar()
      Static method to build a progress dialog of SimpleProgressDialog.Type.BAR Shows the percentage by default.
      Returns:
      a new instance of a SimpleProgressDialog
    • bar

      @Deprecated public static SimpleProgressDialog bar()
      Deprecated.
    • buildIndeterminateCircle

      public static SimpleProgressDialog buildIndeterminateCircle()
      Static method to build an indeterminate progress dialog of SimpleProgressDialog.Type.CIRCLE
      Returns:
      a new instance of a SimpleProgressDialog
    • indeterminateCircle

      @Deprecated public static SimpleProgressDialog indeterminateCircle()
      Deprecated.
    • type

      Set the progress bar type to any of SimpleProgressDialog.Type Please note that some features might not be available depending on the chosen type
      Parameters:
      type - The progress bar type SimpleProgressDialog.Type
      Returns:
      this instance
    • percentage

      public SimpleProgressDialog percentage(boolean visible)
      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 (see SimpleProgressTask.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 - : The SimpleProgressTask associated with this dialog
      cancelable - : If a cancel button is shown to allow canceling the task
      autoDismiss - : 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 progress
      max - 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, use updateProgress(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

      public void updateProgressText(String text)
      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

      public void updateInfoText(String text)
      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 class CustomViewDialog<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 class CustomViewDialog<SimpleProgressDialog>
    • callResultListener

      @CallSuper protected boolean callResultListener(int which, android.os.Bundle extras)
      Overrides:
      callResultListener in class CustomViewDialog<SimpleProgressDialog>
    • onSaveInstanceState

      public void onSaveInstanceState(@NonNull android.os.Bundle outState)
      Overrides:
      onSaveInstanceState in class androidx.fragment.app.DialogFragment