Skip to content

Commit

Permalink
Merge pull request #10957 from Stypox/fix-feed-npe
Browse files Browse the repository at this point in the history
Fix NPE if avatarUrl is null when reloading feed
  • Loading branch information
Stypox authored Apr 11, 2024
2 parents b3a6318 + 3738e30 commit d9da84c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.database.subscription;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
Expand Down Expand Up @@ -95,11 +96,12 @@ public void setName(final String name) {
this.name = name;
}

@Nullable
public String getAvatarUrl() {
return avatarUrl;
}

public void setAvatarUrl(final String avatarUrl) {
public void setAvatarUrl(@Nullable final String avatarUrl) {
this.avatarUrl = avatarUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class FeedUpdateInfo(
@NotificationMode
val notificationMode: Int,
val name: String,
val avatarUrl: String,
val avatarUrl: String?,
val url: String,
val serviceId: Int,
// description and subscriberCount are null if the constructor info is from the fast feed method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class SubscriptionManager(context: Context) {
val subscriptionEntity = subscriptionTable.getSubscription(info.uid)

subscriptionEntity.name = info.name
subscriptionEntity.avatarUrl = info.avatarUrl

// some services do not provide an avatar URL
info.avatarUrl?.let { subscriptionEntity.avatarUrl = it }

// these two fields are null if the feed info was fetched using the fast feed method
info.description?.let { subscriptionEntity.description = it }
Expand Down

0 comments on commit d9da84c

Please sign in to comment.