mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
move a few methods, and add utilities, to superclass.
This commit is contained in:
parent
4b26e04691
commit
a6d8a74102
8 changed files with 48 additions and 20 deletions
|
@ -510,7 +510,7 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
if ( CommonPrefs.getHideTitleBar( m_activity )
|
||||
&& ABUtils.haveMenuKey( m_activity ) ) {
|
||||
m_activity.requestWindowFeature( Window.FEATURE_NO_TITLE );
|
||||
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
||||
}
|
||||
|
||||
if ( BuildConstants.CHAT_SUPPORTED ) {
|
||||
|
@ -930,7 +930,7 @@ public class BoardDelegate extends DelegateBase
|
|||
cmd = JNICmd.CMD_COMMIT;
|
||||
break;
|
||||
case SHOW_EXPL_ACTION:
|
||||
Utils.showToast( m_activity, m_toastStr );
|
||||
showToast( m_toastStr );
|
||||
m_toastStr = null;
|
||||
break;
|
||||
case BUTTON_BROWSEALL_ACTION:
|
||||
|
@ -968,7 +968,7 @@ public class BoardDelegate extends DelegateBase
|
|||
startChatActivity();
|
||||
break;
|
||||
case START_TRADE_ACTION:
|
||||
Utils.showToast( m_activity, R.string.entering_trade );
|
||||
showToast( R.string.entering_trade );
|
||||
cmd = JNICmd.CMD_TRADE;
|
||||
break;
|
||||
case LOOKUP_ACTION:
|
||||
|
@ -1122,7 +1122,7 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
|
||||
if ( doToast ) {
|
||||
Utils.showToast( m_activity, strID );
|
||||
showToast( strID );
|
||||
} else if ( dlgID != DlgID.NONE ) {
|
||||
final int strIDf = strID;
|
||||
final DlgID dlgIDf = dlgID;
|
||||
|
@ -1173,7 +1173,7 @@ public class BoardDelegate extends DelegateBase
|
|||
//////////////////////////////////////////////////
|
||||
public void invalidateParent()
|
||||
{
|
||||
m_activity.runOnUiThread(new Runnable() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
m_view.invalidate();
|
||||
}
|
||||
|
@ -1202,7 +1202,7 @@ public class BoardDelegate extends DelegateBase
|
|||
m_jniThread.setSaveDict( getDict );
|
||||
|
||||
String msg = getString( R.string.reload_new_dict_fmt, getDict );
|
||||
Utils.showToast( m_activity, msg );
|
||||
showToast( msg );
|
||||
finish();
|
||||
GameUtils.launchGame( m_activity, m_rowid, false );
|
||||
}
|
||||
|
@ -1400,7 +1400,7 @@ public class BoardDelegate extends DelegateBase
|
|||
final String bonusStr = getString( id );
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
Utils.showToast( m_activity, bonusStr );
|
||||
showToast( bonusStr );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -1418,7 +1418,7 @@ public class BoardDelegate extends DelegateBase
|
|||
final String text = String.format( "%s\n%s", name, expl );
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
Utils.showToast( m_activity, text );
|
||||
showToast( text );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -1983,7 +1983,7 @@ public class BoardDelegate extends DelegateBase
|
|||
DbgUtils.loge( ie );
|
||||
if ( DlgID.NONE != m_blockingDlgID ) {
|
||||
try {
|
||||
m_activity.dismissDialog( m_blockingDlgID.ordinal() );
|
||||
dismissDialog( m_blockingDlgID );
|
||||
} catch ( java.lang.IllegalArgumentException iae ) {
|
||||
DbgUtils.loge( iae );
|
||||
}
|
||||
|
|
|
@ -162,6 +162,31 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
|||
ABUtils.invalidateOptionsMenuIf( m_activity );
|
||||
}
|
||||
|
||||
public void showToast( int msg )
|
||||
{
|
||||
Utils.showToast( m_activity, msg );
|
||||
}
|
||||
|
||||
public void showToast( String msg )
|
||||
{
|
||||
Utils.showToast( m_activity, msg );
|
||||
}
|
||||
|
||||
public boolean requestWindowFeature( int feature )
|
||||
{
|
||||
return m_activity.requestWindowFeature( feature );
|
||||
}
|
||||
|
||||
public Object getSystemService( String name )
|
||||
{
|
||||
return m_activity.getSystemService( name );
|
||||
}
|
||||
|
||||
public void runOnUiThread( Runnable runnable )
|
||||
{
|
||||
m_activity.runOnUiThread( runnable );
|
||||
}
|
||||
|
||||
protected void showDialog( DlgID dlgID )
|
||||
{
|
||||
m_delegate.showDialog( dlgID );
|
||||
|
@ -172,6 +197,11 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
|||
removeDialog( dlgID.ordinal() );
|
||||
}
|
||||
|
||||
protected void dismissDialog( DlgID dlgID )
|
||||
{
|
||||
m_activity.dismissDialog( dlgID.ordinal() );
|
||||
}
|
||||
|
||||
protected void removeDialog( int id )
|
||||
{
|
||||
m_activity.removeDialog( id );
|
||||
|
|
|
@ -176,7 +176,7 @@ public class DictImportDelegate extends DelegateBase {
|
|||
|
||||
m_handler = new Handler();
|
||||
|
||||
m_activity.requestWindowFeature( Window.FEATURE_LEFT_ICON );
|
||||
requestWindowFeature( Window.FEATURE_LEFT_ICON );
|
||||
setContentView( R.layout.import_dict );
|
||||
m_activity.getWindow().setFeatureDrawableResource( Window.FEATURE_LEFT_ICON,
|
||||
R.drawable.icon48x48 );
|
||||
|
|
|
@ -645,7 +645,7 @@ public class DictsDelegate extends DelegateBase
|
|||
try {
|
||||
startActivity( downloadIntent );
|
||||
} catch ( android.content.ActivityNotFoundException anfe ) {
|
||||
Utils.showToast( m_activity, R.string.no_download_warning );
|
||||
showToast( R.string.no_download_warning );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -790,8 +790,7 @@ public class DictsDelegate extends DelegateBase
|
|||
finish();
|
||||
}
|
||||
} else {
|
||||
Utils.showToast( m_activity,
|
||||
R.string.download_failed );
|
||||
showToast( R.string.download_failed );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -216,8 +216,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
public void onDismiss( DialogInterface di )
|
||||
{
|
||||
if ( m_gi.forceRemoteConsistent() ) {
|
||||
Utils.showToast( m_activity,
|
||||
R.string.forced_consistent );
|
||||
showToast( R.string.forced_consistent );
|
||||
loadPlayersList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
// DBUtils.DBChangeListener interface
|
||||
public void gameSaved( final long rowid, final boolean countChanged )
|
||||
{
|
||||
m_activity.runOnUiThread( new Runnable() {
|
||||
runOnUiThread( new Runnable() {
|
||||
public void run() {
|
||||
if ( countChanged || DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
onContentChanged();
|
||||
|
@ -902,7 +902,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
if ( ! madeGame ) {
|
||||
int id = success ? R.string.download_done
|
||||
: R.string.download_failed;
|
||||
Utils.showToast( m_activity, id );
|
||||
showToast( id );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -203,7 +203,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
msg = String.format( "Cannot write to %s", value );
|
||||
}
|
||||
if ( null != msg ) {
|
||||
Utils.showToast( m_activity, msg );
|
||||
showToast( msg );
|
||||
}
|
||||
}
|
||||
DictUtils.invalDictList();
|
||||
|
|
|
@ -166,12 +166,12 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
case SL_COPY_ACTION:
|
||||
selWords = getSelWords();
|
||||
ClipboardManager clipboard = (ClipboardManager)
|
||||
m_activity.getSystemService( Context.CLIPBOARD_SERVICE );
|
||||
getSystemService( Context.CLIPBOARD_SERVICE );
|
||||
clipboard.setText( TextUtils.join( "\n", selWords ) );
|
||||
|
||||
String msg = getString( R.string.paste_done_fmt,
|
||||
selWords.length );
|
||||
Utils.showToast( m_activity, msg );
|
||||
showToast( msg );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
|
|
Loading…
Reference in a new issue