mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
more cleanup using setters to replace overloading
This commit is contained in:
parent
25823aec74
commit
1a56854d41
2 changed files with 62 additions and 83 deletions
|
@ -383,19 +383,20 @@ public class DlgDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
public void showOKOnlyDialog( String msg )
|
||||
{
|
||||
showOKOnlyDialogThen( msg, Action.SKIP_CALLBACK );
|
||||
}
|
||||
|
||||
public void showOKOnlyDialogThen( String msg, Action action )
|
||||
{
|
||||
// Assert.assertNull( m_dlgStates );
|
||||
DlgState state = new DlgState( DlgID.DIALOG_OKONLY, msg, action );
|
||||
DlgState state = new DlgState( DlgID.DIALOG_OKONLY ).setMsg( msg )
|
||||
.setAction(action);
|
||||
addState( state );
|
||||
showDialog( DlgID.DIALOG_OKONLY );
|
||||
}
|
||||
|
||||
public void showOKOnlyDialog( String msg )
|
||||
{
|
||||
showOKOnlyDialogThen( msg, Action.SKIP_CALLBACK );
|
||||
}
|
||||
|
||||
public void showOKOnlyDialog( int msgID )
|
||||
{
|
||||
showOKOnlyDialogThen( getString( msgID ), Action.SKIP_CALLBACK );
|
||||
|
@ -416,7 +417,9 @@ public class DlgDelegate {
|
|||
// indicating whether enabling is now ok.
|
||||
public void showSMSEnableDialog( Action action, Object... params )
|
||||
{
|
||||
DlgState state = new DlgState( DlgID.DIALOG_ENABLESMS, action, params );
|
||||
DlgState state = new DlgState( DlgID.DIALOG_ENABLESMS )
|
||||
.setAction( action )
|
||||
.setParams( params );
|
||||
addState( state );
|
||||
showDialog( DlgID.DIALOG_ENABLESMS );
|
||||
}
|
||||
|
@ -439,9 +442,9 @@ public class DlgDelegate {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
DlgState state =
|
||||
new DlgState( DlgID.DIALOG_NOTAGAIN, msg, prefsKey, action, more,
|
||||
params );
|
||||
DlgState state = new DlgState( DlgID.DIALOG_NOTAGAIN )
|
||||
.setMsg( msg).setPrefsKey( prefsKey ).setAction( action )
|
||||
.setActionPair( more ).setParams( params );
|
||||
addState( state );
|
||||
showDialog( DlgID.DIALOG_NOTAGAIN );
|
||||
}
|
||||
|
@ -455,9 +458,12 @@ public class DlgDelegate {
|
|||
onNA = nakey; // so the run() method will be called to set the key
|
||||
}
|
||||
if ( null == nakey || !nakey.isSet( m_activity ) ) {
|
||||
DlgState state
|
||||
= new DlgState( DlgID.CONFIRM_THEN, onNA, msg, posButton,
|
||||
negButton, action, 0, params );
|
||||
DlgState state = new DlgState( DlgID.CONFIRM_THEN ).setOnNA(onNA)
|
||||
.setMsg( msg )
|
||||
.setPosButton( posButton )
|
||||
.setNegButton( negButton )
|
||||
.setAction( action )
|
||||
.setParams( params );
|
||||
addState( state );
|
||||
showDialog( DlgID.CONFIRM_THEN );
|
||||
}
|
||||
|
@ -470,7 +476,9 @@ public class DlgDelegate {
|
|||
|| XWPrefs.getNFCToSelfEnabled( m_activity )
|
||||
|| NFCUtils.nfcAvail( m_activity )[0]
|
||||
|| BTService.BTAvailable() ) {
|
||||
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN, action, info );
|
||||
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN )
|
||||
.setAction( action )
|
||||
.setParams( info );
|
||||
addState( state );
|
||||
showDialog( DlgID.INVITE_CHOICES_THEN );
|
||||
} else {
|
||||
|
@ -498,7 +506,8 @@ public class DlgDelegate {
|
|||
{
|
||||
if ( LookupAlert.needAlert( m_activity, words, lang, noStudy ) ) {
|
||||
Bundle params = LookupAlert.makeParams( words, lang, noStudy );
|
||||
addState( new DlgState( DlgID.LOOKUP, new Object[]{params} ) );
|
||||
addState( new DlgState( DlgID.LOOKUP )
|
||||
.setParams( new Object[]{params} ) );
|
||||
showDialog( DlgID.LOOKUP );
|
||||
} else {
|
||||
LookupAlert.launchWordLookup( m_activity, words[0], lang );
|
||||
|
|
|
@ -34,67 +34,31 @@ public class DlgState implements Parcelable {
|
|||
public Action m_action = null;
|
||||
public ActionPair m_pair = null;
|
||||
public int m_prefsKey;
|
||||
// These can't be serialized!!!!
|
||||
public Object[] m_params;
|
||||
public Runnable m_onNAChecked;
|
||||
|
||||
public DlgState( DlgID dlgID, String msg, Action action )
|
||||
{
|
||||
this( dlgID, msg, android.R.string.ok, action, 0 );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, String msg, Action action, int prefsKey )
|
||||
{
|
||||
this( dlgID, msg, android.R.string.ok, action, prefsKey );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, String msg, int prefsKey, Action action,
|
||||
ActionPair more, Object[] params )
|
||||
{
|
||||
this( dlgID, msg, android.R.string.ok, action, prefsKey );
|
||||
m_params = params;
|
||||
m_pair = more;
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, String msg, int posButton,
|
||||
Action action, int prefsKey )
|
||||
{
|
||||
this( dlgID, msg, posButton, action, prefsKey, null );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, String msg, int posButton,
|
||||
Action action, int prefsKey, Object[] params )
|
||||
{
|
||||
this( dlgID, null, msg, posButton, android.R.string.cancel,
|
||||
action, prefsKey, params );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, Runnable onNA, String msg, int posButton, int negButton,
|
||||
Action action, int prefsKey, Object[] params )
|
||||
public DlgState( DlgID dlgID )
|
||||
{
|
||||
m_id = dlgID;
|
||||
m_onNAChecked = onNA;
|
||||
m_msg = msg;
|
||||
m_posButton = posButton;
|
||||
m_negButton = negButton;
|
||||
m_action = action;
|
||||
m_prefsKey = prefsKey;
|
||||
m_params = params;
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, Action action )
|
||||
{
|
||||
this( dlgID, null, 0, action, 0 );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, Object[] params )
|
||||
{
|
||||
this( dlgID, null, 0, null, 0, params );
|
||||
}
|
||||
|
||||
public DlgState( DlgID dlgID, Action action, Object... params )
|
||||
{
|
||||
this( dlgID, null, 0, action, 0, params );
|
||||
}
|
||||
public DlgState setMsg( String msg )
|
||||
{ m_msg = msg; return this; }
|
||||
public DlgState setPrefsKey( int key )
|
||||
{ m_prefsKey = key; return this; }
|
||||
public DlgState setAction( Action action )
|
||||
{ m_action = action; return this; }
|
||||
public DlgState setParams( Object... params )
|
||||
{ m_params = params; return this; }
|
||||
public DlgState setActionPair( ActionPair pair )
|
||||
{ m_pair = pair; return this; }
|
||||
public DlgState setOnNA( Runnable na )
|
||||
{ m_onNAChecked = na; return this; }
|
||||
public DlgState setPosButton( int id )
|
||||
{ m_posButton = id; return this; }
|
||||
public DlgState setNegButton( int id )
|
||||
{ m_negButton = id; return this; }
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
@ -111,19 +75,25 @@ public class DlgState implements Parcelable {
|
|||
|
||||
public static final Parcelable.Creator<DlgState> CREATOR
|
||||
= new Parcelable.Creator<DlgState>() {
|
||||
public DlgState createFromParcel(Parcel in) {
|
||||
DlgID id = DlgID.values()[in.readInt()];
|
||||
int posButton = in.readInt();
|
||||
int negButton = in.readInt();
|
||||
int tmp = in.readInt();
|
||||
Action action = 0 > tmp ? null : Action.values()[tmp];
|
||||
int prefsKey = in.readInt();
|
||||
String msg = in.readString();
|
||||
return new DlgState( id, null, msg, posButton, negButton, action, prefsKey, null );
|
||||
}
|
||||
public DlgState createFromParcel(Parcel in) {
|
||||
DlgID id = DlgID.values()[in.readInt()];
|
||||
int posButton = in.readInt();
|
||||
int negButton = in.readInt();
|
||||
int tmp = in.readInt();
|
||||
Action action = 0 > tmp ? null : Action.values()[tmp];
|
||||
int prefsKey = in.readInt();
|
||||
String msg = in.readString();
|
||||
DlgState state = new DlgState(id)
|
||||
.setMsg( msg )
|
||||
.setPosButton( posButton )
|
||||
.setNegButton( negButton )
|
||||
.setAction( action )
|
||||
.setPrefsKey( prefsKey );
|
||||
return state;
|
||||
}
|
||||
|
||||
public DlgState[] newArray(int size) {
|
||||
return new DlgState[size];
|
||||
}
|
||||
};
|
||||
public DlgState[] newArray(int size) {
|
||||
return new DlgState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue