Update more code with more suggestions and move null-safety into view data

This commit is contained in:
HellPie 2018-08-31 22:20:48 +02:00 committed by HellPie
parent d5d57aae04
commit 07dce8c4d1
2 changed files with 5 additions and 10 deletions

View File

@ -533,15 +533,6 @@ public class NotificationsFragment extends SFragment implements
} }
StatusViewData.Concrete status = ((NotificationViewData.Concrete) notification).getStatusViewData(); StatusViewData.Concrete status = ((NotificationViewData.Concrete) notification).getStatusViewData();
if(status == null) {
Log.e(TAG, String.format(
"Tried to access status in notification but got null at position: %d of %d",
position,
notifications.size() - 1)
);
return;
}
StatusViewData.Concrete updatedStatus = new StatusViewData.Builder(status) StatusViewData.Concrete updatedStatus = new StatusViewData.Builder(status)
.setCollapsed(isCollapsed) .setCollapsed(isCollapsed)
.createStatusViewData(); .createStatusViewData();

View File

@ -18,6 +18,8 @@ package com.keylesspalace.tusky.viewdata;
import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Account;
import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Notification;
import io.reactivex.annotations.NonNull;
/** /**
* Created by charlag on 12/07/2017. * Created by charlag on 12/07/2017.
* *
@ -37,11 +39,12 @@ public abstract class NotificationViewData {
private final Notification.Type type; private final Notification.Type type;
private final String id; private final String id;
private final Account account; private final Account account;
@NonNull
private final StatusViewData.Concrete statusViewData; private final StatusViewData.Concrete statusViewData;
private final boolean isExpanded; private final boolean isExpanded;
public Concrete(Notification.Type type, String id, Account account, public Concrete(Notification.Type type, String id, Account account,
StatusViewData.Concrete statusViewData, boolean isExpanded) { @NonNull StatusViewData.Concrete statusViewData, boolean isExpanded) {
this.type = type; this.type = type;
this.id = id; this.id = id;
this.account = account; this.account = account;
@ -61,6 +64,7 @@ public abstract class NotificationViewData {
return account; return account;
} }
@NonNull
public StatusViewData.Concrete getStatusViewData() { public StatusViewData.Concrete getStatusViewData() {
return statusViewData; return statusViewData;
} }