refactoring
This commit is contained in:
parent
733b51b21b
commit
0a9a008571
|
@ -3,7 +3,6 @@ package org.mariotaku.microblog.library.twitter;
|
|||
import org.mariotaku.microblog.library.twitter.api.PrivateActivityResources;
|
||||
import org.mariotaku.microblog.library.twitter.api.PrivateDirectMessagesResources;
|
||||
import org.mariotaku.microblog.library.twitter.api.PrivateFriendsFollowersResources;
|
||||
import org.mariotaku.microblog.library.twitter.api.PrivateScheduleResources;
|
||||
import org.mariotaku.microblog.library.twitter.api.PrivateTimelineResources;
|
||||
import org.mariotaku.microblog.library.twitter.api.PrivateTweetResources;
|
||||
|
||||
|
@ -11,6 +10,5 @@ import org.mariotaku.microblog.library.twitter.api.PrivateTweetResources;
|
|||
* Created by mariotaku on 16/3/4.
|
||||
*/
|
||||
public interface TwitterPrivate extends PrivateActivityResources, PrivateTweetResources,
|
||||
PrivateTimelineResources, PrivateFriendsFollowersResources, PrivateDirectMessagesResources,
|
||||
PrivateScheduleResources {
|
||||
PrivateTimelineResources, PrivateFriendsFollowersResources, PrivateDirectMessagesResources {
|
||||
}
|
||||
|
|
|
@ -1,58 +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.microblog.library.twitter.api;
|
||||
|
||||
import org.mariotaku.restfu.annotation.method.DELETE;
|
||||
import org.mariotaku.restfu.annotation.method.GET;
|
||||
import org.mariotaku.restfu.annotation.method.POST;
|
||||
import org.mariotaku.restfu.annotation.method.PUT;
|
||||
import org.mariotaku.restfu.annotation.param.KeyValue;
|
||||
import org.mariotaku.restfu.annotation.param.Param;
|
||||
import org.mariotaku.restfu.annotation.param.Path;
|
||||
import org.mariotaku.restfu.annotation.param.Queries;
|
||||
import org.mariotaku.restfu.annotation.param.Query;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.microblog.library.twitter.model.ResponseList;
|
||||
import org.mariotaku.microblog.library.twitter.model.ScheduledStatus;
|
||||
import org.mariotaku.microblog.library.twitter.model.StatusSchedule;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/7/6.
|
||||
*/
|
||||
public interface PrivateScheduleResources {
|
||||
|
||||
@POST("/schedule/status/tweet.json")
|
||||
ScheduledStatus scheduleTweet(@Param StatusSchedule schedule) throws MicroBlogException;
|
||||
|
||||
@DELETE("/schedule/status/{id}.json")
|
||||
ScheduledStatus destroyScheduleTweet(@Path("id") long id) throws MicroBlogException;
|
||||
|
||||
@PUT("/schedule/status/{id}.json")
|
||||
ScheduledStatus updateScheduleTweet(@Path("id") long id, @Param StatusSchedule schedule) throws MicroBlogException;
|
||||
|
||||
@GET("/schedule/status/list.json")
|
||||
@Queries({@KeyValue(key = "include_entities", valueKey = "include_entities"),
|
||||
@KeyValue(key = "include_cards", valueKey = "include_cards"),
|
||||
@KeyValue(key = "cards_platform", valueKey = "cards_platform")})
|
||||
ResponseList<ScheduledStatus> getScheduledStatuses(@Query Paging paging,
|
||||
@Query(value = "state", arrayDelimiter = ',') @ScheduledStatus.State String[] states) throws MicroBlogException;
|
||||
|
||||
}
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/13.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class AccountSettings extends TwitterResponseObject {
|
||||
public class AccountSettings extends TwitterResponseObject implements Parcelable {
|
||||
|
||||
@JsonField(name = "geo_enabled")
|
||||
boolean geoEnabled;
|
||||
|
@ -59,4 +64,25 @@ public class AccountSettings extends TwitterResponseObject {
|
|||
return geoEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
AccountSettingsParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<AccountSettings> CREATOR = new Creator<AccountSettings>() {
|
||||
public AccountSettings createFromParcel(Parcel source) {
|
||||
AccountSettings target = new AccountSettings();
|
||||
AccountSettingsParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public AccountSettings[] newArray(int size) {
|
||||
return new AccountSettings[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,159 +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.microblog.library.twitter.model;
|
||||
|
||||
import com.bluelinelabs.logansquare.JsonMapper;
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* ObjectMapper for Activity object
|
||||
* Created by mariotaku on 15/10/21.
|
||||
*/
|
||||
public class Activity$$JsonObjectMapper extends JsonMapper<Activity> {
|
||||
|
||||
private static final JsonMapper<User> USER_JSON_MAPPER = LoganSquare.mapperFor(User.class);
|
||||
private static final JsonMapper<Status> STATUS_JSON_MAPPER = LoganSquare.mapperFor(Status.class);
|
||||
private static final JsonMapper<UserList> USER_LIST_JSON_MAPPER = LoganSquare.mapperFor(UserList.class);
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
|
||||
|
||||
@SuppressWarnings("TryWithIdenticalCatches")
|
||||
@Override
|
||||
public Activity parse(JsonParser jsonParser) throws IOException {
|
||||
Activity instance = new Activity();
|
||||
if (jsonParser.getCurrentToken() == null) {
|
||||
jsonParser.nextToken();
|
||||
}
|
||||
if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
|
||||
jsonParser.skipChildren();
|
||||
return null;
|
||||
}
|
||||
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
|
||||
String fieldName = jsonParser.getCurrentName();
|
||||
jsonParser.nextToken();
|
||||
parseField(instance, fieldName, jsonParser);
|
||||
jsonParser.skipChildren();
|
||||
}
|
||||
try {
|
||||
instance.maxSortPosition = Long.parseLong(instance.maxPosition);
|
||||
instance.minSortPosition = Long.parseLong(instance.minPosition);
|
||||
} catch (NumberFormatException e) {
|
||||
final long time = instance.createdAt != null ? instance.createdAt.getTime() : -1;
|
||||
instance.maxSortPosition = time;
|
||||
instance.minSortPosition = time;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Activity activity, JsonGenerator jsonGenerator, boolean writeStartAndEnd) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseField(Activity instance, String fieldName, JsonParser jsonParser) throws IOException {
|
||||
if ("action".equals(fieldName)) {
|
||||
//noinspection ResourceType
|
||||
instance.action = jsonParser.getValueAsString();
|
||||
} else if ("created_at".equals(fieldName)) {
|
||||
try {
|
||||
instance.createdAt = DATE_FORMAT.parse(jsonParser.getValueAsString());
|
||||
} catch (ParseException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
} else if ("min_position".equals(fieldName)) {
|
||||
instance.minPosition = jsonParser.getValueAsString();
|
||||
} else if ("max_position".equals(fieldName)) {
|
||||
instance.maxPosition = jsonParser.getValueAsString();
|
||||
} else if ("sources_size".equals(fieldName)) {
|
||||
instance.sourcesSize = jsonParser.getValueAsInt();
|
||||
} else if ("targets_size".equals(fieldName)) {
|
||||
instance.targetsSize = jsonParser.getValueAsInt();
|
||||
} else if ("target_objects_size".equals(fieldName)) {
|
||||
instance.targetObjectsSize = jsonParser.getValueAsInt();
|
||||
} else if ("sources".equals(fieldName)) {
|
||||
instance.sources = USER_JSON_MAPPER.parseList(jsonParser).toArray(new User[instance.sourcesSize]);
|
||||
} else if ("targets".equals(fieldName)) {
|
||||
if (instance.action == null) throw new IOException();
|
||||
switch (instance.action) {
|
||||
case Activity.Action.FAVORITE:
|
||||
case Activity.Action.REPLY:
|
||||
case Activity.Action.RETWEET:
|
||||
case Activity.Action.QUOTE:
|
||||
case Activity.Action.FAVORITED_RETWEET:
|
||||
case Activity.Action.RETWEETED_RETWEET:
|
||||
case Activity.Action.RETWEETED_MENTION:
|
||||
case Activity.Action.FAVORITED_MENTION:
|
||||
case Activity.Action.MEDIA_TAGGED:
|
||||
case Activity.Action.FAVORITED_MEDIA_TAGGED:
|
||||
case Activity.Action.RETWEETED_MEDIA_TAGGED: {
|
||||
instance.targetStatuses = STATUS_JSON_MAPPER.parseList(jsonParser).toArray(new Status[instance.targetsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.FOLLOW:
|
||||
case Activity.Action.MENTION:
|
||||
case Activity.Action.LIST_MEMBER_ADDED: {
|
||||
instance.targetUsers = USER_JSON_MAPPER.parseList(jsonParser).toArray(new User[instance.targetsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.LIST_CREATED: {
|
||||
instance.targetUserLists = USER_LIST_JSON_MAPPER.parseList(jsonParser).toArray(new UserList[instance.targetsSize]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if ("target_objects".equals(fieldName)) {
|
||||
if (instance.action == null) throw new IOException();
|
||||
switch (instance.action) {
|
||||
case Activity.Action.FAVORITE:
|
||||
case Activity.Action.FOLLOW:
|
||||
case Activity.Action.MENTION:
|
||||
case Activity.Action.REPLY:
|
||||
case Activity.Action.RETWEET:
|
||||
case Activity.Action.LIST_CREATED:
|
||||
case Activity.Action.QUOTE: {
|
||||
instance.targetObjectStatuses = STATUS_JSON_MAPPER.parseList(jsonParser).toArray(new Status[instance.targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.LIST_MEMBER_ADDED: {
|
||||
instance.targetObjectUserLists = USER_LIST_JSON_MAPPER.parseList(jsonParser).toArray(new UserList[instance.targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.FAVORITED_RETWEET:
|
||||
case Activity.Action.RETWEETED_RETWEET:
|
||||
case Activity.Action.RETWEETED_MENTION:
|
||||
case Activity.Action.FAVORITED_MENTION:
|
||||
case Activity.Action.MEDIA_TAGGED:
|
||||
case Activity.Action.FAVORITED_MEDIA_TAGGED:
|
||||
case Activity.Action.RETWEETED_MEDIA_TAGGED: {
|
||||
instance.targetObjectUsers = USER_JSON_MAPPER.parseList(jsonParser).toArray(new User[instance.targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,10 +25,18 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.StringDef;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.bluelinelabs.logansquare.JsonMapper;
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.mariotaku.commons.logansquare.JsonStringConverter;
|
||||
import org.mariotaku.microblog.library.annotation.NoObfuscate;
|
||||
import org.mariotaku.microblog.library.twitter.util.TwitterDateConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Arrays;
|
||||
|
@ -38,23 +46,42 @@ import java.util.Date;
|
|||
* Twitter Activity object
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@NoObfuscate
|
||||
public class Activity extends TwitterResponseObject implements TwitterResponse, Comparable<Activity>,Parcelable {
|
||||
@JsonObject
|
||||
public class Activity extends TwitterResponseObject implements TwitterResponse, Comparable<Activity>,
|
||||
Parcelable {
|
||||
|
||||
private static final JsonMapper<User> USER_JSON_MAPPER = LoganSquare.mapperFor(User.class);
|
||||
private static final JsonMapper<Status> STATUS_JSON_MAPPER = LoganSquare.mapperFor(Status.class);
|
||||
private static final JsonMapper<UserList> USER_LIST_JSON_MAPPER = LoganSquare.mapperFor(UserList.class);
|
||||
|
||||
@Action
|
||||
@JsonField(name = "action")
|
||||
String action;
|
||||
String rawAction;
|
||||
|
||||
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
|
||||
Date createdAt;
|
||||
|
||||
@JsonField(name = "sources")
|
||||
User[] sources;
|
||||
@JsonField(name = "targets", typeConverter = JsonStringConverter.class)
|
||||
String rawTargets;
|
||||
@JsonField(name = "sources", typeConverter = JsonStringConverter.class)
|
||||
String rawTargetObjects;
|
||||
User[] targetUsers;
|
||||
User[] targetObjectUsers;
|
||||
Status[] targetObjectStatuses, targetStatuses;
|
||||
UserList[] targetUserLists, targetObjectUserLists;
|
||||
String maxPosition = null, minPosition = null;
|
||||
@JsonField(name = "max_position")
|
||||
String maxPosition = null;
|
||||
@JsonField(name = "min_position")
|
||||
String minPosition = null;
|
||||
long maxSortPosition = -1, minSortPosition = -1;
|
||||
int targetObjectsSize, targetsSize, sourcesSize;
|
||||
@JsonField(name = "target_objects_size")
|
||||
int targetObjectsSize;
|
||||
@JsonField(name = "targets_size")
|
||||
int targetsSize;
|
||||
@JsonField(name = "sources_size")
|
||||
int sourcesSize;
|
||||
|
||||
Activity() {
|
||||
}
|
||||
|
@ -63,16 +90,8 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
|
|||
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);
|
||||
}
|
||||
|
||||
public
|
||||
@Action
|
||||
String getAction() {
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -132,11 +151,17 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
|
|||
return targetUsers;
|
||||
}
|
||||
|
||||
@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 String toString() {
|
||||
return "Activity{" +
|
||||
"action='" + action + '\'' +
|
||||
", rawAction='" + rawAction + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", sources=" + Arrays.toString(sources) +
|
||||
", targetUsers=" + Arrays.toString(targetUsers) +
|
||||
|
@ -155,6 +180,71 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
|
|||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@OnJsonParseComplete
|
||||
void onParseComplete() throws IOException {
|
||||
if (action == null) throw new IOException();
|
||||
switch (action) {
|
||||
case Activity.Action.FAVORITE:
|
||||
case Activity.Action.REPLY:
|
||||
case Activity.Action.RETWEET:
|
||||
case Activity.Action.QUOTE:
|
||||
case Activity.Action.FAVORITED_RETWEET:
|
||||
case Activity.Action.RETWEETED_RETWEET:
|
||||
case Activity.Action.RETWEETED_MENTION:
|
||||
case Activity.Action.FAVORITED_MENTION:
|
||||
case Activity.Action.MEDIA_TAGGED:
|
||||
case Activity.Action.FAVORITED_MEDIA_TAGGED:
|
||||
case Activity.Action.RETWEETED_MEDIA_TAGGED: {
|
||||
targetStatuses = STATUS_JSON_MAPPER.parseList(rawTargets).toArray(new Status[targetsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.FOLLOW:
|
||||
case Activity.Action.MENTION:
|
||||
case Activity.Action.LIST_MEMBER_ADDED: {
|
||||
targetUsers = USER_JSON_MAPPER.parseList(rawTargets).toArray(new User[targetsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.LIST_CREATED: {
|
||||
targetUserLists = USER_LIST_JSON_MAPPER.parseList(rawTargets).toArray(new UserList[targetsSize]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (action) {
|
||||
case Activity.Action.FAVORITE:
|
||||
case Activity.Action.FOLLOW:
|
||||
case Activity.Action.MENTION:
|
||||
case Activity.Action.REPLY:
|
||||
case Activity.Action.RETWEET:
|
||||
case Activity.Action.LIST_CREATED:
|
||||
case Activity.Action.QUOTE: {
|
||||
targetObjectStatuses = STATUS_JSON_MAPPER.parseList(rawTargetObjects).toArray(new Status[targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.LIST_MEMBER_ADDED: {
|
||||
targetObjectUserLists = USER_LIST_JSON_MAPPER.parseList(rawTargetObjects).toArray(new UserList[targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
case Activity.Action.FAVORITED_RETWEET:
|
||||
case Activity.Action.RETWEETED_RETWEET:
|
||||
case Activity.Action.RETWEETED_MENTION:
|
||||
case Activity.Action.FAVORITED_MENTION:
|
||||
case Activity.Action.MEDIA_TAGGED:
|
||||
case Activity.Action.FAVORITED_MEDIA_TAGGED:
|
||||
case Activity.Action.RETWEETED_MEDIA_TAGGED: {
|
||||
targetObjectUsers = USER_JSON_MAPPER.parseList(rawTargetObjects).toArray(new User[targetObjectsSize]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
maxSortPosition = Long.parseLong(maxPosition);
|
||||
minSortPosition = Long.parseLong(minPosition);
|
||||
} catch (NumberFormatException e) {
|
||||
final long time = createdAt != null ? createdAt.getTime() : -1;
|
||||
maxSortPosition = time;
|
||||
minSortPosition = time;
|
||||
}
|
||||
}
|
||||
|
||||
public static Activity fromMention(String twitterId, Status status) {
|
||||
final Activity activity = new Activity();
|
||||
|
||||
|
@ -164,14 +254,12 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
|
|||
|
||||
if (TextUtils.equals(status.getInReplyToUserId(), twitterId)) {
|
||||
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)
|
||||
|
|
|
@ -19,18 +19,45 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/12/31.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class CardResponse {
|
||||
public class CardResponse implements Parcelable {
|
||||
@JsonField(name = "card")
|
||||
CardEntity card;
|
||||
|
||||
public CardEntity getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
CardResponseParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<CardResponse> CREATOR = new Creator<CardResponse>() {
|
||||
public CardResponse createFromParcel(Parcel source) {
|
||||
CardResponse target = new CardResponse();
|
||||
CardResponseParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public CardResponse[] newArray(int size) {
|
||||
return new CardResponse[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
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 com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.mariotaku.microblog.library.annotation.NoObfuscate;
|
||||
|
||||
|
@ -32,8 +36,9 @@ import java.io.IOException;
|
|||
/**
|
||||
* Created by mariotaku on 15/5/10.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@NoObfuscate
|
||||
public class IDs extends TwitterResponseObject implements TwitterResponse, CursorSupport {
|
||||
public class IDs extends TwitterResponseObject implements TwitterResponse, CursorSupport, Parcelable {
|
||||
|
||||
long previousCursor;
|
||||
long nextCursor;
|
||||
|
@ -80,4 +85,26 @@ public class IDs extends TwitterResponseObject implements TwitterResponse, Curso
|
|||
IDS_JSON_MAPPER.serialize(object, jsonGenerator, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
IDsParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<IDs> CREATOR = new Creator<IDs>() {
|
||||
public IDs createFromParcel(Parcel source) {
|
||||
IDs target = new IDs();
|
||||
IDsParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public IDs[] newArray(int size) {
|
||||
return new IDs[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/10.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class Language {
|
||||
public class Language implements Parcelable {
|
||||
@JsonField(name = "name")
|
||||
String name;
|
||||
@JsonField(name = "code")
|
||||
|
@ -54,4 +59,26 @@ public class Language {
|
|||
", status='" + status + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
LanguageParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<Language> CREATOR = new Creator<Language>() {
|
||||
public Language createFromParcel(Parcel source) {
|
||||
Language target = new Language();
|
||||
LanguageParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public Language[] newArray(int size) {
|
||||
return new Language[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/10.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class Location {
|
||||
public class Location implements Parcelable {
|
||||
|
||||
@JsonField(name = "woeid")
|
||||
int woeid;
|
||||
|
@ -87,8 +92,33 @@ public class Location {
|
|||
return woeid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
LocationParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<Location> CREATOR = new Creator<Location>() {
|
||||
@Override
|
||||
public Location createFromParcel(Parcel source) {
|
||||
Location target = new Location();
|
||||
LocationParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location[] newArray(int size) {
|
||||
return new Location[size];
|
||||
}
|
||||
};
|
||||
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public static class PlaceType {
|
||||
public static class PlaceType implements Parcelable {
|
||||
@JsonField(name = "name")
|
||||
String name;
|
||||
|
||||
|
@ -110,5 +140,29 @@ public class Location {
|
|||
", code=" + code +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
Location$PlaceTypeParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<PlaceType> CREATOR = new Creator<PlaceType>() {
|
||||
@Override
|
||||
public PlaceType createFromParcel(Parcel source) {
|
||||
PlaceType target = new PlaceType();
|
||||
Location$PlaceTypeParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaceType[] newArray(int size) {
|
||||
return new PlaceType[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/30.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class NewMediaMetadata {
|
||||
public class NewMediaMetadata implements Parcelable {
|
||||
@JsonField(name = "media_id")
|
||||
String mediaId;
|
||||
@JsonField(name = "alt_text")
|
||||
|
@ -30,8 +35,9 @@ public class NewMediaMetadata {
|
|||
'}';
|
||||
}
|
||||
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public static class AltText {
|
||||
public static class AltText implements Parcelable {
|
||||
@JsonField(name = "text")
|
||||
String text;
|
||||
|
||||
|
@ -49,5 +55,49 @@ public class NewMediaMetadata {
|
|||
"text='" + text + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
NewMediaMetadata$AltTextParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<AltText> CREATOR = new Creator<AltText>() {
|
||||
public AltText createFromParcel(Parcel source) {
|
||||
AltText target = new AltText();
|
||||
NewMediaMetadata$AltTextParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public AltText[] newArray(int size) {
|
||||
return new AltText[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
NewMediaMetadataParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<NewMediaMetadata> CREATOR = new Creator<NewMediaMetadata>() {
|
||||
public NewMediaMetadata createFromParcel(Parcel source) {
|
||||
NewMediaMetadata target = new NewMediaMetadata();
|
||||
NewMediaMetadataParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public NewMediaMetadata[] newArray(int size) {
|
||||
return new NewMediaMetadata[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/13.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class StatusActivitySummary extends TwitterResponseObject implements TwitterResponse {
|
||||
public class StatusActivitySummary extends TwitterResponseObject implements TwitterResponse, Parcelable {
|
||||
|
||||
@JsonField(name = "favoriters", typeConverter = IDs.Converter.class)
|
||||
IDs favoriters;
|
||||
|
@ -71,4 +76,26 @@ public class StatusActivitySummary extends TwitterResponseObject implements Twit
|
|||
public long getDescendentReplyCount() {
|
||||
return descendentReplyCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
StatusActivitySummaryParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<StatusActivitySummary> CREATOR = new Creator<StatusActivitySummary>() {
|
||||
public StatusActivitySummary createFromParcel(Parcel source) {
|
||||
StatusActivitySummary target = new StatusActivitySummary();
|
||||
StatusActivitySummaryParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public StatusActivitySummary[] newArray(int size) {
|
||||
return new StatusActivitySummary[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,36 +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.microblog.library.twitter.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/7/6.
|
||||
*/
|
||||
public class StatusSchedule extends StatusUpdate {
|
||||
public StatusSchedule(String status) {
|
||||
super(status);
|
||||
}
|
||||
|
||||
public void setExecuteAt(Date executeAt) {
|
||||
put("execute_at", TimeUnit.SECONDS.convert(executeAt.getTime(), TimeUnit.MILLISECONDS));
|
||||
}
|
||||
}
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/13.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class TimeZone {
|
||||
public class TimeZone implements Parcelable {
|
||||
|
||||
@JsonField(name = "utc_offset")
|
||||
int utcOffset;
|
||||
|
@ -46,4 +51,26 @@ public class TimeZone {
|
|||
public String getTzInfoName() {
|
||||
return tzInfoName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
TimeZoneParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<TimeZone> CREATOR = new Creator<TimeZone>() {
|
||||
public TimeZone createFromParcel(Parcel source) {
|
||||
TimeZone target = new TimeZone();
|
||||
TimeZoneParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public TimeZone[] newArray(int size) {
|
||||
return new TimeZone[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,18 +19,45 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/12/30.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class TimestampResponse {
|
||||
public class TimestampResponse implements Parcelable {
|
||||
@JsonField(name = "timestamp")
|
||||
long timestamp;
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
TimestampResponseParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<TimestampResponse> CREATOR = new Creator<TimestampResponse>() {
|
||||
public TimestampResponse createFromParcel(Parcel source) {
|
||||
TimestampResponse target = new TimestampResponse();
|
||||
TimestampResponseParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public TimestampResponse[] newArray(int size) {
|
||||
return new TimestampResponse[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,14 +19,19 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/10.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class Trend {
|
||||
public class Trend implements Parcelable {
|
||||
|
||||
@JsonField(name = "name")
|
||||
String name;
|
||||
|
@ -55,4 +60,28 @@ public class Trend {
|
|||
", query='" + query + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
TrendParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<Trend> CREATOR = new Creator<Trend>() {
|
||||
@Override
|
||||
public Trend createFromParcel(Parcel source) {
|
||||
Trend target = new Trend();
|
||||
TrendParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trend[] newArray(int size) {
|
||||
return new Trend[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,10 +19,13 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.mariotaku.microblog.library.twitter.util.TwitterTrendsDateConverter;
|
||||
|
||||
|
@ -31,8 +34,10 @@ import java.util.Date;
|
|||
/**
|
||||
* Created by mariotaku on 15/5/10.
|
||||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class Trends extends TwitterResponseObject implements TwitterResponse, Comparable<Trends> {
|
||||
public class Trends extends TwitterResponseObject implements TwitterResponse, Comparable<Trends>,
|
||||
Parcelable {
|
||||
|
||||
@JsonField(name = "as_of", typeConverter = TwitterTrendsDateConverter.class)
|
||||
Date asOf;
|
||||
|
@ -63,4 +68,26 @@ public class Trends extends TwitterResponseObject implements TwitterResponse, Co
|
|||
public int compareTo(@NonNull Trends another) {
|
||||
return asOf.compareTo(another.getAsOf());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
TrendsParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<Trends> CREATOR = new Creator<Trends>() {
|
||||
public Trends createFromParcel(Parcel source) {
|
||||
Trends target = new Trends();
|
||||
TrendsParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public Trends[] newArray(int size) {
|
||||
return new Trends[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ import java.util.Date;
|
|||
*/
|
||||
@ParcelablePlease
|
||||
@JsonObject
|
||||
public class UserList extends TwitterResponseObject implements Comparable<UserList>, TwitterResponse, Parcelable {
|
||||
public class UserList extends TwitterResponseObject implements Comparable<UserList>, TwitterResponse,
|
||||
Parcelable {
|
||||
@JsonField(name = "id")
|
||||
String id;
|
||||
|
||||
|
|
|
@ -1,157 +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.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.LoadMoreSupportAdapter;
|
||||
import org.mariotaku.microblog.library.twitter.model.ScheduledStatus;
|
||||
import org.mariotaku.twidere.loader.ScheduledStatusesLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/7/10.
|
||||
*/
|
||||
public class ScheduledStatusesFragment extends AbsContentListRecyclerViewFragment<ScheduledStatusesFragment.ScheduledStatusesAdapter>
|
||||
implements LoaderManager.LoaderCallbacks<List<ScheduledStatus>> {
|
||||
|
||||
@Override
|
||||
public boolean isRefreshing() {
|
||||
if (getContext() == null || isDetached()) return false;
|
||||
return getLoaderManager().hasRunningLoaders();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ScheduledStatusesAdapter onCreateAdapter(Context context, boolean compact) {
|
||||
return new ScheduledStatusesAdapter(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<List<ScheduledStatus>> onCreateLoader(int id, Bundle args) {
|
||||
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String[] states = {ScheduledStatus.State.SCHEDULED, ScheduledStatus.State.FAILED};
|
||||
return new ScheduledStatusesLoader(getActivity(), accountKey, sinceId, maxId, states, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<List<ScheduledStatus>> loader, List<ScheduledStatus> data) {
|
||||
getAdapter().setData(data);
|
||||
showContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final Bundle args = getArguments();
|
||||
final Bundle loaderArgs = new Bundle();
|
||||
loaderArgs.putParcelable(EXTRA_ACCOUNT_KEY, args.getParcelable(EXTRA_ACCOUNT_KEY));
|
||||
getLoaderManager().initLoader(0, loaderArgs, this);
|
||||
showProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<List<ScheduledStatus>> loader) {
|
||||
getAdapter().setData(null);
|
||||
}
|
||||
|
||||
public static class ScheduledStatusesAdapter extends LoadMoreSupportAdapter<RecyclerView.ViewHolder> {
|
||||
public static final int ITEM_VIEW_TYPE_SCHEDULED_STATUS = 2;
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
private List<ScheduledStatus> mData;
|
||||
|
||||
public ScheduledStatusesAdapter(Context context) {
|
||||
super(context);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
setLoadMoreSupportedPosition(IndicatorPosition.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
switch (viewType) {
|
||||
case ITEM_VIEW_TYPE_SCHEDULED_STATUS: {
|
||||
return new ScheduledStatusViewHolder(mInflater.inflate(R.layout.list_item_scheduled_status, parent, false));
|
||||
}
|
||||
case ITEM_VIEW_TYPE_LOAD_INDICATOR: {
|
||||
return new LoadIndicatorViewHolder(mInflater.inflate(R.layout.card_item_load_indicator, parent, false));
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return ITEM_VIEW_TYPE_SCHEDULED_STATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (holder.getItemViewType()) {
|
||||
case ITEM_VIEW_TYPE_SCHEDULED_STATUS: {
|
||||
((ScheduledStatusViewHolder) holder).displayScheduledStatus(mData.get(position));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mData == null) return 0;
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
public void setData(List<ScheduledStatus> data) {
|
||||
mData = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ScheduledStatusViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView textView;
|
||||
|
||||
public ScheduledStatusViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
textView = (TextView) itemView.findViewById(R.id.text);
|
||||
}
|
||||
|
||||
public void displayScheduledStatus(ScheduledStatus status) {
|
||||
textView.setText(status.getText());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +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.loader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.microblog.library.twitter.model.ScheduledStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.util.MicroBlogAPIFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/7/10.
|
||||
*/
|
||||
public class ScheduledStatusesLoader extends AsyncTaskLoader<List<ScheduledStatus>> {
|
||||
|
||||
private final UserKey mAccountId;
|
||||
private final String mSinceId;
|
||||
private final String mMaxId;
|
||||
@ScheduledStatus.State
|
||||
private final String[] mStates;
|
||||
|
||||
public ScheduledStatusesLoader(Context context, UserKey accountId, String sinceId, String maxId,
|
||||
@ScheduledStatus.State String[] states, List<ScheduledStatus> data) {
|
||||
super(context);
|
||||
mAccountId = accountId;
|
||||
mSinceId = sinceId;
|
||||
mMaxId = maxId;
|
||||
mStates = states;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ScheduledStatus> loadInBackground() {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getTwitterInstance(getContext(), mAccountId, true);
|
||||
if (twitter == null) return null;
|
||||
final Paging paging = new Paging();
|
||||
if (mSinceId != null) {
|
||||
paging.setSinceId(mSinceId);
|
||||
}
|
||||
if (mMaxId != null) {
|
||||
paging.setMaxId(mMaxId);
|
||||
}
|
||||
try {
|
||||
return twitter.getScheduledStatuses(paging, mStates);
|
||||
} catch (MicroBlogException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
|
@ -138,7 +138,6 @@ import org.mariotaku.twidere.fragment.MessagesConversationFragment;
|
|||
import org.mariotaku.twidere.fragment.MutesUsersListFragment;
|
||||
import org.mariotaku.twidere.fragment.PublicTimelineFragment;
|
||||
import org.mariotaku.twidere.fragment.SavedSearchesListFragment;
|
||||
import org.mariotaku.twidere.fragment.ScheduledStatusesFragment;
|
||||
import org.mariotaku.twidere.fragment.SearchFragment;
|
||||
import org.mariotaku.twidere.fragment.StatusFavoritersListFragment;
|
||||
import org.mariotaku.twidere.fragment.StatusFragment;
|
||||
|
@ -600,10 +599,6 @@ public final class Utils implements Constants {
|
|||
fragment = new MutesUsersListFragment();
|
||||
break;
|
||||
}
|
||||
case LINK_ID_SCHEDULED_STATUSES: {
|
||||
fragment = new ScheduledStatusesFragment();
|
||||
break;
|
||||
}
|
||||
case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
|
||||
fragment = new MessagesConversationFragment();
|
||||
isAccountIdRequired = false;
|
||||
|
|
Loading…
Reference in New Issue