logansqaure 1.3.4

This commit is contained in:
Mariotaku Lee 2015-12-13 21:30:14 +08:00
parent 11ff55a68a
commit 77e8793e67
104 changed files with 2575 additions and 5440 deletions

View File

@ -38,7 +38,6 @@ android {
dependencies {
apt 'com.bluelinelabs:logansquare-compiler:1.3.4'
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.1'
apt 'com.github.mariotaku.LoganSquareExtension:processor:0.9.6-SNAPSHOT'
apt 'com.github.mariotaku.ObjectCursor:processor:0.9.2'
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
@ -47,7 +46,6 @@ dependencies {
compile 'com.github.mariotaku.RestFu:library:0.9.8'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1'
compile 'com.github.mariotaku:SQLiteQB:88291f3a28'
compile 'com.github.mariotaku.LoganSquareExtension:core:0.9.6-SNAPSHOT'
compile 'com.github.mariotaku.ObjectCursor:core:0.9.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@ -28,8 +28,6 @@ import org.mariotaku.twidere.api.twitter.http.HttpResponseCode;
import org.mariotaku.twidere.api.twitter.model.ErrorInfo;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.TwitterResponse;
import org.mariotaku.twidere.api.twitter.model.impl.ErrorInfoImpl;
import org.mariotaku.twidere.api.twitter.model.impl.RateLimitStatusJSONImpl;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.Locale;
@ -46,7 +44,7 @@ public class TwitterException extends Exception implements TwitterResponse, Http
private static final long serialVersionUID = -2623309261327598087L;
@JsonField(name = "errors")
ErrorInfoImpl[] errors;
ErrorInfo[] errors;
@JsonField(name = "error")
String errorMessage;
@JsonField(name = "request")
@ -118,7 +116,7 @@ public class TwitterException extends Exception implements TwitterResponse, Http
public void setHttpResponse(RestHttpResponse res) {
httpResponse = res;
if (res != null) {
rateLimitStatus = RateLimitStatusJSONImpl.createFromResponseHeader(res);
rateLimitStatus = RateLimitStatus.createFromResponseHeader(res);
statusCode = res.getStatus();
} else {
rateLimitStatus = null;
@ -280,7 +278,7 @@ public class TwitterException extends Exception implements TwitterResponse, Http
nested = true;
}
static class SingleErrorInfo implements ErrorInfo {
static class SingleErrorInfo extends ErrorInfo {
private final String message;
private final String request;
private final int code;
@ -291,17 +289,14 @@ public class TwitterException extends Exception implements TwitterResponse, Http
this.code = -1;
}
@Override
public int getCode() {
return code;
}
@Override
public String getRequest() {
return request;
}
@Override
public String getMessage() {
return message;
}

View File

@ -19,49 +19,44 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.AccountSettingsImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.9
* Created by mariotaku on 15/5/13.
*/
@Implementation(AccountSettingsImpl.class)
public interface AccountSettings extends TwitterResponse {
/**
* Returns the language used to render Twitter's UII for this user.
*
* @return the language ISO 639-1 representation
*/
String getLanguage();
@JsonObject
public class AccountSettings extends TwitterResponseObject {
/**
* Returns the timezone configured for this user.
*
* @return the timezone (formated as a Rails TimeZone name)
*/
TimeZone getTimeZone();
@JsonField(name = "geo_enabled")
boolean geoEnabled;
@JsonField(name = "trend_location")
Location[] trendLocations;
@JsonField(name = "language")
String language;
@JsonField(name = "always_use_https")
boolean alwaysUseHttps;
@JsonField(name = "time_zone")
TimeZone timezone;
/**
* Return the user's trend locations
*
* @return the user's trend locations
*/
Location[] getTrendLocations();
public boolean isAlwaysUseHttps() {
return alwaysUseHttps;
}
/**
* Returns true if the wants to always access twitter using HTTPS.
*
* @return true if the wants to always access twitter using HTTPS
*/
boolean isAlwaysUseHttps();
public String getLanguage() {
return language;
}
public TimeZone getTimeZone() {
return timezone;
}
/**
* Return true if the user is enabling geo location
*
* @return true if the user is enabling geo location
*/
boolean isGeoEnabled();
public Location[] getTrendLocations() {
return trendLocations;
}
public boolean isGeoEnabled() {
return geoEnabled;
}
}

View File

@ -1,56 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model;
import java.io.Serializable;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.9
*/
public interface AccountTotals extends TwitterResponse, Serializable {
/**
* Returns the number of total favorites.
*
* @return the number of total favorites
*/
int getFavorites();
/**
* Returns the number of total followers.
*
* @return the number of total followers
*/
int getFollowers();
/**
* Returns the number of total friends.
*
* @return the number of total friends
*/
int getFriends();
/**
* Returns the number of total updates.
*
* @return the number of total updates
*/
int getUpdates();
}

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.JsonMapper;
import com.bluelinelabs.logansquare.LoganSquare;
@ -25,25 +25,20 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.mariotaku.twidere.api.twitter.model.Activity;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserList;
import java.io.IOException;
import java.text.ParseException;
/**
* Created by mariotaku on 15/10/21.
*/
public class ActivityImplMapper extends JsonMapper<ActivityImpl> {
public class Activity$$JsonObjectMapper extends JsonMapper<Activity> {
public static final ActivityImplMapper INSTANCE = new ActivityImplMapper();
public static final Activity$$JsonObjectMapper INSTANCE = new Activity$$JsonObjectMapper();
@SuppressWarnings("TryWithIdenticalCatches")
@Override
public ActivityImpl parse(JsonParser jsonParser) throws IOException {
ActivityImpl instance = new ActivityImpl();
public Activity parse(JsonParser jsonParser) throws IOException {
Activity instance = new Activity();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
@ -61,18 +56,18 @@ public class ActivityImplMapper extends JsonMapper<ActivityImpl> {
}
@Override
public void serialize(ActivityImpl activity, JsonGenerator jsonGenerator, boolean writeStartAndEnd) {
public void serialize(Activity activity, JsonGenerator jsonGenerator, boolean writeStartAndEnd) {
throw new UnsupportedOperationException();
}
public void parseField(ActivityImpl instance, String fieldName, JsonParser jsonParser) throws IOException {
public void parseField(Activity instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("action".equals(fieldName)) {
final String rawAction = jsonParser.getValueAsString();
instance.action = Activity.Action.parse(rawAction);
instance.rawAction = rawAction;
} else if ("created_at".equals(fieldName)) {
try {
instance.createdAt = ActivityImpl.DATE_FORMAT.parse(jsonParser.getValueAsString());
instance.createdAt = Activity.DATE_FORMAT.parse(jsonParser.getValueAsString());
} catch (ParseException e) {
throw new IOException(e);
}

View File

@ -1,5 +1,5 @@
/*
* Twidere - Twitter client for Android
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
@ -19,67 +19,164 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.ActivityImpl;
import android.support.annotation.NonNull;
import org.mariotaku.twidere.util.AbsLogger;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
@Implementation(ActivityImpl.class)
public interface Activity extends TwitterResponse, Comparable<Activity> {
public class Activity extends TwitterResponseObject implements TwitterResponse, Comparable<Activity> {
int ACTION_UNKNOWN = 0x00;
int ACTION_FAVORITE = 0x01;
int ACTION_FOLLOW = 0x02;
int ACTION_MENTION = 0x03;
int ACTION_REPLY = 0x04;
int ACTION_RETWEET = 0x05;
int ACTION_LIST_MEMBER_ADDED = 0x06;
int ACTION_LIST_CREATED = 0x07;
int ACTION_FAVORITED_RETWEET = 0x08;
int ACTION_RETWEETED_RETWEET = 0x09;
int ACTION_QUOTE = 0x0A;
int ACTION_RETWEETED_MENTION = 0x0B;
int ACTION_FAVORITED_MENTION = 0x0C;
int ACTION_JOINED_TWITTER = 0x0D;
int ACTION_MEDIA_TAGGED = 0x0E;
int ACTION_FAVORITED_MEDIA_TAGGED = 0x0F;
int ACTION_RETWEETED_MEDIA_TAGGED = 0x10;
public static final int ACTION_UNKNOWN = 0x00;
public static final int ACTION_FAVORITE = 0x01;
public static final int ACTION_FOLLOW = 0x02;
public static final int ACTION_MENTION = 0x03;
public static final int ACTION_REPLY = 0x04;
public static final int ACTION_RETWEET = 0x05;
public static final int ACTION_LIST_MEMBER_ADDED = 0x06;
public static final int ACTION_LIST_CREATED = 0x07;
public static final int ACTION_FAVORITED_RETWEET = 0x08;
public static final int ACTION_RETWEETED_RETWEET = 0x09;
public static final int ACTION_QUOTE = 0x0A;
public static final int ACTION_RETWEETED_MENTION = 0x0B;
public static final int ACTION_FAVORITED_MENTION = 0x0C;
public static final int ACTION_JOINED_TWITTER = 0x0D;
public static final int ACTION_MEDIA_TAGGED = 0x0E;
public static final int ACTION_FAVORITED_MEDIA_TAGGED = 0x0F;
public static final int ACTION_RETWEETED_MEDIA_TAGGED = 0x10;
static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Action action;
String rawAction;
Action getAction();
Date createdAt;
String getRawAction();
User[] sources;
User[] targetUsers;
User[] targetObjectUsers;
Status[] targetObjectStatuses, targetStatuses;
UserList[] targetUserLists, targetObjectUserLists;
long maxPosition, minPosition;
int targetObjectsSize, targetsSize, sourcesSize;
Date getCreatedAt();
Activity() {
}
long getMaxPosition();
public String getRawAction() {
return rawAction;
}
long getMinPosition();
public User[] getTargetObjectUsers() {
return targetObjectUsers;
}
User[] getSources();
@Override
public int compareTo(@NonNull final Activity another) {
final Date thisDate = getCreatedAt(), thatDate = another.getCreatedAt();
if (thisDate == null || thatDate == null) return 0;
return thisDate.compareTo(thatDate);
}
int getSourcesSize();
public Action getAction() {
return action;
}
int getTargetObjectsSize();
public Date getCreatedAt() {
return createdAt;
}
Status[] getTargetObjectStatuses();
public long getMaxPosition() {
return maxPosition;
}
UserList[] getTargetObjectUserLists();
public long getMinPosition() {
return minPosition;
}
int getTargetsSize();
public User[] getSources() {
return sources;
}
Status[] getTargetStatuses();
public int getSourcesSize() {
return sourcesSize;
}
UserList[] getTargetUserLists();
public int getTargetObjectsSize() {
return targetObjectsSize;
}
User[] getTargetUsers();
public Status[] getTargetObjectStatuses() {
return targetObjectStatuses;
}
User[] getTargetObjectUsers();
public UserList[] getTargetObjectUserLists() {
return targetObjectUserLists;
}
public int getTargetsSize() {
return targetsSize;
}
@EnumClass
enum Action {
public Status[] getTargetStatuses() {
return targetStatuses;
}
public UserList[] getTargetUserLists() {
return targetUserLists;
}
public User[] getTargetUsers() {
return targetUsers;
}
@Override
public String toString() {
return "ActivityJSONImpl{" +
"action=" + action +
", createdAt=" + createdAt +
", sources=" + Arrays.toString(sources) +
", targetUsers=" + Arrays.toString(targetUsers) +
", targetObjectStatuses=" + Arrays.toString(targetObjectStatuses) +
", targetStatuses=" + Arrays.toString(targetStatuses) +
", targetUserLists=" + Arrays.toString(targetUserLists) +
", targetObjectUserLists=" + Arrays.toString(targetObjectUserLists) +
", maxPosition=" + maxPosition +
", minPosition=" + minPosition +
", targetObjectsSize=" + targetObjectsSize +
", targetsSize=" + targetsSize +
", sourcesSize=" + sourcesSize +
'}';
}
public static Activity fromMention(long accountId, Status status) {
final Activity activity = new Activity();
activity.maxPosition = activity.minPosition = status.getId();
activity.createdAt = status.getCreatedAt();
if (status.getInReplyToUserId() == accountId) {
activity.action = Action.REPLY;
activity.rawAction = "reply";
activity.targetStatuses = new Status[]{status};
//TODO set target statuses (in reply to status)
activity.targetObjectStatuses = new Status[0];
} else {
activity.action = Action.MENTION;
activity.rawAction = "mention";
activity.targetObjectStatuses = new Status[]{status};
// TODO set target users (mentioned users)
activity.targetUsers = null;
}
activity.sourcesSize = 1;
activity.sources = new User[]{status.getUser()};
return activity;
}
public enum Action {
FAVORITE(ACTION_FAVORITE),
/**
* Sources: followers to targets (User)
@ -139,4 +236,4 @@ public interface Activity extends TwitterResponse, Comparable<Activity> {
return actionId;
}
}
}
}

View File

@ -19,28 +19,62 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.CardEntityImpl;
import android.support.v4.util.ArrayMap;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import java.util.Map;
/**
* Created by mariotaku on 14/12/31.
* Created by mariotaku on 15/5/7.
*/
@Implementation(CardEntityImpl.class)
public interface CardEntity {
@JsonObject
public class CardEntity {
String getName();
String getUrl();
@JsonField(name = "name")
String name;
User[] getUsers();
@JsonField(name = "url")
String url;
BindingValue getBindingValue(String key);
@JsonField(name = "binding_values")
Map<String, RawBindingValue> rawBindingValues;
Map<String, BindingValue> bindingValues;
Map<String, BindingValue> getBindingValues();
public String getName() {
return name;
}
interface BindingValue {
public String getUrl() {
return url;
}
public User[] getUsers() {
return new User[0];
}
public BindingValue getBindingValue(String key) {
return bindingValues.get(key);
}
public Map<String, BindingValue> getBindingValues() {
return bindingValues;
}
@OnJsonParseComplete
void onParseComplete() {
if (rawBindingValues != null) {
bindingValues = new ArrayMap<>();
for (Map.Entry<String, RawBindingValue> entry : rawBindingValues.entrySet()) {
bindingValues.put(entry.getKey(), entry.getValue().getBindingValue());
}
}
}
public interface BindingValue {
String TYPE_STRING = "STRING";
String TYPE_IMAGE = "IMAGE";
@ -49,24 +83,98 @@ public interface CardEntity {
}
@JsonObject
public static class ImageValue implements BindingValue {
@JsonField(name = "width")
int width;
@JsonField(name = "height")
int height;
@JsonField(name = "url")
String url;
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public String getUrl() {
return url;
}
interface UserValue extends BindingValue {
long getUserId();
}
interface StringValue extends BindingValue {
String getValue();
public static class BooleanValue implements BindingValue {
public BooleanValue(boolean value) {
this.value = value;
}
private boolean value;
public boolean getValue() {
return value;
}
}
interface BooleanValue extends BindingValue {
boolean getValue();
public static class StringValue implements BindingValue {
private final String value;
public StringValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
interface ImageValue extends BindingValue {
int getWidth();
@JsonObject
public static class UserValue implements BindingValue {
int getHeight();
@JsonField(name = "id")
long userId;
public long getUserId() {
return userId;
}
}
@JsonObject
public static class RawBindingValue {
@JsonField(name = "type")
String type;
@JsonField(name = "boolean_value")
boolean booleanValue;
@JsonField(name = "string_value")
String stringValue;
@JsonField(name = "image_value")
ImageValue imageValue;
@JsonField(name = "user_value")
UserValue userValue;
public BindingValue getBindingValue() {
if (type == null) return null;
switch (type) {
case BindingValue.TYPE_BOOLEAN: {
return new BooleanValue(booleanValue);
}
case BindingValue.TYPE_STRING: {
return new StringValue(stringValue);
}
case BindingValue.TYPE_IMAGE: {
return imageValue;
}
case BindingValue.TYPE_USER: {
return userValue;
}
}
return null;
}
String getUrl();
}
}

View File

@ -19,16 +19,36 @@
package org.mariotaku.twidere.api.twitter.model;
import java.io.Serializable;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.1
*/
public interface Category extends Serializable {
String getName();
@JsonObject
public class Category {
@JsonField(name = "name")
String name;
@JsonField(name = "size")
long size;
@JsonField(name = "slug")
String slug;
int getSize();
public String getName() {
return name;
}
String getSlug();
public long getSize() {
return size;
}
public String getSlug() {
return slug;
}
@Override
public String toString() {
return "Category{" +
"name='" + name + '\'' +
", size=" + size +
", slug='" + slug + '\'' +
'}';
}
}

View File

@ -19,39 +19,94 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.DirectMessageImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* A data interface representing sent/received direct message.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/7.
*/
@Implementation(DirectMessageImpl.class)
public interface DirectMessage extends TwitterResponse, EntitySupport {
@JsonObject
public class DirectMessage extends TwitterResponseObject implements TwitterResponse, EntitySupport {
/**
* @return created_at
* @since Twitter4J 1.1.0
*/
Date getCreatedAt();
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
long getId();
@JsonField(name = "sender")
User sender;
User getRecipient();
@JsonField(name = "recipient")
User recipient;
long getRecipientId();
@JsonField(name = "entities")
Entities entities;
String getRecipientScreenName();
@JsonField(name = "text")
String text;
User getSender();
@JsonField(name = "id")
long id;
long getSenderId();
public long getId() {
return id;
}
String getSenderScreenName();
public String getText() {
return text;
}
String getText();
@Override
public HashtagEntity[] getHashtagEntities() {
if (entities == null) return null;
return entities.getHashtags();
}
@Override
public MediaEntity[] getMediaEntities() {
if (entities == null) return null;
return entities.getMedia();
}
@Override
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrls();
}
@Override
public UserMentionEntity[] getUserMentionEntities() {
if (entities == null) return null;
return entities.getUserMentions();
}
public Date getCreatedAt() {
return createdAt;
}
public User getSender() {
return sender;
}
public long getSenderId() {
return sender.id;
}
public String getSenderScreenName() {
return sender.screenName;
}
public User getRecipient() {
return recipient;
}
public long getRecipientId() {
return recipient.id;
}
public String getRecipientScreenName() {
return recipient.screenName;
}
}

View File

@ -17,40 +17,35 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.HashtagEntity;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
import java.util.Arrays;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class EntitiesImpl {
public class Entities {
@JsonField(name = "hashtags")
HashtagEntityImpl[] hashtags;
HashtagEntity[] hashtags;
@JsonField(name = "user_mentions")
UserMentionEntityImpl[] userMentions;
UserMentionEntity[] userMentions;
@JsonField(name = "urls")
UrlEntityImpl[] urls;
UrlEntity[] urls;
@JsonField(name = "media")
MediaEntityImpl[] media;
MediaEntity[] media;
public HashtagEntity[] getHashtags() {
public org.mariotaku.twidere.api.twitter.model.HashtagEntity[] getHashtags() {
return hashtags;
}
public UserMentionEntity[] getUserMentions() {
public org.mariotaku.twidere.api.twitter.model.UserMentionEntity[] getUserMentions() {
return userMentions;
}
@ -64,7 +59,7 @@ public class EntitiesImpl {
@Override
public String toString() {
return "EntitiesImpl{" +
return "Entities{" +
"hashtags=" + Arrays.toString(hashtags) +
", userMentions=" + Arrays.toString(userMentions) +
", urls=" + Arrays.toString(urls) +

View File

@ -19,18 +19,29 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.ErrorInfoImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Created by mariotaku on 15/5/7.
*/
@Implementation(ErrorInfoImpl.class)
public interface ErrorInfo {
@JsonObject
public class ErrorInfo {
int getCode();
@JsonField(name = "code")
int code;
@JsonField(name = "message")
String message;
String getMessage();
public int getCode() {
return code;
}
String getRequest();
public String getMessage() {
return message;
}
public String getRequest() {
return null;
}
}

View File

@ -19,33 +19,65 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.ExtendedProfileImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.ExtendedProfile;
/**
* Created by mariotaku on 15/7/8.
*/
@Implementation(ExtendedProfileImpl.class)
public interface ExtendedProfile {
@JsonObject
public class ExtendedProfile {
long getId();
@JsonField(name = "id")
long id;
@JsonField(name = "birthdate")
Birthdate birthdate;
Birthdate getBirthdate();
public long getId() {
return id;
}
interface Birthdate {
int getDay();
public Birthdate getBirthdate() {
return birthdate;
}
int getMonth();
@JsonObject
public static class Birthdate {
int getYear();
@JsonField(name = "day")
int day;
@JsonField(name = "month")
int month;
@JsonField(name = "year")
int year;
@JsonField(name = "visibility")
Visibility visibility;
@JsonField(name = "year_visibility")
Visibility yearVisibility;
Visibility getVisibility();
public int getDay() {
return day;
}
Visibility getYearVisibility();
public int getMonth() {
return month;
}
@EnumClass
enum Visibility {
public int getYear() {
return year;
}
public Visibility getVisibility() {
return visibility;
}
public Visibility getYearVisibility() {
return yearVisibility;
}
public enum Visibility {
MUTUALFOLLOW, PUBLIC, UNKNOWN;
public static Visibility parse(String s) {
@ -55,5 +87,4 @@ public interface ExtendedProfile {
}
}
}
}

View File

@ -19,18 +19,24 @@
package org.mariotaku.twidere.api.twitter.model;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.9
*/
public interface Friendship {
long getId();
public class Friendship {
public long getId() {
throw new UnsupportedOperationException();
}
String getName();
public String getName() {
throw new UnsupportedOperationException();
}
String getScreenName();
public String getScreenName() {
throw new UnsupportedOperationException();
}
boolean isFollowedBy();
public boolean isFollowedBy() {
throw new UnsupportedOperationException();
}
boolean isFollowing();
public boolean isFollowing() {
throw new UnsupportedOperationException();
}
}

View File

@ -19,7 +19,6 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Mapper;
import org.mariotaku.restfu.http.ValueMap;
/**

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;

View File

@ -2,7 +2,7 @@
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -19,35 +19,29 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.HashtagEntityImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* A data interface representing one single Hashtag entity.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.9
* Created by mariotaku on 15/3/31.
*/
@Implementation(HashtagEntityImpl.class)
public interface HashtagEntity {
/**
* Returns the index of the end character of the hashtag.
*
* @return the index of the end character of the hashtag
*/
int getEnd();
@JsonObject
public class HashtagEntity {
/**
* Returns the index of the start character of the hashtag.
*
* @return the index of the start character of the hashtag
*/
int getStart();
@JsonField(name = "text")
String text;
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
/**
* Returns the text of the hashtag without #.
*
* @return the text of the hashtag
*/
String getText();
public int getEnd() {
return indices.getEnd();
}
public int getStart() {
return indices.getStart();
}
public String getText() {
return text;
}
}

View File

@ -17,15 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.JsonMapper;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.mariotaku.twidere.api.twitter.model.IDs;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -33,14 +31,12 @@ import java.util.List;
/**
* Created by mariotaku on 15/10/21.
*/
public class IDsImplMapper extends JsonMapper<IDsImpl> {
public static final IDsImplMapper INSTANCE = new IDsImplMapper();
public class IDs$$JsonObjectMapper extends JsonMapper<IDs> {
@SuppressWarnings("TryWithIdenticalCatches")
@Override
public IDsImpl parse(JsonParser jsonParser) throws IOException {
IDsImpl instance = new IDsImpl();
public IDs parse(JsonParser jsonParser) throws IOException {
IDs instance = new IDs();
if (jsonParser.getCurrentToken() == null) {
jsonParser.nextToken();
}
@ -61,11 +57,11 @@ public class IDsImplMapper extends JsonMapper<IDsImpl> {
}
@Override
public void serialize(IDsImpl activity, JsonGenerator jsonGenerator, boolean writeStartAndEnd) {
public void serialize(IDs activity, JsonGenerator jsonGenerator, boolean writeStartAndEnd) {
throw new UnsupportedOperationException();
}
public void parseField(IDsImpl instance, String fieldName, JsonParser jsonParser) throws IOException {
public void parseField(IDs instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("ids".equals(fieldName)) {
parseIDsArray(instance, jsonParser);
} else if ("previous_cursor".equals(fieldName)) {
@ -75,7 +71,7 @@ public class IDsImplMapper extends JsonMapper<IDsImpl> {
}
}
private void parseIDsArray(IDsImpl instance, JsonParser jsonParser) throws IOException {
private void parseIDsArray(IDs instance, JsonParser jsonParser) throws IOException {
List<Long> collection1 = new ArrayList<>();
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
collection1.add(jsonParser.getValueAsLong());

View File

@ -19,17 +19,37 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.IDsImpl;
/**
* A data interface representing array of numeric IDs.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/10.
*/
@Implementation(IDsImpl.class)
public interface IDs extends TwitterResponse, CursorSupport {
public class IDs extends TwitterResponseObject implements TwitterResponse, CursorSupport {
long[] getIDs();
long previousCursor;
long nextCursor;
long[] ids;
@Override
public long getNextCursor() {
return nextCursor;
}
@Override
public long getPreviousCursor() {
return previousCursor;
}
@Override
public boolean hasNext() {
return nextCursor != 0;
}
@Override
public boolean hasPrevious() {
return previousCursor != 0;
}
public long[] getIDs() {
return ids;
}
}

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
/**
* Created by mariotaku on 15/3/31.

View File

@ -17,13 +17,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.typeconverters.TypeConverter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.mariotaku.twidere.api.twitter.model.Indices;
import java.io.IOException;
/**

View File

@ -19,17 +19,39 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.LanguageImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Created by mariotaku on 15/5/10.
*/
@Implementation(LanguageImpl.class)
public interface Language {
String getCode();
@JsonObject
public class Language {
@JsonField(name = "name")
String name;
@JsonField(name = "code")
String code;
@JsonField(name = "status")
String status;
String getName();
public String getName() {
return name;
}
String getStatus();
public String getCode() {
return code;
}
public String getStatus() {
return status;
}
@Override
public String toString() {
return "Language{" +
"name='" + name + '\'' +
", code='" + code + '\'' +
", status='" + status + '\'' +
'}';
}
}

View File

@ -19,32 +19,66 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.LocationImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/10.
*/
@Implementation(LocationImpl.class)
public interface Location {
String getCountryCode();
@JsonObject
public class Location {
String getCountryName();
@JsonField(name = "woeid")
int woeid;
@JsonField(name = "country")
String countryName;
@JsonField(name = "countryCode")
String countryCode;
@JsonField(name = "placeType")
PlaceTypeImpl placeType;
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
String getName();
public int getWoeid() {
return woeid;
}
String getUrl();
public String getCountryName() {
return countryName;
}
int getWoeid();
public String getCountryCode() {
return countryCode;
}
PlaceType getPlaceType();
public PlaceTypeImpl getPlaceType() {
return placeType;
}
@Implementation(LocationImpl.PlaceTypeImpl.class)
interface PlaceType {
public String getName() {
return name;
}
int getCode();
public String getUrl() {
return url;
}
String getName();
@JsonObject
public static class PlaceTypeImpl {
}
@JsonField(name = "name")
String name;
@JsonField(name = "code")
int code;
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
}

View File

@ -1,10 +1,8 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -21,34 +19,116 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.MediaEntityImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class MediaEntity extends UrlEntity {
@JsonField(name = "id")
long id;
@Implementation(MediaEntityImpl.class)
public interface MediaEntity extends UrlEntity {
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
long getId();
@JsonField(name = "media_url")
String mediaUrl;
@JsonField(name = "media_url_https")
String mediaUrlHttps;
@JsonField(name = "url")
String url;
@JsonField(name = "display_url")
String displayUrl;
@JsonField(name = "expanded_url")
String expandedUrl;
@JsonField(name = "type")
Type type;
@JsonField(name = "sizes")
HashMap<String, Size> sizes;
@JsonField(name = "source_status_id")
long sourceStatusId;
@JsonField(name = "source_user_id")
long sourceUserId;
@JsonField(name = "video_info")
VideoInfo videoInfo;
@JsonField(name = "features")
HashMap<String, Feature> features;
Map<String, Feature> getFeatures();
public Map<String, Feature> getFeatures() {
return features;
}
String getMediaUrl();
@Override
public String toString() {
return "MediaEntity{" +
"id=" + id +
", indices=" + indices +
", mediaUrl='" + mediaUrl + '\'' +
", mediaUrlHttps='" + mediaUrlHttps + '\'' +
", url='" + url + '\'' +
", displayUrl='" + displayUrl + '\'' +
", expandedUrl='" + expandedUrl + '\'' +
", type=" + type +
", sizes=" + sizes +
", sourceStatusId=" + sourceStatusId +
", sourceUserId=" + sourceUserId +
", videoInfo=" + videoInfo +
", features=" + features +
'}';
}
public String getMediaUrl() {
return mediaUrl;
}
String getMediaUrlHttps();
public VideoInfo getVideoInfo() {
return videoInfo;
}
public String getMediaUrlHttps() {
return mediaUrlHttps;
}
Map<String, Size> getSizes();
public String getExpandedUrl() {
return expandedUrl;
}
public String getDisplayUrl() {
return displayUrl;
}
Type getType();
public String getUrl() {
return url;
}
@EnumClass
enum Type {
public Type getType() {
return type;
}
public Map<String, Size> getSizes() {
return sizes;
}
public int getEnd() {
return indices.getEnd();
}
public int getStart() {
return indices.getStart();
}
public long getId() {
return id;
}
public enum Type {
PHOTO, VIDEO, ANIMATED_GIF, UNKNOWN;
public static Type parse(String typeString) {
@ -63,61 +143,158 @@ public interface MediaEntity extends UrlEntity {
}
}
VideoInfo getVideoInfo();
@Implementation(MediaEntityImpl.VideoInfoImpl.class)
interface VideoInfo {
@JsonObject
public static class Feature {
@JsonField(name = "faces")
Face[] faces;
Variant[] getVariants();
@Override
public String toString() {
return "Feature{" +
"faces=" + Arrays.toString(faces) +
'}';
}
long[] getAspectRatio();
@JsonObject
public static class Face {
@JsonField(name = "x")
int x;
@JsonField(name = "y")
int y;
@JsonField(name = "h")
int height;
@JsonField(name = "w")
int width;
long getDuration();
public int getX() {
return x;
}
@Implementation(MediaEntityImpl.VideoInfoImpl.VariantImpl.class)
interface Variant {
public int getY() {
return y;
}
String getContentType();
@Override
public String toString() {
return "Face{" +
"x=" + x +
", y=" + y +
", height=" + height +
", width=" + width +
'}';
}
String getUrl();
public int getHeight() {
return height;
}
long getBitrate();
public int getWidth() {
return width;
}
}
}
@Implementation(MediaEntityImpl.SizeImpl.class)
interface Size {
String THUMB = "thumb";
String SMALL = "small";
String MEDIUM = "medium";
String LARGE = "large";
int FIT = 100;
int CROP = 101;
@JsonObject
public static class VideoInfo {
int getHeight();
@JsonField(name = "duration")
long duration;
@JsonField(name = "variants")
Variant[] variants;
@JsonField(name = "aspect_ratio")
long[] aspectRatio;
String getResize();
public Variant[] getVariants() {
return variants;
}
int getWidth();
public long[] getAspectRatio() {
return aspectRatio;
}
@Override
public String toString() {
return "VideoInfo{" +
"duration=" + duration +
", variants=" + Arrays.toString(variants) +
", aspectRatio=" + Arrays.toString(aspectRatio) +
'}';
}
public long getDuration() {
return duration;
}
@JsonObject
public static class Variant {
@JsonField(name = "bitrate")
long bitrate;
@JsonField(name = "content_type")
String contentType;
@JsonField(name = "url")
String url;
@Override
public String toString() {
return "Variant{" +
"bitrate=" + bitrate +
", contentType='" + contentType + '\'' +
", url='" + url + '\'' +
'}';
}
public String getContentType() {
return contentType;
}
public String getUrl() {
return url;
}
public long getBitrate() {
return bitrate;
}
}
}
/**
* Created by mariotaku on 15/3/31.
*/
@Implementation(MediaEntityImpl.FeatureImpl.class)
interface Feature {
@Implementation(MediaEntityImpl.FeatureImpl.FaceImpl.class)
interface Face {
@JsonObject
public static class Size {
int getX();
public static final String THUMB = "thumb";
public static final String SMALL = "small";
public static final String MEDIUM = "medium";
public static final String LARGE = "large";
public static final int FIT = 100;
public static final int CROP = 101;
@JsonField(name = "w")
int width;
@JsonField(name = "h")
int height;
@JsonField(name = "resize")
String resize;
int getY();
@Override
public String toString() {
return "Size{" +
"width=" + width +
", height=" + height +
", resize='" + resize + '\'' +
'}';
}
int getHeight();
public int getHeight() {
return height;
}
int getWidth();
public String getResize() {
return resize;
}
public int getWidth() {
return width;
}
}
}

View File

@ -19,25 +19,55 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.MediaUploadResponseImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@Implementation(MediaUploadResponseImpl.class)
public interface MediaUploadResponse extends TwitterResponse {
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class MediaUploadResponse extends TwitterResponseObject implements TwitterResponse {
long getId();
public long getId() {
return mediaId;
}
Image getImage();
public Image getImage() {
return image;
}
long getSize();
public long getSize() {
return size;
}
@Implementation(MediaUploadResponseImpl.ImageImpl.class)
interface Image {
@JsonField(name = "media_id")
long mediaId;
@JsonField(name = "size")
long size;
@JsonField(name = "image")
Image image;
int getHeight();
String getImageType();
@JsonObject
public static class Image {
int getWidth();
@JsonField(name = "width")
int width;
@JsonField(name = "height")
int height;
@JsonField(name = "image_type")
String imageType;
public int getHeight() {
return height;
}
public String getImageType() {
return imageType;
}
public int getWidth() {
return width;
}
}
}

View File

@ -19,22 +19,56 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.ParameterizedImplementation;
import org.mariotaku.library.logansquare.extension.annotation.TypeImplementation;
import org.mariotaku.twidere.api.twitter.model.impl.PagableStatusListImpl;
import org.mariotaku.twidere.api.twitter.model.impl.PagableUserListImpl;
import org.mariotaku.twidere.api.twitter.model.impl.PagableUserListListImpl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.ArrayList;
/**
* ResponseList with cursor support.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/7.
*/
@ParameterizedImplementation({
@TypeImplementation(parameter = Status.class, implementation = PagableStatusListImpl.class),
@TypeImplementation(parameter = User.class, implementation = PagableUserListImpl.class),
@TypeImplementation(parameter = UserList.class, implementation = PagableUserListListImpl.class)
})
public interface PageableResponseList<T> extends ResponseList<T>, CursorSupport {
@JsonObject
public class PageableResponseList<T> extends ArrayList<T> implements TwitterResponse, CursorSupport {
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatus.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
@Override
public long getNextCursor() {
return 0;
}
@Override
public long getPreviousCursor() {
return 0;
}
@Override
public boolean hasNext() {
return getNextCursor() != 0;
}
@Override
public boolean hasPrevious() {
return getPreviousCursor() != 0;
}
}

View File

@ -19,38 +19,75 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.PlaceImpl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.1
* Created by mariotaku on 15/5/7.
*/
@Implementation(PlaceImpl.class)
public interface Place extends TwitterResponse, Comparable<Place> {
GeoLocation[][] getBoundingBoxCoordinates();
@JsonObject
public class Place extends TwitterResponseObject implements TwitterResponse, Comparable<Place> {
String getBoundingBoxType();
@JsonField(name = "full_name")
String fullName;
Place[] getContainedWithIn();
public GeoLocation[][] getBoundingBoxCoordinates() {
throw new UnsupportedOperationException();
}
String getCountry();
public String getBoundingBoxType() {
throw new UnsupportedOperationException();
}
String getCountryCode();
public Place[] getContainedWithIn() {
throw new UnsupportedOperationException();
}
String getFullName();
public String getCountry() {
throw new UnsupportedOperationException();
}
GeoLocation[][] getGeometryCoordinates();
public String getCountryCode() {
throw new UnsupportedOperationException();
}
String getGeometryType();
public String getFullName() {
return fullName;
}
String getId();
public GeoLocation[][] getGeometryCoordinates() {
throw new UnsupportedOperationException();
}
String getName();
public String getGeometryType() {
throw new UnsupportedOperationException();
}
String getPlaceType();
public String getId() {
throw new UnsupportedOperationException();
}
String getStreetAddress();
public String getName() {
throw new UnsupportedOperationException();
}
public String getPlaceType() {
throw new UnsupportedOperationException();
}
public String getStreetAddress() {
throw new UnsupportedOperationException();
}
public String getUrl() {
throw new UnsupportedOperationException();
}
@Override
public int compareTo(@NonNull Place another) {
return 0;
}
String getUrl();
}

View File

@ -19,77 +19,224 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import android.support.annotation.Nullable;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Entities;
import org.mariotaku.twidere.api.twitter.model.EntitySupport;
import org.mariotaku.twidere.api.twitter.model.HashtagEntity;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
import java.util.Map;
/**
* Created by mariotaku on 15/7/5.
*/
public interface PrivateDirectMessages {
@JsonObject
public class PrivateDirectMessages {
UserEvents getUserEvents();
@JsonField(name = "user_inbox")
UserInbox userInbox;
@JsonField(name = "user_events")
UserEvents userEvents;
interface UserInbox {
User getUser(long userId);
Conversation getConversation(String conversationId);
Message[] getEntries();
public UserInbox getUserInbox() {
return userInbox;
}
interface UserEvents {
String getCursor();
long getLastSeenEventId();
public UserEvents getUserEvents() {
return userEvents;
}
UserInbox getUserInbox();
interface Message {
interface Data extends EntitySupport {
String getText();
String getConversationId();
long getId();
long getRecipientId();
long getSenderId();
long getTime();
}
}
interface Conversation {
Participant[] getParticipants();
String getConversationId();
long getLastReadEventId();
long getMaxEntryId();
long getMinEntryId();
boolean isNotificationsDisabled();
interface Participant {
long getUserId();
}
@EnumClass
enum Type {
ONE_TO_ONE, GROUP_DM
}
}
@EnumClass
enum Status {
public enum Status {
HAS_MORE, AT_END
}
@JsonObject
public static class UserInbox {
@JsonField(name = "users")
Map<String, User> users;
@JsonField(name = "conversations")
Map<String, Conversation> conversations;
@JsonField(name = "entries")
Message[] entries;
public User getUser(long userId) {
return users.get(String.valueOf(userId));
}
public Conversation getConversation(String conversationId) {
return conversations.get(conversationId);
}
public Message[] getEntries() {
return entries;
}
}
@JsonObject
public static class UserEvents {
@JsonField(name = "cursor")
String cursor;
@JsonField(name = "last_seen_event_id")
long lastSeenEventId;
public String getCursor() {
return cursor;
}
public long getLastSeenEventId() {
return lastSeenEventId;
}
}
@JsonObject
public static class Message {
@JsonObject
public static class Data implements EntitySupport {
@Nullable
@JsonField(name = "entities")
Entities entities;
@JsonField(name = "sender_id")
long senderId;
@JsonField(name = "recipient_id")
long recipientId;
@JsonField(name = "id")
long id;
@JsonField(name = "conversation_id")
String conversationId;
@JsonField(name = "text")
String text;
@JsonField(name = "time")
long time;
public String getText() {
return text;
}
public String getConversationId() {
return conversationId;
}
public long getId() {
return id;
}
public long getRecipientId() {
return recipientId;
}
public long getSenderId() {
return senderId;
}
public long getTime() {
return time;
}
@Override
public HashtagEntity[] getHashtagEntities() {
if (entities == null) return null;
return entities.getHashtags();
}
@Override
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrls();
}
@Override
public MediaEntity[] getMediaEntities() {
if (entities == null) return null;
return entities.getMedia();
}
@Override
public UserMentionEntity[] getUserMentionEntities() {
if (entities == null) return null;
return entities.getUserMentions();
}
}
}
@JsonObject
public static class Conversation {
@JsonField(name = "conversation_id")
String conversationId;
@JsonField(name = "last_read_event_id")
long lastReadEventId;
@JsonField(name = "max_entry_id")
long maxEntryId;
@JsonField(name = "min_entry_id")
long minEntryId;
@JsonField(name = "notifications_disabled")
boolean notificationsDisabled;
@JsonField(name = "participants")
Participant[] participants;
@JsonField(name = "read_only")
boolean readOnly;
@JsonField(name = "sort_event_id")
long sortEventId;
@JsonField(name = "sort_timestamp")
long sortTimestamp;
@JsonField(name = "status")
Status status;
@JsonField(name = "type")
Type type;
public Participant[] getParticipants() {
return participants;
}
public String getConversationId() {
return conversationId;
}
public long getLastReadEventId() {
return lastReadEventId;
}
public long getMaxEntryId() {
return maxEntryId;
}
public long getMinEntryId() {
return minEntryId;
}
public boolean isNotificationsDisabled() {
return notificationsDisabled;
}
public enum Type {
ONE_TO_ONE, GROUP_DM
}
@JsonObject
public static class Participant {
@JsonField(name = "user_id")
long userId;
public long getUserId() {
return userId;
}
}
}
}

View File

@ -22,5 +22,5 @@ package org.mariotaku.twidere.api.twitter.model;
/**
* Created by mariotaku on 15/10/21.
*/
public interface PrivateSearchResult {
public class PrivateSearchResult {
}

View File

@ -19,25 +19,119 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.QueryResultImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.AbstractList;
import java.util.ArrayList;
/**
* A data interface representing search API response
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/7.
*/
@Implementation(QueryResultImpl.class)
public interface QueryResult extends ResponseList<Status>, CursorSupport {
double getCompletedIn();
@JsonObject
public class QueryResult extends AbstractList<Status> implements TwitterResponse, CursorSupport {
long getMaxId();
@JsonField(name = "previous_cursor")
long previousCursor;
@JsonField(name = "next_cursor")
long nextCursor;
String getQuery();
@JsonField(name = "search_metadata")
SearchMetadata metadata;
int getResultsPerPage();
@JsonField(name = "statuses")
ArrayList<Status> statuses;
long getSinceId();
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatus.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
@Override
public Status get(int index) {
return statuses.get(index);
}
@Override
public int size() {
return statuses.size();
}
public double getCompletedIn() {
return metadata.completedIn;
}
public long getMaxId() {
return metadata.maxId;
}
public String getQuery() {
return metadata.query;
}
public int getResultsPerPage() {
return metadata.count;
}
@Override
public long getNextCursor() {
return nextCursor;
}
@Override
public boolean hasNext() {
return nextCursor != 0;
}
@Override
public boolean hasPrevious() {
return previousCursor != 0;
}
@Override
public long getPreviousCursor() {
return previousCursor;
}
public long getSinceId() {
return metadata.sinceId;
}
public String getWarning() {
return metadata.warning;
}
@JsonObject
public static class SearchMetadata {
@JsonField(name = "max_id")
long maxId;
@JsonField(name = "since_id")
long sinceId;
@JsonField(name = "count")
int count;
@JsonField(name = "completed_in")
double completedIn;
@JsonField(name = "query")
String query;
@JsonField(name = "warning")
String warning;
}
String getWarning();
}

View File

@ -19,46 +19,161 @@
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
/**
* A data interface representing Twitter REST API's rate limit status
*
* A data class representing Twitter REST API's rate limit status
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @see <a href="https://dev.twitter.com/docs/rate-limiting">Rate Limiting |
* Twitter Developers</a>
* Twitter Developers</a>
*/
public interface RateLimitStatus {
@JsonObject
public final class RateLimitStatus {
int getLimit();
private final long creationTimeInMillis;
int getRemaining();
@JsonField(name = "remaining")
int remaining;
@JsonField(name = "limit")
int limit;
@JsonField(name = "reset")
int resetTimeInSeconds;
/**
* Returns the remaining number of API requests available.<br>
* This value is identical to the &quot;X-RateLimit-Remaining&quot; response
* header.
*
* @return the remaining number of API requests available
*/
int getRemainingHits();
private RateLimitStatus(final int limit, final int remaining, final int resetTimeInSeconds) {
this();
this.limit = limit;
this.remaining = remaining;
this.resetTimeInSeconds = resetTimeInSeconds;
}
/**
* Returns the seconds the current rate limiting period ends.<br>
* This should be a same as getResetTime().getTime()/1000.
*
* @return the seconds the current rate limiting period ends
* @since Twitter4J 2.0.9
*/
int getResetTimeInSeconds();
public RateLimitStatus() {
creationTimeInMillis = System.currentTimeMillis();
}
/**
* Returns the amount of seconds until the current rate limiting period
* ends.<br>
* This is a value provided/calculated only by Twitter4J for handiness and
* not a part of the twitter API spec.
*
* @return the amount of seconds until next rate limiting period
* @since Twitter4J 2.1.0
*/
int getSecondsUntilReset();
/**
* {@inheritDoc}
*/
public int getLimit() {
return limit;
}
}
/**
* {@inheritDoc}
*/
public int getRemaining() {
return remaining;
}
/**
* {@inheritDoc}
*/
public int getRemainingHits() {
return getRemaining();
}
/**
* {@inheritDoc}
*/
public int getResetTimeInSeconds() {
return resetTimeInSeconds;
}
/**
* {@inheritDoc}
*/
public int getSecondsUntilReset() {
return (int) ((resetTimeInSeconds * 1000L - creationTimeInMillis) / 1000);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RateLimitStatus that = (RateLimitStatus) o;
if (creationTimeInMillis != that.creationTimeInMillis) return false;
if (remaining != that.remaining) return false;
if (limit != that.limit) return false;
return resetTimeInSeconds == that.resetTimeInSeconds;
}
@Override
public int hashCode() {
int result = (int) (creationTimeInMillis ^ (creationTimeInMillis >>> 32));
result = 31 * result + remaining;
result = 31 * result + limit;
result = 31 * result + resetTimeInSeconds;
return result;
}
@Override
public String toString() {
return "RateLimitStatus{" +
"creationTimeInMillis=" + creationTimeInMillis +
", remaining=" + remaining +
", limit=" + limit +
", resetTimeInSeconds=" + resetTimeInSeconds +
'}';
}
public static RateLimitStatus createFromResponseHeader(final RestHttpResponse res) {
if (null == res) return null;
int remainingHits;// "X-Rate-Limit-Remaining"
int limit;// "X-Rate-Limit-Limit"
int resetTimeInSeconds;// not included in the response header. Need to
// be calculated.
final String strLimit = res.getHeader("X-Rate-Limit-Limit");
if (strLimit != null) {
limit = Integer.parseInt(strLimit);
} else
return null;
final String remaining = res.getHeader("X-Rate-Limit-Remaining");
if (remaining != null) {
remainingHits = Integer.parseInt(remaining);
} else
return null;
final String reset = res.getHeader("X-Rate-Limit-Reset");
if (reset != null) {
final long longReset = Long.parseLong(reset);
resetTimeInSeconds = (int) longReset;
} else
return null;
return new RateLimitStatus(limit, remainingHits, resetTimeInSeconds);
}
// static Map<String, RateLimitStatus> createRateLimitStatuses(final HttpResponse res, final Configuration conf)
// throws TwitterException {
// final JSONObject json = res.asJSONObject();
// final Map<String, RateLimitStatus> map = createRateLimitStatuses(json);
// return map;
// }
//
// static Map<String, RateLimitStatus> createRateLimitStatuses(final InputStream stream) throws TwitterException {
// final Map<String, RateLimitStatus> map = new HashMap<String, RateLimitStatus>();
// try {
// final JSONObject resources = json.getJSONObject("resources");
// final Iterator<?> resourceKeys = resources.keys();
// while (resourceKeys.hasNext()) {
// final JSONObject resource = resources.getJSONObject((String) resourceKeys.next());
// final Iterator<?> endpointKeys = resource.keys();
// while (endpointKeys.hasNext()) {
// final String endpoint = (String) endpointKeys.next();
// final JSONObject rateLimitStatusJSON = resource.getJSONObject(endpoint);
// final RateLimitStatus rateLimitStatus = new RateLimitStatus(rateLimitStatusJSON);
// map.put(endpoint, rateLimitStatus);
// }
// }
// return Collections.unmodifiableMap(map);
// } catch (final JSONException jsone) {
// throw new TwitterException(jsone);
// }
// }
}

View File

@ -19,99 +19,143 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.RelationshipImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@Implementation(RelationshipImpl.class)
public interface Relationship extends TwitterResponse {
boolean canSourceDMTarget();
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class Relationship extends TwitterResponseObject implements TwitterResponse {
boolean canSourceMediaTagTarget();
@JsonField(name = "relationship")
RelationshipObject object;
/**
* Returns the source user id
*
* @return the source user id
*/
long getSourceUserId();
public boolean isSourceBlockingTarget() {
return object.source.blocking;
}
/**
* Returns the source user screen name
*
* @return returns the source user screen name
*/
String getSourceUserScreenName();
public boolean isTargetFollowingSource() {
return object.target.following;
}
/**
* Returns the target user id
*
* @return target user id
*/
long getTargetUserId();
public boolean isTargetFollowedBySource() {
return object.target.followedBy;
}
/**
* Returns the target user screen name
*
* @return the target user screen name
*/
String getTargetUserScreenName();
public boolean isSourceNotificationsEnabled() {
return object.source.notificationsEnabled;
}
/**
* Returns if the source user is blocking the target user
*
* @return if the source is blocking the target
*/
boolean isSourceBlockingTarget();
public boolean isSourceMutingTarget() {
return object.source.muting;
}
boolean isSourceBlockedByTarget();
public boolean isSourceMarkedTargetAsSpam() {
return false;
}
/**
* Checks if source user is being followed by target user
*
* @return true if source user is being followed by target user
*/
boolean isSourceFollowedByTarget();
public boolean isSourceFollowingTarget() {
return object.source.following;
}
/**
* Checks if source user is following target user
*
* @return true if source user is following target user
*/
boolean isSourceFollowingTarget();
public boolean isSourceFollowedByTarget() {
return object.source.followedBy;
}
boolean isSourceMarkedTargetAsSpam();
public boolean isSourceBlockedByTarget() {
return object.source.blockedBy;
}
boolean isSourceMutingTarget();
public String getTargetUserScreenName() {
return object.target.screenName;
}
/**
* Checks if the source user has enabled notifications for updates of the
* target user
*
* @return true if source user enabled notifications for target user
*/
boolean isSourceNotificationsEnabled();
public long getTargetUserId() {
return object.target.id;
}
/**
* Checks if target user is being followed by source user.<br>
* This method is equivalent to isSourceFollowingTarget().
*
* @return true if target user is being followed by source user
*/
boolean isTargetFollowedBySource();
public String getSourceUserScreenName() {
return object.source.screenName;
}
/**
* Checks if target user is following source user.<br>
* This method is equivalent to isSourceFollowedByTarget().
*
* @return true if target user is following source user
*/
boolean isTargetFollowingSource();
public long getSourceUserId() {
return object.source.id;
}
boolean isSourceRequestedFollowingTarget();
public boolean canSourceMediaTagTarget() {
return object.source.canMediaTag;
}
boolean isTargetRequestedFollowingSource();
public boolean canSourceDMTarget() {
return object.source.canDm;
}
boolean isSourceWantRetweetsFromTarget();
public boolean isSourceRequestedFollowingTarget() {
return object.source.followingRequested;
}
boolean isSourceNotificationsEnabledForTarget();
public boolean isTargetRequestedFollowingSource() {
return object.target.followingRequested;
}
public boolean isSourceWantRetweetsFromTarget() {
return object.source.wantRetweets;
}
public boolean isSourceNotificationsEnabledForTarget() {
return object.source.notificationsEnabled;
}
@JsonObject
public static class RelationshipObject {
@JsonField(name = "source")
Source source;
@JsonField(name = "target")
Target target;
@JsonObject
public static class Target {
@JsonField(name = "id")
long id;
@JsonField(name = "screen_name")
public String screenName;
@JsonField(name = "following")
boolean following;
@JsonField(name = "followed_by")
boolean followedBy;
@JsonField(name = "following_requested")
boolean followingRequested;
}
@JsonObject
public static class Source {
@JsonField(name = "id")
long id;
@JsonField(name = "screen_name")
public String screenName;
@JsonField(name = "blocked_by")
boolean blockedBy;
@JsonField(name = "blocking")
boolean blocking;
@JsonField(name = "muting")
boolean muting;
@JsonField(name = "following")
boolean following;
@JsonField(name = "followed_by")
boolean followedBy;
@JsonField(name = "following_requested")
boolean followingRequested;
@JsonField(name = "want_retweets")
boolean wantRetweets;
@JsonField(name = "notifications_enabled")
boolean notificationsEnabled;
@JsonField(name = "can_dm")
boolean canDm;
@JsonField(name = "can_media_tag")
boolean canMediaTag;
}
}
}

View File

@ -19,53 +19,36 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.library.logansquare.extension.annotation.ParameterizedImplementation;
import org.mariotaku.library.logansquare.extension.annotation.ParameterizedMapper;
import org.mariotaku.library.logansquare.extension.annotation.TypeImplementation;
import org.mariotaku.library.logansquare.extension.annotation.TypeMapper;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseArrayList;
import org.mariotaku.twidere.api.twitter.model.impl.ScheduledStatusesListImpl;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.ActivityResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.DirectMessageResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.LanguageResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.LocationResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.PlaceResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.SavedSearchResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.StatusResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.TrendsResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.UserListResponseListMapper;
import org.mariotaku.twidere.api.twitter.model.impl.mapper.list.UserResponseListMapper;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.util.List;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.ArrayList;
/**
* List of TwitterResponse.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/5/7.
*/
@ParameterizedMapper({
@TypeMapper(parameter = Activity.class, mapper = ActivityResponseListMapper.class),
@TypeMapper(parameter = DirectMessage.class, mapper = DirectMessageResponseListMapper.class),
@TypeMapper(parameter = Language.class, mapper = LanguageResponseListMapper.class),
@TypeMapper(parameter = Location.class, mapper = LocationResponseListMapper.class),
@TypeMapper(parameter = Place.class, mapper = PlaceResponseListMapper.class),
@TypeMapper(parameter = SavedSearch.class, mapper = SavedSearchResponseListMapper.class),
@TypeMapper(parameter = Status.class, mapper = StatusResponseListMapper.class),
@TypeMapper(parameter = Trends.class, mapper = TrendsResponseListMapper.class),
@TypeMapper(parameter = UserList.class, mapper = UserListResponseListMapper.class),
@TypeMapper(parameter = User.class, mapper = UserResponseListMapper.class),
})
@ParameterizedImplementation({
@TypeImplementation(parameter = ScheduledStatus.class, implementation = ScheduledStatusesListImpl.class)
})
@Implementation(ResponseArrayList.class)
public interface ResponseList<T> extends TwitterResponse, List<T> {
@JsonObject
public class ResponseList<T> extends ArrayList<T> implements TwitterResponse {
private int accessLevel;
private RateLimitStatus rateLimitStatus;
/**
* {@inheritDoc}
*/
@Override
RateLimitStatus getRateLimitStatus();
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatus.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
}

View File

@ -19,27 +19,59 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.SavedSearchImpl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* A data interface representing a Saved Search
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.0.8
* Created by mariotaku on 15/5/7.
*/
@Implementation(SavedSearchImpl.class)
public interface SavedSearch extends Comparable<SavedSearch>, TwitterResponse {
Date getCreatedAt();
@JsonObject
public class SavedSearch extends TwitterResponseObject implements Comparable<SavedSearch>, TwitterResponse {
long getId();
public long getId() {
return id;
}
String getName();
public Date getCreatedAt() {
return createdAt;
}
int getPosition();
public String getName() {
return name;
}
String getQuery();
public int getPosition() {
return position;
}
public String getQuery() {
return query;
}
@JsonField(name = "id")
long id;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "name")
String name;
@JsonField(name = "position")
int position;
@JsonField(name = "query")
String query;
@Override
public int compareTo(@NonNull SavedSearch another) {
return (int) (id - another.id);
}
}

View File

@ -19,38 +19,75 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.ScheduledStatusImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* Created by mariotaku on 15/7/6.
*/
@Implementation(ScheduledStatusImpl.class)
public interface ScheduledStatus {
@JsonObject
public class ScheduledStatus {
long getUserId();
@JsonField(name = "updated_at", typeConverter = TwitterDateConverter.class)
Date updatedAt;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "execute_at", typeConverter = TwitterDateConverter.class)
Date executeAt;
@JsonField(name = "text")
String text;
@JsonField(name = "media_ids")
long[] mediaIds;
@JsonField(name = "id")
long id;
@JsonField(name = "possiblySensitive")
boolean possiblySensitive;
@JsonField(name = "user_id")
long userId;
@JsonField(name = "state")
State state;
boolean isPossiblySensitive();
public long getUserId() {
return userId;
}
long getId();
public boolean isPossiblySensitive() {
return possiblySensitive;
}
long[] getMediaIds();
public long getId() {
return id;
}
Date getUpdatedAt();
public long[] getMediaIds() {
return mediaIds;
}
Date getCreatedAt();
public Date getUpdatedAt() {
return updatedAt;
}
Date getExecuteAt();
public Date getCreatedAt() {
return createdAt;
}
String getText();
public Date getExecuteAt() {
return executeAt;
}
State getState();
public String getText() {
return text;
}
@EnumClass
enum State {
public State getState() {
return state;
}
public enum State {
SCHEDULED("scheduled"), FAILED("failed"), CANCELED("canceled");
private final String value;

View File

@ -17,15 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
import org.mariotaku.twidere.api.twitter.model.TwitterResponse;
import org.mariotaku.twidere.api.twitter.model.TwitterResponseObject;
import java.util.AbstractList;
import java.util.List;
@ -34,12 +35,12 @@ import java.util.List;
* Created by mariotaku on 15/7/9.
*/
@JsonObject
public class ScheduledStatusesListImpl extends AbstractList<ScheduledStatus> implements ResponseList<ScheduledStatus> {
public class ScheduledStatusesList extends AbstractList<ScheduledStatus> implements TwitterResponse {
@JsonField(name = "results")
List<ScheduledStatus> list;
TwitterResponseImpl response = new TwitterResponseImpl();
TwitterResponseObject response = new TwitterResponseObject();
@Override
public void processResponseHeader(RestHttpResponse resp) {

View File

@ -19,24 +19,5 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.twidere.api.twitter.model.GeoLocation;
import org.mariotaku.twidere.api.twitter.model.Place;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import java.io.Serializable;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.7
*/
public interface SimilarPlaces extends ResponseList<Place>, Serializable {
/**
* Returns the token needed to be able to create a new place with
* {@link org.mariotaku.twidere.api.twitter.api.PlacesGeoResources#createPlace(String, String, String, GeoLocation, String)}
* .
*
* @return token the token needed to be able to create a new place with
* {@link org.mariotaku.twidere.api.twitter.api.PlacesGeoResources#createPlace(String, String, String, GeoLocation, String)}
*/
String getToken();
public class SimilarPlaces extends ResponseList<Place> {
}

View File

@ -25,10 +25,6 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import org.mariotaku.twidere.api.twitter.model.impl.EntitiesImpl;
import org.mariotaku.twidere.api.twitter.model.impl.GeoPoint;
import org.mariotaku.twidere.api.twitter.model.impl.TwitterResponseImpl;
import org.mariotaku.twidere.api.twitter.model.impl.UserImpl;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.io.IOException;
@ -39,7 +35,8 @@ import java.util.Date;
* Created by mariotaku on 15/5/5.
*/
@JsonObject
public class Status extends TwitterResponseImpl {
public class Status extends TwitterResponseObject implements Comparable<Status>, TwitterResponse,
ExtendedEntitySupport {
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@ -57,10 +54,10 @@ public class Status extends TwitterResponseImpl {
boolean truncated;
@JsonField(name = "entities")
EntitiesImpl entities;
Entities entities;
@JsonField(name = "extended_entities")
EntitiesImpl extendedEntities;
Entities extendedEntities;
@JsonField(name = "in_reply_to_status_id")
long inReplyToStatusId;
@ -72,7 +69,7 @@ public class Status extends TwitterResponseImpl {
String inReplyToScreenName;
@JsonField(name = "user")
UserImpl user;
User user;
@JsonField(name = "geo")
GeoPoint geo;
@ -116,6 +113,7 @@ public class Status extends TwitterResponseImpl {
@JsonField(name = "possibly_sensitive")
boolean possiblySensitive;
private Status mThat;
public static void setQuotedStatus(Status status, Status quoted) {
if (!(status instanceof Status)) return;
@ -287,6 +285,7 @@ public class Status extends TwitterResponseImpl {
public int compareTo(@NonNull final Status that) {
mThat = that;
final long delta = id - that.getId();
if (delta < Integer.MIN_VALUE)
return Integer.MIN_VALUE;
@ -295,6 +294,7 @@ public class Status extends TwitterResponseImpl {
}
@Override
public String toString() {
return "Status{" +
"createdAt=" + createdAt +

View File

@ -19,24 +19,56 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.StatusActivitySummaryImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@Implementation(StatusActivitySummaryImpl.class)
public interface StatusActivitySummary extends TwitterResponse {
/**
* Created by mariotaku on 15/5/13.
*/
@JsonObject
public class StatusActivitySummary extends TwitterResponseObject implements TwitterResponse {
long getDescendentReplyCount();
@JsonField(name = "favoriters")
IDs favoriters;
@JsonField(name = "repliers")
IDs repliers;
@JsonField(name = "retweeters")
IDs retweeters;
IDs getFavoriters();
@JsonField(name = "favoriters_count")
long favoritersCount;
@JsonField(name = "repliers_count")
long repliersCount;
@JsonField(name = "retweeters_count")
long retweetersCount;
@JsonField(name = "descendent_reply_count")
long descendentReplyCount;
long getFavoritersCount();
public IDs getFavoriters() {
return favoriters;
}
IDs getRepliers();
public IDs getRepliers() {
return repliers;
}
long getRepliersCount();
public IDs getRetweeters() {
return retweeters;
}
IDs getRetweeters();
public long getFavoritersCount() {
return favoritersCount;
}
long getRetweetersCount();
public long getRepliersCount() {
return repliersCount;
}
public long getRetweetersCount() {
return retweetersCount;
}
public long getDescendentReplyCount() {
return descendentReplyCount;
}
}

View File

@ -19,13 +19,14 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.StatusDeletionNoticeImpl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Created by mariotaku on 15/5/26.
*/
@Implementation(StatusDeletionNoticeImpl.class)
public interface StatusDeletionNotice {
long getStatusId();
@JsonObject
public class StatusDeletionNotice {
public long getStatusId() {
return 0;
}
}

View File

@ -19,17 +19,33 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.TimeZoneImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.TimeZone;
/**
* @author Alessandro Bahgat - ale.bahgat at gmail.com
* Created by mariotaku on 15/5/13.
*/
@Implementation(TimeZoneImpl.class)
public interface TimeZone {
String getName();
@JsonObject
public class TimeZone {
String getTzInfoName();
@JsonField(name = "utc_offset")
int utcOffset;
@JsonField(name = "name")
String name;
@JsonField(name = "tzinfo_name")
String tzInfoName;
int getUtcOffset();
public int getUtcOffset() {
return utcOffset;
}
public String getName() {
return name;
}
public String getTzInfoName() {
return tzInfoName;
}
}

View File

@ -19,20 +19,43 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.TranslationResultImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@Implementation(TranslationResultImpl.class)
public interface TranslationResult extends TwitterResponse {
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class TranslationResult extends TwitterResponseObject implements TwitterResponse {
public long getId();
@JsonField(name = "id")
long id;
@JsonField(name = "lang")
String lang;
@JsonField(name = "translated_lang")
String translatedLang;
@JsonField(name = "translation_type")
String translationType;
@JsonField(name = "text")
String text;
public String getLang();
public long getId() {
return id;
}
public String getText();
public String getLang() {
return lang;
}
public String getTranslatedLang();
public String getText() {
return text;
}
public String getTranslationType();
public String getTranslatedLang() {
return translatedLang;
}
public String getTranslationType() {
return translationType;
}
}

View File

@ -19,22 +19,40 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.TrendImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* A data interface representing Trend.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.0.2
* Created by mariotaku on 15/5/10.
*/
@Implementation(TrendImpl.class)
public interface Trend {
@JsonObject
public class Trend {
String getName();
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
@JsonField(name = "query")
String query;
String getQuery();
public String getName() {
return name;
}
String getUrl();
public String getUrl() {
return url;
}
public String getQuery() {
return query;
}
@Override
public String toString() {
return "Trend{" +
"name='" + name + '\'' +
", url='" + url + '\'' +
", query='" + query + '\'' +
'}';
}
}

View File

@ -19,26 +19,48 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.TrendsImpl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterTrendsDateConverter;
import java.io.Serializable;
import java.util.Date;
/**
* A data class representing Trends.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.0.2
* Created by mariotaku on 15/5/10.
*/
@Implementation(TrendsImpl.class)
public interface Trends extends TwitterResponse, Comparable<Trends>, Serializable {
Date getAsOf();
@JsonObject
public class Trends extends TwitterResponseObject implements TwitterResponse, Comparable<Trends> {
Date getCreatedAt();
@JsonField(name = "as_of", typeConverter = TwitterTrendsDateConverter.class)
Date asOf;
@JsonField(name = "created_at", typeConverter = TwitterTrendsDateConverter.class)
Date createdAt;
@JsonField(name = "trends")
Trend[] trends;
@JsonField(name = "locations")
Location[] locations;
Location[] getLocations();
public Date getAsOf() {
return asOf;
}
Trend[] getTrends();
public Trend[] getTrends() {
return trends;
}
public Location[] getLocations() {
return locations;
}
public Date getCreatedAt() {
return createdAt;
}
@Override
public int compareTo(@NonNull Trends another) {
return asOf.compareTo(another.getAsOf());
}
}

View File

@ -19,27 +19,34 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import org.mariotaku.twidere.api.twitter.model.TwitterResponse;
import java.util.Map;
/**
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.2.3
*/
public interface TwitterAPIConfiguration extends TwitterResponse {
int getCharactersReservedPerMedia();
public class TwitterAPIConfiguration extends TwitterResponseObject implements TwitterResponse {
public int getCharactersReservedPerMedia() {
throw new UnsupportedOperationException();
}
int getMaxMediaPerUpload();
public int getMaxMediaPerUpload() {
throw new UnsupportedOperationException();
}
String[] getNonUsernamePaths();
public String[] getNonUsernamePaths() {
throw new UnsupportedOperationException();
}
int getPhotoSizeLimit();
public int getPhotoSizeLimit() {
throw new UnsupportedOperationException();
}
Map<Integer, MediaEntity.Size> getPhotoSizes();
public Map<Integer, MediaEntity.Size> getPhotoSizes() {
throw new UnsupportedOperationException();
}
int getShortUrlLength();
public int getShortUrlLength() {
throw new UnsupportedOperationException();
}
int getShortUrlLengthHttps();
public int getShortUrlLengthHttps() {
throw new UnsupportedOperationException();
}
}

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.restfu.http.RestHttpResponse;
@ -28,14 +28,14 @@ import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
/**
* Created by mariotaku on 15/5/7.
*/
public class TwitterResponseImpl implements TwitterResponse {
public class TwitterResponseObject implements TwitterResponse {
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatusJSONImpl.createFromResponseHeader(resp);
rateLimitStatus = RateLimitStatus.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}

View File

@ -2,7 +2,7 @@
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -19,54 +19,51 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.UrlEntityImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* A data interface representing one single URL entity.
*
* @author Mocel - mocel at guma.jp
* @since Twitter4J 2.1.9
* Created by mariotaku on 15/3/31.
*/
@Implementation(UrlEntityImpl.class)
public interface UrlEntity {
@JsonObject
public class UrlEntity {
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@JsonField(name = "display_url")
String displayUrl;
@JsonField(name = "expanded_url")
String expandedUrl;
/**
* Returns the display URL if mentioned URL is shorten.
*
* @return the display URL if mentioned URL is shorten, or null if no
* shorten URL was mentioned.
*/
String getDisplayUrl();
@JsonField(name = "url")
String url;
/**
* Returns the index of the end character of the URL mentioned in the tweet.
*
* @return the index of the end character of the URL mentioned in the tweet
*/
int getEnd();
public String getDisplayUrl() {
return displayUrl;
}
/**
* Returns the expanded URL if mentioned URL is shorten.
*
* @return the expanded URL if mentioned URL is shorten, or null if no
* shorten URL was mentioned.
*/
String getExpandedUrl();
@Override
public String toString() {
return "UrlEntity{" +
"indices=" + indices +
", displayUrl='" + displayUrl + '\'' +
", expandedUrl='" + expandedUrl + '\'' +
", url='" + url + '\'' +
'}';
}
/**
* Returns the index of the start character of the URL mentioned in the
* tweet.
*
* @return the index of the start character of the URL mentioned in the
* tweet
*/
int getStart();
public int getEnd() {
return indices.getEnd();
}
/**
* Returns the URL mentioned in the tweet.
*
* @return the mentioned URL
*/
String getUrl();
public int getStart() {
return indices.getStart();
}
public String getExpandedUrl() {
return expandedUrl;
}
public String getUrl() {
return url;
}
}

View File

@ -19,209 +19,467 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.UserImpl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.io.IOException;
import java.util.Date;
/**
* A data interface representing Basic user information element
*
* @author Yusuke Yamamoto - yusuke at mac.com
* Created by mariotaku on 15/3/31.
*/
@Implementation(UserImpl.class)
public interface User extends Comparable<User>, TwitterResponse {
Date getCreatedAt();
@JsonObject
public class User extends TwitterResponseObject implements Comparable<User> {
boolean isDefaultProfile();
@JsonField(name = "id")
long id;
/**
* Returns the description of the user
*
* @return the description of the user
*/
String getDescription();
@JsonField(name = "name")
String name;
UrlEntity[] getDescriptionEntities();
@JsonField(name = "screen_name")
String screenName;
long getFavouritesCount();
@JsonField(name = "location")
String location;
boolean isFollowedBy();
@JsonField(name = "profile_location")
String profileLocation;
/**
* Returns the number of followers
*
* @return the number of followers
* @since Twitter4J 1.0.4
*/
long getFollowersCount();
@JsonField(name = "description")
String description;
long getFriendsCount();
@JsonField(name = "url")
String url;
boolean hasCustomTimelines();
@JsonField(name = "entities")
UserEntities entities;
/**
* Returns the id of the user
*
* @return the id of the user
*/
long getId();
@JsonField(name = "protected")
boolean isProtected;
/**
* Returns the preferred language of the user
*
* @return the preferred language of the user
* @since Twitter4J 2.1.2
*/
String getLang();
@JsonField(name = "followers_count")
long followersCount;
/**
* Returns the number of public lists the user is listed on, or -1 if the
* count is unavailable.
*
* @return the number of public lists the user is listed on.
* @since Twitter4J 2.1.4
*/
long getListedCount();
@JsonField(name = "friends_count")
long friendsCount;
/**
* Returns the location of the user
*
* @return the location of the user
*/
String getLocation();
@JsonField(name = "listed_count")
long listedCount;
/**
* Returns the name of the user
*
* @return the name of the user
*/
String getName();
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
boolean isNeedsPhoneVerification();
@JsonField(name = "favourites_count")
long favouritesCount;
boolean isNotifications();
@JsonField(name = "utc_offset")
int utcOffset;
String getProfileBackgroundColor();
@JsonField(name = "time_zone")
String timeZone;
String getProfileBackgroundImageUrl();
@JsonField(name = "geo_enabled")
boolean geoEnabled;
String getProfileBackgroundImageUrlHttps();
@JsonField(name = "verified")
boolean isVerified;
String getProfileBannerImageUrl();
@JsonField(name = "statuses_count")
long statusesCount;
/**
* Returns the profile image url of the user
*
* @return the profile image url of the user
*/
String getProfileImageUrl();
@JsonField(name = "media_count")
long mediaCount;
/**
* Returns the profile image url of the user, served over SSL
*
* @return the profile image url of the user, served over SSL
*/
String getProfileImageUrlHttps();
@JsonField(name = "lang")
String lang;
String getProfileLinkColor();
@JsonField(name = "status")
Status status;
String getProfileLocation();
@JsonField(name = "contributors_enabled")
boolean contributorsEnabled;
String getProfileSidebarBorderColor();
@JsonField(name = "is_translator")
boolean isTranslator;
String getProfileSidebarFillColor();
@JsonField(name = "is_translation_enabled")
boolean isTranslationEnabled;
String getProfileTextColor();
@JsonField(name = "profile_background_color")
String profileBackgroundColor;
/**
* Returns the screen name of the user
*
* @return the screen name of the user
*/
String getScreenName();
@JsonField(name = "profile_background_image_url")
String profileBackgroundImageUrl;
/**
* Returns the current status of the user<br>
* This can be null if the instance if from Status.getUser().
*
* @return current status of the user
* @since Twitter4J 2.1.1
*/
Status getStatus();
@JsonField(name = "profile_background_image_url_https")
String profileBackgroundImageUrlHttps;
long getStatusesCount();
@JsonField(name = "profile_background_tile")
boolean profileBackgroundTile;
long getMediaCount();
@JsonField(name = "profile_image_url")
String profileImageUrl;
boolean isSuspended();
@JsonField(name = "profile_image_url_https")
String profileImageUrlHttps;
String getTimeZone();
@JsonField(name = "profile_banner_url")
String profileBannerUrl;
/**
* Returns the url of the user
*
* @return the url of the user
*/
String getUrl();
@JsonField(name = "profile_link_color")
String profileLinkColor;
UrlEntity[] getUrlEntities();
@JsonField(name = "profile_sidebar_border_color")
String profileSidebarBorderColor;
int getUtcOffset();
@JsonField(name = "profile_sidebar_fill_color")
String profileSidebarFillColor;
boolean canMediaTag();
@JsonField(name = "profile_text_color")
String profileTextColor;
/**
* Tests if the user is enabling contributors
*
* @return if the user is enabling contributors
* @since Twitter4J 2.1.2
*/
boolean isContributorsEnabled();
@JsonField(name = "profile_use_background_image")
boolean profileUseBackgroundImage;
boolean isDefaultProfileImage();
@JsonField(name = "default_profile")
boolean defaultProfile;
boolean isFollowing();
@JsonField(name = "default_profile_image")
boolean defaultProfileImage;
/**
* Returns true if the authenticating user has requested to follow this
* user, otherwise false.
*
* @return true if the authenticating user has requested to follow this
* user.
* @since Twitter4J 2.1.4
*/
boolean isFollowRequestSent();
@JsonField(name = "has_custom_timelines")
boolean hasCustomTimelines;
/**
* @return the user is enabling geo location
* @since Twitter4J 2.0.10
*/
boolean isGeoEnabled();
@JsonField(name = "can_media_tag")
boolean canMediaTag;
boolean isProfileBackgroundTiled();
@JsonField(name = "followed_by")
boolean followedBy;
boolean isProfileUseBackgroundImage();
@JsonField(name = "following")
boolean following;
/**
* Test if the user status is protected
*
* @return true if the user status is protected
*/
boolean isProtected();
@JsonField(name = "follow_request_sent")
boolean followRequestSent;
boolean isTranslationEnabled();
@JsonField(name = "notifications")
boolean notifications;
/**
* @return returns true if the user is a translator
* @since Twitter4J 2.1.9
*/
boolean isTranslator();
@JsonField(name = "suspended")
boolean isSuspended;
/**
* @return returns true if the user is a verified celebrity
* @since Twitter4J 2.0.10
*/
boolean isVerified();
@JsonField(name = "needs_phone_verification")
boolean needsPhoneVerification;
public boolean canMediaTag() {
return canMediaTag;
}
public boolean isContributorsEnabled() {
return contributorsEnabled;
}
public boolean isDefaultProfile() {
return defaultProfile;
}
public String getDescription() {
return description;
}
public UrlEntity[] getDescriptionEntities() {
if (entities == null) return null;
return entities.getDescriptionEntities();
}
public long getFavouritesCount() {
return favouritesCount;
}
public boolean isFollowRequestSent() {
return followRequestSent;
}
public boolean isFollowedBy() {
return followedBy;
}
public long getFollowersCount() {
return followersCount;
}
public boolean isFollowing() {
return following;
}
public long getFriendsCount() {
return friendsCount;
}
public boolean isGeoEnabled() {
return geoEnabled;
}
public boolean isProfileBackgroundTiled() {
return profileBackgroundTile;
}
public boolean hasCustomTimelines() {
return hasCustomTimelines;
}
public long getId() {
return id;
}
public boolean isTranslationEnabled() {
return isTranslationEnabled;
}
public boolean isTranslator() {
return isTranslator;
}
public String getLang() {
return lang;
}
public long getListedCount() {
return listedCount;
}
public String getLocation() {
return location;
}
public long getMediaCount() {
return mediaCount;
}
public String getName() {
return name;
}
public boolean isNeedsPhoneVerification() {
return needsPhoneVerification;
}
public boolean isNotifications() {
return notifications;
}
public String getProfileBackgroundColor() {
return profileBackgroundColor;
}
public String getProfileBackgroundImageUrl() {
return profileBackgroundImageUrl;
}
public String getProfileBackgroundImageUrlHttps() {
return profileBackgroundImageUrlHttps;
}
public String getProfileBannerImageUrl() {
return profileBannerUrl;
}
public String getProfileImageUrl() {
return profileImageUrl;
}
public String getProfileImageUrlHttps() {
return profileImageUrlHttps;
}
public String getProfileLinkColor() {
return profileLinkColor;
}
public String getProfileLocation() {
return profileLocation;
}
public String getProfileSidebarBorderColor() {
return profileSidebarBorderColor;
}
public String getProfileSidebarFillColor() {
return profileSidebarFillColor;
}
public boolean isProfileUseBackgroundImage() {
return profileUseBackgroundImage;
}
public boolean isProtected() {
return isProtected;
}
public String getScreenName() {
return screenName;
}
public Status getStatus() {
return status;
}
public long getStatusesCount() {
return statusesCount;
}
public boolean isSuspended() {
return isSuspended;
}
public String getTimeZone() {
return timeZone;
}
public String getUrl() {
return url;
}
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrlEntities();
}
public int getUtcOffset() {
return utcOffset;
}
public boolean isVerified() {
return isVerified;
}
public String getProfileTextColor() {
return profileTextColor;
}
public boolean isDefaultProfileImage() {
return defaultProfileImage;
}
public Date getCreatedAt() {
return createdAt;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
", screenName='" + screenName + '\'' +
", location='" + location + '\'' +
", profileLocation='" + profileLocation + '\'' +
", description='" + description + '\'' +
", url='" + url + '\'' +
", entities=" + entities +
", isProtected=" + isProtected +
", followersCount=" + followersCount +
", friendsCount=" + friendsCount +
", listedCount=" + listedCount +
", createdAt=" + createdAt +
", favouritesCount=" + favouritesCount +
", utcOffset=" + utcOffset +
", timeZone='" + timeZone + '\'' +
", geoEnabled=" + geoEnabled +
", isVerified=" + isVerified +
", statusesCount=" + statusesCount +
", mediaCount=" + mediaCount +
", lang='" + lang + '\'' +
", status=" + status +
", contributorsEnabled=" + contributorsEnabled +
", isTranslator=" + isTranslator +
", isTranslationEnabled=" + isTranslationEnabled +
", profileBackgroundColor='" + profileBackgroundColor + '\'' +
", profileBackgroundImageUrl='" + profileBackgroundImageUrl + '\'' +
", profileBackgroundImageUrlHttps='" + profileBackgroundImageUrlHttps + '\'' +
", profileBackgroundTile=" + profileBackgroundTile +
", profileImageUrl='" + profileImageUrl + '\'' +
", profileImageUrlHttps='" + profileImageUrlHttps + '\'' +
", profileBannerUrl='" + profileBannerUrl + '\'' +
", profileLinkColor='" + profileLinkColor + '\'' +
", profileSidebarBorderColor='" + profileSidebarBorderColor + '\'' +
", profileSidebarFillColor='" + profileSidebarFillColor + '\'' +
", profileTextColor='" + profileTextColor + '\'' +
", profileUseBackgroundImage=" + profileUseBackgroundImage +
", defaultProfile=" + defaultProfile +
", defaultProfileImage=" + defaultProfileImage +
", hasCustomTimelines=" + hasCustomTimelines +
", canMediaTag=" + canMediaTag +
", followedBy=" + followedBy +
", following=" + following +
", followRequestSent=" + followRequestSent +
", notifications=" + notifications +
", isSuspended=" + isSuspended +
", needsPhoneVerification=" + needsPhoneVerification +
"} " + super.toString();
}
@Override
public int compareTo(@NonNull final User that) {
return (int) (id - that.getId());
}
@OnJsonParseComplete
void onJsonParseComplete() throws IOException {
if (id <= 0 || screenName == null) throw new IOException("Malformed User object");
}
}

View File

@ -17,31 +17,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
package org.mariotaku.twidere.api.twitter.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Entities;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class UserEntitiesImpl {
@Override
public String toString() {
return "UserEntitiesImpl{" +
"url=" + url +
", description=" + description +
'}';
}
public class UserEntities {
@JsonField(name = "url")
EntitiesImpl url;
Entities url;
@JsonField(name = "description")
EntitiesImpl description;
Entities description;
public UrlEntity[] getDescriptionEntities() {
if (description == null) return null;
@ -52,4 +46,12 @@ public class UserEntitiesImpl {
if (url == null) return null;
return url.getUrls();
}
@Override
public String toString() {
return "UserEntities{" +
"url=" + url +
", description=" + description +
'}';
}
}

View File

@ -2,7 +2,7 @@
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -19,49 +19,129 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.EnumClass;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.UserListImpl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
@Implementation(UserListImpl.class)
public interface UserList extends Comparable<UserList>, TwitterResponse {
Mode getMode();
/**
* Created by mariotaku on 15/4/7.
*/
@JsonObject
public class UserList extends TwitterResponseObject implements Comparable<UserList>, TwitterResponse {
@JsonField(name = "id")
long id;
String getDescription();
@JsonField(name = "name")
String name;
@JsonField(name = "uri")
String uri;
@JsonField(name = "subscriber_count")
long subscriberCount;
@JsonField(name = "member_count")
long memberCount;
@JsonField(name = "mode")
Mode mode;
@JsonField(name = "description")
String description;
@JsonField(name = "slug")
String slug;
@JsonField(name = "full_name")
String fullName;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "following")
boolean following;
@JsonField(name = "user")
User user;
public long getId() {
return id;
}
String getFullName();
public String getName() {
return name;
}
public String getUri() {
return uri;
}
long getId();
public long getSubscriberCount() {
return subscriberCount;
}
public long getMemberCount() {
return memberCount;
}
long getMemberCount();
public Mode getMode() {
return mode;
}
public String getDescription() {
return description;
}
String getName();
public String getSlug() {
return slug;
}
public String getFullName() {
return fullName;
}
String getSlug();
public Date getCreatedAt() {
return createdAt;
}
public boolean isFollowing() {
return following;
}
long getSubscriberCount();
public User getUser() {
return user;
}
@Override
public int compareTo(@NonNull UserList another) {
return (int) (id - another.id);
}
String getUri();
@Override
public String toString() {
return "UserList{" +
"id=" + id +
", name='" + name + '\'' +
", uri='" + uri + '\'' +
", subscriberCount=" + subscriberCount +
", memberCount=" + memberCount +
", mode=" + mode +
", description='" + description + '\'' +
", slug='" + slug + '\'' +
", fullName='" + fullName + '\'' +
", createdAt=" + createdAt +
", following=" + following +
", user=" + user +
"} " + super.toString();
}
User getUser();
Date getCreatedAt();
boolean isFollowing();
@EnumClass
enum Mode {
public enum Mode {
PUBLIC("public"), PRIVATE("private");
private final String mode;

View File

@ -2,7 +2,7 @@
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -19,49 +19,51 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.UserMentionEntityImpl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* A data interface representing one single user mention entity.
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @since Twitter4J 2.1.9
* Created by mariotaku on 15/3/31.
*/
@Implementation(UserMentionEntityImpl.class)
public interface UserMentionEntity {
/**
* Returns the index of the end character of the user mention.
*
* @return the index of the end character of the user mention
*/
int getEnd();
@JsonObject
public class UserMentionEntity {
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@JsonField(name = "id")
long id;
@JsonField(name = "name")
String name;
@JsonField(name = "screen_name")
String screenName;
/**
* Returns the user id mentioned in the status.
*
* @return the user id mentioned in the status
*/
long getId();
@Override
public String toString() {
return "UserMentionEntity{" +
"indices=" + indices +
", id=" + id +
", name='" + name + '\'' +
", screenName='" + screenName + '\'' +
'}';
}
/**
* Returns the name mentioned in the status.
*
* @return the name mentioned in the status
*/
String getName();
public int getEnd() {
return indices.getEnd();
}
/**
* Returns the screen name mentioned in the status.
*
* @return the screen name mentioned in the status
*/
String getScreenName();
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getScreenName() {
return screenName;
}
public int getStart() {
return indices.getStart();
}
/**
* Returns the index of the start character of the user mention.
*
* @return the index of the start character of the user mention
*/
int getStart();
}

View File

@ -19,12 +19,13 @@
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.library.logansquare.extension.annotation.Implementation;
import org.mariotaku.twidere.api.twitter.model.impl.WarningImpl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Warning;
/**
* Created by mariotaku on 15/5/26.
*/
@Implementation(WarningImpl.class)
public interface Warning {
@JsonObject
public class Warning {
}

View File

@ -1,71 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.AccountSettings;
import org.mariotaku.twidere.api.twitter.model.Location;
import org.mariotaku.twidere.api.twitter.model.TimeZone;
/**
* Created by mariotaku on 15/5/13.
*/
@JsonObject
public class AccountSettingsImpl extends TwitterResponseImpl implements AccountSettings {
@JsonField(name = "geo_enabled")
boolean geoEnabled;
@JsonField(name = "trend_location")
LocationImpl[] trendLocations;
@JsonField(name = "language")
String language;
@JsonField(name = "always_use_https")
boolean alwaysUseHttps;
@JsonField(name = "time_zone")
TimeZoneImpl timezone;
@Override
public boolean isAlwaysUseHttps() {
return alwaysUseHttps;
}
@Override
public String getLanguage() {
return language;
}
@Override
public TimeZone getTimeZone() {
return timezone;
}
@Override
public Location[] getTrendLocations() {
return trendLocations;
}
@Override
public boolean isGeoEnabled() {
return geoEnabled;
}
}

View File

@ -1,181 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.NonNull;
import org.mariotaku.library.logansquare.extension.annotation.Mapper;
import org.mariotaku.twidere.api.twitter.model.Activity;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserList;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
@Mapper(ActivityImplMapper.class)
public class ActivityImpl extends TwitterResponseImpl implements Activity {
static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Action action;
String rawAction;
Date createdAt;
User[] sources;
User[] targetUsers;
User[] targetObjectUsers;
Status[] targetObjectStatuses, targetStatuses;
UserList[] targetUserLists, targetObjectUserLists;
long maxPosition, minPosition;
int targetObjectsSize, targetsSize, sourcesSize;
ActivityImpl() {
}
@Override
public String getRawAction() {
return rawAction;
}
@Override
public User[] getTargetObjectUsers() {
return targetObjectUsers;
}
@Override
public int compareTo(@NonNull final Activity another) {
final Date thisDate = getCreatedAt(), thatDate = another.getCreatedAt();
if (thisDate == null || thatDate == null) return 0;
return thisDate.compareTo(thatDate);
}
@Override
public Action getAction() {
return action;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public long getMaxPosition() {
return maxPosition;
}
@Override
public long getMinPosition() {
return minPosition;
}
@Override
public User[] getSources() {
return sources;
}
@Override
public int getSourcesSize() {
return sourcesSize;
}
@Override
public int getTargetObjectsSize() {
return targetObjectsSize;
}
@Override
public Status[] getTargetObjectStatuses() {
return targetObjectStatuses;
}
@Override
public UserList[] getTargetObjectUserLists() {
return targetObjectUserLists;
}
@Override
public int getTargetsSize() {
return targetsSize;
}
@Override
public Status[] getTargetStatuses() {
return targetStatuses;
}
@Override
public UserList[] getTargetUserLists() {
return targetUserLists;
}
@Override
public User[] getTargetUsers() {
return targetUsers;
}
@Override
public String toString() {
return "ActivityJSONImpl{" +
"action=" + action +
", createdAt=" + createdAt +
", sources=" + Arrays.toString(sources) +
", targetUsers=" + Arrays.toString(targetUsers) +
", targetObjectStatuses=" + Arrays.toString(targetObjectStatuses) +
", targetStatuses=" + Arrays.toString(targetStatuses) +
", targetUserLists=" + Arrays.toString(targetUserLists) +
", targetObjectUserLists=" + Arrays.toString(targetObjectUserLists) +
", maxPosition=" + maxPosition +
", minPosition=" + minPosition +
", targetObjectsSize=" + targetObjectsSize +
", targetsSize=" + targetsSize +
", sourcesSize=" + sourcesSize +
'}';
}
public static Activity fromMention(long accountId, Status status) {
final ActivityImpl activity = new ActivityImpl();
activity.maxPosition = activity.minPosition = status.getId();
activity.createdAt = status.getCreatedAt();
if (status.getInReplyToUserId() == accountId) {
activity.action = Action.REPLY;
activity.rawAction = "reply";
activity.targetStatuses = new Status[]{status};
//TODO set target statuses (in reply to status)
activity.targetObjectStatuses = new Status[0];
} else {
activity.action = Action.MENTION;
activity.rawAction = "mention";
activity.targetObjectStatuses = new Status[]{status};
// TODO set target users (mentioned users)
activity.targetUsers = null;
}
activity.sourcesSize = 1;
activity.sources = new User[]{status.getUser()};
return activity;
}
}

View File

@ -1,185 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.v4.util.ArrayMap;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import org.mariotaku.twidere.api.twitter.model.CardEntity;
import org.mariotaku.twidere.api.twitter.model.User;
import java.util.Map;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class CardEntityImpl implements CardEntity {
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
@JsonField(name = "binding_values")
Map<String, RawBindingValue> rawBindingValues;
Map<String, BindingValue> bindingValues;
@Override
public String getName() {
return name;
}
@Override
public String getUrl() {
return url;
}
@Override
public User[] getUsers() {
return new User[0];
}
@Override
public BindingValue getBindingValue(String key) {
return bindingValues.get(key);
}
@Override
public Map<String, BindingValue> getBindingValues() {
return bindingValues;
}
@OnJsonParseComplete
void onParseComplete() {
if (rawBindingValues != null) {
bindingValues = new ArrayMap<>();
for (Map.Entry<String, RawBindingValue> entry : rawBindingValues.entrySet()) {
bindingValues.put(entry.getKey(), entry.getValue().getBindingValue());
}
}
}
@JsonObject
public static class ImageValueImpl implements ImageValue {
@JsonField(name = "width")
int width;
@JsonField(name = "height")
int height;
@JsonField(name = "url")
String url;
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public String getUrl() {
return url;
}
}
public static class BooleanValueImpl implements BooleanValue {
public BooleanValueImpl(boolean value) {
this.value = value;
}
private boolean value;
@Override
public boolean getValue() {
return value;
}
}
public static class StringValueImpl implements StringValue {
private final String value;
public StringValueImpl(String value) {
this.value = value;
}
@Override
public String getValue() {
return value;
}
}
@JsonObject
public static class UserValueImpl implements UserValue {
@JsonField(name = "id")
long userId;
@Override
public long getUserId() {
return userId;
}
}
@JsonObject
public static class RawBindingValue {
@JsonField(name = "type")
String type;
@JsonField(name = "boolean_value")
boolean booleanValue;
@JsonField(name = "string_value")
String stringValue;
@JsonField(name = "image_value")
ImageValueImpl imageValue;
@JsonField(name = "user_value")
UserValueImpl userValue;
public BindingValue getBindingValue() {
if (type == null) return null;
switch (type) {
case BindingValue.TYPE_BOOLEAN: {
return new BooleanValueImpl(booleanValue);
}
case BindingValue.TYPE_STRING: {
return new StringValueImpl(stringValue);
}
case BindingValue.TYPE_IMAGE: {
return imageValue;
}
case BindingValue.TYPE_USER: {
return userValue;
}
}
return null;
}
}
}

View File

@ -1,127 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
import org.mariotaku.twidere.api.twitter.model.HashtagEntity;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class DirectMessageImpl extends TwitterResponseImpl implements DirectMessage {
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "sender")
UserImpl sender;
@JsonField(name = "recipient")
UserImpl recipient;
@JsonField(name = "entities")
EntitiesImpl entities;
@JsonField(name = "text")
String text;
@JsonField(name = "id")
long id;
@Override
public long getId() {
return id;
}
@Override
public String getText() {
return text;
}
@Override
public HashtagEntity[] getHashtagEntities() {
if (entities == null) return null;
return entities.getHashtags();
}
@Override
public MediaEntity[] getMediaEntities() {
if (entities == null) return null;
return entities.getMedia();
}
@Override
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrls();
}
@Override
public UserMentionEntity[] getUserMentionEntities() {
if (entities == null) return null;
return entities.getUserMentions();
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public UserImpl getSender() {
return sender;
}
@Override
public long getSenderId() {
return sender.id;
}
@Override
public String getSenderScreenName() {
return sender.screenName;
}
@Override
public UserImpl getRecipient() {
return recipient;
}
@Override
public long getRecipientId() {
return recipient.id;
}
@Override
public String getRecipientScreenName() {
return recipient.screenName;
}
}

View File

@ -1,52 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.ErrorInfo;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class ErrorInfoImpl implements ErrorInfo {
@JsonField(name = "code")
int code;
@JsonField(name = "message")
String message;
@Override
public int getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
@Override
public String getRequest() {
return null;
}
}

View File

@ -1,87 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.ExtendedProfile;
/**
* Created by mariotaku on 15/7/8.
*/
@JsonObject
public class ExtendedProfileImpl implements ExtendedProfile {
@JsonField(name = "id")
long id;
@JsonField(name = "birthdate")
BirthdateImpl birthdate;
@Override
public long getId() {
return id;
}
@Override
public Birthdate getBirthdate() {
return birthdate;
}
@JsonObject
public static class BirthdateImpl implements Birthdate {
@JsonField(name = "day")
int day;
@JsonField(name = "month")
int month;
@JsonField(name = "year")
int year;
@JsonField(name = "visibility")
Visibility visibility;
@JsonField(name = "year_visibility")
Visibility yearVisibility;
@Override
public int getDay() {
return day;
}
@Override
public int getMonth() {
return month;
}
@Override
public int getYear() {
return year;
}
@Override
public Visibility getVisibility() {
return visibility;
}
@Override
public Visibility getYearVisibility() {
return yearVisibility;
}
}
}

View File

@ -1,52 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.HashtagEntity;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class HashtagEntityImpl implements HashtagEntity {
@JsonField(name = "text")
String text;
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@Override
public int getEnd() {
return indices.getEnd();
}
@Override
public int getStart() {
return indices.getStart();
}
@Override
public String getText() {
return text;
}
}

View File

@ -1,60 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import org.mariotaku.library.logansquare.extension.annotation.Mapper;
import org.mariotaku.twidere.api.twitter.model.IDs;
/**
* Created by mariotaku on 15/5/10.
*/
@Mapper(IDsImplMapper.class)
public class IDsImpl extends TwitterResponseImpl implements IDs {
long previousCursor;
long nextCursor;
long[] ids;
@Override
public long getNextCursor() {
return nextCursor;
}
@Override
public long getPreviousCursor() {
return previousCursor;
}
@Override
public boolean hasNext() {
return nextCursor != 0;
}
@Override
public boolean hasPrevious() {
return previousCursor != 0;
}
@Override
public long[] getIDs() {
return ids;
}
}

View File

@ -1,53 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Language;
/**
* Created by mariotaku on 15/5/10.
*/
@JsonObject
public class LanguageImpl implements Language {
@JsonField(name = "name")
String name;
@JsonField(name = "code")
String code;
@JsonField(name = "status")
String status;
@Override
public String getName() {
return name;
}
@Override
public String getCode() {
return code;
}
@Override
public String getStatus() {
return status;
}
}

View File

@ -1,95 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Location;
/**
* Created by mariotaku on 15/5/10.
*/
@JsonObject
public class LocationImpl implements Location {
@JsonField(name = "woeid")
int woeid;
@JsonField(name = "country")
String countryName;
@JsonField(name = "countryCode")
String countryCode;
@JsonField(name = "placeType")
PlaceTypeImpl placeType;
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
@Override
public int getWoeid() {
return woeid;
}
@Override
public String getCountryName() {
return countryName;
}
@Override
public String getCountryCode() {
return countryCode;
}
@Override
public PlaceTypeImpl getPlaceType() {
return placeType;
}
@Override
public String getName() {
return name;
}
@Override
public String getUrl() {
return url;
}
@JsonObject
public static class PlaceTypeImpl implements PlaceType {
@JsonField(name = "name")
String name;
@JsonField(name = "code")
int code;
@Override
public int getCode() {
return code;
}
@Override
public String getName() {
return name;
}
}
}

View File

@ -1,305 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class MediaEntityImpl implements MediaEntity {
@JsonField(name = "id")
long id;
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@JsonField(name = "media_url")
String mediaUrl;
@JsonField(name = "media_url_https")
String mediaUrlHttps;
@JsonField(name = "url")
String url;
@JsonField(name = "display_url")
String displayUrl;
@JsonField(name = "expanded_url")
String expandedUrl;
@JsonField(name = "type")
Type type;
@JsonField(name = "sizes")
HashMap<String, Size> sizes;
@JsonField(name = "source_status_id")
long sourceStatusId;
@JsonField(name = "source_user_id")
long sourceUserId;
@JsonField(name = "video_info")
VideoInfoImpl videoInfo;
@JsonField(name = "features")
HashMap<String, Feature> features;
@Override
public Map<String, Feature> getFeatures() {
return features;
}
@Override
public String toString() {
return "MediaEntityImpl{" +
"id=" + id +
", indices=" + indices +
", mediaUrl='" + mediaUrl + '\'' +
", mediaUrlHttps='" + mediaUrlHttps + '\'' +
", url='" + url + '\'' +
", displayUrl='" + displayUrl + '\'' +
", expandedUrl='" + expandedUrl + '\'' +
", type=" + type +
", sizes=" + sizes +
", sourceStatusId=" + sourceStatusId +
", sourceUserId=" + sourceUserId +
", videoInfo=" + videoInfo +
", features=" + features +
'}';
}
@Override
public String getMediaUrl() {
return mediaUrl;
}
@Override
public VideoInfo getVideoInfo() {
return videoInfo;
}
@Override
public String getMediaUrlHttps() {
return mediaUrlHttps;
}
@Override
public String getExpandedUrl() {
return expandedUrl;
}
@Override
public String getDisplayUrl() {
return displayUrl;
}
@Override
public String getUrl() {
return url;
}
@Override
public Type getType() {
return type;
}
@Override
public Map<String, Size> getSizes() {
return sizes;
}
@Override
public int getEnd() {
return indices.getEnd();
}
@Override
public int getStart() {
return indices.getStart();
}
@Override
public long getId() {
return id;
}
@JsonObject
public static class FeatureImpl implements Feature {
@JsonField(name = "faces")
FaceImpl[] faces;
@Override
public String toString() {
return "FeatureImpl{" +
"faces=" + Arrays.toString(faces) +
'}';
}
@JsonObject
public static class FaceImpl implements Face {
@JsonField(name = "x")
int x;
@JsonField(name = "y")
int y;
@JsonField(name = "h")
int height;
@JsonField(name = "w")
int width;
@Override
public int getX() {
return x;
}
@Override
public int getY() {
return y;
}
@Override
public String toString() {
return "FaceImpl{" +
"x=" + x +
", y=" + y +
", height=" + height +
", width=" + width +
'}';
}
@Override
public int getHeight() {
return height;
}
@Override
public int getWidth() {
return width;
}
}
}
@JsonObject
public static class VideoInfoImpl implements VideoInfo {
@JsonField(name = "duration")
long duration;
@JsonField(name = "variants")
VariantImpl[] variants;
@JsonField(name = "aspect_ratio")
long[] aspectRatio;
@Override
public Variant[] getVariants() {
return variants;
}
@Override
public long[] getAspectRatio() {
return aspectRatio;
}
@Override
public String toString() {
return "VideoInfoImpl{" +
"duration=" + duration +
", variants=" + Arrays.toString(variants) +
", aspectRatio=" + Arrays.toString(aspectRatio) +
'}';
}
@Override
public long getDuration() {
return duration;
}
@JsonObject
public static class VariantImpl implements Variant {
@JsonField(name = "bitrate")
long bitrate;
@JsonField(name = "content_type")
String contentType;
@JsonField(name = "url")
String url;
@Override
public String toString() {
return "VariantImpl{" +
"bitrate=" + bitrate +
", contentType='" + contentType + '\'' +
", url='" + url + '\'' +
'}';
}
@Override
public String getContentType() {
return contentType;
}
@Override
public String getUrl() {
return url;
}
@Override
public long getBitrate() {
return bitrate;
}
}
}
@JsonObject
public static class SizeImpl implements Size {
@JsonField(name = "w")
int width;
@JsonField(name = "h")
int height;
@JsonField(name = "resize")
String resize;
@Override
public String toString() {
return "SizeImpl{" +
"width=" + width +
", height=" + height +
", resize='" + resize + '\'' +
'}';
}
@Override
public int getHeight() {
return height;
}
@Override
public String getResize() {
return resize;
}
@Override
public int getWidth() {
return width;
}
}
}

View File

@ -1,81 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.MediaUploadResponse;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class MediaUploadResponseImpl extends TwitterResponseImpl implements MediaUploadResponse {
@Override
public long getId() {
return mediaId;
}
@Override
public Image getImage() {
return image;
}
@Override
public long getSize() {
return size;
}
@JsonField(name = "media_id")
long mediaId;
@JsonField(name = "size")
long size;
@JsonField(name = "image")
ImageImpl image;
@JsonObject
public static class ImageImpl implements Image {
@JsonField(name = "width")
int width;
@JsonField(name = "height")
int height;
@JsonField(name = "image_type")
String imageType;
@Override
public int getHeight() {
return height;
}
@Override
public String getImageType() {
return imageType;
}
@Override
public int getWidth() {
return width;
}
}
}

View File

@ -1,49 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Status;
import java.util.ArrayList;
/**
* Created by mariotaku on 15/12/13.
*/
@JsonObject
public class PagableStatusListImpl extends PageableResponseListImpl<Status> {
@JsonField(name = "statuses")
ArrayList<Status> statuses;
@Override
public Status get(int location) {
return statuses.get(location);
}
@Override
public int size() {
if (statuses == null) return 0;
return statuses.size();
}
}

View File

@ -1,48 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.User;
import java.util.ArrayList;
/**
* Created by mariotaku on 15/12/13.
*/
@JsonObject
public class PagableUserListImpl extends PageableResponseListImpl<User> {
@JsonField(name = "users")
ArrayList<User> user;
@Override
public User get(int location) {
return user.get(location);
}
@Override
public int size() {
if (user == null) return 0;
return user.size();
}
}

View File

@ -1,48 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.UserList;
import java.util.ArrayList;
/**
* Created by mariotaku on 15/12/13.
*/
@JsonObject
public class PagableUserListListImpl extends PageableResponseListImpl<UserList> {
@JsonField(name = "lists")
ArrayList<UserList> lists;
@Override
public UserList get(int location) {
return lists.get(location);
}
@Override
public int size() {
if (lists == null) return 0;
return lists.size();
}
}

View File

@ -1,57 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.PageableResponseList;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public abstract class PageableResponseListImpl<T> extends ResponseListImpl<T> implements PageableResponseList<T> {
@JsonField(name = "previous_cursor")
long previousCursor;
@JsonField(name = "next_cursor")
long nextCursor;
@Override
public long getNextCursor() {
return nextCursor;
}
@Override
public long getPreviousCursor() {
return previousCursor;
}
@Override
public boolean hasNext() {
return nextCursor != 0;
}
@Override
public boolean hasPrevious() {
return previousCursor != 0;
}
}

View File

@ -1,107 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.GeoLocation;
import org.mariotaku.twidere.api.twitter.model.Place;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class PlaceImpl extends TwitterResponseImpl implements Place {
@JsonField(name = "full_name")
String fullName;
@Override
public GeoLocation[][] getBoundingBoxCoordinates() {
throw new UnsupportedOperationException();
}
@Override
public String getBoundingBoxType() {
throw new UnsupportedOperationException();
}
@Override
public Place[] getContainedWithIn() {
throw new UnsupportedOperationException();
}
@Override
public String getCountry() {
throw new UnsupportedOperationException();
}
@Override
public String getCountryCode() {
throw new UnsupportedOperationException();
}
@Override
public String getFullName() {
return fullName;
}
@Override
public GeoLocation[][] getGeometryCoordinates() {
throw new UnsupportedOperationException();
}
@Override
public String getGeometryType() {
throw new UnsupportedOperationException();
}
@Override
public String getId() {
throw new UnsupportedOperationException();
}
@Override
public String getName() {
throw new UnsupportedOperationException();
}
@Override
public String getPlaceType() {
throw new UnsupportedOperationException();
}
@Override
public String getStreetAddress() {
throw new UnsupportedOperationException();
}
@Override
public String getUrl() {
throw new UnsupportedOperationException();
}
@Override
public int compareTo(Place another) {
return 0;
}
}

View File

@ -1,253 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.Nullable;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.HashtagEntity;
import org.mariotaku.twidere.api.twitter.model.MediaEntity;
import org.mariotaku.twidere.api.twitter.model.PrivateDirectMessages;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
import java.util.Map;
/**
* Created by mariotaku on 15/7/5.
*/
@JsonObject
public class PrivateDirectMessagesImpl implements PrivateDirectMessages {
@JsonField(name = "user_inbox")
UserInboxImpl userInbox;
@JsonField(name = "user_events")
UserEventsImpl userEvents;
@Override
public UserInbox getUserInbox() {
return userInbox;
}
@Override
public UserEvents getUserEvents() {
return userEvents;
}
@JsonObject
public static class UserInboxImpl implements UserInbox {
@JsonField(name = "users")
Map<String, UserImpl> users;
@JsonField(name = "conversations")
Map<String, ConversationImpl> conversations;
@JsonField(name = "entries")
MessageImpl[] entries;
@Override
public User getUser(long userId) {
return users.get(String.valueOf(userId));
}
@Override
public Conversation getConversation(String conversationId) {
return conversations.get(conversationId);
}
@Override
public Message[] getEntries() {
return entries;
}
}
@JsonObject
public static class UserEventsImpl implements UserEvents {
@JsonField(name = "cursor")
String cursor;
@JsonField(name = "last_seen_event_id")
long lastSeenEventId;
@Override
public String getCursor() {
return cursor;
}
@Override
public long getLastSeenEventId() {
return lastSeenEventId;
}
}
@JsonObject
public static class MessageImpl implements Message {
@JsonObject
public static class DataImpl implements Data {
@Nullable
@JsonField(name = "entities")
EntitiesImpl entities;
@JsonField(name = "sender_id")
long senderId;
@JsonField(name = "recipient_id")
long recipientId;
@JsonField(name = "id")
long id;
@JsonField(name = "conversation_id")
String conversationId;
@JsonField(name = "text")
String text;
@JsonField(name = "time")
long time;
@Override
public String getText() {
return text;
}
@Override
public String getConversationId() {
return conversationId;
}
@Override
public long getId() {
return id;
}
@Override
public long getRecipientId() {
return recipientId;
}
@Override
public long getSenderId() {
return senderId;
}
@Override
public long getTime() {
return time;
}
@Override
public HashtagEntity[] getHashtagEntities() {
if (entities == null) return null;
return entities.getHashtags();
}
@Override
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrls();
}
@Override
public MediaEntity[] getMediaEntities() {
if (entities == null) return null;
return entities.getMedia();
}
@Override
public UserMentionEntity[] getUserMentionEntities() {
if (entities == null) return null;
return entities.getUserMentions();
}
}
}
@JsonObject
public static class ConversationImpl implements Conversation {
@JsonField(name = "conversation_id")
String conversationId;
@JsonField(name = "last_read_event_id")
long lastReadEventId;
@JsonField(name = "max_entry_id")
long maxEntryId;
@JsonField(name = "min_entry_id")
long minEntryId;
@JsonField(name = "notifications_disabled")
boolean notificationsDisabled;
@JsonField(name = "participants")
ParticipantImpl[] participants;
@JsonField(name = "read_only")
boolean readOnly;
@JsonField(name = "sort_event_id")
long sortEventId;
@JsonField(name = "sort_timestamp")
long sortTimestamp;
@JsonField(name = "status")
Status status;
@JsonField(name = "type")
Type type;
@Override
public Participant[] getParticipants() {
return participants;
}
@Override
public String getConversationId() {
return conversationId;
}
@Override
public long getLastReadEventId() {
return lastReadEventId;
}
@Override
public long getMaxEntryId() {
return maxEntryId;
}
@Override
public long getMinEntryId() {
return minEntryId;
}
@Override
public boolean isNotificationsDisabled() {
return notificationsDisabled;
}
@JsonObject
public static class ParticipantImpl implements Participant {
@JsonField(name = "user_id")
long userId;
@Override
public long getUserId() {
return userId;
}
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import org.mariotaku.twidere.api.twitter.model.PrivateSearchResult;
/**
* Created by mariotaku on 15/10/21.
*/
public class PrivateSearchResultImpl implements PrivateSearchResult {
}

View File

@ -1,146 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.model.QueryResult;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.AbstractList;
import java.util.ArrayList;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class QueryResultImpl extends AbstractList<Status> implements QueryResult {
@JsonField(name = "previous_cursor")
long previousCursor;
@JsonField(name = "next_cursor")
long nextCursor;
@JsonField(name = "search_metadata")
SearchMetadata metadata;
@JsonField(name = "statuses")
ArrayList<Status> statuses;
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatusJSONImpl.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
@Override
public Status get(int index) {
return statuses.get(index);
}
@Override
public int size() {
return statuses.size();
}
@Override
public double getCompletedIn() {
return metadata.completedIn;
}
@Override
public long getMaxId() {
return metadata.maxId;
}
@Override
public String getQuery() {
return metadata.query;
}
@Override
public int getResultsPerPage() {
return metadata.count;
}
@Override
public long getNextCursor() {
return nextCursor;
}
@Override
public boolean hasNext() {
return nextCursor != 0;
}
@Override
public boolean hasPrevious() {
return previousCursor != 0;
}
@Override
public long getPreviousCursor() {
return previousCursor;
}
@Override
public long getSinceId() {
return metadata.sinceId;
}
@Override
public String getWarning() {
return metadata.warning;
}
@JsonObject
public static class SearchMetadata {
@JsonField(name = "max_id")
long maxId;
@JsonField(name = "since_id")
long sinceId;
@JsonField(name = "count")
int count;
@JsonField(name = "completed_in")
double completedIn;
@JsonField(name = "query")
String query;
@JsonField(name = "warning")
String warning;
}
}

View File

@ -1,186 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
/**
* A data class representing Twitter REST API's rate limit status
*
* @author Yusuke Yamamoto - yusuke at mac.com
* @see <a href="https://dev.twitter.com/docs/rate-limiting">Rate Limiting |
* Twitter Developers</a>
*/
@JsonObject
public final class RateLimitStatusJSONImpl implements RateLimitStatus {
private final long creationTimeInMillis;
@JsonField(name = "remaining")
int remaining;
@JsonField(name = "limit")
int limit;
@JsonField(name = "reset")
int resetTimeInSeconds;
private RateLimitStatusJSONImpl(final int limit, final int remaining, final int resetTimeInSeconds) {
this();
this.limit = limit;
this.remaining = remaining;
this.resetTimeInSeconds = resetTimeInSeconds;
}
public RateLimitStatusJSONImpl() {
creationTimeInMillis = System.currentTimeMillis();
}
/**
* {@inheritDoc}
*/
@Override
public int getLimit() {
return limit;
}
/**
* {@inheritDoc}
*/
@Override
public int getRemaining() {
return remaining;
}
/**
* {@inheritDoc}
*/
@Override
public int getRemainingHits() {
return getRemaining();
}
/**
* {@inheritDoc}
*/
@Override
public int getResetTimeInSeconds() {
return resetTimeInSeconds;
}
/**
* {@inheritDoc}
*/
@Override
public int getSecondsUntilReset() {
return (int) ((resetTimeInSeconds * 1000L - creationTimeInMillis) / 1000);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RateLimitStatusJSONImpl that = (RateLimitStatusJSONImpl) o;
if (creationTimeInMillis != that.creationTimeInMillis) return false;
if (remaining != that.remaining) return false;
if (limit != that.limit) return false;
return resetTimeInSeconds == that.resetTimeInSeconds;
}
@Override
public int hashCode() {
int result = (int) (creationTimeInMillis ^ (creationTimeInMillis >>> 32));
result = 31 * result + remaining;
result = 31 * result + limit;
result = 31 * result + resetTimeInSeconds;
return result;
}
@Override
public String toString() {
return "RateLimitStatusJSONImpl{" +
"creationTimeInMillis=" + creationTimeInMillis +
", remaining=" + remaining +
", limit=" + limit +
", resetTimeInSeconds=" + resetTimeInSeconds +
'}';
}
public static RateLimitStatus createFromResponseHeader(final RestHttpResponse res) {
if (null == res) return null;
int remainingHits;// "X-Rate-Limit-Remaining"
int limit;// "X-Rate-Limit-Limit"
int resetTimeInSeconds;// not included in the response header. Need to
// be calculated.
final String strLimit = res.getHeader("X-Rate-Limit-Limit");
if (strLimit != null) {
limit = Integer.parseInt(strLimit);
} else
return null;
final String remaining = res.getHeader("X-Rate-Limit-Remaining");
if (remaining != null) {
remainingHits = Integer.parseInt(remaining);
} else
return null;
final String reset = res.getHeader("X-Rate-Limit-Reset");
if (reset != null) {
final long longReset = Long.parseLong(reset);
resetTimeInSeconds = (int) longReset;
} else
return null;
return new RateLimitStatusJSONImpl(limit, remainingHits, resetTimeInSeconds);
}
// static Map<String, RateLimitStatus> createRateLimitStatuses(final HttpResponse res, final Configuration conf)
// throws TwitterException {
// final JSONObject json = res.asJSONObject();
// final Map<String, RateLimitStatus> map = createRateLimitStatuses(json);
// return map;
// }
//
// static Map<String, RateLimitStatus> createRateLimitStatuses(final InputStream stream) throws TwitterException {
// final Map<String, RateLimitStatus> map = new HashMap<String, RateLimitStatus>();
// try {
// final JSONObject resources = json.getJSONObject("resources");
// final Iterator<?> resourceKeys = resources.keys();
// while (resourceKeys.hasNext()) {
// final JSONObject resource = resources.getJSONObject((String) resourceKeys.next());
// final Iterator<?> endpointKeys = resource.keys();
// while (endpointKeys.hasNext()) {
// final String endpoint = (String) endpointKeys.next();
// final JSONObject rateLimitStatusJSON = resource.getJSONObject(endpoint);
// final RateLimitStatus rateLimitStatus = new RateLimitStatusJSONImpl(rateLimitStatusJSON);
// map.put(endpoint, rateLimitStatus);
// }
// }
// return Collections.unmodifiableMap(map);
// } catch (final JSONException jsone) {
// throw new TwitterException(jsone);
// }
// }
}

View File

@ -1,182 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Relationship;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class RelationshipImpl extends TwitterResponseImpl implements Relationship {
@JsonField(name = "relationship")
RelationshipObject object;
@Override
public boolean isSourceBlockingTarget() {
return object.source.blocking;
}
@Override
public boolean isTargetFollowingSource() {
return object.target.following;
}
@Override
public boolean isTargetFollowedBySource() {
return object.target.followedBy;
}
@Override
public boolean isSourceNotificationsEnabled() {
return object.source.notificationsEnabled;
}
@Override
public boolean isSourceMutingTarget() {
return object.source.muting;
}
@Override
public boolean isSourceMarkedTargetAsSpam() {
return false;
}
@Override
public boolean isSourceFollowingTarget() {
return object.source.following;
}
@Override
public boolean isSourceFollowedByTarget() {
return object.source.followedBy;
}
@Override
public boolean isSourceBlockedByTarget() {
return object.source.blockedBy;
}
@Override
public String getTargetUserScreenName() {
return object.target.screenName;
}
@Override
public long getTargetUserId() {
return object.target.id;
}
@Override
public String getSourceUserScreenName() {
return object.source.screenName;
}
@Override
public long getSourceUserId() {
return object.source.id;
}
@Override
public boolean canSourceMediaTagTarget() {
return object.source.canMediaTag;
}
@Override
public boolean canSourceDMTarget() {
return object.source.canDm;
}
@Override
public boolean isSourceRequestedFollowingTarget() {
return object.source.followingRequested;
}
@Override
public boolean isTargetRequestedFollowingSource() {
return object.target.followingRequested;
}
@Override
public boolean isSourceWantRetweetsFromTarget() {
return object.source.wantRetweets;
}
@Override
public boolean isSourceNotificationsEnabledForTarget() {
return object.source.notificationsEnabled;
}
@JsonObject
public static class RelationshipObject {
@JsonField(name = "source")
Source source;
@JsonField(name = "target")
Target target;
@JsonObject
public static class Target {
@JsonField(name = "id")
long id;
@JsonField(name = "screen_name")
public String screenName;
@JsonField(name = "following")
boolean following;
@JsonField(name = "followed_by")
boolean followedBy;
@JsonField(name = "following_requested")
boolean followingRequested;
}
@JsonObject
public static class Source {
@JsonField(name = "id")
long id;
@JsonField(name = "screen_name")
public String screenName;
@JsonField(name = "blocked_by")
boolean blockedBy;
@JsonField(name = "blocking")
boolean blocking;
@JsonField(name = "muting")
boolean muting;
@JsonField(name = "following")
boolean following;
@JsonField(name = "followed_by")
boolean followedBy;
@JsonField(name = "following_requested")
boolean followingRequested;
@JsonField(name = "want_retweets")
boolean wantRetweets;
@JsonField(name = "notifications_enabled")
boolean notificationsEnabled;
@JsonField(name = "can_dm")
boolean canDm;
@JsonField(name = "can_media_tag")
boolean canMediaTag;
}
}
}

View File

@ -1,56 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.ArrayList;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class ResponseArrayList<T> extends ArrayList<T> implements ResponseList<T> {
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatusJSONImpl.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
}

View File

@ -1,53 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import org.mariotaku.restfu.http.RestHttpResponse;
import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.util.AbstractList;
/**
* Created by mariotaku on 15/5/7.
*/
public abstract class ResponseListImpl<T> extends AbstractList<T> implements ResponseList<T> {
private int accessLevel;
private RateLimitStatus rateLimitStatus;
@Override
public final void processResponseHeader(RestHttpResponse resp) {
rateLimitStatus = RateLimitStatusJSONImpl.createFromResponseHeader(resp);
accessLevel = InternalParseUtil.toAccessLevel(resp);
}
@Override
public final int getAccessLevel() {
return accessLevel;
}
@Override
public final RateLimitStatus getRateLimitStatus() {
return rateLimitStatus;
}
}

View File

@ -42,7 +42,7 @@ public class ResponseListMapper<T> extends JsonMapper<ResponseList<T>> {
@Override
public ResponseList<T> parse(JsonParser jsonParser) throws IOException {
ResponseArrayList<T> list = new ResponseArrayList<>();
ResponseList<T> list = new ResponseList<>();
final JsonMapper<T> mapper = LoganSquare.mapperFor(elementCls);
if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {

View File

@ -1,83 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class SavedSearchImpl extends TwitterResponseImpl implements SavedSearch {
@Override
public long getId() {
return id;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public String getName() {
return name;
}
@Override
public int getPosition() {
return position;
}
@Override
public String getQuery() {
return query;
}
@JsonField(name = "id")
long id;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "name")
String name;
@JsonField(name = "position")
int position;
@JsonField(name = "query")
String query;
@Override
public int compareTo(@NonNull SavedSearch another) {
return (int) (id - another.getId());
}
}

View File

@ -1,99 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* Created by mariotaku on 15/7/6.
*/
@JsonObject
public class ScheduledStatusImpl implements ScheduledStatus {
@JsonField(name = "updated_at", typeConverter = TwitterDateConverter.class)
Date updatedAt;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "execute_at", typeConverter = TwitterDateConverter.class)
Date executeAt;
@JsonField(name = "text")
String text;
@JsonField(name = "media_ids")
long[] mediaIds;
@JsonField(name = "id")
long id;
@JsonField(name = "possiblySensitive")
boolean possiblySensitive;
@JsonField(name = "user_id")
long userId;
@JsonField(name = "state")
State state;
@Override
public long getUserId() {
return userId;
}
@Override
public boolean isPossiblySensitive() {
return possiblySensitive;
}
@Override
public long getId() {
return id;
}
@Override
public long[] getMediaIds() {
return mediaIds;
}
@Override
public Date getUpdatedAt() {
return updatedAt;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public Date getExecuteAt() {
return executeAt;
}
@Override
public String getText() {
return text;
}
@Override
public State getState() {
return state;
}
}

View File

@ -1,84 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.IDs;
import org.mariotaku.twidere.api.twitter.model.StatusActivitySummary;
/**
* Created by mariotaku on 15/5/13.
*/
@JsonObject
public class StatusActivitySummaryImpl extends TwitterResponseImpl implements StatusActivitySummary {
@JsonField(name = "favoriters")
IDs favoriters;
@JsonField(name = "repliers")
IDs repliers;
@JsonField(name = "retweeters")
IDs retweeters;
@JsonField(name = "favoriters_count")
long favoritersCount;
@JsonField(name = "repliers_count")
long repliersCount;
@JsonField(name = "retweeters_count")
long retweetersCount;
@JsonField(name = "descendent_reply_count")
long descendentReplyCount;
@Override
public IDs getFavoriters() {
return favoriters;
}
@Override
public IDs getRepliers() {
return repliers;
}
@Override
public IDs getRetweeters() {
return retweeters;
}
@Override
public long getFavoritersCount() {
return favoritersCount;
}
@Override
public long getRepliersCount() {
return repliersCount;
}
@Override
public long getRetweetersCount() {
return retweetersCount;
}
@Override
public long getDescendentReplyCount() {
return descendentReplyCount;
}
}

View File

@ -1,35 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.StatusDeletionNotice;
/**
* Created by mariotaku on 15/5/26.
*/
@JsonObject
public class StatusDeletionNoticeImpl implements StatusDeletionNotice {
@Override
public long getStatusId() {
return 0;
}
}

View File

@ -1,54 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.TimeZone;
/**
* Created by mariotaku on 15/5/13.
*/
@JsonObject
public class TimeZoneImpl implements TimeZone {
@JsonField(name = "utc_offset")
int utcOffset;
@JsonField(name = "name")
String name;
@JsonField(name = "tzinfo_name")
String tzInfoName;
@Override
public int getUtcOffset() {
return utcOffset;
}
@Override
public String getName() {
return name;
}
@Override
public String getTzInfoName() {
return tzInfoName;
}
}

View File

@ -1,68 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.TranslationResult;
/**
* Created by mariotaku on 15/5/7.
*/
@JsonObject
public class TranslationResultImpl extends TwitterResponseImpl implements TranslationResult {
@JsonField(name = "id")
long id;
@JsonField(name = "lang")
String lang;
@JsonField(name = "translated_lang")
String translatedLang;
@JsonField(name = "translation_type")
String translationType;
@JsonField(name = "text")
String text;
@Override
public long getId() {
return id;
}
@Override
public String getLang() {
return lang;
}
@Override
public String getText() {
return text;
}
@Override
public String getTranslatedLang() {
return translatedLang;
}
@Override
public String getTranslationType() {
return translationType;
}
}

View File

@ -1,54 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Trend;
/**
* Created by mariotaku on 15/5/10.
*/
@JsonObject
public class TrendImpl implements Trend {
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
@JsonField(name = "query")
String query;
@Override
public String getName() {
return name;
}
@Override
public String getUrl() {
return url;
}
@Override
public String getQuery() {
return query;
}
}

View File

@ -1,78 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.JsonMapper;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.mariotaku.twidere.api.twitter.model.Trends;
import org.mariotaku.twidere.api.twitter.util.TwitterTrendsDateConverter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Created by mariotaku on 15/5/10.
*/
@JsonObject
public class TrendsImpl extends TwitterResponseImpl implements Trends {
@JsonField(name = "as_of", typeConverter = TwitterTrendsDateConverter.class)
Date asOf;
@JsonField(name = "created_at", typeConverter = TwitterTrendsDateConverter.class)
Date createdAt;
@JsonField(name = "trends")
TrendImpl[] trends;
@JsonField(name = "locations")
LocationImpl[] locations;
@Override
public Date getAsOf() {
return asOf;
}
@Override
public TrendImpl[] getTrends() {
return trends;
}
@Override
public LocationImpl[] getLocations() {
return locations;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public int compareTo(@NonNull Trends another) {
return asOf.compareTo(another.getAsOf());
}
}

View File

@ -1,86 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.JsonMapper;
import com.bluelinelabs.logansquare.LoganSquare;
import com.bluelinelabs.logansquare.typeconverters.TypeConverter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Map;
/**
* Created by mariotaku on 15/5/5.
*/
public class TypeConverterMapper<T> implements TypeConverter<T> {
private final Class<? extends T> cls;
TypeConverterMapper(Class<? extends T> cls) {
this.cls = cls;
}
@Override
public T parse(JsonParser jsonParser) throws IOException {
return LoganSquare.mapperFor(cls).parse(jsonParser);
}
@Override
public void serialize(T object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) {
throw new UnsupportedOperationException();
}
@SuppressWarnings({"TryWithIdenticalCatches"})
public static <T> void register(Class<T> cls, Class<? extends T> impl) {
LoganSquare.registerTypeConverter(cls, new TypeConverterMapper<>(impl));
try {
//noinspection unchecked
register(cls, impl, (JsonMapper) Class.forName(impl.getName() + "$$JsonObjectMapper").newInstance());
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings({"TryWithIdenticalCatches"})
public static <T> void register(Class<T> cls, Class<? extends T> impl, JsonMapper<? extends T> mapper) {
LoganSquare.registerTypeConverter(cls, new TypeConverterMapper<>(impl));
try {
//noinspection unchecked
final Field objectMappersField = LoganSquare.class.getDeclaredField("OBJECT_MAPPERS");
objectMappersField.setAccessible(true);
//noinspection unchecked
final Map<Class, JsonMapper> mappers = (Map<Class, JsonMapper>) objectMappersField.get(null);
mappers.put(cls, mapper);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,76 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class UrlEntityImpl implements UrlEntity {
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@JsonField(name = "display_url")
String displayUrl;
@JsonField(name = "expanded_url")
String expandedUrl;
@JsonField(name = "url")
String url;
@Override
public String getDisplayUrl() {
return displayUrl;
}
@Override
public String toString() {
return "UrlEntityImpl{" +
"indices=" + indices +
", displayUrl='" + displayUrl + '\'' +
", expandedUrl='" + expandedUrl + '\'' +
", url='" + url + '\'' +
'}';
}
@Override
public int getEnd() {
return indices.getEnd();
}
@Override
public int getStart() {
return indices.getStart();
}
@Override
public String getExpandedUrl() {
return expandedUrl;
}
@Override
public String getUrl() {
return url;
}
}

View File

@ -1,489 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.io.IOException;
import java.util.Date;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class UserImpl extends TwitterResponseImpl implements User {
@JsonField(name = "id")
long id;
@JsonField(name = "name")
String name;
@JsonField(name = "screen_name")
String screenName;
@JsonField(name = "location")
String location;
@JsonField(name = "profile_location")
String profileLocation;
@JsonField(name = "description")
String description;
@JsonField(name = "url")
String url;
@JsonField(name = "entities")
UserEntitiesImpl entities;
@JsonField(name = "protected")
boolean isProtected;
@JsonField(name = "followers_count")
long followersCount;
@JsonField(name = "friends_count")
long friendsCount;
@JsonField(name = "listed_count")
long listedCount;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "favourites_count")
long favouritesCount;
@JsonField(name = "utc_offset")
int utcOffset;
@JsonField(name = "time_zone")
String timeZone;
@JsonField(name = "geo_enabled")
boolean geoEnabled;
@JsonField(name = "verified")
boolean isVerified;
@JsonField(name = "statuses_count")
long statusesCount;
@JsonField(name = "media_count")
long mediaCount;
@JsonField(name = "lang")
String lang;
@JsonField(name = "status")
Status status;
@JsonField(name = "contributors_enabled")
boolean contributorsEnabled;
@JsonField(name = "is_translator")
boolean isTranslator;
@JsonField(name = "is_translation_enabled")
boolean isTranslationEnabled;
@JsonField(name = "profile_background_color")
String profileBackgroundColor;
@JsonField(name = "profile_background_image_url")
String profileBackgroundImageUrl;
@JsonField(name = "profile_background_image_url_https")
String profileBackgroundImageUrlHttps;
@JsonField(name = "profile_background_tile")
boolean profileBackgroundTile;
@JsonField(name = "profile_image_url")
String profileImageUrl;
@JsonField(name = "profile_image_url_https")
String profileImageUrlHttps;
@JsonField(name = "profile_banner_url")
String profileBannerUrl;
@JsonField(name = "profile_link_color")
String profileLinkColor;
@JsonField(name = "profile_sidebar_border_color")
String profileSidebarBorderColor;
@JsonField(name = "profile_sidebar_fill_color")
String profileSidebarFillColor;
@JsonField(name = "profile_text_color")
String profileTextColor;
@JsonField(name = "profile_use_background_image")
boolean profileUseBackgroundImage;
@JsonField(name = "default_profile")
boolean defaultProfile;
@JsonField(name = "default_profile_image")
boolean defaultProfileImage;
@JsonField(name = "has_custom_timelines")
boolean hasCustomTimelines;
@JsonField(name = "can_media_tag")
boolean canMediaTag;
@JsonField(name = "followed_by")
boolean followedBy;
@JsonField(name = "following")
boolean following;
@JsonField(name = "follow_request_sent")
boolean followRequestSent;
@JsonField(name = "notifications")
boolean notifications;
@JsonField(name = "suspended")
boolean isSuspended;
@JsonField(name = "needs_phone_verification")
boolean needsPhoneVerification;
@Override
public boolean canMediaTag() {
return canMediaTag;
}
@Override
public boolean isContributorsEnabled() {
return contributorsEnabled;
}
@Override
public boolean isDefaultProfile() {
return defaultProfile;
}
@Override
public String getDescription() {
return description;
}
@Override
public UrlEntity[] getDescriptionEntities() {
if (entities == null) return null;
return entities.getDescriptionEntities();
}
@Override
public long getFavouritesCount() {
return favouritesCount;
}
@Override
public boolean isFollowRequestSent() {
return followRequestSent;
}
@Override
public boolean isFollowedBy() {
return followedBy;
}
@Override
public long getFollowersCount() {
return followersCount;
}
@Override
public boolean isFollowing() {
return following;
}
@Override
public long getFriendsCount() {
return friendsCount;
}
@Override
public boolean isGeoEnabled() {
return geoEnabled;
}
@Override
public boolean isProfileBackgroundTiled() {
return profileBackgroundTile;
}
@Override
public boolean hasCustomTimelines() {
return hasCustomTimelines;
}
@Override
public long getId() {
return id;
}
@Override
public boolean isTranslationEnabled() {
return isTranslationEnabled;
}
@Override
public boolean isTranslator() {
return isTranslator;
}
@Override
public String getLang() {
return lang;
}
@Override
public long getListedCount() {
return listedCount;
}
@Override
public String getLocation() {
return location;
}
@Override
public long getMediaCount() {
return mediaCount;
}
@Override
public String getName() {
return name;
}
@Override
public boolean isNeedsPhoneVerification() {
return needsPhoneVerification;
}
@Override
public boolean isNotifications() {
return notifications;
}
@Override
public String getProfileBackgroundColor() {
return profileBackgroundColor;
}
@Override
public String getProfileBackgroundImageUrl() {
return profileBackgroundImageUrl;
}
@Override
public String getProfileBackgroundImageUrlHttps() {
return profileBackgroundImageUrlHttps;
}
@Override
public String getProfileBannerImageUrl() {
return profileBannerUrl;
}
@Override
public String getProfileImageUrl() {
return profileImageUrl;
}
@Override
public String getProfileImageUrlHttps() {
return profileImageUrlHttps;
}
@Override
public String getProfileLinkColor() {
return profileLinkColor;
}
@Override
public String getProfileLocation() {
return profileLocation;
}
@Override
public String getProfileSidebarBorderColor() {
return profileSidebarBorderColor;
}
@Override
public String getProfileSidebarFillColor() {
return profileSidebarFillColor;
}
@Override
public boolean isProfileUseBackgroundImage() {
return profileUseBackgroundImage;
}
@Override
public boolean isProtected() {
return isProtected;
}
@Override
public String getScreenName() {
return screenName;
}
@Override
public Status getStatus() {
return status;
}
@Override
public long getStatusesCount() {
return statusesCount;
}
@Override
public boolean isSuspended() {
return isSuspended;
}
@Override
public String getTimeZone() {
return timeZone;
}
@Override
public String getUrl() {
return url;
}
@Override
public UrlEntity[] getUrlEntities() {
if (entities == null) return null;
return entities.getUrlEntities();
}
@Override
public int getUtcOffset() {
return utcOffset;
}
@Override
public boolean isVerified() {
return isVerified;
}
@Override
public String getProfileTextColor() {
return profileTextColor;
}
@Override
public String toString() {
return "UserImpl{" +
"id=" + id +
", name='" + name + '\'' +
", screenName='" + screenName + '\'' +
", location='" + location + '\'' +
", profileLocation='" + profileLocation + '\'' +
", description='" + description + '\'' +
", url='" + url + '\'' +
", entities=" + entities +
", isProtected=" + isProtected +
", followersCount=" + followersCount +
", friendsCount=" + friendsCount +
", listedCount=" + listedCount +
", createdAt=" + createdAt +
", favouritesCount=" + favouritesCount +
", utcOffset=" + utcOffset +
", timeZone='" + timeZone + '\'' +
", geoEnabled=" + geoEnabled +
", isVerified=" + isVerified +
", statusesCount=" + statusesCount +
", mediaCount=" + mediaCount +
", lang='" + lang + '\'' +
", status=" + status +
", contributorsEnabled=" + contributorsEnabled +
", isTranslator=" + isTranslator +
", isTranslationEnabled=" + isTranslationEnabled +
", profileBackgroundColor='" + profileBackgroundColor + '\'' +
", profileBackgroundImageUrl='" + profileBackgroundImageUrl + '\'' +
", profileBackgroundImageUrlHttps='" + profileBackgroundImageUrlHttps + '\'' +
", profileBackgroundTile=" + profileBackgroundTile +
", profileImageUrl='" + profileImageUrl + '\'' +
", profileImageUrlHttps='" + profileImageUrlHttps + '\'' +
", profileBannerUrl='" + profileBannerUrl + '\'' +
", profileLinkColor='" + profileLinkColor + '\'' +
", profileSidebarBorderColor='" + profileSidebarBorderColor + '\'' +
", profileSidebarFillColor='" + profileSidebarFillColor + '\'' +
", profileTextColor='" + profileTextColor + '\'' +
", profileUseBackgroundImage=" + profileUseBackgroundImage +
", defaultProfile=" + defaultProfile +
", defaultProfileImage=" + defaultProfileImage +
", hasCustomTimelines=" + hasCustomTimelines +
", canMediaTag=" + canMediaTag +
", followedBy=" + followedBy +
", following=" + following +
", followRequestSent=" + followRequestSent +
", notifications=" + notifications +
", isSuspended=" + isSuspended +
", needsPhoneVerification=" + needsPhoneVerification +
'}';
}
@Override
public boolean isDefaultProfileImage() {
return defaultProfileImage;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public int compareTo(@NonNull final User that) {
return (int) (id - that.getId());
}
@OnJsonParseComplete
void onJsonParseComplete() throws IOException {
if (id <= 0 || screenName == null) throw new IOException("Malformed User object");
}
}

View File

@ -1,158 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserList;
/**
* Created by mariotaku on 15/4/7.
*/
@JsonObject
public class UserListImpl extends TwitterResponseImpl implements UserList {
@JsonField(name = "id")
long id;
@JsonField(name = "name")
String name;
@JsonField(name = "uri")
String uri;
@JsonField(name = "subscriber_count")
long subscriberCount;
@JsonField(name = "member_count")
long memberCount;
@JsonField(name = "mode")
Mode mode;
@JsonField(name = "description")
String description;
@JsonField(name = "slug")
String slug;
@JsonField(name = "full_name")
String fullName;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "following")
boolean following;
@JsonField(name = "user")
User user;
@Override
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
public String getUri() {
return uri;
}
@Override
public long getSubscriberCount() {
return subscriberCount;
}
@Override
public long getMemberCount() {
return memberCount;
}
@Override
public Mode getMode() {
return mode;
}
@Override
public String getDescription() {
return description;
}
@Override
public String getSlug() {
return slug;
}
@Override
public String getFullName() {
return fullName;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public boolean isFollowing() {
return following;
}
@Override
public User getUser() {
return user;
}
@Override
public int compareTo(@NonNull UserList another) {
return (int) (id - another.getId());
}
@Override
public String toString() {
return "UserListImpl{" +
"id=" + id +
", name='" + name + '\'' +
", uri='" + uri + '\'' +
", subscriberCount=" + subscriberCount +
", memberCount=" + memberCount +
", mode=" + mode +
", description='" + description + '\'' +
", slug='" + slug + '\'' +
", fullName='" + fullName + '\'' +
", createdAt=" + createdAt +
", following=" + following +
", user=" + user +
"} " + super.toString();
}
}

View File

@ -1,76 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
/**
* Created by mariotaku on 15/3/31.
*/
@JsonObject
public class UserMentionEntityImpl implements UserMentionEntity {
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@JsonField(name = "id")
long id;
@JsonField(name = "name")
String name;
@JsonField(name = "screen_name")
String screenName;
@Override
public String toString() {
return "UserMentionEntityImpl{" +
"indices=" + indices +
", id=" + id +
", name='" + name + '\'' +
", screenName='" + screenName + '\'' +
'}';
}
@Override
public int getEnd() {
return indices.getEnd();
}
@Override
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getScreenName() {
return screenName;
}
@Override
public int getStart() {
return indices.getStart();
}
}

View File

@ -1,31 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.Warning;
/**
* Created by mariotaku on 15/5/26.
*/
@JsonObject
public class WarningImpl implements Warning {
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Activity;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class ActivityResponseListMapper extends ResponseListMapper<Activity> {
public ActivityResponseListMapper() {
super(Activity.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class DirectMessageResponseListMapper extends ResponseListMapper<DirectMessage> {
public DirectMessageResponseListMapper() {
super(DirectMessage.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Language;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class LanguageResponseListMapper extends ResponseListMapper<Language> {
public LanguageResponseListMapper() {
super(Language.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Location;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class LocationResponseListMapper extends ResponseListMapper<Location> {
public LocationResponseListMapper() {
super(Location.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Place;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class PlaceResponseListMapper extends ResponseListMapper<Place> {
public PlaceResponseListMapper() {
super(Place.class);
}
}

View File

@ -1,33 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.api.twitter.model.UserList;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class SavedSearchResponseListMapper extends ResponseListMapper<SavedSearch> {
public SavedSearchResponseListMapper() {
super(SavedSearch.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class StatusResponseListMapper extends ResponseListMapper<Status> {
public StatusResponseListMapper() {
super(Status.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.Trends;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class TrendsResponseListMapper extends ResponseListMapper<Trends> {
public TrendsResponseListMapper() {
super(Trends.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.UserList;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class UserListResponseListMapper extends ResponseListMapper<UserList> {
public UserListResponseListMapper() {
super(UserList.class);
}
}

View File

@ -1,32 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl.mapper.list;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListMapper;
/**
* Created by mariotaku on 15/12/13.
*/
public class UserResponseListMapper extends ResponseListMapper<User> {
public UserResponseListMapper() {
super(User.class);
}
}

Some files were not shown because too many files have changed in this diff Show More