Skip to content

Commit 3738e30

Browse files
committed
Fix NPE when avatarUrl is empty
1 parent 0ba73b1 commit 3738e30

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionEntity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.database.subscription;
22

33
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
45
import androidx.room.ColumnInfo;
56
import androidx.room.Entity;
67
import androidx.room.Ignore;
@@ -95,11 +96,12 @@ public void setName(final String name) {
9596
this.name = name;
9697
}
9798

99+
@Nullable
98100
public String getAvatarUrl() {
99101
return avatarUrl;
100102
}
101103

102-
public void setAvatarUrl(final String avatarUrl) {
104+
public void setAvatarUrl(@Nullable final String avatarUrl) {
103105
this.avatarUrl = avatarUrl;
104106
}
105107

app/src/main/java/org/schabi/newpipe/local/feed/service/FeedUpdateInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data class FeedUpdateInfo(
1818
@NotificationMode
1919
val notificationMode: Int,
2020
val name: String,
21-
val avatarUrl: String,
21+
val avatarUrl: String?,
2222
val url: String,
2323
val serviceId: Int,
2424
// description and subscriberCount are null if the constructor info is from the fast feed method

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionManager.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class SubscriptionManager(context: Context) {
100100
val subscriptionEntity = subscriptionTable.getSubscription(info.uid)
101101

102102
subscriptionEntity.name = info.name
103-
subscriptionEntity.avatarUrl = info.avatarUrl
103+
104+
// some services do not provide an avatar URL
105+
info.avatarUrl?.let { subscriptionEntity.avatarUrl = it }
104106

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

0 commit comments

Comments
 (0)