mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
Fix crash when password dialog comes up second time: don't be cute and
reuse custom views as they remember their parent and that needs to be cleared. Just recreate each time and let gc() do its job.
This commit is contained in:
parent
851b2d296f
commit
46392da205
1 changed files with 20 additions and 8 deletions
|
@ -96,6 +96,7 @@ public class BoardActivity extends XWActivity
|
|||
private static final String DLG_TITLESTR = "DLG_TITLESTR";
|
||||
private static final String DLG_BYTES = "DLG_BYTES";
|
||||
private static final String ROOM = "ROOM";
|
||||
private static final String PWDNAME = "PWDNAME";
|
||||
private static final String TOASTSTR = "TOASTSTR";
|
||||
private static final String WORDS = "WORDS";
|
||||
|
||||
|
@ -139,6 +140,7 @@ public class BoardActivity extends XWActivity
|
|||
private String m_room;
|
||||
private String m_toastStr;
|
||||
private String[] m_words;
|
||||
private String m_pwdName;
|
||||
|
||||
private int m_missing;
|
||||
private boolean m_haveInvited = false;
|
||||
|
@ -278,6 +280,9 @@ public class BoardActivity extends XWActivity
|
|||
break;
|
||||
|
||||
case ASK_PASSWORD_BLK:
|
||||
if ( null == m_passwdLyt ) {
|
||||
setupPasswdVars();
|
||||
}
|
||||
m_passwdEdit.setText( "", TextView.BufferType.EDITABLE );
|
||||
ab = new AlertDialog.Builder( this )
|
||||
.setTitle( m_dlgTitleStr )
|
||||
|
@ -424,6 +429,7 @@ public class BoardActivity extends XWActivity
|
|||
outState.putString( ROOM, m_room );
|
||||
outState.putString( TOASTSTR, m_toastStr );
|
||||
outState.putStringArray( WORDS, m_words );
|
||||
outState.putString( PWDNAME, m_pwdName );
|
||||
}
|
||||
|
||||
private void getBundledData( Bundle bundle )
|
||||
|
@ -435,6 +441,7 @@ public class BoardActivity extends XWActivity
|
|||
m_room = bundle.getString( ROOM );
|
||||
m_toastStr = bundle.getString( TOASTSTR );
|
||||
m_words = bundle.getStringArray( WORDS );
|
||||
m_pwdName = bundle.getString( PWDNAME );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1053,15 +1060,11 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
public String askPassword( String name )
|
||||
{
|
||||
String fmt = getString( R.string.msg_ask_password );
|
||||
m_dlgTitleStr = String.format( fmt, name );
|
||||
// call this each time dlg created or will get exception
|
||||
// for reusing m_passwdLyt
|
||||
m_pwdName = name;
|
||||
setupPasswdVars();
|
||||
|
||||
if ( null == m_passwdEdit ) {
|
||||
m_passwdLyt =
|
||||
(LinearLayout)Utils.inflate( BoardActivity.this,
|
||||
R.layout.passwd_view );
|
||||
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
|
||||
}
|
||||
waitBlockingDialog( ASK_PASSWORD_BLK, 0 );
|
||||
|
||||
String result = null; // means cancelled
|
||||
|
@ -1596,4 +1599,13 @@ public class BoardActivity extends XWActivity
|
|||
showDialog( DLG_LOOKUP );
|
||||
}
|
||||
|
||||
private void setupPasswdVars()
|
||||
{
|
||||
String fmt = getString( R.string.msg_ask_password );
|
||||
m_dlgTitleStr = String.format( fmt, m_pwdName );
|
||||
m_passwdLyt = (LinearLayout)Utils.inflate( BoardActivity.this,
|
||||
R.layout.passwd_view );
|
||||
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
|
||||
}
|
||||
|
||||
} // class BoardActivity
|
||||
|
|
Loading…
Reference in a new issue