From d854cf180d04ce46926621874980aead7756f953 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 11 Nov 2015 17:49:05 +0800 Subject: [PATCH] fixed crashes on refresh --- .../twitter/model/impl/MediaEntityImpl.java | 2 +- .../api/twitter/model/impl/UrlEntityImpl.java | 2 +- .../model/impl/UserMentionEntityImpl.java | 2 +- .../edu/tsinghua/hotmobi/HotMobiLogger.java | 2 ++ .../tsinghua/hotmobi/model/ScreenEvent.java | 18 ++++++++++++------ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/MediaEntityImpl.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/MediaEntityImpl.java index b9ceed1e2..1ea28de52 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/MediaEntityImpl.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/MediaEntityImpl.java @@ -36,7 +36,7 @@ public class MediaEntityImpl implements MediaEntity { @JsonField(name = "id") long id; - @JsonField(name = "indices") + @JsonField(name = "indices", typeConverter = IndicesConverter.class) Indices indices; @JsonField(name = "media_url") diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UrlEntityImpl.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UrlEntityImpl.java index cf0c16c89..17ddcc881 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UrlEntityImpl.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UrlEntityImpl.java @@ -29,7 +29,7 @@ import org.mariotaku.twidere.api.twitter.model.UrlEntity; */ @JsonObject public class UrlEntityImpl implements UrlEntity { - @JsonField(name = "indices") + @JsonField(name = "indices", typeConverter = IndicesConverter.class) Indices indices; @JsonField(name = "display_url") String displayUrl; diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UserMentionEntityImpl.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UserMentionEntityImpl.java index 4e5bfcd56..8628cb54f 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UserMentionEntityImpl.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/UserMentionEntityImpl.java @@ -29,7 +29,7 @@ import org.mariotaku.twidere.api.twitter.model.UserMentionEntity; */ @JsonObject public class UserMentionEntityImpl implements UserMentionEntity { - @JsonField(name = "indices") + @JsonField(name = "indices", typeConverter = IndicesConverter.class) Indices indices; @JsonField(name = "id") long id; diff --git a/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java b/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java index 0c974e7b5..03523d611 100644 --- a/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java +++ b/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java @@ -102,6 +102,8 @@ public class HotMobiLogger { return "battery"; } else if (event instanceof NotificationEvent) { return "notification"; + } else if (event instanceof ScreenEvent) { + return "screen"; } throw new UnsupportedOperationException("Unknown event type " + event); } diff --git a/twidere/src/main/java/edu/tsinghua/hotmobi/model/ScreenEvent.java b/twidere/src/main/java/edu/tsinghua/hotmobi/model/ScreenEvent.java index 9b669873f..8fcb89c4a 100644 --- a/twidere/src/main/java/edu/tsinghua/hotmobi/model/ScreenEvent.java +++ b/twidere/src/main/java/edu/tsinghua/hotmobi/model/ScreenEvent.java @@ -34,6 +34,13 @@ public class ScreenEvent extends BaseEvent { @JsonField(name = "action", typeConverter = Action.ScreenActionConverter.class) Action action; + public static ScreenEvent create(Context context, Action action) { + final ScreenEvent event = new ScreenEvent(); + event.markStart(context); + event.setAction(action); + return event; + } + public Action getAction() { return action; } @@ -42,11 +49,11 @@ public class ScreenEvent extends BaseEvent { this.action = action; } - public static ScreenEvent create(Context context, Action action) { - final ScreenEvent event = new ScreenEvent(); - event.markStart(context); - event.setAction(action); - return event; + @Override + public String toString() { + return "ScreenEvent{" + + "action=" + action + + "} " + super.toString(); } public enum Action { @@ -81,5 +88,4 @@ public class ScreenEvent extends BaseEvent { } } } - }