2017-03-08 23:19:03 +01:00
|
|
|
/* Copyright 2017 Andrew Dawson
|
|
|
|
*
|
|
|
|
* This file is part of Tusky.
|
|
|
|
*
|
|
|
|
* Tusky is free software: you can redistribute it and/or modify it under the terms of the GNU
|
2017-03-21 02:44:30 +01:00
|
|
|
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
2017-03-08 23:19:03 +01:00
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
2017-03-21 02:44:30 +01:00
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
|
|
|
* General Public License for more details.
|
2017-03-08 23:19:03 +01:00
|
|
|
*
|
2017-03-21 02:44:30 +01:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License along with Tusky. If
|
|
|
|
* not, see <http://www.gnu.org/licenses/>. */
|
2017-03-08 23:19:03 +01:00
|
|
|
|
|
|
|
package com.keylesspalace.tusky.entity;
|
|
|
|
|
2017-03-10 23:31:08 +01:00
|
|
|
import android.os.Parcel;
|
2017-03-08 23:19:03 +01:00
|
|
|
import android.text.Spanned;
|
|
|
|
|
2017-03-10 23:31:08 +01:00
|
|
|
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion;
|
2017-03-08 23:19:03 +01:00
|
|
|
import com.google.gson.annotations.SerializedName;
|
2017-03-20 03:38:39 +01:00
|
|
|
import com.keylesspalace.tusky.HtmlUtils;
|
2017-03-08 23:19:03 +01:00
|
|
|
|
2017-03-10 23:31:08 +01:00
|
|
|
public class Account implements SearchSuggestion {
|
2017-03-08 23:19:03 +01:00
|
|
|
public String id;
|
|
|
|
|
2017-03-10 23:31:08 +01:00
|
|
|
@SerializedName("username")
|
|
|
|
public String localUsername;
|
|
|
|
|
2017-03-08 23:19:03 +01:00
|
|
|
@SerializedName("acct")
|
|
|
|
public String username;
|
|
|
|
|
|
|
|
@SerializedName("display_name")
|
|
|
|
public String displayName;
|
|
|
|
|
|
|
|
public Spanned note;
|
|
|
|
|
|
|
|
public String url;
|
|
|
|
|
|
|
|
public String avatar;
|
|
|
|
|
|
|
|
public String header;
|
|
|
|
|
2017-03-09 17:37:24 +01:00
|
|
|
public boolean locked;
|
|
|
|
|
2017-03-08 23:19:03 +01:00
|
|
|
@SerializedName("followers_count")
|
|
|
|
public String followersCount;
|
|
|
|
|
|
|
|
@SerializedName("following_count")
|
|
|
|
public String followingCount;
|
|
|
|
|
|
|
|
@SerializedName("statuses_count")
|
|
|
|
public String statusesCount;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return id.hashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
if (this.id == null) {
|
|
|
|
return this == other;
|
|
|
|
} else if (!(other instanceof Account)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Account account = (Account) other;
|
|
|
|
return account.id.equals(this.id);
|
|
|
|
}
|
2017-03-10 23:31:08 +01:00
|
|
|
|
|
|
|
public String getDisplayName() {
|
|
|
|
if (displayName.length() == 0) {
|
|
|
|
return localUsername;
|
|
|
|
}
|
|
|
|
|
|
|
|
return displayName;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBody() {
|
|
|
|
return username;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToParcel(Parcel dest, int flags) {
|
2017-03-20 03:38:39 +01:00
|
|
|
dest.writeString(id);
|
|
|
|
dest.writeString(localUsername);
|
|
|
|
dest.writeString(username);
|
|
|
|
dest.writeString(displayName);
|
|
|
|
dest.writeString(HtmlUtils.toHtml(note));
|
|
|
|
dest.writeString(url);
|
|
|
|
dest.writeString(avatar);
|
|
|
|
dest.writeString(header);
|
|
|
|
dest.writeBooleanArray(new boolean[] { locked });
|
|
|
|
dest.writeString(followersCount);
|
|
|
|
dest.writeString(followingCount);
|
|
|
|
dest.writeString(statusesCount);
|
2017-03-10 23:31:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Account() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Account(Parcel in) {
|
2017-03-20 03:38:39 +01:00
|
|
|
id = in.readString();
|
|
|
|
localUsername = in.readString();
|
|
|
|
username = in.readString();
|
|
|
|
displayName = in.readString();
|
|
|
|
note = HtmlUtils.fromHtml(in.readString());
|
|
|
|
url = in.readString();
|
|
|
|
avatar = in.readString();
|
|
|
|
header = in.readString();
|
|
|
|
boolean[] lockedArray = new boolean[1];
|
|
|
|
in.readBooleanArray(lockedArray);
|
|
|
|
locked = lockedArray[0];
|
|
|
|
followersCount = in.readString();
|
|
|
|
followingCount = in.readString();
|
|
|
|
statusesCount = in.readString();
|
2017-03-10 23:31:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
|
|
|
@Override
|
|
|
|
public Account createFromParcel(Parcel source) {
|
|
|
|
return new Account(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Account[] newArray(int size) {
|
|
|
|
return new Account[size];
|
|
|
|
}
|
|
|
|
};
|
2017-03-08 23:19:03 +01:00
|
|
|
}
|