findbug: SUI_CONTAINS_BEFORE_REMOVE: Method checks for an item in a set with contains, before using remove()

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2019-02-07 19:17:19 +01:00
parent e1feb49fe1
commit 5b6ad9add1
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -154,10 +154,9 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
} else if (file.isDown()) {
fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(i), false);
} else {
if (mDownloadErrors.contains(i)) {
if (mDownloadErrors.remove(i)) {
fragment = FileDownloadFragment.newInstance(file, mAccount, true);
((FileDownloadFragment) fragment).setError(true);
mDownloadErrors.remove(i);
} else {
if (file.isEncrypted()) {
fragment = FileDownloadFragment.newInstance(file, mAccount, mObsoletePositions.contains(i));
@ -212,8 +211,7 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
@Override
public int getItemPosition(@NonNull Object object) {
if (mObsoleteFragments.contains(object)) {
mObsoleteFragments.remove(object);
if (mObsoleteFragments.remove(object)) {
return POSITION_NONE;
}
return super.getItemPosition(object);