cleanup and rename method

This commit is contained in:
Eric House 2012-10-24 07:40:14 -07:00
parent 643a301214
commit 3d14ed96e7
5 changed files with 29 additions and 31 deletions

View file

@ -258,10 +258,10 @@ public class BoardActivity extends XWActivity
if ( DLG_USEDICT == id ) {
setGotGameDict( m_getDict );
} else {
NetUtils.launchAndDownload( BoardActivity.this,
m_gi.dictLang,
m_getDict,
BoardActivity.this );
NetUtils.downloadDictInBack( BoardActivity.this,
m_gi.dictLang,
m_getDict,
BoardActivity.this );
}
}
};

View file

@ -347,8 +347,8 @@ public class DictsActivity extends ExpandableListActivity
String name = intent.getStringExtra( MultiService.DICT );
m_launchedForMissing = true;
m_handler = new Handler();
NetUtils.launchAndDownload( DictsActivity.this, lang,
name, DictsActivity.this );
NetUtils.downloadDictInBack( DictsActivity.this, lang,
name, DictsActivity.this );
}
};
lstnr2 = new OnClickListener() {
@ -438,7 +438,7 @@ public class DictsActivity extends ExpandableListActivity
downloadNewDict( intent );
}
}
}
} // onCreate
@Override
protected void onResume()
@ -566,7 +566,7 @@ public class DictsActivity extends ExpandableListActivity
DictLoc loc = DictLoc.values()[loci];
String url =
intent.getStringExtra( UpdateCheckReceiver.NEW_DICT_URL );
NetUtils.launchAndDownload( this, url, loc, null );
NetUtils.downloadDictInBack( this, url, loc, null );
finish();
}
}
@ -677,12 +677,6 @@ public class DictsActivity extends ExpandableListActivity
}
private void startDownload( int lang, String name )
{
boolean toSD = XWPrefs.getDefaultLocInternal( this );
startDownload( lang, name, toSD );
}
private void startDownload( int lang, String name, boolean toSD )
{
Intent intent = mkDownloadIntent( this, lang, name );
startDownload( intent );
@ -758,6 +752,11 @@ public class DictsActivity extends ExpandableListActivity
launchAndDownload( activity, lang, null );
}
public static void launchAndDownload( Activity activity )
{
launchAndDownload( activity, 0, null );
}
// NetUtils.DownloadFinishedListener interface
public void downloadFinished( String name, final boolean success )
{

View file

@ -784,7 +784,7 @@ public class GameConfig extends XWActivity
String chosen =
(String)parentView.getItemAtPosition( position );
if ( chosen.equals( m_browseText ) ) {
DictsActivity.launchAndDownload( GameConfig.this, 0 );
DictsActivity.launchAndDownload( GameConfig.this );
} else {
m_gi.setLang( DictLangCache.
getLangLangCode( GameConfig.this,

View file

@ -103,12 +103,11 @@ public class GamesList extends XWListActivity
case WARN_NODICT_SUBST:
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
for ( String name : m_missingDictNames ) {
NetUtils.launchAndDownload( GamesList.this,
m_missingDictLang,
name, GamesList.this );
break; // just do one
}
// just do one
NetUtils.downloadDictInBack( GamesList.this,
m_missingDictLang,
m_missingDictNames[0],
GamesList.this );
}
};
String message;

View file

@ -274,24 +274,24 @@ public class NetUtils {
}
} // sendToRelay
static void launchAndDownload( Context context, int lang, String name,
DownloadFinishedListener lstnr )
static void downloadDictInBack( Context context, int lang, String name,
DownloadFinishedListener lstnr )
{
DictUtils.DictLoc loc = XWPrefs.getDefaultLoc( context );
launchAndDownload( context, lang, name, loc, lstnr );
downloadDictInBack( context, lang, name, loc, lstnr );
}
static void launchAndDownload( Context context, int lang, String name,
DictUtils.DictLoc loc,
DownloadFinishedListener lstnr )
static void downloadDictInBack( Context context, int lang, String name,
DictUtils.DictLoc loc,
DownloadFinishedListener lstnr )
{
String url = Utils.makeDictUrl( context, lang, name );
launchAndDownload( context, url, loc, lstnr );
downloadDictInBack( context, url, loc, lstnr );
}
static void launchAndDownload( final Context context, final String urlStr,
final DictUtils.DictLoc loc,
final DownloadFinishedListener lstnr )
static void downloadDictInBack( final Context context, final String urlStr,
final DictUtils.DictLoc loc,
final DownloadFinishedListener lstnr )
{
String tmp = Utils.dictFromURL( context, urlStr );
final String name = DictUtils.removeDictExtn( tmp );