public class MultitapAlertCompatDialog
extends android.support.v7.app.AlertDialog
implements android.content.DialogInterface.OnClickListener
AlertDialog
, this class is its own builder.
Special thanks to @dapayne1
for the original inspiration.
This version of the dialog builds on the Android Compatibility Library. For
an extension of the modern AlertDialog
class, see
MultitapAlertDialog
.android.support.v7.app.AlertDialog.Builder
android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnClickListener, android.content.DialogInterface.OnDismissListener, android.content.DialogInterface.OnKeyListener, android.content.DialogInterface.OnMultiChoiceClickListener, android.content.DialogInterface.OnShowListener
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TAPS_REQUIRED
Specifies the default number of taps required on the positive button
before its action is executed.
|
static java.lang.String |
LOG_TAG |
protected android.widget.Button |
m_btnPositive
Once the dialog is constructed, this will hold a persistent reference to
the positive button itself, so that we can dynamically update its text.
|
protected int |
m_nTapsCurrent
The number of times that the positive button has been tapped so far.
|
protected int |
m_nTapsRequired
The number of taps required to execute the positive button's action.
|
protected int |
m_resPositiveLabelFormat
The resource ID of the string which formats the positive button's label.
|
protected java.lang.String |
m_sPositiveLabel
The positive button label.
|
protected java.lang.Runnable |
m_taskNegative
The task to be executed if the negative button is tapped.
|
protected java.lang.Runnable |
m_taskPositive
The task to be executed if the positive button is tapped sufficiently.
|
Constructor and Description |
---|
MultitapAlertCompatDialog(android.content.Context ctx,
int resTitle,
int resMessage)
Additional constructor allowing initial setup of title and message.
|
Modifier and Type | Method and Description |
---|---|
void |
onClick(android.content.DialogInterface dia,
int zButtonID) |
protected MultitapAlertCompatDialog |
regeneratePositiveLabel()
Regenerates the label of the positive button, showing the difference
between the number of taps required and the number of taps already
intercepted.
|
MultitapAlertCompatDialog |
setNegativeButton(int resLabel,
java.lang.Runnable task)
Add a negative button with the specified label, such that the specified
task is executed when tapped once.
|
MultitapAlertCompatDialog |
setNegativeButton(java.lang.Runnable task)
Add a negative button which will execute the specified task when tapped
once.
|
MultitapAlertCompatDialog |
setPositiveButton(int resLabel,
java.lang.Runnable task)
Add a positive button with the specified label, such that the specified
task is executed when tapped the requisite number of times.
|
MultitapAlertCompatDialog |
setPositiveButton(java.lang.Runnable task)
Add a positive button which will execute the specified task when tapped
the requisite number of times.
|
MultitapAlertCompatDialog |
setPositiveTapsRequired(int nTaps)
Sets the number of taps required to execute the positive action.
|
MultitapAlertCompatDialog |
setStandardButtons(java.lang.Runnable taskPositive,
java.lang.Runnable taskNegative)
Sets up a standard "OK" positive button and a standard "Cancel" negative
button, using the specified tasks.
|
void |
show() |
getButton, getListView, onCreate, onKeyDown, onKeyUp, setButton, setButton, setButton, setCustomTitle, setIcon, setIcon, setIconAttribute, setMessage, setTitle, setView, setView
addContentView, findViewById, getDelegate, getSupportActionBar, invalidateOptionsMenu, onStop, onSupportActionModeFinished, onSupportActionModeStarted, onWindowStartingSupportActionMode, setContentView, setContentView, setContentView, setTitle, supportRequestWindowFeature
cancel, closeOptionsMenu, create, dismiss, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, getActionBar, getContext, getCurrentFocus, getLayoutInflater, getOwnerActivity, getSearchEvent, getVolumeControlStream, getWindow, hide, isShowing, onActionModeFinished, onActionModeStarted, onAttachedToWindow, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onDetachedFromWindow, onGenericMotionEvent, onKeyLongPress, onKeyMultiple, onKeyShortcut, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, onStart, onTouchEvent, onTrackballEvent, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, registerForContextMenu, requestWindowFeature, setCancelable, setCanceledOnTouchOutside, setCancelMessage, setDismissMessage, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setOnCancelListener, setOnDismissListener, setOnKeyListener, setOnShowListener, setOwnerActivity, setVolumeControlStream, takeKeyEvents, unregisterForContextMenu
public static final java.lang.String LOG_TAG
public static final int DEFAULT_TAPS_REQUIRED
protected int m_nTapsCurrent
protected int m_nTapsRequired
protected int m_resPositiveLabelFormat
R.string#label_btnMultitapPositive_LTR
,
R.string#label_btnMultitapPositive_RTL
protected java.lang.String m_sPositiveLabel
m_resPositiveLabelFormat
,
R.string#label_btnMultitapPositive_LTR
,
R.string#label_btnMultitapPositive_RTL
protected java.lang.Runnable m_taskPositive
protected java.lang.Runnable m_taskNegative
protected android.widget.Button m_btnPositive
public MultitapAlertCompatDialog(android.content.Context ctx, int resTitle, int resMessage)
ctx
- the context that will spawn the dialogresTitle
- the resource ID of the title stringresMessage
- the resource ID of the message stringpublic MultitapAlertCompatDialog setPositiveTapsRequired(int nTaps)
nTaps
- the number of taps requiredpublic MultitapAlertCompatDialog setPositiveButton(int resLabel, java.lang.Runnable task)
resLabel
- the label for the buttontask
- the task to be executedpublic MultitapAlertCompatDialog setPositiveButton(java.lang.Runnable task)
R.string.ok
) will be used
as the button label.task
- the task to be executedpublic MultitapAlertCompatDialog setNegativeButton(int resLabel, java.lang.Runnable task)
resLabel
- the label for the buttontask
- the task to be executedpublic MultitapAlertCompatDialog setNegativeButton(java.lang.Runnable task)
R.string.cancel
) will be
used as the button label.task
- the task to be executedpublic MultitapAlertCompatDialog setStandardButtons(java.lang.Runnable taskPositive, java.lang.Runnable taskNegative)
taskPositive
- the task to be executed if the positive button is
tapped the requisite number of timestaskNegative
- the task to be executed if the negative button is
tapped onceprotected MultitapAlertCompatDialog regeneratePositiveLabel()
public void onClick(android.content.DialogInterface dia, int zButtonID)
onClick
in interface android.content.DialogInterface.OnClickListener
public void show()
show
in class android.app.Dialog