This commit is contained in:
Eric House 2016-07-14 07:01:02 -07:00
parent dcb4968ed9
commit 15256ac2ad
2 changed files with 58 additions and 69 deletions

View file

@ -65,67 +65,63 @@ public class ChatDelegate extends DelegateBase {
}
@Override
protected void init( Bundle savedInstanceState )
protected void init( Bundle savedInstanceState )
{
if ( BuildConstants.CHAT_SUPPORTED ) {
m_edit = (EditText)findViewById( R.id.chat_edit );
m_edit.addTextChangedListener( new TextWatcher() {
public void afterTextChanged( Editable s ) {
invalidateOptionsMenuIf();
}
public void beforeTextChanged( CharSequence s, int st,
int cnt, int a ) {}
public void onTextChanged( CharSequence s, int start,
int before, int count ) {}
} );
Bundle args = getArguments();
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 );
m_names = args.getStringArray( INTENT_KEY_NAMES );
boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS );
m_scroll = (ScrollView)findViewById( R.id.scroll );
m_layout = (TableLayout)findViewById( R.id.chat_history );
// OnLayoutChangeListener added in API 11
if ( 11 <= Integer.valueOf( android.os.Build.VERSION.SDK ) ) {
m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() {
@Override
public void onLayoutChange( View vv, int ll, int tt, int rr,
int bb, int ol, int ot,
int or, int ob ) {
scrollDown();
}
});
}
Button sendButton = (Button)findViewById( R.id.chat_send );
if ( ABUtils.haveActionBar() ) {
sendButton.setVisibility( View.GONE );
} else {
sendButton.setOnClickListener( new View.OnClickListener() {
public void onClick( View view ) {
handleSend();
}
} );
}
DBUtils.HistoryPair[] pairs
= DBUtils.getChatHistory( m_activity, m_rowid, locals );
if ( null != pairs ) {
for ( DBUtils.HistoryPair pair : pairs ) {
addRow( pair.msg, pair.playerIndx );
DbgUtils.logf( "ChatDelegate.init()" );
m_edit = (EditText)findViewById( R.id.chat_edit );
m_edit.addTextChangedListener( new TextWatcher() {
public void afterTextChanged( Editable s ) {
invalidateOptionsMenuIf();
}
}
public void beforeTextChanged( CharSequence s, int st,
int cnt, int a ) {}
public void onTextChanged( CharSequence s, int start,
int before, int count ) {}
} );
String title = getString( R.string.chat_title_fmt,
GameUtils.getName( m_activity, m_rowid ) );
setTitle( title );
} else {
// Should really assert....
finish();
Bundle args = getArguments();
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 );
m_names = args.getStringArray( INTENT_KEY_NAMES );
boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS );
m_scroll = (ScrollView)findViewById( R.id.scroll );
m_layout = (TableLayout)findViewById( R.id.chat_history );
// OnLayoutChangeListener added in API 11
if ( 11 <= Integer.valueOf( android.os.Build.VERSION.SDK ) ) {
m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() {
@Override
public void onLayoutChange( View vv, int ll, int tt, int rr,
int bb, int ol, int ot,
int or, int ob ) {
scrollDown();
}
});
}
Button sendButton = (Button)findViewById( R.id.chat_send );
if ( ABUtils.haveActionBar() ) {
sendButton.setVisibility( View.GONE );
} else {
sendButton.setOnClickListener( new View.OnClickListener() {
public void onClick( View view ) {
handleSend();
}
} );
}
DBUtils.HistoryPair[] pairs
= DBUtils.getChatHistory( m_activity, m_rowid, locals );
if ( null != pairs ) {
for ( DBUtils.HistoryPair pair : pairs ) {
addRow( pair.msg, pair.playerIndx );
}
}
String title = getString( R.string.chat_title_fmt,
GameUtils.getName( m_activity, m_rowid ) );
setTitle( title );
} // init
@Override

View file

@ -60,12 +60,12 @@ public class MainActivity extends XWActivity
protected void onCreate( Bundle savedInstanceState )
{
m_dpEnabled = XWPrefs.dualpaneEnabled( this );
if ( m_dpEnabled ) {
m_dlgt = new DualpaneDelegate( this, savedInstanceState );
Utils.showToast( this, "dualpane mode" );
} else {
m_dlgt = new GamesListDelegate( this, savedInstanceState );
if ( BuildConfig.DEBUG ) {
Utils.showToast( this, "dualpane mode: " + m_dpEnabled );
}
m_dlgt = m_dpEnabled ? new DualpaneDelegate( this, savedInstanceState )
: new GamesListDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, m_dlgt );
if ( m_dpEnabled ) {
@ -81,13 +81,6 @@ public class MainActivity extends XWActivity
addFragmentImpl( new GamesListFrag(), getIntent().getExtras(), null );
}
}
// Trying to debug situation where two of this activity are running at
// once. finish()ing when Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT is
// passed is not the fix, but perhaps there's another
// int flags = getIntent().getFlags();
// DbgUtils.logf( "MainActivity.onCreate(this=%H): flags=0x%x",
// this, flags );
} // onCreate
// called when we're brought to the front (probably as a result of