remove old FILE_NAME DB column for new DBs; ignore it elsewhere. Move

default name creation from DBUtils to GameUtils.
This commit is contained in:
Andy2 2011-08-04 06:15:00 -07:00
parent 9aeb8858fe
commit 97d5e3cc6d
8 changed files with 17 additions and 17 deletions

View file

@ -1108,7 +1108,7 @@ public class BoardActivity extends XWActivity
m_jniThread.handle( JNICmd.CMD_START );
if ( !CommonPrefs.getHideTitleBar( this ) ) {
setTitle( DBUtils.getName( this, m_rowid ) );
setTitle( GameUtils.getName( this, m_rowid ) );
}
m_toolbar = new Toolbar( this );

View file

@ -65,7 +65,7 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
((Button)findViewById( R.id.send_button )).setOnClickListener( this );
String fmt = getString( R.string.chat_titlef );
setTitle( String.format( fmt, DBUtils.getName( this, m_rowid ) ) );
setTitle( String.format( fmt, GameUtils.getName( this, m_rowid ) ) );
}
@Override

View file

@ -31,7 +31,6 @@ public class DBHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "xwdb";
private static final int DB_VERSION = 9;
public static final String FILE_NAME = "FILE_NAME";
public static final String GAME_NAME = "GAME_NAME";
public static final String NUM_MOVES = "NUM_MOVES";
public static final String TURN = "TURN";
@ -71,7 +70,6 @@ public class DBHelper extends SQLiteOpenHelper {
private void onCreateSum( SQLiteDatabase db )
{
db.execSQL( "CREATE TABLE " + TABLE_NAME_SUM + " ("
+ FILE_NAME + " TEXT PRIMARY KEY,"
+ GAME_NAME + " TEXT,"
+ NUM_MOVES + " INTEGER,"
+ TURN + " INTEGER,"

View file

@ -601,21 +601,13 @@ public class DBUtils {
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
String[] columns = { DBHelper.FILE_NAME, DBHelper.GAME_NAME };
String[] columns = { DBHelper.GAME_NAME };
String selection = String.format( ROW_ID_FMT, rowid );
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = cursor.getString( cursor
.getColumnIndex(DBHelper.GAME_NAME));
if ( null == result || 0 == result.length() ) {
result = cursor.getString( cursor
.getColumnIndex(DBHelper.FILE_NAME));
if ( null == result || 0 == result.length() ) {
String fmt = context.getString( R.string.gamef );
result = String.format( fmt, rowid );
}
}
}
cursor.close();
db.close();

View file

@ -974,7 +974,7 @@ public class GameConfig extends XWActivity
String fmt = getString( m_notNetworkedGame ?
R.string.title_game_configf
: R.string.title_gamenet_configf );
setTitle( String.format( fmt, DBUtils.getName( this, m_rowid ) ) );
setTitle( String.format( fmt, GameUtils.getName( this, m_rowid ) ) );
}
}

View file

@ -78,7 +78,7 @@ public class GameListAdapter extends XWListAdapter {
if ( hideTitle ) {
view.setVisibility( View.GONE );
} else {
String name = DBUtils.getName( m_context, m_rowid );
String name = GameUtils.getName( m_context, m_rowid );
String format =
m_context.getString( R.string.str_game_namef );
String lang =
@ -172,7 +172,7 @@ public class GameListAdapter extends XWListAdapter {
if ( hideTitle ) {
view.setVisibility( View.GONE );
} else {
String text = DBUtils.getName( m_context, rowid );
String text = GameUtils.getName( m_context, rowid );
view.setText( text );
}

View file

@ -286,6 +286,16 @@ public class GameUtils {
}
}
public static String getName( Context context, long rowid )
{
String result = DBUtils.getName( context, rowid );
if ( null == result || 0 == result.length() ) {
String fmt = context.getString( R.string.gamef );
result = String.format( fmt, rowid );
}
return result;
}
public static void loadMakeGame( Context context, int gamePtr,
CurGameInfo gi, GameLock lock )
{

View file

@ -227,7 +227,7 @@ public class GamesList extends XWListActivity
{
switch( id ) {
case RENAME_GAME:
String name = DBUtils.getName( this, m_rowid );
String name = GameUtils.getName( this, m_rowid );
EditText txt = (EditText)dialog.findViewById( R.id.name_edit );
txt.setText( name );
break;