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;
|
private static ArrayList<NewsArticle> articles;
|
||||||
|
|
||||||
public static boolean articlesAvailable(){
|
public static synchronized boolean articlesAvailable(){
|
||||||
return articles != null;
|
return articles != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<NewsArticle> articles(){
|
public static synchronized ArrayList<NewsArticle> articles(){
|
||||||
return new ArrayList<>(articles);
|
return new ArrayList<>(articles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int unreadArticles(Date lastRead){
|
public static synchronized int unreadArticles(Date lastRead) {
|
||||||
int unread = 0;
|
int unread = 0;
|
||||||
for (NewsArticle article : articles){
|
if (articles != null) {
|
||||||
if (article.date.after(lastRead)) unread++;
|
for (NewsArticle article : articles) {
|
||||||
|
if (article.date.after(lastRead)) unread++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return unread;
|
return unread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearArticles(){
|
public static synchronized void clearArticles(){
|
||||||
articles = null;
|
articles = null;
|
||||||
lastCheck = null;
|
lastCheck = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class MobSprite extends CharSprite {
|
||||||
|
|
||||||
super.onComplete( anim );
|
super.onComplete( anim );
|
||||||
|
|
||||||
if (anim == die) {
|
if (anim == die && parent != null) {
|
||||||
parent.add( new AlphaTweener( this, 0, FADE_TIME ) {
|
parent.add( new AlphaTweener( this, 0, FADE_TIME ) {
|
||||||
@Override
|
@Override
|
||||||
protected void onComplete() {
|
protected void onComplete() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user