Package eltos.simpledialogfragment
Class CustomViewDialog<This extends CustomViewDialog<This>>
java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<This>
- 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
- Direct Known Subclasses:
CustomListDialog
,SimpleCheckDialog
,SimpleColorWheelDialog
,SimpleDateDialog
,SimpleFormDialog
,SimpleImageDialog
,SimpleInputDialog
,SimplePinDialog
,SimpleProgressDialog
,SimpleTimeDialog
public abstract class CustomViewDialog<This extends CustomViewDialog<This>>
extends SimpleDialog<This>
The base class for all custom dialogs.
Extend this class and implement/overwrite the methods to use your custom view
See
SimpleCheckDialog
as an example.
Created by eltos on 11.10.2015.-
Nested Class Summary
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
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 TypeMethodDescriptionprotected boolean
Overwrite this method to catch positive button presses, e.g. if you need to verify input by the user Note: do not callpressPositiveButton()
here!static CustomViewDialog
build()
protected boolean
callResultListener
(int which, android.os.Bundle extras) final android.view.View
extractContentView
(android.os.Bundle savedInstanceState) Method to extract the underlying content view.protected final android.view.View
inflate
(int resource) Method to inflate your custom View fromonCreateContentView(android.os.Bundle)
protected final android.view.View
inflate
(int resource, android.view.ViewGroup root, boolean attachToRoot) Method to inflate your custom View fromonCreateContentView(android.os.Bundle)
.void
onCreate
(android.os.Bundle savedInstanceState) protected abstract android.view.View
onCreateContentView
(android.os.Bundle savedInstanceState) Inflate your custom view here.android.app.Dialog
onCreateDialog
(android.os.Bundle savedInstanceState) protected void
Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonStateprotected void
Overwrite this method to modify what happens if the user presses the negative button.protected void
Overwrite this method to modify what happens if the user presses the neutral button.protected void
Overwrite this method to modify what happens if the user presses the positive button.protected android.os.Bundle
onResult
(int which) Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
protected final void
Simulates a positive button press.final void
setNegativeButtonEnabled
(boolean enabled) Call this method to enable or disable the positive button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
final void
setNeutralButtonEnabled
(boolean enabled) Call this method to enable or disable the neutral button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
final void
setPositiveButtonEnabled
(boolean enabled) Call this method to enable or disable the positive button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
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, onSaveInstanceState, 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:
-
-
Constructor Details
-
CustomViewDialog
public CustomViewDialog()
-
-
Method Details
-
build
-
onCreateContentView
protected abstract android.view.View onCreateContentView(android.os.Bundle savedInstanceState) Inflate your custom view here.- 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.
-
onResult
@Nullable protected android.os.Bundle onResult(int which) Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
- Parameters:
which
- seeSimpleDialog.OnDialogResultListener
- Returns:
- the bundle to merge with the results or null
-
setPositiveButtonEnabled
public final void setPositiveButtonEnabled(boolean enabled) Call this method to enable or disable the positive button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
- Parameters:
enabled
- whether to en- or disable the button
-
setNeutralButtonEnabled
public final void setNeutralButtonEnabled(boolean enabled) Call this method to enable or disable the neutral button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
- Parameters:
enabled
- whether to en- or disable the button
-
setNegativeButtonEnabled
public final void setNegativeButtonEnabled(boolean enabled) Call this method to enable or disable the positive button, e.g. if you want to consider for preconditions to be fulfilled Note: call this inonDialogShown()
rather thanonCreateContentView(android.os.Bundle)
- Parameters:
enabled
- whether to en- or disable the button
-
acceptsPositiveButtonPress
protected boolean acceptsPositiveButtonPress()Overwrite this method to catch positive button presses, e.g. if you need to verify input by the user Note: do not callpressPositiveButton()
here!- Returns:
- false to ignore the press, true to process normally
-
onDialogShown
protected void onDialogShown()Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonState -
onPositiveButtonClick
protected void onPositiveButtonClick()Overwrite this method to modify what happens if the user presses the positive button. The default implementation dismisses the dialog and calls the result listener. -
onNegativeButtonClick
protected void onNegativeButtonClick()Overwrite this method to modify what happens if the user presses the negative button. The default implementation dismisses the dialog and calls the result listener. -
onNeutralButtonClick
protected void onNeutralButtonClick()Overwrite this method to modify what happens if the user presses the neutral button. The default implementation dismisses the dialog and calls the result listener. -
pressPositiveButton
protected final void pressPositiveButton()Simulates a positive button press. You may use this method in combination with ImeOptions such asEditorInfo.IME_ACTION_DONE
Note: do not call this method fromacceptsPositiveButtonPress()
!!! -
inflate
protected final android.view.View inflate(@LayoutRes int resource) Method to inflate your custom View fromonCreateContentView(android.os.Bundle)
- Parameters:
resource
- The resource to be inflated- Returns:
- The inflated view
-
inflate
protected final android.view.View inflate(@LayoutRes int resource, android.view.ViewGroup root, boolean attachToRoot) Method to inflate your custom View fromonCreateContentView(android.os.Bundle)
. ThrowsInflateException
if there is an error.- Parameters:
resource
- ID for an XML layout resource to loadroot
- Optional view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)attachToRoot
- Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.- Returns:
- The root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file.
-
extractContentView
public final android.view.View extractContentView(android.os.Bundle savedInstanceState) Method to extract the underlying content view.- Parameters:
savedInstanceState
- The saved instance state- Returns:
- the extracted view
-
onCreate
@CallSuper public void onCreate(android.os.Bundle savedInstanceState) - Overrides:
onCreate
in classSimpleDialog<This extends CustomViewDialog<This>>
-
onCreateDialog
@NonNull public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) - Overrides:
onCreateDialog
in classSimpleDialog<This extends CustomViewDialog<This>>
-
callResultListener
@CallSuper protected boolean callResultListener(int which, @Nullable android.os.Bundle extras) - Overrides:
callResultListener
in classSimpleDialog<This extends CustomViewDialog<This>>
-