diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableLocation.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableLocation.java index 6a8bac70b..5b3478958 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableLocation.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableLocation.java @@ -29,14 +29,10 @@ import com.bluelinelabs.logansquare.annotation.JsonObject; import org.mariotaku.twidere.util.ParseUtils; -import java.io.Serializable; - import twitter4j.GeoLocation; @JsonObject -public class ParcelableLocation implements Serializable, Parcelable { - - private static final long serialVersionUID = -1690848439775407442L; +public class ParcelableLocation implements Parcelable { @JsonField(name = "latitude") public double latitude; diff --git a/twidere.component.twitter4j/src/main/java/org/mariotaku/simplerestapi/http/SimpleValueMap.java b/twidere.component.twitter4j/src/main/java/org/mariotaku/simplerestapi/http/SimpleValueMap.java new file mode 100644 index 000000000..ab89fac66 --- /dev/null +++ b/twidere.component.twitter4j/src/main/java/org/mariotaku/simplerestapi/http/SimpleValueMap.java @@ -0,0 +1,52 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.simplerestapi.http; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by mariotaku on 15/5/8. + */ +public class SimpleValueMap implements ValueMap { + + private final Map internalMap = new HashMap<>(); + + @Override + public boolean has(String key) { + return internalMap.containsKey(key); + } + + @Override + public Object get(String key) { + return internalMap.get(key); + } + + protected void put(String key, Object value) { + internalMap.put(key, value); + } + + @Override + public String[] keys() { + final Set keySet = internalMap.keySet(); + return keySet.toArray(new String[keySet.size()]); + } +} diff --git a/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/TwitterConverter.java b/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/TwitterConverter.java index eee3063ff..53f845e73 100644 --- a/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/TwitterConverter.java +++ b/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/TwitterConverter.java @@ -22,6 +22,7 @@ package org.mariotaku.twidere.api.twitter; import com.bluelinelabs.logansquare.LoganSquare; import com.bluelinelabs.logansquare.typeconverters.TypeConverter; import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import org.mariotaku.simplerestapi.Converter; @@ -63,6 +64,7 @@ import java.lang.reflect.Type; import java.nio.charset.Charset; import java.text.ParseException; import java.util.HashMap; +import java.util.List; import java.util.Map; import twitter4j.CardEntity; @@ -124,14 +126,13 @@ public class TwitterConverter implements Converter { registerWrapper(PageableResponseList.class, PageableResponseListWrapper.class); registerWrapper(Relationship.class, RelationshipWrapper.class); registerWrapper(CardEntity.BindingValue.class, CardEntityImpl.BindingValueWrapper.class); -// TypeConverterMapper.register(DirectMessage.class, DirectMessageImpl.class); } @Override public Object convert(RestResponse response, Type type) throws Exception { final TypedData body = response.getBody(); if (!response.isSuccessful()) { - throw LoganSquare.parse(body.stream(), TwitterException.class); + throw parseOrThrow(response, body.stream(), TwitterException.class); } final ContentType contentType = body.contentType(); final InputStream stream = body.stream(); @@ -139,7 +140,7 @@ public class TwitterConverter implements Converter { final Class cls = (Class) type; final Class wrapperCls = wrapperMap.get(cls); if (wrapperCls != null) { - final Wrapper wrapper = (Wrapper) LoganSquare.parse(stream, wrapperCls); + final Wrapper wrapper = (Wrapper) parseOrThrow(response, stream, wrapperCls); wrapper.processResponseHeader(response); return wrapper.getWrapped(null); } else if (OAuthToken.class.isAssignableFrom(cls)) { @@ -155,7 +156,7 @@ public class TwitterConverter implements Converter { throw new IOException(e); } } - final Object object = LoganSquare.parse(stream, cls); + final Object object = parseOrThrow(response, stream, cls); checkResponse(cls, object, response); if (object instanceof TwitterResponseImpl) { ((TwitterResponseImpl) object).processResponseHeader(response); @@ -167,12 +168,12 @@ public class TwitterConverter implements Converter { final Class rawClass = (Class) rawType; final Class wrapperCls = wrapperMap.get(rawClass); if (wrapperCls != null) { - final Wrapper wrapper = (Wrapper) LoganSquare.parse(stream, wrapperCls); + final Wrapper wrapper = (Wrapper) parseOrThrow(response, stream, wrapperCls); wrapper.processResponseHeader(response); return wrapper.getWrapped(((ParameterizedType) type).getActualTypeArguments()); } else if (ResponseList.class.isAssignableFrom(rawClass)) { final Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0]; - final ResponseListImpl responseList = new ResponseListImpl<>(LoganSquare.parseList(stream, (Class) elementType)); + final ResponseListImpl responseList = new ResponseListImpl<>(parseListOrThrow(response, stream, (Class) elementType)); responseList.processResponseHeader(response); return responseList; } @@ -181,6 +182,22 @@ public class TwitterConverter implements Converter { throw new UnsupportedTypeException(type); } + private static T parseOrThrow(RestResponse resp, InputStream stream, Class cls) throws IOException, TwitterException { + try { + return LoganSquare.parse(stream, cls); + } catch (JsonParseException e) { + throw new TwitterException("Malformed JSON Data", resp); + } + } + + private static List parseListOrThrow(RestResponse resp, InputStream stream, Class elementCls) throws IOException, TwitterException { + try { + return LoganSquare.parseList(stream, elementCls); + } catch (JsonParseException e) { + throw new TwitterException("Malformed JSON Data", resp); + } + } + private void checkResponse(Class cls, Object object, RestResponse response) throws TwitterException { if (User.class.isAssignableFrom(cls)) { if (object == null) throw new TwitterException("User is null"); diff --git a/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/RateLimitStatusJSONImpl.java b/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/RateLimitStatusJSONImpl.java index f2d7bb73d..0d3eacde8 100644 --- a/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/RateLimitStatusJSONImpl.java +++ b/twidere.component.twitter4j/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/RateLimitStatusJSONImpl.java @@ -34,9 +34,7 @@ import twitter4j.RateLimitStatus; * Twitter Developers */ @JsonObject -final class RateLimitStatusJSONImpl implements RateLimitStatus, java.io.Serializable { - - private static final long serialVersionUID = 1625565652687304084L; +final class RateLimitStatusJSONImpl implements RateLimitStatus { private final long creationTimeInMillis; diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/AccountSettings.java b/twidere.component.twitter4j/src/main/java/twitter4j/AccountSettings.java index f9328ba18..a2499bcf6 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/AccountSettings.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/AccountSettings.java @@ -22,7 +22,7 @@ import java.io.Serializable; * @author Yusuke Yamamoto - yusuke at mac.com * @since Twitter4J 2.1.9 */ -public interface AccountSettings extends TwitterResponse, Serializable { +public interface AccountSettings extends TwitterResponse { /** * Returns the language used to render Twitter's UII for this user. * diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/Activity.java b/twidere.component.twitter4j/src/main/java/twitter4j/Activity.java index e00e28e3b..f2ad7d909 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/Activity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/Activity.java @@ -1,37 +1,36 @@ package twitter4j; -import java.io.Serializable; import java.util.Date; -public interface Activity extends TwitterResponse, Comparable, Serializable { +public interface Activity extends TwitterResponse, Comparable { - public Action getAction(); + Action getAction(); - public Date getCreatedAt(); + Date getCreatedAt(); - public long getMaxPosition(); + long getMaxPosition(); - public long getMinPosition(); + long getMinPosition(); - public User[] getSources(); + User[] getSources(); - public int getSourcesSize(); + int getSourcesSize(); - public int getTargetObjectsSize(); + int getTargetObjectsSize(); - public Status[] getTargetObjectStatuses(); + Status[] getTargetObjectStatuses(); - public UserList[] getTargetObjectUserLists(); + UserList[] getTargetObjectUserLists(); - public int getTargetsSize(); + int getTargetsSize(); - public Status[] getTargetStatuses(); + Status[] getTargetStatuses(); - public UserList[] getTargetUserLists(); + UserList[] getTargetUserLists(); - public User[] getTargetUsers(); + User[] getTargetUsers(); - public static enum Action implements Serializable { + enum Action { FAVORITE(0x1), FOLLOW(0x2), MENTION(0x3), REPLY(0x4), RETWEET(0x5), LIST_MEMBER_ADDED(0x06), LIST_CREATED(0x07), FAVORITED_RETWEET(0x08), RETWEETED_RETWEET(0x09); diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/CardEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/CardEntity.java index e7290d7dd..958df0f5f 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/CardEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/CardEntity.java @@ -19,13 +19,12 @@ package twitter4j; -import java.io.Serializable; import java.util.Map; /** * Created by mariotaku on 14/12/31. */ -public interface CardEntity extends Serializable { +public interface CardEntity { String getName(); @@ -37,7 +36,7 @@ public interface CardEntity extends Serializable { Map getBindingValues(); - interface BindingValue extends Serializable { + interface BindingValue { String TYPE_STRING = "STRING"; String TYPE_IMAGE = "IMAGE"; diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/EntitySupport.java b/twidere.component.twitter4j/src/main/java/twitter4j/EntitySupport.java index ee0ce0fc3..1792c0f55 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/EntitySupport.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/EntitySupport.java @@ -22,7 +22,7 @@ import java.io.Serializable; * @author Yusuke Yamamoto - yusuke at mac.com * @since Twitter4J 2.2.5 */ -public interface EntitySupport extends Serializable { +public interface EntitySupport { /** * Returns an array if hashtag mentioned in the tweet, or null if no hashtag * were mentioned. diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/GeoLocation.java b/twidere.component.twitter4j/src/main/java/twitter4j/GeoLocation.java index 4e3524b30..0cd54f575 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/GeoLocation.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/GeoLocation.java @@ -24,19 +24,13 @@ import com.fasterxml.jackson.core.JsonParser; import org.mariotaku.twidere.api.twitter.model.impl.GeoPoint; import java.io.IOException; -import java.io.Serializable; /** * A data class representing geo location. * * @author Yusuke Yamamoto - yusuke at mac.com */ -public class GeoLocation implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4603460402828968366L; +public class GeoLocation { public static final TypeConverter CONVERTER = new TypeConverter() { @Override diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/HashtagEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/HashtagEntity.java index 23ed2c1bb..86a8a41b1 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/HashtagEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/HashtagEntity.java @@ -24,7 +24,7 @@ import java.io.Serializable; * @author Yusuke Yamamoto - yusuke at mac.com * @since Twitter4J 2.1.9 */ -public interface HashtagEntity extends Serializable { +public interface HashtagEntity { /** * Returns the index of the end character of the hashtag. * diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java index 6ce836177..7326d2982 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java @@ -6,7 +6,7 @@ import java.io.Serializable; import java.util.Map; -public interface MediaEntity extends UrlEntity, Serializable { +public interface MediaEntity extends UrlEntity { long getId(); @@ -41,7 +41,7 @@ public interface MediaEntity extends UrlEntity, Serializable { VideoInfo getVideoInfo(); - interface VideoInfo extends Serializable { + interface VideoInfo { Variant[] getVariants(); @@ -49,7 +49,7 @@ public interface MediaEntity extends UrlEntity, Serializable { long getDuration(); - interface Variant extends Serializable { + interface Variant { String getContentType(); @@ -60,7 +60,7 @@ public interface MediaEntity extends UrlEntity, Serializable { } - interface Size extends Serializable { + interface Size { String THUMB = "thumb"; String SMALL = "small"; String MEDIUM = "medium"; diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/ResponseList.java b/twidere.component.twitter4j/src/main/java/twitter4j/ResponseList.java index 4a463afdd..b32ed8ea1 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/ResponseList.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/ResponseList.java @@ -16,7 +16,6 @@ package twitter4j; -import java.io.Serializable; import java.util.List; /** @@ -24,12 +23,12 @@ import java.util.List; * * @author Yusuke Yamamoto - yusuke at mac.com */ -public interface ResponseList extends TwitterResponse, List, Serializable { +public interface ResponseList extends TwitterResponse, List { - /** - * {@inheritDoc} - */ - @Override - public RateLimitStatus getRateLimitStatus(); + /** + * {@inheritDoc} + */ + @Override + public RateLimitStatus getRateLimitStatus(); } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/SearchQuery.java b/twidere.component.twitter4j/src/main/java/twitter4j/SearchQuery.java index 431070af5..58fc21806 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/SearchQuery.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/SearchQuery.java @@ -38,7 +38,7 @@ public final class SearchQuery implements ValueMap { private String lang = null; private String locale = null; private long maxId = -1l; - private int rpp = -1; + private int count = -1; private int page = -1; private String since = null; private long sinceId = -1; @@ -77,7 +77,7 @@ public final class SearchQuery implements ValueMap { if (maxId != query1.maxId) return false; if (page != query1.page) return false; - if (rpp != query1.rpp) return false; + if (count != query1.count) return false; if (sinceId != query1.sinceId) return false; if (geocode != null ? !geocode.equals(query1.geocode) : query1.geocode != null) return false; @@ -180,10 +180,10 @@ public final class SearchQuery implements ValueMap { /** * Returns the number of tweets to return per page, up to a max of 100 * - * @return rpp + * @return count */ - public int getRpp() { - return rpp; + public int getCount() { + return count; } /** @@ -222,7 +222,7 @@ public final class SearchQuery implements ValueMap { result = 31 * result + (lang != null ? lang.hashCode() : 0); result = 31 * result + (locale != null ? locale.hashCode() : 0); result = 31 * result + (int) (maxId ^ maxId >>> 32); - result = 31 * result + rpp; + result = 31 * result + count; result = 31 * result + page; result = 31 * result + (since != null ? since.hashCode() : 0); result = 31 * result + (int) (sinceId ^ sinceId >>> 32); @@ -322,7 +322,7 @@ public final class SearchQuery implements ValueMap { * @since Twitter4J 2.1.0 */ public SearchQuery rpp(final int rpp) { - setRpp(rpp); + setCount(rpp); return this; } @@ -408,10 +408,10 @@ public final class SearchQuery implements ValueMap { /** * sets the number of tweets to return per page, up to a max of 100 * - * @param rpp the number of tweets to return per page + * @param count the number of tweets to return per page */ - public void setRpp(final int rpp) { - this.rpp = rpp; + public void setCount(final int count) { + this.count = count; } /** @@ -473,7 +473,7 @@ public final class SearchQuery implements ValueMap { @Override public String toString() { return "Query{" + "query='" + query + '\'' + ", lang='" + lang + '\'' + ", locale='" + locale + '\'' - + ", maxId=" + maxId + ", rpp=" + rpp + ", page=" + page + ", since='" + since + '\'' + ", sinceId=" + + ", maxId=" + maxId + ", count=" + count + ", page=" + page + ", since='" + since + '\'' + ", sinceId=" + sinceId + ", geocode='" + geocode + '\'' + ", until='" + until + '\'' + ", resultType='" + resultType + '\'' + '}'; } @@ -509,8 +509,8 @@ public final class SearchQuery implements ValueMap { case "since_id": { return sinceId != -1; } - case "rpp": { - return rpp != -1; + case "count": { + return count != -1; } case "page": { return page != -1; @@ -551,9 +551,9 @@ public final class SearchQuery implements ValueMap { if (sinceId == -1) return null; return String.valueOf(sinceId); } - case "rpp": { - if (rpp == -1) return null; - return String.valueOf(rpp); + case "count": { + if (count == -1) return null; + return String.valueOf(count); } case "page": { if (page == -1) return null; @@ -577,7 +577,7 @@ public final class SearchQuery implements ValueMap { @Override public String[] keys() { - return new String[]{"q", "lang", "locale", "max_id", "since_id", "rpp", "page", "since", + return new String[]{"q", "lang", "locale", "max_id", "since_id", "count", "page", "since", "until", "geocode", "result_type"}; } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/SettingsUpdate.java b/twidere.component.twitter4j/src/main/java/twitter4j/SettingsUpdate.java index e2cf5fbce..38b8192fb 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/SettingsUpdate.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/SettingsUpdate.java @@ -19,76 +19,55 @@ package twitter4j; -import org.mariotaku.simplerestapi.http.ValueMap; - -import java.util.HashMap; -import java.util.Set; +import org.mariotaku.simplerestapi.http.SimpleValueMap; /** * Created by mariotaku on 15/1/6. */ -public class SettingsUpdate implements ValueMap { +public class SettingsUpdate extends SimpleValueMap { - private final HashMap settingsMap = new HashMap<>(); - - public void set(String key, boolean value) { - set(key, String.valueOf(value)); + public void put(String key, boolean value) { + super.put(key, String.valueOf(value)); } - public void set(String key, int value) { - set(key, String.valueOf(value)); + public void put(String key, int value) { + super.put(key, String.valueOf(value)); } - public void set(String key, String value) { - settingsMap.put(key, value); + public void put(String key, String value) { + super.put(key, value); } public void setTrendLocationWoeid(int woeid) { - set("trend_location_woeid", woeid); + put("trend_location_woeid", woeid); } public void setSleepTimeEnabled(boolean enabled) { - set("sleep_time_enabled", enabled); + put("sleep_time_enabled", enabled); } public void setStartSleepTime(int startSleepTime) { - set("start_sleep_time", startSleepTime); + put("start_sleep_time", startSleepTime); } public void setEndSleepTime(int endSleepTime) { - set("end_sleep_time", endSleepTime); + put("end_sleep_time", endSleepTime); } public void setTimezone(String timezone) { - set("time_zone", timezone); + put("time_zone", timezone); } public void setProtected(boolean userProtected) { - set("protected", userProtected); + put("protected", userProtected); } public void setLang(String lang) { - set("lang", lang); + put("lang", lang); } public void setScreenName(String screenName) { - set("screen_name", screenName); + put("screen_name", screenName); } - - @Override - public boolean has(String key) { - return settingsMap.containsKey(key); - } - - @Override - public String get(String key) { - return settingsMap.get(key); - } - - @Override - public String[] keys() { - final Set keySet = settingsMap.keySet(); - return keySet.toArray(new String[keySet.size()]); - } } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/Status.java b/twidere.component.twitter4j/src/main/java/twitter4j/Status.java index 4d01d5dcd..7459a55f8 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/Status.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/Status.java @@ -24,7 +24,7 @@ import java.util.Date; * * @author Yusuke Yamamoto - yusuke at mac.com */ -public interface Status extends Comparable, TwitterResponse, ExtendedEntitySupport, Serializable { +public interface Status extends Comparable, TwitterResponse, ExtendedEntitySupport { /** * Returns an array of contributors, or null if no contributor is associated diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterAPIConfiguration.java b/twidere.component.twitter4j/src/main/java/twitter4j/TwitterAPIConfiguration.java index 204ace02c..2d5649bed 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterAPIConfiguration.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/TwitterAPIConfiguration.java @@ -23,7 +23,7 @@ import java.util.Map; * @author Yusuke Yamamoto - yusuke at mac.com * @since Twitter4J 2.2.3 */ -public interface TwitterAPIConfiguration extends TwitterResponse, Serializable { +public interface TwitterAPIConfiguration extends TwitterResponse { int getCharactersReservedPerMedia(); int getMaxMediaPerUpload(); diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterResponse.java b/twidere.component.twitter4j/src/main/java/twitter4j/TwitterResponse.java index db9be01bf..b44cf884b 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterResponse.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/TwitterResponse.java @@ -32,7 +32,7 @@ import java.io.Serializable; * @see twitter4j.Status * @see User */ -public interface TwitterResponse extends Serializable { +public interface TwitterResponse { int NONE = 0; int READ = 1; diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/UrlEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/UrlEntity.java index 7273e937e..ce8f929c1 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/UrlEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/UrlEntity.java @@ -25,7 +25,7 @@ import java.net.URL; * @author Mocel - mocel at guma.jp * @since Twitter4J 2.1.9 */ -public interface UrlEntity extends Serializable { +public interface UrlEntity { /** * Returns the display URL if mentioned URL is shorten. diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/User.java b/twidere.component.twitter4j/src/main/java/twitter4j/User.java index e0492c114..079c1c1f0 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/User.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/User.java @@ -24,7 +24,7 @@ import java.util.Date; * * @author Yusuke Yamamoto - yusuke at mac.com */ -public interface User extends Comparable, TwitterResponse, Serializable { +public interface User extends Comparable, TwitterResponse { Date getCreatedAt(); boolean isDefaultProfile(); diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/UserList.java b/twidere.component.twitter4j/src/main/java/twitter4j/UserList.java index 3bbeaf881..2b29f4d27 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/UserList.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/UserList.java @@ -16,10 +16,9 @@ package twitter4j; -import java.io.Serializable; import java.util.Date; -public interface UserList extends Comparable, TwitterResponse, Serializable { +public interface UserList extends Comparable, TwitterResponse { Mode getMode(); String getDescription(); diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterBase.java b/twidere.component.twitter4j/src/main/java/twitter4j/UserListUpdate.java similarity index 61% rename from twidere.component.twitter4j/src/main/java/twitter4j/TwitterBase.java rename to twidere.component.twitter4j/src/main/java/twitter4j/UserListUpdate.java index ebd449aa6..5e8c89c3a 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/TwitterBase.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/UserListUpdate.java @@ -1,5 +1,5 @@ /* - * Twidere - Twitter client for Android + * Twidere - Twitter client for Android * * Copyright (C) 2012-2015 Mariotaku Lee * @@ -19,14 +19,22 @@ package twitter4j; -import org.mariotaku.simplerestapi.http.Authorization; - -import twitter4j.conf.Configuration; +import org.mariotaku.simplerestapi.http.SimpleValueMap; /** - * @author Yusuke Yamamoto - yusuke at mac.com - * @since Twitter4J 2.2.0 + * Created by mariotaku on 15/5/8. */ -public interface TwitterBase extends TwitterOAuth{ +public class UserListUpdate extends SimpleValueMap { + public void setDescription(String description) { + put("description", description); + } + + public void setName(String name) { + put("name", name); + } + + public void setPublic(boolean isPublic) { + put("public", String.valueOf(isPublic)); + } } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/UserMentionEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/UserMentionEntity.java index f911ab8c5..eceeeff43 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/UserMentionEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/UserMentionEntity.java @@ -16,47 +16,45 @@ package twitter4j; -import java.io.Serializable; - /** * A data interface representing one single user mention entity. - * + * * @author Yusuke Yamamoto - yusuke at mac.com * @since Twitter4J 2.1.9 */ -public interface UserMentionEntity extends Serializable { - /** - * Returns the index of the end character of the user mention. - * - * @return the index of the end character of the user mention - */ - int getEnd(); +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(); - /** - * Returns the user id mentioned in the status. - * - * @return the user id mentioned in the status - */ - long getId(); + /** + * Returns the user id mentioned in the status. + * + * @return the user id mentioned in the status + */ + long getId(); - /** - * Returns the name mentioned in the status. - * - * @return the name mentioned in the status - */ - String getName(); + /** + * Returns the name mentioned in the status. + * + * @return the name mentioned in the status + */ + String getName(); - /** - * Returns the screen name mentioned in the status. - * - * @return the screen name mentioned in the status - */ - String getScreenName(); + /** + * Returns the screen name mentioned in the status. + * + * @return the screen name mentioned in the status + */ + String getScreenName(); - /** - * Returns the index of the start character of the user mention. - * - * @return the index of the start character of the user mention - */ - int 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(); } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/api/ListsResources.java b/twidere.component.twitter4j/src/main/java/twitter4j/api/ListsResources.java index 1ce68c4f7..aeb89338f 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/api/ListsResources.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/api/ListsResources.java @@ -19,6 +19,10 @@ package twitter4j.api; +import org.mariotaku.simplerestapi.method.GET; +import org.mariotaku.simplerestapi.param.Form; +import org.mariotaku.simplerestapi.param.Query; + import twitter4j.PageableResponseList; import twitter4j.Paging; import twitter4j.ResponseList; @@ -26,116 +30,24 @@ import twitter4j.Status; import twitter4j.TwitterException; import twitter4j.User; import twitter4j.UserList; +import twitter4j.UserListUpdate; /** * @author Joern Huxhorn - jhuxhorn at googlemail.com */ public interface ListsResources { - /** - * Adds a member to a list. The authenticated user must own the list to be - * able to add members to it. Lists are limited to having 500 members.
- * This method calls http://api.twitter.com/1.1/lists/members/create.json - * - * @param listId The id of the list. - * @param userId The id of the user to add as a member of the list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/members/create | Twitter Developers - * @since Twitter4J 2.1.0 - */ UserList addUserListMember(long listId, long userId) throws TwitterException; UserList addUserListMember(long listId, String userScreenName) throws TwitterException; - /** - * Adds multiple members to a list, by specifying a comma-separated list of - * member ids or screen names. The authenticated user must own the list to - * be able to add members to it. Lists are limited to having 500 members, - * and you are limited to adding up to 100 members to a list at a time with - * this method.
- * This method calls - * http://api.twitter.com/1.1/lists/members/create_all.json - * - * @param listId The id of the list. - * @param userIds The array of ids of the user to add as member of the list. - * up to 100 are allowed in a single request. - * @see POST - * lists/members/create_all | Twitter Developers - * @since Twitter4J 2.1.7 - */ UserList addUserListMembers(long listId, long[] userIds) throws TwitterException; - /** - * Adds multiple members to a list, by specifying a comma-separated list of - * member ids or screen names. The authenticated user must own the list to - * be able to add members to it. Lists are limited to having 500 members, - * and you are limited to adding up to 100 members to a list at a time with - * this method.
- * This method calls - * http://api.twitter.com/1.1/lists/members/create_all.json - * - * @param listId The id of the list. - * @param screenNames The array of screen names of the user to add as member - * of the list. up to 100 are allowed in a single request. - * @see POST - * lists/members/create_all | Twitter Developers - * @since Twitter4J 2.1.7 - */ UserList addUserListMembers(long listId, String[] screenNames) throws TwitterException; - /** - * Creates a new list for the authenticated user. Accounts are limited to 20 - * lists.
- * This method calls http://api.twitter.com/1.1/lists/create.json - * - * @param listName The name of the list you are creating. Required. - * @param isPublicList set true if you wish to make a public list - * @param description The description of the list you are creating. - * Optional. - * @return the list that was created - * @throws twitter4j.TwitterException when Twitter service or network is - * unavailable, or the authenticated user already has 20 - * lists(TwitterException.getStatusCode() == 403). - * @see POST - * lists/create | Twitter Developers - * @since Twitter4J 2.1.0 - */ UserList createUserList(String listName, boolean isPublicList, String description) throws TwitterException; - /** - * Make the authenticated user follow the specified list.
- * This method calls http://api.twitter.com/1.1/list/subscribers/create.json - * - * @param listId The id of the list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/subscribers/create | Twitter Developers - * @since Twitter4J 2.2.3 - */ UserList createUserListSubscription(long listId) throws TwitterException; - /** - * Removes the specified member from the list. The authenticated user must - * be the list's owner to remove members from the list.
- * This method calls http://api.twitter.com/1.1/lists/members/destroy.json - * - * @param listId The id of the list. - * @param userId The screen name of the member you wish to remove from the - * list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/members/destroy | Twitter Developers - * @since Twitter4J 2.1.0 - */ UserList deleteUserListMember(long listId, long userId) throws TwitterException; UserList deleteUserListMember(long listId, String screenName) throws TwitterException; @@ -144,49 +56,10 @@ public interface ListsResources { UserList deleteUserListMembers(long listId, String[] screenNames) throws TwitterException; - /** - * Deletes the specified list. Must be owned by the authenticated user.
- * This method calls http://api.twitter.com/1.1/lists/destroy.json - * - * @param listId The id of the list to delete - * @return the deleted list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/destroy | Twitter Developers - * @since Twitter4J 2.1.0 - */ UserList destroyUserList(long listId) throws TwitterException; - /** - * Unsubscribes the authenticated user form the specified list.
- * This method calls http://api.twitter.com/1.1/subscribers/destroy.json - * - * @param listId The id of the list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/subscribers/destroy | Twitter Developers - * @since Twitter4J 2.2.3 - */ UserList destroyUserListSubscription(long listId) throws TwitterException; - /** - * Returns the members of the specified list.
- * This method calls http://api.twitter.com/1.1/lists/members.json - * - * @param listId The id of the list - * @param paging Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the members of the specified list. - * @throws TwitterException when Twitter service or network is unavailable - * @see GET - * lists/members | Twitter Developers - * @since Twitter4J 2.2.3 - */ PageableResponseList getUserListMembers(long listId, Paging paging) throws TwitterException; PageableResponseList getUserListMembers(String slug, long ownerId, Paging paging) @@ -195,106 +68,16 @@ public interface ListsResources { PageableResponseList getUserListMembers(String slug, String ownerScreenName, Paging paging) throws TwitterException; - /** - * List the lists the authenticating user has been added to.
- * This method calls http://api.twitter.com/1.1/lists/memberships.json - * - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @throws IllegalStateException when authorization is not enabled - * @see GET - * lists/memberships | Twitter Developers - * @since Twitter4J 2.2.4 - */ PageableResponseList getUserListMemberships(long cursor) throws TwitterException; - /** - * List the lists the specified user has been added to.
- * This method calls http://api.twitter.com/1.1/lists/memberships.json - * - * @param listMemberId The id of the list member - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @see GET - * lists/memberships | Twitter Developers - * @since Twitter4J 2.2.4 - */ PageableResponseList getUserListMemberships(long listMemberId, long cursor) throws TwitterException; - /** - * List the lists the specified user has been added to.
- * This method calls http://api.twitter.com/1.1/lists/memberships.json - * - * @param listMemberId The id of the list member - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @param filterToOwnedLists Whether to return just lists the authenticating - * user owns, and the user represented by listMemberId is a - * member of. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @throws IllegalStateException when filerToOwnedLists is true but - * authorization is not enabled - * @see GET - * lists/memberships | Twitter Developers - * @since Twitter4J 2.2.4 - */ PageableResponseList getUserListMemberships(long listMemberId, long cursor, boolean filterToOwnedLists) throws TwitterException; - /** - * List the lists the specified user has been added to.
- * This method calls http://api.twitter.com/1.1/lists/memberships.json - * - * @param listMemberScreenName The screen name of the list member - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @see GET - * lists/memberships | Twitter Developers - * @since Twitter4J 2.1.0 - */ PageableResponseList getUserListMemberships(String listMemberScreenName, long cursor) throws TwitterException; - /** - * List the lists the specified user has been added to.
- * This method calls http://api.twitter.com/1.1/lists/memberships.json - * - * @param listMemberScreenName The screen name of the list member - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @param filterToOwnedLists Whether to return just lists the authenticating - * user owns, and the user represented by listMemberScreenName is - * a member of. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @throws IllegalStateException when filerToOwnedLists is true but - * authorization is not enabled - * @see GET - * lists/memberships | Twitter Developers - * @since Twitter4J 2.2.4 - */ PageableResponseList getUserListMemberships(String listMemberScreenName, long cursor, boolean filterToOwnedLists) throws TwitterException; @@ -305,175 +88,51 @@ public interface ListsResources { PageableResponseList getUserListOwnerships(String listMemberScreenName, long cursor) throws TwitterException; - /** - * List the lists of the specified user. Private lists will be included if - * the authenticated users is the same as the user whose lists are being - * returned.
- * This method calls http://api.twitter.com/1.1/lists.json - * - * @param userId The id of the list owner - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @see GET lists | - * Twitter Developers - * @since Twitter4J 2.2.3 - */ - ResponseList getUserLists(long userId, boolean reverse) throws TwitterException; + @GET("/lists/list.json") + ResponseList getUserLists(@Query("user_id") long userId, @Query("reverse") boolean reverse) throws TwitterException; - /** - * List the lists of the specified user. Private lists will be included if - * the authenticated users is the same as the user whose lists are being - * returned.
- * This method calls http://api.twitter.com/1.1/lists.json - * - * @param screenName The screen name of the user - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @see GET lists | - * Twitter Developers - * @since Twitter4J 2.1.0 - */ - ResponseList getUserLists(String screenName, boolean reverse) throws TwitterException; + @GET("/lists/list.json") + ResponseList getUserLists(@Query("screen_name") String screenName, @Query("reverse") boolean reverse) throws TwitterException; - /** - * Show tweet timeline for members of the specified list.
- * http://api.twitter.com/1.1/user/lists/list_id/statuses.json - * - * @param listId The id of the list - * @param paging controls pagination. Supports since_id, max_id, count and - * page parameters. - * @return list of statuses for members of the specified list - * @throws TwitterException when Twitter service or network is unavailable - * @see GET - * lists/statuses | Twitter Developers - * @since Twitter4J 2.2.3 - */ - ResponseList getUserListStatuses(long listId, Paging paging) throws TwitterException; + @GET("/lists/statuses.json") + ResponseList getUserListStatuses(@Query("list_id") long listId, @Query Paging paging) throws TwitterException; - ResponseList getUserListStatuses(String slug, long ownerId, Paging paging) throws TwitterException; + @GET("/lists/statuses.json") + ResponseList getUserListStatuses(@Query("list_id") String slug, @Query("owner_id") long ownerId, @Query Paging paging) throws TwitterException; - ResponseList getUserListStatuses(String slug, String ownerScreenName, Paging paging) + @GET("/lists/statuses.json") + ResponseList getUserListStatuses(@Query("list_id") String slug, @Query("owner_screen_name") String ownerScreenName, @Query Paging paging) throws TwitterException; - /** - * Returns the subscribers of the specified list.
- * This method calls http://api.twitter.com/1.1/lists/subscribers.json - * - * @param listId The id of the list - * @param paging Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the members of the specified list. - * @throws twitter4j.TwitterException when Twitter service or network is - * unavailable - * @see GET - * lists/subscribers | Twitter Developers - * @since Twitter4J 2.2.3 - */ - PageableResponseList getUserListSubscribers(long listId, Paging paging) throws TwitterException; + @GET("/lists/subscribers.json") + PageableResponseList getUserListSubscribers(@Query("list_id") long listId, @Query Paging paging) throws TwitterException; - PageableResponseList getUserListSubscribers(String slug, long ownerId, Paging paging) + @GET("/lists/subscribers.json") + PageableResponseList getUserListSubscribers(@Query("list_id") String slug, @Query("owner_id") long ownerId, @Query Paging paging) throws TwitterException; - PageableResponseList getUserListSubscribers(String slug, String ownerScreenName, Paging paging) + @GET("/lists/subscribers.json") + PageableResponseList getUserListSubscribers(@Query("list_id") String slug, @Query("owner_screen_name") String ownerScreenName, @Query Paging paging) throws TwitterException; - /** - * List the lists the specified user follows.
- * This method calls http://api.twitter.com/1.1/lists/subscriptions.json - * - * @param listOwnerScreenName The screen name of the list owner - * @param cursor Breaks the results into pages. A single page contains 20 - * lists. Provide a value of -1 to begin paging. Provide values - * as returned to in the response body's next_cursor and - * previous_cursor attributes to page back and forth in the list. - * @return the list of lists - * @throws TwitterException when Twitter service or network is unavailable - * @see GET - * lists/subscriptions | Twitter Developers - * @since Twitter4J 2.1.0 - */ - PageableResponseList getUserListSubscriptions(String listOwnerScreenName, long cursor) + + @GET("/lists/subscriptions.json") + PageableResponseList getUserListSubscriptions(@Query("screen_name") String listOwnerScreenName, long cursor) + throws TwitterException; + + @GET("/lists/subscriptions.json") + PageableResponseList getUserListSubscriptions(@Query("user_id") long userId, long cursor) throws TwitterException; - /** - * Show the specified list. Private lists will only be shown if the - * authenticated user owns the specified list.
- * This method calls http://api.twitter.com/1.1/lists/show.json - * - * @param listId The id of the list to show - * @return the specified list - * @throws TwitterException when Twitter service or network is unavailable - * @see https://dev.twitter.com/docs/api/1.1/get/lists/show | Twitter Developers - * @since Twitter4J 2.2.3 - */ UserList showUserList(long listId) throws TwitterException; UserList showUserList(String slug, long ownerId) throws TwitterException; UserList showUserList(String slug, String ownerScreenName) throws TwitterException; - /** - * Check if a user is a member of the specified list.
- *
- * This method calls http://api.twitter.com/1.1/lists/members/show.json - * - * @param listId The id of the list. - * @param userId The id of the user who you want to know is a member or not - * of the specified list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable , - * or the user is not a member of the specified - * list(TwitterException.getStatusCode() returns 404 in that - * case.) - * @see GET - * lists/members/show | Twitter Developers - * @since Twitter4J 2.2.3 - */ User showUserListMembership(long listId, long userId) throws TwitterException; - /** - * Check if the specified user is a subscriber of the specified list.
- * This method calls http://api.twitter.com/1.1/lists/subscribers/show.json - * - * @param listId The id of the list. - * @param userId The id of the user who you want to know is a member or not - * of the specified list. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable , - * or the user is not a member of the specified - * list(TwitterException.getStatusCode() returns 404 in that - * case.) - * @see GET - * lists/subscribers/show | Twitter Developers - * @since Twitter4J 2.2.3 - */ User showUserListSubscription(long listId, long userId) throws TwitterException; - /** - * Updates the specified list.
- * This method calls http://api.twitter.com/1.1/lists/update.json - * - * @param listId The id of the list to update. - * @param newListName What you'd like to change the list's name to. - * @param isPublicList Whether your list is public or private. Optional. - * Values can be public or private. Lists are public by default - * if no mode is specified. - * @param newDescription What you'd like to change the list description to. - * @return the updated list - * @throws TwitterException when Twitter service or network is unavailable - * @see POST - * lists/update | Twitter Developers - * @since Twitter4J 2.1.0 - */ - UserList updateUserList(long listId, String newListName, boolean isPublicList, String newDescription) - throws TwitterException; + UserList updateUserList(@Query("list_id") long listId, @Form UserListUpdate update) throws TwitterException; } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java index b5c4c5f95..829e44ae9 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java @@ -83,6 +83,7 @@ import org.mariotaku.twidere.view.TabPagerIndicator; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.UserList; +import twitter4j.UserListUpdate; import static org.mariotaku.twidere.util.MenuUtils.setMenuItemAvailability; import static org.mariotaku.twidere.util.Utils.addIntentToMenu; @@ -474,7 +475,11 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList mDescription = ParseUtils.parseString(mEditDescription.getText()); mIsPublic = mPublicCheckBox.isChecked(); if (mName == null || mName.length() <= 0) return; - mTwitterWrapper.updateUserListDetails(mAccountId, mListId, mIsPublic, mName, mDescription); + final UserListUpdate update = new UserListUpdate(); + update.setPublic(mIsPublic); + update.setName(mName); + update.setDescription(mDescription); + mTwitterWrapper.updateUserListDetails(mAccountId, mListId, update); break; } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/loader/support/TweetSearchLoader.java b/twidere/src/main/java/org/mariotaku/twidere/loader/support/TweetSearchLoader.java index b6dcae061..d8739783b 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/loader/support/TweetSearchLoader.java +++ b/twidere/src/main/java/org/mariotaku/twidere/loader/support/TweetSearchLoader.java @@ -53,7 +53,7 @@ public class TweetSearchLoader extends TwitterAPIStatusesLoader { @Override public List getStatuses(@NonNull final Twitter twitter, final Paging paging) throws TwitterException { final SearchQuery query = new SearchQuery(processQuery(mQuery)); - query.setRpp(paging.getCount()); + query.setCount(paging.getCount()); if (paging.getMaxId() > 0) { query.setMaxId(paging.getMaxId()); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/AsyncTwitterWrapper.java b/twidere/src/main/java/org/mariotaku/twidere/util/AsyncTwitterWrapper.java index acfac484c..fe805d004 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/AsyncTwitterWrapper.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/AsyncTwitterWrapper.java @@ -96,6 +96,7 @@ import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; import twitter4j.UserList; +import twitter4j.UserListUpdate; import twitter4j.http.HttpResponseCode; import static org.mariotaku.twidere.provider.TwidereDataStore.STATUSES_URIS; @@ -107,7 +108,6 @@ import static org.mariotaku.twidere.util.Utils.getDefaultAccountId; import static org.mariotaku.twidere.util.Utils.getNewestMessageIdsFromDatabase; import static org.mariotaku.twidere.util.Utils.getNewestStatusIdsFromDatabase; import static org.mariotaku.twidere.util.Utils.getStatusCountInDatabase; -import static org.mariotaku.twidere.util.TwitterAPIUtils.getTwitterInstance; import static org.mariotaku.twidere.util.Utils.showErrorMessage; import static org.mariotaku.twidere.util.Utils.showInfoMessage; import static org.mariotaku.twidere.util.Utils.showOkMessage; @@ -500,10 +500,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper { return 0; } - public int updateUserListDetails(final long accountId, final long listId, final boolean isPublic, - final String name, final String description) { - final UpdateUserListDetailsTask task = new UpdateUserListDetailsTask(accountId, listId, isPublic, name, - description); + public int updateUserListDetails(final long accountId, final long listId, final UserListUpdate update) { + final UpdateUserListDetailsTask task = new UpdateUserListDetailsTask(accountId, listId, update); return mAsyncTaskManager.add(task, true); } @@ -2522,17 +2520,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper { private final long accountId; private final long listId; - private final boolean isPublic; - private final String name, description; + private final UserListUpdate update; - public UpdateUserListDetailsTask(final long accountId, final long listId, final boolean isPublic, - final String name, final String description) { + public UpdateUserListDetailsTask(final long accountId, final long listId, UserListUpdate update) { super(mContext, mAsyncTaskManager); this.accountId = accountId; this.listId = listId; - this.name = name; - this.isPublic = isPublic; - this.description = description; + this.update = update; } @Override @@ -2541,7 +2535,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper { final Twitter twitter = TwitterAPIUtils.getTwitterInstance(mContext, accountId, false); if (twitter != null) { try { - final UserList list = twitter.updateUserList(listId, name, isPublic, description); + final UserList list = twitter.updateUserList(listId, update); return SingleResponse.getInstance(new ParcelableUserList(list, accountId)); } catch (final TwitterException e) { return SingleResponse.getInstance(e);