Revert "feat: add remote lookups to the PaginatedAccountListFragment"
This reverts commit 74f2bb4707
.
This commit is contained in:
parent
74f2bb4707
commit
fb02689c30
|
@ -6,7 +6,6 @@ import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetAccountFollowers;
|
import org.joinmastodon.android.api.requests.accounts.GetAccountFollowers;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
|
|
||||||
public class FollowerListFragment extends AccountRelatedAccountListFragment{
|
public class FollowerListFragment extends AccountRelatedAccountListFragment{
|
||||||
|
|
||||||
|
@ -16,22 +15,8 @@ public class FollowerListFragment extends AccountRelatedAccountListFragment{
|
||||||
setSubtitle(getResources().getQuantityString(R.plurals.x_followers, (int)(account.followersCount%1000), account.followersCount));
|
setSubtitle(getResources().getQuantityString(R.plurals.x_followers, (int)(account.followersCount%1000), account.followersCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Account getTargetAccount(){
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Status getTargetStatus(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
||||||
return new GetAccountFollowers(account.id, maxID, count);
|
return new GetAccountFollowers(account.id, maxID, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count){
|
|
||||||
return new GetAccountFollowers(id, maxID, count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetAccountFollowing;
|
import org.joinmastodon.android.api.requests.accounts.GetAccountFollowing;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
|
|
||||||
public class FollowingListFragment extends AccountRelatedAccountListFragment{
|
public class FollowingListFragment extends AccountRelatedAccountListFragment{
|
||||||
|
|
||||||
|
@ -15,22 +14,9 @@ public class FollowingListFragment extends AccountRelatedAccountListFragment{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setSubtitle(getResources().getQuantityString(R.plurals.x_following, (int)(account.followingCount%1000), account.followingCount));
|
setSubtitle(getResources().getQuantityString(R.plurals.x_following, (int)(account.followingCount%1000), account.followingCount));
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public Account getTargetAccount(){
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Status getTargetStatus(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
||||||
return new GetAccountFollowing(account.id, maxID, count);
|
return new GetAccountFollowing(account.id, maxID, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count){
|
|
||||||
return new GetAccountFollowing(id, maxID, count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +1,33 @@
|
||||||
package org.joinmastodon.android.fragments.account_list;
|
package org.joinmastodon.android.fragments.account_list;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
||||||
import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
import org.joinmastodon.android.model.HeaderPaginationList;
|
||||||
import org.joinmastodon.android.model.SearchResults;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.grishka.appkit.api.Callback;
|
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
|
|
||||||
public abstract class PaginatedAccountListFragment extends BaseAccountListFragment{
|
public abstract class PaginatedAccountListFragment extends BaseAccountListFragment{
|
||||||
private String nextMaxID;
|
private String nextMaxID;
|
||||||
|
|
||||||
public abstract Status getTargetStatus();
|
|
||||||
|
|
||||||
public abstract Account getTargetAccount();
|
|
||||||
|
|
||||||
public abstract HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count);
|
|
||||||
|
|
||||||
public abstract HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count);
|
public abstract HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
if(!GlobalUserPreferences.relocatePublishButton){
|
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
||||||
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
.setCallback(new SimpleCallback<>(this){
|
||||||
.setCallback(new SimpleCallback<>(this){
|
@Override
|
||||||
@Override
|
public void onSuccess(HeaderPaginationList<Account> result){
|
||||||
public void onSuccess(HeaderPaginationList<Account> result){
|
if(result.nextPageUri!=null)
|
||||||
if(result.nextPageUri!=null)
|
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
else
|
||||||
else
|
nextMaxID=null;
|
||||||
nextMaxID=null;
|
if (getActivity() == null) return;
|
||||||
if (getActivity() == null) return;
|
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
||||||
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
} else {
|
|
||||||
Status targetStatus = getTargetStatus();
|
|
||||||
Account targetAccount = getTargetAccount();
|
|
||||||
|
|
||||||
if(targetAccount != null){
|
|
||||||
UiUtils.lookupRemoteAccount(getContext(), targetAccount, accountID, null, account -> {
|
|
||||||
Pattern pattern = Pattern.compile("(?<=\\/\\/)([^\\/]+)(?=\\/@)");
|
|
||||||
Matcher matcher = pattern.matcher(account.url);
|
|
||||||
String domain = null;
|
|
||||||
if(matcher.find()){
|
|
||||||
domain = matcher.group(1);
|
|
||||||
}
|
}
|
||||||
currentRequest=onCreateRemoteRequest(account.id, offset==0 ? null : nextMaxID, count)
|
})
|
||||||
.setCallback(new SimpleCallback<>(this) {
|
.exec(accountID);
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Account> result) {
|
|
||||||
if(result.nextPageUri!=null)
|
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
|
||||||
else
|
|
||||||
nextMaxID=null;
|
|
||||||
if (getActivity() == null) return;
|
|
||||||
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
|
||||||
}
|
|
||||||
}).execNoAuth(domain);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(targetStatus != null){
|
|
||||||
UiUtils.lookupRemoteStatus(getContext(), targetStatus, accountID, null, status -> {
|
|
||||||
Pattern pattern = Pattern.compile("(?<=\\/\\/)([^\\/]+)(?=\\/@)");
|
|
||||||
Matcher matcher = pattern.matcher(status.url);
|
|
||||||
String domain = null;
|
|
||||||
if(matcher.find()){
|
|
||||||
domain = matcher.group(1);
|
|
||||||
}
|
|
||||||
currentRequest=onCreateRemoteRequest(status.id, offset==0 ? null : nextMaxID, count)
|
|
||||||
.setCallback(new SimpleCallback<>(this) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Account> result) {
|
|
||||||
if(result.nextPageUri!=null)
|
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
|
||||||
else
|
|
||||||
nextMaxID=null;
|
|
||||||
if (getActivity() == null) return;
|
|
||||||
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
|
||||||
}
|
|
||||||
}).execNoAuth(domain);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetStatusFavorites;
|
import org.joinmastodon.android.api.requests.statuses.GetStatusFavorites;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
|
|
||||||
public class StatusFavoritesListFragment extends StatusRelatedAccountListFragment{
|
public class StatusFavoritesListFragment extends StatusRelatedAccountListFragment{
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,22 +14,8 @@ public class StatusFavoritesListFragment extends StatusRelatedAccountListFragmen
|
||||||
setTitle(getResources().getQuantityString(R.plurals.x_favorites, (int)(status.favouritesCount%1000), status.favouritesCount));
|
setTitle(getResources().getQuantityString(R.plurals.x_favorites, (int)(status.favouritesCount%1000), status.favouritesCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Account getTargetAccount(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Status getTargetStatus(){
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
||||||
return new GetStatusFavorites(status.id, maxID, count);
|
return new GetStatusFavorites(status.id, maxID, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count){
|
|
||||||
return new GetStatusFavorites(id, maxID, count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetStatusReblogs;
|
import org.joinmastodon.android.api.requests.statuses.GetStatusReblogs;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
|
|
||||||
public class StatusReblogsListFragment extends StatusRelatedAccountListFragment{
|
public class StatusReblogsListFragment extends StatusRelatedAccountListFragment{
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,21 +14,8 @@ public class StatusReblogsListFragment extends StatusRelatedAccountListFragment{
|
||||||
setTitle(getResources().getQuantityString(R.plurals.x_reblogs, (int)(status.reblogsCount%1000), status.reblogsCount));
|
setTitle(getResources().getQuantityString(R.plurals.x_reblogs, (int)(status.reblogsCount%1000), status.reblogsCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Account getTargetAccount(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Status getTargetStatus(){
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
public HeaderPaginationRequest<Account> onCreateRequest(String maxID, int count){
|
||||||
return new GetStatusReblogs(status.id, maxID, count);
|
return new GetStatusReblogs(status.id, maxID, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count){
|
|
||||||
return new GetStatusReblogs(id, maxID, count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue