implement fetching listings from remote instances

This commit is contained in:
sk
2023-06-06 17:04:29 +02:00
parent 969f29e2e9
commit 4258c55b88
19 changed files with 422 additions and 53 deletions

View File

@@ -1,7 +1,10 @@
package org.joinmastodon.android.model;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import org.parceler.Parcel;
@@ -135,6 +138,8 @@ public class Account extends BaseModel implements Searchable{
public List<Role> roles;
public @Nullable String fqn; // akkoma has this, mastodon't
@Override
public String getQuery() {
return url;
@@ -162,6 +167,7 @@ public class Account extends BaseModel implements Searchable{
moved.postprocess();
if(TextUtils.isEmpty(displayName))
displayName=username;
if(fqn == null) fqn = getFullyQualifiedName();
}
public boolean isLocal(){
@@ -173,6 +179,10 @@ public class Account extends BaseModel implements Searchable{
return parts.length==1 ? null : parts[1];
}
public String getDomainFromURL() {
return Uri.parse(url).getHost();
}
public String getDisplayUsername(){
return '@'+acct;
}
@@ -181,6 +191,10 @@ public class Account extends BaseModel implements Searchable{
return '@'+acct.split("@")[0];
}
public String getFullyQualifiedName() {
return fqn != null ? fqn : acct.split("@")[0] + "@" + getDomainFromURL();
}
@Override
public String toString(){
return "Account{"+

View File

@@ -11,6 +11,14 @@ import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
public abstract class BaseModel implements Cloneable{
/**
* indicates the profile has been fetched from a foreign instance.
*
* @see MastodonAPIRequest#execRemote
*/
public transient boolean isRemote;
@CallSuper
public void postprocess() throws ObjectValidationException{
try{