mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
cleanup
This commit is contained in:
parent
dcb4968ed9
commit
15256ac2ad
2 changed files with 58 additions and 69 deletions
|
@ -65,67 +65,63 @@ public class ChatDelegate extends DelegateBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init( Bundle savedInstanceState )
|
protected void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
if ( BuildConstants.CHAT_SUPPORTED ) {
|
DbgUtils.logf( "ChatDelegate.init()" );
|
||||||
m_edit = (EditText)findViewById( R.id.chat_edit );
|
m_edit = (EditText)findViewById( R.id.chat_edit );
|
||||||
m_edit.addTextChangedListener( new TextWatcher() {
|
m_edit.addTextChangedListener( new TextWatcher() {
|
||||||
public void afterTextChanged( Editable s ) {
|
public void afterTextChanged( Editable s ) {
|
||||||
invalidateOptionsMenuIf();
|
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 );
|
|
||||||
}
|
}
|
||||||
}
|
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,
|
Bundle args = getArguments();
|
||||||
GameUtils.getName( m_activity, m_rowid ) );
|
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||||
setTitle( title );
|
m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 );
|
||||||
} else {
|
m_names = args.getStringArray( INTENT_KEY_NAMES );
|
||||||
// Should really assert....
|
boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS );
|
||||||
finish();
|
|
||||||
|
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
|
} // init
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,12 +60,12 @@ public class MainActivity extends XWActivity
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
m_dpEnabled = XWPrefs.dualpaneEnabled( this );
|
m_dpEnabled = XWPrefs.dualpaneEnabled( this );
|
||||||
if ( m_dpEnabled ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
m_dlgt = new DualpaneDelegate( this, savedInstanceState );
|
Utils.showToast( this, "dualpane mode: " + m_dpEnabled );
|
||||||
Utils.showToast( this, "dualpane mode" );
|
|
||||||
} else {
|
|
||||||
m_dlgt = new GamesListDelegate( this, savedInstanceState );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_dlgt = m_dpEnabled ? new DualpaneDelegate( this, savedInstanceState )
|
||||||
|
: new GamesListDelegate( this, savedInstanceState );
|
||||||
super.onCreate( savedInstanceState, m_dlgt );
|
super.onCreate( savedInstanceState, m_dlgt );
|
||||||
|
|
||||||
if ( m_dpEnabled ) {
|
if ( m_dpEnabled ) {
|
||||||
|
@ -81,13 +81,6 @@ public class MainActivity extends XWActivity
|
||||||
addFragmentImpl( new GamesListFrag(), getIntent().getExtras(), null );
|
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
|
} // onCreate
|
||||||
|
|
||||||
// called when we're brought to the front (probably as a result of
|
// called when we're brought to the front (probably as a result of
|
||||||
|
|
Loading…
Reference in a new issue