mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
persist BT invitee dev scan results
Only launch the scan automatically when the persisted list is empty.
This commit is contained in:
parent
3a0e67c7b3
commit
2f508c0b5c
2 changed files with 28 additions and 2 deletions
|
@ -37,6 +37,7 @@ import java.util.Set;
|
||||||
|
|
||||||
public class BTInviteDelegate extends InviteDelegate {
|
public class BTInviteDelegate extends InviteDelegate {
|
||||||
private static final String TAG = BTInviteDelegate.class.getSimpleName();
|
private static final String TAG = BTInviteDelegate.class.getSimpleName();
|
||||||
|
private static final String KEY_PAIRS = TAG + "_pairs";
|
||||||
private static final int[] BUTTONIDS = { R.id.button_scan,
|
private static final int[] BUTTONIDS = { R.id.button_scan,
|
||||||
R.id.button_settings,
|
R.id.button_settings,
|
||||||
};
|
};
|
||||||
|
@ -74,7 +75,12 @@ public class BTInviteDelegate extends InviteDelegate {
|
||||||
super.init( msg, 0 );
|
super.init( msg, 0 );
|
||||||
addButtonBar( R.layout.bt_buttons, BUTTONIDS );
|
addButtonBar( R.layout.bt_buttons, BUTTONIDS );
|
||||||
|
|
||||||
scan();
|
m_pairs = loadPairs();
|
||||||
|
if ( m_pairs == null || m_pairs.length == 0 ) {
|
||||||
|
scan();
|
||||||
|
} else {
|
||||||
|
updateListAdapter( m_pairs );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -165,11 +171,29 @@ public class BTInviteDelegate extends InviteDelegate {
|
||||||
DbgUtils.assertOnUIThread();
|
DbgUtils.assertOnUIThread();
|
||||||
|
|
||||||
m_pairs = TwoStringPair.add( m_pairs, dev.getAddress(), dev.getName() );
|
m_pairs = TwoStringPair.add( m_pairs, dev.getAddress(), dev.getName() );
|
||||||
|
storePairs( m_pairs );
|
||||||
|
|
||||||
updateListAdapter( m_pairs );
|
updateListAdapter( m_pairs );
|
||||||
tryEnable();
|
tryEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TwoStringPair[] loadPairs()
|
||||||
|
{
|
||||||
|
TwoStringPair[] pairs = null;
|
||||||
|
try {
|
||||||
|
String str64 = DBUtils.getStringFor( m_activity, KEY_PAIRS, null );
|
||||||
|
pairs = (TwoStringPair[])Utils.string64ToSerializable( str64 );
|
||||||
|
} catch ( Exception ex ) {} // NPE, de-serialization problems, etc.
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storePairs( TwoStringPair[] pairs )
|
||||||
|
{
|
||||||
|
String str64 = pairs == null
|
||||||
|
? "" : Utils.serializableToString64( pairs );
|
||||||
|
DBUtils.setStringFor( m_activity, KEY_PAIRS, str64 );
|
||||||
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
@Override
|
@Override
|
||||||
public boolean onPosButton( Action action, Object[] params )
|
public boolean onPosButton( Action action, Object[] params )
|
||||||
|
|
|
@ -36,6 +36,8 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -53,7 +55,7 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
String getDev(); // the string that identifies this item in results
|
String getDev(); // the string that identifies this item in results
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class TwoStringPair implements InviterItem {
|
protected static class TwoStringPair implements InviterItem, Serializable {
|
||||||
public String str1;
|
public String str1;
|
||||||
public String str2;
|
public String str2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue