avoid crash (maybe on corrupt data?)

This commit is contained in:
Eric House 2020-10-26 13:04:28 -07:00
parent f1eea13c5e
commit ba99eb0838
2 changed files with 19 additions and 3 deletions

View file

@ -128,9 +128,19 @@ public class BTInviteDelegate extends InviteDelegate
Collections.sort( pairs, new Comparator<TwoStringPair>() {
@Override
public int compare( TwoStringPair rec1, TwoStringPair rec2 ) {
long val1 = stamps.get( rec1.str2 );
long val2 = stamps.get( rec2.str2 );
return (int)(val2 - val1);
int result = 0;
try {
long val1 = stamps.get( rec1.str2 );
long val2 = stamps.get( rec2.str2 );
if ( val2 > val1 ) {
result = 1;
} else if ( val1 > val2 ) {
result = -1;
}
} catch ( Exception ex ) {
Log.e( TAG, "ex %s on %s vs %s", ex, rec1, rec2 );
}
return result;
}
});
}

View file

@ -82,6 +82,12 @@ abstract class InviteDelegate extends DelegateBase
}
return result;
}
@Override
public String toString()
{
return String.format( "{dev: \"%s\", str2: \"%s\"}", mDev, str2 );
}
}
public static final String DEVS = "DEVS";