v0.9.0: added a couple safety checks to prevent crashes
This commit is contained in:
parent
fbf04c3c2e
commit
dfbd43df11
|
@ -70,23 +70,25 @@ public class News {
|
|||
|
||||
private static ArrayList<NewsArticle> articles;
|
||||
|
||||
public static boolean articlesAvailable(){
|
||||
public static synchronized boolean articlesAvailable(){
|
||||
return articles != null;
|
||||
}
|
||||
|
||||
public static ArrayList<NewsArticle> articles(){
|
||||
public static synchronized ArrayList<NewsArticle> articles(){
|
||||
return new ArrayList<>(articles);
|
||||
}
|
||||
|
||||
public static int unreadArticles(Date lastRead){
|
||||
public static synchronized int unreadArticles(Date lastRead) {
|
||||
int unread = 0;
|
||||
for (NewsArticle article : articles){
|
||||
if (article.date.after(lastRead)) unread++;
|
||||
if (articles != null) {
|
||||
for (NewsArticle article : articles) {
|
||||
if (article.date.after(lastRead)) unread++;
|
||||
}
|
||||
}
|
||||
return unread;
|
||||
}
|
||||
|
||||
public static void clearArticles(){
|
||||
public static synchronized void clearArticles(){
|
||||
articles = null;
|
||||
lastCheck = null;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MobSprite extends CharSprite {
|
|||
|
||||
super.onComplete( anim );
|
||||
|
||||
if (anim == die) {
|
||||
if (anim == die && parent != null) {
|
||||
parent.add( new AlphaTweener( this, 0, FADE_TIME ) {
|
||||
@Override
|
||||
protected void onComplete() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user