abandoning old account code
This commit is contained in:
parent
ddccb2c34b
commit
ccb9ab47ee
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.microblog.library.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MutesUsersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
public MutesUsersLoader(final Context context, @Nullable final UserKey accountKey,
|
||||
@Nullable final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected final PageableResponseList<User> getCursoredUsers(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials, @NonNull final Paging paging)
|
||||
throws MicroBlogException {
|
||||
return twitter.getMutesUsersList(paging);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.IDs;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StatusFavoritersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
private final String mStatusId;
|
||||
|
||||
public StatusFavoritersLoader(final Context context, final UserKey accountKey,
|
||||
final String statusId, final List<ParcelableUser> data,
|
||||
final boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mStatusId = statusId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected IDs getIDs(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials, @NonNull final Paging paging) throws MicroBlogException {
|
||||
return twitter.getStatusActivitySummary(mStatusId).getFavoriters();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useIDs(@NonNull ParcelableCredentials credentials) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.IDs;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StatusRetweetersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
private final String mStatusId;
|
||||
|
||||
public StatusRetweetersLoader(final Context context, final UserKey accountKey,
|
||||
final String statusId, final List<ParcelableUser> data,
|
||||
final boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mStatusId = statusId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected IDs getIDs(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials, @NonNull final Paging paging) throws MicroBlogException {
|
||||
return twitter.getRetweetersIDs(mStatusId, paging);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useIDs(@NonNull ParcelableCredentials credentials) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
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.User;
|
||||
import org.mariotaku.twidere.annotation.AccountType;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserBlocksLoader extends CursorSupportUsersLoader {
|
||||
|
||||
public UserBlocksLoader(final Context context, final UserKey accountKey,
|
||||
final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected final List<User> getCursoredUsers(@NonNull final MicroBlog twitter,
|
||||
@NonNull ParcelableCredentials credentials,
|
||||
@NonNull final Paging paging)
|
||||
throws MicroBlogException {
|
||||
switch (ParcelableAccountUtils.getAccountType(credentials)) {
|
||||
case AccountType.FANFOU: {
|
||||
return twitter.getFanfouBlocking(paging);
|
||||
}
|
||||
}
|
||||
return twitter.getBlocksList(paging);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.microblog.library.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserListMembersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
private final String mListId;
|
||||
private final UserKey mUserKey;
|
||||
private final String mScreenName, mListName;
|
||||
|
||||
public UserListMembersLoader(final Context context, final UserKey accountKey, final String listId,
|
||||
final UserKey userKey, final String screenName, final String listName,
|
||||
final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mListId = listId;
|
||||
mUserKey = userKey;
|
||||
mScreenName = screenName;
|
||||
mListName = listName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PageableResponseList<User> getCursoredUsers(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials, @NonNull final Paging paging)
|
||||
throws MicroBlogException {
|
||||
if (mListId != null)
|
||||
return twitter.getUserListMembers(mListId, paging);
|
||||
else if (mUserKey != null)
|
||||
return twitter.getUserListMembers(mListName.replace(' ', '-'), mUserKey.getId(), paging);
|
||||
else if (mScreenName != null)
|
||||
return twitter.getUserListMembersByScreenName(mListName.replace(' ', '-'), mScreenName, paging);
|
||||
throw new MicroBlogException("list_id or list_name and user_id (or screen_name) required");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
import org.mariotaku.microblog.library.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserListSubscribersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
private final String mListId;
|
||||
private final UserKey mUserKey;
|
||||
private final String mScreenName, mListName;
|
||||
|
||||
public UserListSubscribersLoader(final Context context, final UserKey accountKey, final String listId,
|
||||
final UserKey userKey, final String screenName, final String listName,
|
||||
final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mListId = listId;
|
||||
mUserKey = userKey;
|
||||
mScreenName = screenName;
|
||||
mListName = listName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PageableResponseList<User> getCursoredUsers(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials, @NonNull final Paging paging)
|
||||
throws MicroBlogException {
|
||||
if (mListId != null)
|
||||
return twitter.getUserListSubscribers(mListId, paging);
|
||||
else if (mUserKey != null)
|
||||
return twitter.getUserListSubscribers(mListName.replace(' ', '-'), mUserKey.getId(), paging);
|
||||
else if (mScreenName != null)
|
||||
return twitter.getUserListSubscribersByScreenName(mListName.replace(' ', '-'), mScreenName, paging);
|
||||
throw new MicroBlogException("list_id or list_name and user_id (or screen_name) required");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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.annotation.NonNull;
|
||||
|
||||
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.User;
|
||||
import org.mariotaku.twidere.annotation.AccountType;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserSearchLoader extends TwitterAPIUsersLoader {
|
||||
|
||||
private final String mQuery;
|
||||
private final int mPage;
|
||||
|
||||
public UserSearchLoader(final Context context, final UserKey accountKey, final String query,
|
||||
final int page, final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mQuery = query;
|
||||
mPage = page;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return mPage;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return mQuery;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<User> getUsers(@NonNull final MicroBlog twitter, @NonNull ParcelableCredentials credentials) throws MicroBlogException {
|
||||
final Paging paging = new Paging();
|
||||
paging.page(mPage);
|
||||
switch (ParcelableAccountUtils.getAccountType(credentials)) {
|
||||
case AccountType.FANFOU: {
|
||||
return twitter.searchFanfouUsers(mQuery, paging);
|
||||
}
|
||||
}
|
||||
return twitter.searchUsers(mQuery, paging);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,6 +40,13 @@ public class AccountUtils {
|
|||
return details;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AccountDetails getAccountDetails(@NonNull AccountManager am, @NonNull UserKey accountKey) {
|
||||
final Account account = findByAccountKey(am, accountKey);
|
||||
if (account == null) return null;
|
||||
return getAccountDetails(am, account);
|
||||
}
|
||||
|
||||
public static AccountDetails getAccountDetails(@NonNull AccountManager am, @NonNull Account account) {
|
||||
AccountDetails details = new AccountDetails();
|
||||
details.key = AccountExtensionsKt.getAccountKey(account, am);
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.ParcelableAccount
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils
|
||||
|
||||
class UserFollowersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog, credentials: ParcelableCredentials, paging: Paging): ResponseList<User> {
|
||||
when (ParcelableAccountUtils.getAccountType(credentials)) {
|
||||
AccountType.STATUSNET -> {
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getStatusesFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getStatusesFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getUsersFollowers(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFollowers(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
AccountType.FANFOU -> {
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getUsersFollowers(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFollowers(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (userKey != null) {
|
||||
return twitter.getFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
throw MicroBlogException("user_id or screen_name required")
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.ParcelableAccount
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils
|
||||
|
||||
class UserFriendsLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog,
|
||||
credentials: ParcelableCredentials, paging: Paging): ResponseList<User> {
|
||||
when (ParcelableAccountUtils.getAccountType(credentials)) {
|
||||
AccountType.STATUSNET -> {
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getStatusesFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getStatusesFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getUsersFriends(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFriends(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
AccountType.FANFOU -> {
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getUsersFriends(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFriends(screenName, paging)
|
||||
}
|
||||
}
|
||||
run {
|
||||
if (userKey != null) {
|
||||
return twitter.getFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (userKey != null) {
|
||||
return twitter.getFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
}
|
||||
throw MicroBlogException("user_id or screen_name required")
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ fun Account.getCredentials(am: AccountManager): Credentials {
|
|||
return creds
|
||||
}
|
||||
|
||||
@Credentials.Type
|
||||
fun Account.getCredentialsType(am: AccountManager): String {
|
||||
return am.getUserData(this, ACCOUNT_USER_DATA_CREDS_TYPE) ?: Credentials.Type.OAUTH
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.mariotaku.microblog.library.twitter.model.Paging
|
|||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.loader.iface.ICursorSupportLoader
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
|
@ -72,20 +72,17 @@ abstract class CursorSupportUsersLoader(
|
|||
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
protected open fun getCursoredUsers(twitter: MicroBlog,
|
||||
credentials: ParcelableCredentials,
|
||||
paging: Paging): List<User> {
|
||||
protected open fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): List<User> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
protected open fun getIDs(twitter: MicroBlog, credentials: ParcelableCredentials,
|
||||
paging: Paging): IDs {
|
||||
protected open fun getIDs(twitter: MicroBlog, details: AccountDetails, paging: Paging): IDs {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getUsers(twitter: MicroBlog, credentials: ParcelableCredentials): List<User> {
|
||||
override fun getUsers(twitter: MicroBlog, details: AccountDetails): List<User> {
|
||||
val paging = Paging()
|
||||
paging.count(count)
|
||||
if (cursor > 0) {
|
||||
|
@ -94,12 +91,12 @@ abstract class CursorSupportUsersLoader(
|
|||
paging.setPage(page)
|
||||
}
|
||||
val users: List<User>
|
||||
if (useIDs(credentials)) {
|
||||
val ids = getIDs(twitter, credentials, paging)
|
||||
if (useIDs(details)) {
|
||||
val ids = getIDs(twitter, details, paging)
|
||||
setCursors(ids)
|
||||
users = twitter.lookupUsers(ids.iDs)
|
||||
} else {
|
||||
users = getCursoredUsers(twitter, credentials, paging)
|
||||
users = getCursoredUsers(twitter, details, paging)
|
||||
if (users is CursorSupport) {
|
||||
setCursors(users)
|
||||
}
|
||||
|
@ -108,7 +105,7 @@ abstract class CursorSupportUsersLoader(
|
|||
return users
|
||||
}
|
||||
|
||||
protected open fun useIDs(credentials: ParcelableCredentials): Boolean {
|
||||
protected open fun useIDs(details: AccountDetails): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -20,13 +20,12 @@
|
|||
package org.mariotaku.twidere.loader
|
||||
|
||||
import android.content.Context
|
||||
|
||||
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.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
|
@ -40,7 +39,7 @@ class GroupMembersLoader(
|
|||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
public override fun getCursoredUsers(twitter: MicroBlog, credentials: ParcelableCredentials, paging: Paging): ResponseList<User> {
|
||||
public override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): ResponseList<User> {
|
||||
if (groupId != null)
|
||||
return twitter.getGroupMembers(groupId, paging)
|
||||
else if (groupName != null)
|
|
@ -20,7 +20,6 @@
|
|||
package org.mariotaku.twidere.loader
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.IDs
|
||||
|
@ -28,10 +27,9 @@ import org.mariotaku.microblog.library.twitter.model.Paging
|
|||
import org.mariotaku.microblog.library.twitter.model.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils
|
||||
|
||||
class IncomingFriendshipsLoader(
|
||||
context: Context,
|
||||
|
@ -41,17 +39,17 @@ class IncomingFriendshipsLoader(
|
|||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getIDs(twitter: MicroBlog, credentials: ParcelableCredentials, paging: Paging): IDs {
|
||||
override fun getIDs(twitter: MicroBlog, details: AccountDetails, paging: Paging): IDs {
|
||||
return twitter.getIncomingFriendships(paging)
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog, credentials: ParcelableCredentials, paging: Paging): ResponseList<User> {
|
||||
override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): ResponseList<User> {
|
||||
return twitter.getFriendshipsRequests(paging)
|
||||
}
|
||||
|
||||
override fun useIDs(credentials: ParcelableCredentials): Boolean {
|
||||
when (ParcelableAccountUtils.getAccountType(credentials)) {
|
||||
override fun useIDs(details: AccountDetails): Boolean {
|
||||
when (details.type) {
|
||||
AccountType.FANFOU -> {
|
||||
return false
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class MutesUsersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): PageableResponseList<User> {
|
||||
return twitter.getMutesUsersList(paging)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.IDs
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class StatusFavoritersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
private val statusId: String,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getIDs(twitter: MicroBlog, details: AccountDetails, paging: Paging): IDs {
|
||||
return twitter.getStatusActivitySummary(statusId).favoriters
|
||||
}
|
||||
|
||||
override fun useIDs(details: AccountDetails): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.IDs
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class StatusRetweetersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
private val statusId: String,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getIDs(twitter: MicroBlog, details: AccountDetails, paging: Paging): IDs {
|
||||
return twitter.getRetweetersIDs(statusId, paging)
|
||||
}
|
||||
|
||||
override fun useIDs(details: AccountDetails): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -19,19 +19,20 @@
|
|||
|
||||
package org.mariotaku.twidere.loader
|
||||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.TwidereConstants
|
||||
import org.mariotaku.twidere.extension.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ListResponse
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserUtils
|
||||
import org.mariotaku.twidere.util.MicroBlogAPIFactory
|
||||
import java.util.*
|
||||
|
||||
abstract class TwitterAPIUsersLoader(
|
||||
|
@ -45,14 +46,14 @@ abstract class TwitterAPIUsersLoader(
|
|||
if (accountKey == null) {
|
||||
return ListResponse.getListInstance<ParcelableUser>(MicroBlogException("No Account"))
|
||||
}
|
||||
val credentials = ParcelableCredentialsUtils.getCredentials(context,
|
||||
accountKey) ?: return ListResponse.getListInstance<ParcelableUser>(MicroBlogException("No Account"))
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, credentials, true,
|
||||
true) ?: return ListResponse.getListInstance<ParcelableUser>(MicroBlogException("No Account"))
|
||||
val am = AccountManager.get(context)
|
||||
val details = AccountUtils.getAccountDetails(am, accountKey) ?:
|
||||
return ListResponse.getListInstance<ParcelableUser>(MicroBlogException("No Account"))
|
||||
val twitter: MicroBlog = details.credentials.newMicroBlogInstance(context = context, cls = MicroBlog::class.java)
|
||||
val data = data
|
||||
val users: List<User>
|
||||
try {
|
||||
users = getUsers(twitter, credentials)
|
||||
users = getUsers(twitter, details)
|
||||
} catch (e: MicroBlogException) {
|
||||
Log.w(TwidereConstants.LOGTAG, e)
|
||||
return ListResponse.getListInstance(data)
|
||||
|
@ -71,6 +72,5 @@ abstract class TwitterAPIUsersLoader(
|
|||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
protected abstract fun getUsers(twitter: MicroBlog,
|
||||
credentials: ParcelableCredentials): List<User>
|
||||
protected abstract fun getUsers(twitter: MicroBlog, details: AccountDetails): List<User>
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserBlocksLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog,
|
||||
details: AccountDetails,
|
||||
paging: Paging): List<User> {
|
||||
when (details.type) {
|
||||
AccountType.FANFOU -> {
|
||||
return twitter.getFanfouBlocking(paging)
|
||||
}
|
||||
}
|
||||
return twitter.getBlocksList(paging)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserFollowersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): ResponseList<User> {
|
||||
when (details.type) {
|
||||
AccountType.STATUSNET -> if (userKey != null) {
|
||||
return twitter.getStatusesFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getStatusesFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
AccountType.FANFOU -> if (userKey != null) {
|
||||
return twitter.getUsersFollowers(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFollowers(screenName, paging)
|
||||
}
|
||||
else -> if (userKey != null) {
|
||||
return twitter.getFollowersList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFollowersListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
throw MicroBlogException("user_id or screen_name required")
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.ResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserFriendsLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): ResponseList<User> {
|
||||
when (details.type) {
|
||||
AccountType.STATUSNET -> if (userKey != null) {
|
||||
return twitter.getStatusesFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getStatusesFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
AccountType.FANFOU -> if (userKey != null) {
|
||||
return twitter.getUsersFriends(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getUsersFriends(screenName, paging)
|
||||
}
|
||||
else -> if (userKey != null) {
|
||||
return twitter.getFriendsList(userKey.id, paging)
|
||||
} else if (screenName != null) {
|
||||
return twitter.getFriendsListByScreenName(screenName, paging)
|
||||
}
|
||||
}
|
||||
throw MicroBlogException("user_id or screen_name required")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListMembersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
private val listId: String?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
private val listName: String,
|
||||
data: List<ParcelableUser>,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
public override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): PageableResponseList<User> {
|
||||
if (listId != null)
|
||||
return twitter.getUserListMembers(listId, paging)
|
||||
else if (userKey != null)
|
||||
return twitter.getUserListMembers(listName.replace(' ', '-'), userKey.id, paging)
|
||||
else if (screenName != null)
|
||||
return twitter.getUserListMembersByScreenName(listName.replace(' ', '-'), screenName, paging)
|
||||
throw MicroBlogException("list_id or list_name and user_id (or screen_name) required")
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.PageableResponseList
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListSubscribersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
private val listId: String?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
private val listName: String?,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
public override fun getCursoredUsers(twitter: MicroBlog, details: AccountDetails, paging: Paging): PageableResponseList<User> {
|
||||
if (listId != null)
|
||||
return twitter.getUserListSubscribers(listId, paging)
|
||||
else if (userKey != null)
|
||||
return twitter.getUserListSubscribers(listName!!.replace(' ', '-'), userKey.id, paging)
|
||||
else if (screenName != null)
|
||||
return twitter.getUserListSubscribersByScreenName(listName!!.replace(' ', '-'), screenName, paging)
|
||||
throw MicroBlogException("list_id or list_name and user_id (or screen_name) required")
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 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.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
open class UserSearchLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
val query: String,
|
||||
val page: Int,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : TwitterAPIUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
public override fun getUsers(twitter: MicroBlog, details: AccountDetails): List<User> {
|
||||
val paging = Paging()
|
||||
paging.page(page)
|
||||
when (details.type) {
|
||||
AccountType.FANFOU -> {
|
||||
return twitter.searchFanfouUsers(query, paging)
|
||||
}
|
||||
}
|
||||
return twitter.searchUsers(query, paging)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue