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