mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
wrap a bit more chat code in test so java can leave it out
This commit is contained in:
parent
bd81eb4bbe
commit
1669687f19
2 changed files with 64 additions and 50 deletions
|
@ -40,6 +40,7 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
|
|||
@Override
|
||||
public void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
if ( XWApp.CHAT_SUPPORTED ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
|
||||
setContentView( R.layout.chat );
|
||||
|
@ -48,12 +49,13 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
|
|||
|
||||
DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( this, m_rowid );
|
||||
if ( null != pairs ) {
|
||||
LinearLayout layout = (LinearLayout)findViewById( R.id.chat_history );
|
||||
LinearLayout layout = (LinearLayout)
|
||||
findViewById( R.id.chat_history );
|
||||
LayoutInflater factory = LayoutInflater.from( this );
|
||||
|
||||
for ( DBUtils.HistoryPair pair : pairs ) {
|
||||
TextView view =
|
||||
(TextView)factory.inflate( pair.sourceLocal
|
||||
TextView view = (TextView)factory
|
||||
.inflate( pair.sourceLocal
|
||||
? R.layout.chat_history_local
|
||||
: R.layout.chat_history_remote,
|
||||
null );
|
||||
|
@ -62,10 +64,15 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
((Button)findViewById( R.id.send_button )).setOnClickListener( this );
|
||||
((Button)findViewById( R.id.send_button ))
|
||||
.setOnClickListener( this );
|
||||
|
||||
setTitle( getString( R.string.chat_titlef,
|
||||
GameUtils.getName( this, m_rowid ) ) );
|
||||
} else {
|
||||
// Should really assert....
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -847,6 +847,7 @@ public class DBUtils {
|
|||
public static HistoryPair[] getChatHistory( Context context, long rowid )
|
||||
{
|
||||
HistoryPair[] result = null;
|
||||
if ( XWApp.CHAT_SUPPORTED ) {
|
||||
final String localPrefix = context.getString( R.string.chat_local_id );
|
||||
String history = getChatHistoryStr( context, rowid );
|
||||
if ( null != history ) {
|
||||
|
@ -858,6 +859,7 @@ public class DBUtils {
|
|||
result[ii] = new HistoryPair( msg, isLocal );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1107,6 +1109,7 @@ public class DBUtils {
|
|||
private static String getChatHistoryStr( Context context, long rowid )
|
||||
{
|
||||
String result = null;
|
||||
if ( XWApp.CHAT_SUPPORTED ) {
|
||||
initDB( context );
|
||||
synchronized( s_dbHelper ) {
|
||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||
|
@ -1118,17 +1121,20 @@ public class DBUtils {
|
|||
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
||||
result =
|
||||
cursor.getString( cursor
|
||||
.getColumnIndex(DBHelper.CHAT_HISTORY));
|
||||
.getColumnIndex(DBHelper
|
||||
.CHAT_HISTORY));
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void appendChatHistory( Context context, long rowid,
|
||||
String msg, boolean local )
|
||||
{
|
||||
if ( XWApp.CHAT_SUPPORTED ) {
|
||||
Assert.assertNotNull( msg );
|
||||
int id = local ? R.string.chat_local_id : R.string.chat_other_id;
|
||||
msg = context.getString( id ) + msg;
|
||||
|
@ -1139,6 +1145,7 @@ public class DBUtils {
|
|||
}
|
||||
|
||||
saveChatHistory( context, rowid, msg );
|
||||
}
|
||||
} // appendChatHistory
|
||||
|
||||
public static void clearChatHistory( Context context, long rowid )
|
||||
|
|
Loading…
Reference in a new issue