implemented some api
This commit is contained in:
parent
3a286bf321
commit
9a9852d394
|
@ -121,6 +121,7 @@ public class TwitterConverter implements Converter {
|
|||
LoganSquare.registerTypeConverter(Indices.class, Indices.CONVERTER);
|
||||
LoganSquare.registerTypeConverter(GeoLocation.class, GeoLocation.CONVERTER);
|
||||
LoganSquare.registerTypeConverter(MediaEntity.Type.class, EnumConverter.get(MediaEntity.Type.class));
|
||||
LoganSquare.registerTypeConverter(UserList.Mode.class, EnumConverter.get(UserList.Mode.class));
|
||||
|
||||
registerWrapper(QueryResult.class, QueryResultWrapper.class);
|
||||
registerWrapper(PageableResponseList.class, PageableResponseListWrapper.class);
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Collection;
|
|||
import twitter4j.PageableResponseList;
|
||||
import twitter4j.Status;
|
||||
import twitter4j.User;
|
||||
import twitter4j.UserList;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/7.
|
||||
|
@ -49,6 +50,9 @@ public class PageableResponseListWrapper extends TwitterResponseImpl implements
|
|||
@JsonField(name = "statuses")
|
||||
ArrayList<Status> statuses;
|
||||
|
||||
@JsonField(name = "user_lists")
|
||||
ArrayList<Status> userLists;
|
||||
|
||||
@Override
|
||||
public PageableResponseList<?> getWrapped(Object extra) {
|
||||
final Type[] typeArgs = (Type[]) extra;
|
||||
|
@ -57,6 +61,8 @@ public class PageableResponseListWrapper extends TwitterResponseImpl implements
|
|||
return new PageableResponseListImpl<>(users);
|
||||
} else if (Status.class.isAssignableFrom(elementType)) {
|
||||
return new PageableResponseListImpl<>(statuses);
|
||||
} else if (UserList.class.isAssignableFrom(elementType)) {
|
||||
return new PageableResponseListImpl<>(userLists);
|
||||
}
|
||||
throw new TwitterConverter.UnsupportedTypeException(elementType);
|
||||
}
|
||||
|
|
|
@ -70,12 +70,15 @@ public interface ListsResources {
|
|||
|
||||
PageableResponseList<UserList> getUserListMemberships(long cursor) throws TwitterException;
|
||||
|
||||
PageableResponseList<UserList> getUserListMemberships(long listMemberId, long cursor) throws TwitterException;
|
||||
@GET("/lists/memberships.json")
|
||||
PageableResponseList<UserList> getUserListMemberships(@Query("user_id") long listMemberId, @Query Paging paging) throws TwitterException;
|
||||
|
||||
PageableResponseList<UserList> getUserListMemberships(long listMemberId, long cursor, boolean filterToOwnedLists)
|
||||
throws TwitterException;
|
||||
@GET("/lists/memberships.json")
|
||||
PageableResponseList<UserList> getUserListMemberships(@Query("user_id") long listMemberId, @Query Paging paging,
|
||||
@Query("filter_to_owned_lists") boolean filterToOwnedLists) throws TwitterException;
|
||||
|
||||
PageableResponseList<UserList> getUserListMemberships(String listMemberScreenName, long cursor)
|
||||
@GET("/lists/memberships.json")
|
||||
PageableResponseList<UserList> getUserListMemberships(@Query("screen_name") String listMemberScreenName, @Query Paging paging)
|
||||
throws TwitterException;
|
||||
|
||||
PageableResponseList<UserList> getUserListMemberships(String listMemberScreenName, long cursor,
|
||||
|
|
|
@ -26,29 +26,32 @@ import org.mariotaku.twidere.model.ParcelableUserList;
|
|||
import java.util.List;
|
||||
|
||||
import twitter4j.PageableResponseList;
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.TwitterException;
|
||||
import twitter4j.UserList;
|
||||
|
||||
public class UserListMembershipsLoader extends BaseUserListsLoader {
|
||||
|
||||
private final long mUserId;
|
||||
private final String mScreenName;
|
||||
private final long mUserId;
|
||||
private final String mScreenName;
|
||||
|
||||
public UserListMembershipsLoader(final Context context, final long account_id, final long user_id,
|
||||
final String screen_name, final long cursor, final List<ParcelableUserList> data) {
|
||||
super(context, account_id, cursor, data);
|
||||
mUserId = user_id;
|
||||
mScreenName = screen_name;
|
||||
}
|
||||
public UserListMembershipsLoader(final Context context, final long account_id, final long user_id,
|
||||
final String screen_name, final long cursor, final List<ParcelableUserList> data) {
|
||||
super(context, account_id, cursor, data);
|
||||
mUserId = user_id;
|
||||
mScreenName = screen_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseList<UserList> getUserLists(final Twitter twitter) throws TwitterException {
|
||||
if (twitter == null) return null;
|
||||
if (mUserId > 0)
|
||||
return twitter.getUserListMemberships(mUserId, getCursor());
|
||||
else if (mScreenName != null) return twitter.getUserListMemberships(mScreenName, getCursor());
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public PageableResponseList<UserList> getUserLists(final Twitter twitter) throws TwitterException {
|
||||
if (twitter == null) return null;
|
||||
final Paging paging = new Paging();
|
||||
paging.cursor(getCursor());
|
||||
if (mUserId > 0)
|
||||
return twitter.getUserListMemberships(mUserId, paging);
|
||||
else if (mScreenName != null) return twitter.getUserListMemberships(mScreenName, paging);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue