mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
fix removal of unpaired device
Two uses of remove() were passing different info. So pass the other one from the other use.
This commit is contained in:
parent
1019271c94
commit
a5b98c483c
1 changed files with 17 additions and 22 deletions
|
@ -351,31 +351,26 @@ public class BTInviteDelegate extends InviteDelegate
|
||||||
private static void removeNotPaired( Persisted prs )
|
private static void removeNotPaired( Persisted prs )
|
||||||
{
|
{
|
||||||
Log.d( TAG, "removeNotPaired()" );
|
Log.d( TAG, "removeNotPaired()" );
|
||||||
BluetoothAdapter adapter = BTUtils.getAdapterIf();
|
Set<BluetoothDevice> pairedDevs = BTUtils.getCandidates();
|
||||||
if ( null != adapter ) {
|
Set<String> paired = new HashSet<>();
|
||||||
Set<BluetoothDevice> pairedDevs = BTUtils.getCandidates();
|
for ( BluetoothDevice dev : pairedDevs ) {
|
||||||
Set<String> paired = new HashSet<>();
|
Log.d( TAG, "removeNotPaired(): paired dev: %s", dev.getName() );
|
||||||
for ( BluetoothDevice dev : pairedDevs ) {
|
paired.add( dev.getName() );
|
||||||
Log.d( TAG, "removeNotPaired(): paired dev: %s", dev.getName() );
|
}
|
||||||
paired.add( dev.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> toRemove = new HashSet<>();
|
Set<String> toRemove = new HashSet<>();
|
||||||
for ( TwoStringPair pair : prs.pairs ) {
|
for ( TwoStringPair pair : prs.pairs ) {
|
||||||
String name = pair.str2;
|
String name = pair.str2;
|
||||||
if ( ! paired.contains( name ) ) {
|
if ( ! paired.contains( name ) ) {
|
||||||
Log.d( TAG, "%s no longer paired; removing", name );
|
Log.d( TAG, "%s no longer paired; removing", name );
|
||||||
toRemove.add( name );
|
toRemove.add( pair.getDev() );
|
||||||
} else {
|
} else {
|
||||||
Log.d( TAG, "%s STILL paired", name );
|
Log.d( TAG, "%s STILL paired", name );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! toRemove.isEmpty() ) {
|
if ( ! toRemove.isEmpty() ) {
|
||||||
prs.remove( toRemove );
|
prs.remove( toRemove );
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e( TAG, "removeNotPaired(): adapter null" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue