make DlgState Parcelable rather than Serializable to work around what

seems to be a bug in the Blaze's OS.  (Requires that it be a
standalone class.)
This commit is contained in:
Eric House 2013-01-30 07:58:37 -08:00
parent 5e7fd39d66
commit 66a00bd76e
2 changed files with 90 additions and 39 deletions

View file

@ -79,7 +79,7 @@ public class DlgDelegate {
int[] ids = bundle.getIntArray( IDS );
for ( int id : ids ) {
String key = String.format( STATE_KEYF, id );
addState( (DlgState)bundle.getSerializable( key ) );
addState( (DlgState)bundle.getParcelable( key ) );
}
}
}
@ -93,7 +93,7 @@ public class DlgDelegate {
while ( iter.hasNext() ) {
DlgState state = iter.next();
String key = String.format( STATE_KEYF, state.m_id );
outState.putSerializable( key, state );
outState.putParcelable( key, state );
ids[indx++] = state.m_id;
}
}
@ -172,8 +172,9 @@ public class DlgDelegate {
AlertDialog.BUTTON_POSITIVE );
}
} else {
DlgState state = new DlgState( DIALOG_NOTAGAIN, msgID, callbackID,
prefsKey );
String msg = m_activity.getString( msgID );
DlgState state =
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey );
addState( state );
m_activity.showDialog( DIALOG_NOTAGAIN );
}
@ -445,41 +446,6 @@ public class DlgDelegate {
return dialog;
}
private class DlgState implements java.io.Serializable {
public int m_id;
public String m_msg;
public int m_posButton;
public int m_cbckID = 0;
public int m_prefsKey;
public DlgState( int id, String msg, int cbckID )
{
this( id, msg, 0, cbckID, 0 );
}
public DlgState( int id, int msgID, int cbckID, int prefsKey )
{
this( id, m_activity.getString(msgID), 0, cbckID, prefsKey );
}
public DlgState( int id, String msg, int posButton,
int cbckID, int prefsKey )
{
m_id = id;
m_msg = msg;
m_posButton = posButton;
m_cbckID = cbckID;
m_prefsKey = prefsKey;
DbgUtils.logf( "DlgState(%d)=>%H", id, this );
}
public DlgState( int id, int cbckID )
{
this( id, null, 0, cbckID, 0 );
}
}
private DlgState findForID( int id )
{
DlgState state = m_dlgStates.get( id );

View file

@ -0,0 +1,85 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/*
* Copyright 2009 - 2013 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
import android.os.Parcelable;
import android.os.Parcel;
public class DlgState implements Parcelable {
public int m_id;
public String m_msg;
public int m_posButton;
public int m_cbckID = 0;
public int m_prefsKey;
public DlgState( int id, String msg, int cbckID )
{
this( id, msg, 0, cbckID, 0 );
}
public DlgState( int id, String msg, int cbckID, int prefsKey )
{
this( id, msg, 0, cbckID, prefsKey );
}
public DlgState( int id, String msg, int posButton,
int cbckID, int prefsKey )
{
m_id = id;
m_msg = msg;
m_posButton = posButton;
m_cbckID = cbckID;
m_prefsKey = prefsKey;
}
public DlgState( int id, int cbckID )
{
this( id, null, 0, cbckID, 0 );
}
public int describeContents() {
return 0;
}
public void writeToParcel( Parcel out, int flags ) {
out.writeInt( m_id );
out.writeInt( m_posButton );
out.writeInt( m_cbckID );
out.writeInt( m_prefsKey );
out.writeString( m_msg );
}
public static final Parcelable.Creator<DlgState> CREATOR
= new Parcelable.Creator<DlgState>() {
public DlgState createFromParcel(Parcel in) {
int id = in.readInt();
int posButton = in.readInt();
int cbckID = in.readInt();
int prefsKey = in.readInt();
String msg = in.readString();
return new DlgState( id, msg, posButton, cbckID, prefsKey );
}
public DlgState[] newArray(int size) {
return new DlgState[size];
}
};
}