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 ) { if ( DLG_USEDICT == id ) {
setGotGameDict( m_getDict ); setGotGameDict( m_getDict );
} else { } else {
NetUtils.launchAndDownload( BoardActivity.this, NetUtils.downloadDictInBack( BoardActivity.this,
m_gi.dictLang, m_gi.dictLang,
m_getDict, m_getDict,
BoardActivity.this ); BoardActivity.this );
} }
} }
}; };

View file

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

View file

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

View file

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

View file

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