support setActionPair() for okOnly alerts too

This commit is contained in:
Eric House 2019-03-04 10:45:15 -08:00
parent 4493f9d9cd
commit c59e86b724
3 changed files with 19 additions and 5 deletions

View file

@ -207,8 +207,8 @@ public class DlgDelegate {
@Override
public void show()
{
Assert.assertTrue( null == m_actionPair || !BuildConfig.DEBUG );
showOKOnlyDialogThen( m_msgString, m_action, m_params, m_titleId );
showOKOnlyDialogThen( m_msgString, m_action, m_actionPair,
m_params, m_titleId );
}
}
@ -337,12 +337,14 @@ public class DlgDelegate {
}
private void showOKOnlyDialogThen( String msg, Action action,
Object[] params, int titleId )
ActionPair more, Object[] params,
int titleId )
{
DlgState state = new DlgState( DlgID.DIALOG_OKONLY )
.setMsg( msg )
.setParams( params )
.setTitle( titleId )
.setActionPair( more )
.setAction(action);
m_dlgt.show( state );
}

View file

@ -120,6 +120,11 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
};
}
protected OnClickListener mkCallbackClickListener( ActionPair pair )
{
return mkCallbackClickListener( pair, null );
}
protected OnClickListener mkCallbackClickListener( final NotAgainView naView )
{
OnClickListener cbkOnClickLstnr;

View file

@ -52,11 +52,18 @@ public class OkOnlyAlert extends DlgDelegateAlert {
final DlgState state = getState( sis );
Dialog dialog = LocUtils.makeAlertBuilder( getActivity() )
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( getActivity() )
.setTitle( state.m_titleId == 0 ? R.string.info_title : state.m_titleId )
.setMessage( state.m_msg )
.setPositiveButton( android.R.string.ok, null )
.create();
;
ActionPair pair = state.m_pair;
if ( null != pair ) {
builder.setNeutralButton( pair.buttonStr, mkCallbackClickListener( pair ) );
}
Dialog dialog = builder.create();
// dialog = setCallbackDismissListener( dialog, state, dlgID );
return dialog;
}