Fix potential edge case unseen messages

pull/162/head
M66B 6 years ago
parent f84100d9e1
commit f44b5a7815

@ -154,7 +154,9 @@ public class ServiceSynchronize extends ServiceBase {
@Override @Override
public void onChanged(TupleMessageStats stats) { public void onChanged(TupleMessageStats stats) {
if (stats != null) { if (stats == null)
stats = new TupleMessageStats();
boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false); boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
if (!unseen_ignored || stats.ignored == null) if (!unseen_ignored || stats.ignored == null)
stats.ignored = 0; stats.ignored = 0;
@ -166,7 +168,6 @@ public class ServiceSynchronize extends ServiceBase {
setUnseen(stats.unseen - stats.ignored); setUnseen(stats.unseen - stats.ignored);
} }
} }
}
}); });
final TwoStateOwner cowner = new TwoStateOwner(this, "liveUnseenNotify"); final TwoStateOwner cowner = new TwoStateOwner(this, "liveUnseenNotify");

@ -25,8 +25,8 @@ import androidx.annotation.Nullable;
import java.util.Objects; import java.util.Objects;
public class TupleMessageStats { public class TupleMessageStats {
public Integer unseen; public Integer unseen = 0;
public Integer ignored; public Integer ignored = 0;
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {

Loading…
Cancel
Save