Skip to content

Commit

Permalink
Analysis: Un-guard usages of non-null on media changed media list
Browse files Browse the repository at this point in the history
  • Loading branch information
ParaskP7 committed Nov 1, 2023
1 parent eff8564 commit d2ccda4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -804,17 +804,15 @@ public void onMediaChanged(OnMediaChanged event) {

switch (event.cause) {
case DELETE_MEDIA:
if (event.mediaList != null) {
// If the media was deleted, remove it from multi select if it was selected
for (MediaModel mediaModel : event.mediaList) {
int localMediaId = mediaModel.getId();
mMediaGridFragment.removeFromMultiSelect(localMediaId);
}
// If the media was deleted, remove it from multi select if it was selected
for (MediaModel mediaModel : event.mediaList) {
int localMediaId = mediaModel.getId();
mMediaGridFragment.removeFromMultiSelect(localMediaId);
}
break;
}

if (event.mediaList != null && event.mediaList.size() == 1) {
if (event.mediaList.size() == 1) {
updateMediaGridItem(event.mediaList.get(0), true);
} else {
reloadMediaGrid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMediaChanged(OnMediaChanged event) {
// event for unknown media, ignoring
if (event.mediaList == null || event.mediaList.isEmpty() || !matchesInProgressMedia(event.mediaList.get(0))) {
if (event.mediaList.isEmpty() || !matchesInProgressMedia(event.mediaList.get(0))) {
AppLog.w(T.MEDIA, "Media event not recognized: " + event.mediaList);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class PostListEventListener(
@Suppress("unused")
@Subscribe(threadMode = BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
if (!event.isError && event.mediaList != null) {
if (!event.isError) {
featuredMediaChanged(*event.mediaList.map { it.mediaId }.toLongArray())
uploadStatusChanged(*event.mediaList.map { it.localPostId }.toIntArray())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ class PageListEventListener(
@Suppress("unused")
@Subscribe(threadMode = BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
if (event.mediaList != null) {
uploadStatusChanged(*event.mediaList.map { LocalId(it.localPostId) }.toTypedArray())
}
uploadStatusChanged(*event.mediaList.map { LocalId(it.localPostId) }.toTypedArray())
}

@Suppress("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class PageListViewModel @Inject constructor(
@Suppress("unused")
@Subscribe(threadMode = ThreadMode.BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
if (!event.isError && event.mediaList != null) {
if (!event.isError) {
invalidateFeaturedMedia(*event.mediaList.map { it.mediaId }.toLongArray())
}
}
Expand Down

0 comments on commit d2ccda4

Please sign in to comment.