migrating account

This commit is contained in:
Mariotaku Lee 2016-03-08 01:25:18 +08:00
parent 5fe7ef804c
commit 016e2493e3
213 changed files with 1749 additions and 1638 deletions

View File

@ -0,0 +1,53 @@
package org.mariotaku.twidere.api.statusnet.model;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Created by mariotaku on 16/3/7.
*/
@JsonObject
public class Attention {
@JsonField(name = "fullname")
String fullName;
@JsonField(name = "id")
long id;
@JsonField(name = "ostatus_uri")
String ostatusUri;
@JsonField(name = "profileurl")
String profileUrl;
@JsonField(name = "screen_name")
String screenName;
public String getFullName() {
return fullName;
}
public long getId() {
return id;
}
public String getOstatusUri() {
return ostatusUri;
}
public String getProfileUrl() {
return profileUrl;
}
public String getScreenName() {
return screenName;
}
@Override
public String toString() {
return "Attention{" +
"fullName='" + fullName + '\'' +
", id='" + id + '\'' +
", ostatusUri='" + ostatusUri + '\'' +
", profileUrl='" + profileUrl + '\'' +
", screenName='" + screenName + '\'' +
'}';
}
}

View File

@ -30,6 +30,7 @@ import org.mariotaku.twidere.api.twitter.model.RateLimitStatus;
import org.mariotaku.twidere.api.twitter.model.TwitterResponse;
import org.mariotaku.twidere.api.twitter.util.InternalParseUtil;
import java.io.IOException;
import java.util.Locale;
/**
@ -76,6 +77,7 @@ public class TwitterException extends Exception implements TwitterResponse, Http
if (cause instanceof TwitterException) {
((TwitterException) cause).setNested();
}
setCausedByNetworkIssue(cause instanceof IOException);
}

View File

@ -27,6 +27,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
import org.mariotaku.twidere.api.gnusocial.model.Attachment;
import org.mariotaku.twidere.api.statusnet.model.Attention;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.io.IOException;
@ -124,6 +125,9 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
@JsonField(name = "external_url")
String externalUrl;
@JsonField(name = "attentions")
Attention[] attentions;
public User getUser() {
return user;
@ -308,6 +312,10 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
return externalUrl;
}
public Attention[] getAttentions() {
return attentions;
}
@Override
public int compareTo(@NonNull final Status that) {
final long delta = id - that.getId();
@ -317,7 +325,6 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
return (int) delta;
}
@Override
public String toString() {
return "Status{" +
@ -347,7 +354,10 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
", quotedStatus=" + quotedStatus +
", card=" + card +
", possiblySensitive=" + possiblySensitive +
'}';
", attachments=" + Arrays.toString(attachments) +
", externalUrl='" + externalUrl + '\'' +
", attentions=" + Arrays.toString(attentions) +
"} " + super.toString();
}

View File

@ -105,6 +105,7 @@ public interface IntentConstants {
String EXTRA_PAGE = "page";
String EXTRA_DATA = "data";
String EXTRA_QUERY = "query";
String EXTRA_USER_KEY = "user_key";
String EXTRA_USER_ID = "user_id";
String EXTRA_USER_IDS = "user_ids";
String EXTRA_LIST_ID = "list_id";

View File

@ -30,7 +30,7 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.draft.ActionExtra;
import org.mariotaku.twidere.model.util.AccountKeysCursorFieldConverter;
import org.mariotaku.twidere.model.util.UserKeysCursorFieldConverter;
import org.mariotaku.twidere.model.util.DraftExtrasConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
@ -43,8 +43,8 @@ import java.lang.annotation.RetentionPolicy;
public class Draft implements Parcelable {
@ParcelableThisPlease
@CursorField(value = Drafts.ACCOUNT_IDS, converter = AccountKeysCursorFieldConverter.class)
public AccountKey[] account_ids;
@CursorField(value = Drafts.ACCOUNT_IDS, converter = UserKeysCursorFieldConverter.class)
public UserKey[] account_ids;
@ParcelableThisPlease
@CursorField(value = Drafts._ID, excludeWrite = true)
public long _id;

View File

@ -30,8 +30,8 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.AccountKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
@ -46,9 +46,9 @@ public class ParcelableAccount implements Parcelable {
public long id;
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
@CursorField(value = Accounts.ACCOUNT_KEY, converter = AccountKeyCursorFieldConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Accounts.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "screen_name")

View File

@ -22,7 +22,6 @@ package org.mariotaku.twidere.model;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@ -31,9 +30,8 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.api.twitter.model.Activity;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.AccountKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.model.util.LongArrayConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
@ -61,9 +59,9 @@ public class ParcelableActivity implements Comparable<ParcelableActivity>, Parce
@CursorField(value = Activities._ID, excludeWrite = true)
public long _id;
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
@CursorField(value = Activities.ACCOUNT_KEY, converter = AccountKeyCursorFieldConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Activities.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "timestamp")
@CursorField(value = Activities.TIMESTAMP)
@ -134,7 +132,7 @@ public class ParcelableActivity implements Comparable<ParcelableActivity>, Parce
public ParcelableActivity() {
}
public static int calculateHashCode(AccountKey accountKey, long timestamp, long maxPosition, long minPosition) {
public static int calculateHashCode(UserKey accountKey, long timestamp, long maxPosition, long minPosition) {
int result = accountKey.hashCode();
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
result = 31 * result + (int) (maxPosition ^ (maxPosition >>> 32));

View File

@ -33,7 +33,7 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.twidere.api.twitter.model.CardEntity;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import java.util.Arrays;
import java.util.HashMap;
@ -58,8 +58,8 @@ public final class ParcelableCardEntity implements Parcelable {
}
};
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "name")
public String name;

View File

@ -30,8 +30,8 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.AccountKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
@ -55,9 +55,9 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
};
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
@CursorField(value = DirectMessages.ACCOUNT_KEY, converter = AccountKeyCursorFieldConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
@CursorField(value = DirectMessages.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "id")
@CursorField(DirectMessages.MESSAGE_ID)

View File

@ -34,9 +34,9 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.AfterCursorObjectCreated;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.AccountKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
import java.io.IOException;
@ -47,50 +47,42 @@ import java.util.Comparator;
@JsonObject
@ParcelablePlease
public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus>, Cloneable {
public static final Comparator<ParcelableStatus> REVERSE_TIMESTAMP_COMPARATOR = new Comparator<ParcelableStatus>() {
@Override
public int compare(final ParcelableStatus object1, final ParcelableStatus object2) {
final long diff = object1.timestamp - object2.timestamp;
if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE;
if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE;
return (int) diff;
}
};
@ParcelableThisPlease
@JsonField(name = "id")
@CursorField(Statuses.STATUS_ID)
public long id;
public static final Comparator<ParcelableStatus> REVERSE_ID_COMPARATOR = new Comparator<ParcelableStatus>() {
@Override
public int compare(final ParcelableStatus object1, final ParcelableStatus object2) {
final long diff = object1.id - object2.id;
if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE;
if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE;
return (int) diff;
}
};
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
@CursorField(value = Statuses.ACCOUNT_KEY, converter = AccountKeyCursorFieldConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Statuses.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "timestamp")
@CursorField(Statuses.STATUS_TIMESTAMP)
public long timestamp;
public static final Comparator<ParcelableStatus> TIMESTAMP_COMPARATOR = new Comparator<ParcelableStatus>() {
@Override
public int compare(final ParcelableStatus object1, final ParcelableStatus object2) {
final long diff = object2.timestamp - object1.timestamp;
if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE;
if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE;
return (int) diff;
}
};
@ParcelableThisPlease
@JsonField(name = "user_id")
@CursorField(Statuses.USER_ID)
public long user_id = -1;
@JsonField(name = "user_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Statuses.USER_ID, converter = UserKeyCursorFieldConverter.class)
public UserKey user_key;
@ParcelableThisPlease
@JsonField(name = "retweet_id")
@CursorField(Statuses.RETWEET_ID)
public long retweet_id = -1;
@ParcelableThisPlease
@JsonField(name = "retweeted_by_user_id")
@CursorField(Statuses.RETWEETED_BY_USER_ID)
public long retweeted_by_user_id = -1;
@JsonField(name = "retweeted_by_user_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Statuses.RETWEETED_BY_USER_ID, converter = UserKeyCursorFieldConverter.class)
public UserKey retweeted_by_user_id;
@ParcelableThisPlease
@JsonField(name = "retweet_timestamp")
@CursorField(Statuses.RETWEET_TIMESTAMP)
@ -112,9 +104,9 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@CursorField(Statuses.IN_REPLY_TO_STATUS_ID)
public long in_reply_to_status_id;
@ParcelableThisPlease
@JsonField(name = "in_reply_to_user_id")
@CursorField(Statuses.IN_REPLY_TO_USER_ID)
public long in_reply_to_user_id;
@JsonField(name = "in_reply_to_user_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Statuses.IN_REPLY_TO_USER_ID, converter = UserKeyCursorFieldConverter.class)
public UserKey in_reply_to_user_id;
@ParcelableThisPlease
@JsonField(name = "my_retweet_id")
@CursorField(Statuses.MY_RETWEET_ID)
@ -128,9 +120,9 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@CursorField(Statuses.QUOTED_TIMESTAMP)
public long quoted_timestamp;
@ParcelableThisPlease
@JsonField(name = "quoted_user_id")
@CursorField(Statuses.QUOTED_USER_ID)
public long quoted_user_id;
@JsonField(name = "quoted_user_id", typeConverter = UserKeyConverter.class)
@CursorField(value = Statuses.QUOTED_USER_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey quoted_user_id;
@ParcelableThisPlease
@JsonField(name = "is_gap")
@CursorField(Statuses.IS_GAP)
@ -351,7 +343,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
return calculateHashCode(account_key, id);
}
public static int calculateHashCode(AccountKey account_key, long id) {
public static int calculateHashCode(UserKey account_key, long id) {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + account_key.hashCode();
return result;
@ -363,7 +355,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
"id=" + id +
", account_key=" + account_key +
", timestamp=" + timestamp +
", user_id=" + user_id +
", user_id=" + user_key +
", retweet_id=" + retweet_id +
", retweeted_by_user_id=" + retweeted_by_user_id +
", retweet_timestamp=" + retweet_timestamp +

View File

@ -31,7 +31,8 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.library.objectcursor.annotation.AfterCursorObjectCreated;
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers;
@ -42,16 +43,16 @@ import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers;
public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
public UserKey account_key;
@ParcelableThisPlease
public int account_color;
@ParcelableThisPlease
@JsonField(name = "id")
@CursorField(CachedUsers.USER_ID)
public long id;
@JsonField(name = "id", typeConverter = UserKeyConverter.class)
@CursorField(value = CachedUsers.USER_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey key;
@ParcelableThisPlease
@JsonField(name = "created_at")
@CursorField(CachedUsers.CREATED_AT)
@ -171,11 +172,6 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
@CursorField(value = CachedUsers.EXTRAS, converter = LoganSquareCursorFieldConverter.class)
public Extras extras;
@ParcelableThisPlease
@JsonField(name = "user_host")
@CursorField(value = CachedUsers.USER_HOST)
public String user_host;
public static final Creator<ParcelableUser> CREATOR = new Creator<ParcelableUser>() {
public ParcelableUser createFromParcel(Parcel source) {
ParcelableUser target = new ParcelableUser();
@ -191,13 +187,13 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
public ParcelableUser() {
}
public ParcelableUser(final AccountKey account_key, final long id, final String name,
final String screen_name, final String profile_image_url) {
public ParcelableUser(final UserKey account_key, final UserKey key, final String name,
final String screenName, final String profileImageUrl) {
this.account_key = account_key;
this.id = id;
this.key = key;
this.name = name;
this.screen_name = screen_name;
this.profile_image_url = profile_image_url;
this.screen_name = screenName;
this.profile_image_url = profileImageUrl;
is_cache = true;
is_basic = true;
}
@ -235,19 +231,19 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
ParcelableUser user = (ParcelableUser) o;
if (id != user.id) return false;
return account_key.equals(user.account_key);
if (!account_key.equals(user.account_key)) return false;
return key.equals(user.key);
}
@Override
public int hashCode() {
return calculateHashCode(account_key, id);
return calculateHashCode(account_key, key);
}
public static int calculateHashCode(AccountKey account_key, long id) {
int result = account_key.hashCode();
result = 31 * result + (int) (id ^ (id >>> 32));
public static int calculateHashCode(UserKey accountKey, UserKey userKey) {
int result = accountKey.hashCode();
result = 31 * result + userKey.hashCode();
return result;
}
@ -256,7 +252,7 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
return "ParcelableUser{" +
"account_id=" + account_key +
", account_color=" + account_color +
", id=" + id +
", id=" + key +
", created_at=" + created_at +
", position=" + position +
", is_protected=" + is_protected +

View File

@ -28,31 +28,19 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.twidere.model.util.AccountKeyConverter;
import org.mariotaku.twidere.model.util.UserKeyConverter;
@ParcelablePlease
@JsonObject
public class ParcelableUserList implements Parcelable, Comparable<ParcelableUserList> {
@ParcelableThisPlease
@JsonField(name = "members_count")
public long members_count;
@ParcelableThisPlease
@JsonField(name = "subscribers_count")
public long subscribers_count;
@ParcelableThisPlease
@JsonField(name = "account_id", typeConverter = AccountKeyConverter.class)
public AccountKey account_key;
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
public UserKey account_key;
@ParcelableThisPlease
@JsonField(name = "id")
public long id;
@ParcelableThisPlease
@JsonField(name = "user_id")
public long user_id;
@ParcelableThisPlease
@JsonField(name = "position")
public long position;
@ParcelableThisPlease
@JsonField(name = "is_public")
public boolean is_public;
@ParcelableThisPlease
@ -64,6 +52,21 @@ public class ParcelableUserList implements Parcelable, Comparable<ParcelableUser
@ParcelableThisPlease
@JsonField(name = "name")
public String name;
@ParcelableThisPlease
@JsonField(name = "position")
public long position;
@ParcelableThisPlease
@JsonField(name = "members_count")
public long members_count;
@ParcelableThisPlease
@JsonField(name = "subscribers_count")
public long subscribers_count;
@ParcelableThisPlease
@JsonField(name = "user_id", typeConverter = UserKeyConverter.class)
public UserKey user_key;
@ParcelableThisPlease
@JsonField(name = "user_screen_name")
public String user_screen_name;
@ -111,7 +114,7 @@ public class ParcelableUserList implements Parcelable, Comparable<ParcelableUser
", subscribers_count=" + subscribers_count +
", account_key=" + account_key +
", id=" + id +
", user_id=" + user_id +
", user_id=" + user_key +
", position=" + position +
", is_public=" + is_public +
", is_following=" + is_following +

View File

@ -27,27 +27,15 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
import org.mariotaku.twidere.model.util.UserKeyConverter;
@JsonObject
@ParcelablePlease(allFields = false)
public class ParcelableUserMention implements Parcelable {
public static final Parcelable.Creator<ParcelableUserMention> CREATOR = new Parcelable.Creator<ParcelableUserMention>() {
@Override
public ParcelableUserMention createFromParcel(final Parcel in) {
return new ParcelableUserMention(in);
}
@Override
public ParcelableUserMention[] newArray(final int size) {
return new ParcelableUserMention[size];
}
};
@ParcelableThisPlease
@JsonField(name = "id")
public long id;
@JsonField(name = "id", typeConverter = UserKeyConverter.class)
public UserKey key;
@ParcelableThisPlease
@JsonField(name = "name")
public String name;
@ -59,62 +47,52 @@ public class ParcelableUserMention implements Parcelable {
}
public ParcelableUserMention(final Parcel in) {
id = in.readLong();
name = in.readString();
screen_name = in.readString();
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ParcelableUserMention that = (ParcelableUserMention) o;
if (key != null ? !key.equals(that.key) : that.key != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
return !(screen_name != null ? !screen_name.equals(that.screen_name) : that.screen_name != null);
}
public ParcelableUserMention(final UserMentionEntity entity) {
id = entity.getId();
name = entity.getName();
screen_name = entity.getScreenName();
@Override
public int hashCode() {
int result = key != null ? key.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (screen_name != null ? screen_name.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "ParcelableUserMention{id=" + key + ", name=" + name + ", screen_name=" + screen_name + "}";
}
@Override
public int describeContents() {
return 0;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof ParcelableUserMention)) return false;
final ParcelableUserMention other = (ParcelableUserMention) obj;
if (id != other.id) return false;
return true;
public void writeToParcel(Parcel dest, int flags) {
ParcelableUserMentionParcelablePlease.writeToParcel(this, dest, flags);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (id ^ id >>> 32);
return result;
}
@Override
public String toString() {
return "ParcelableUserMention{id=" + id + ", name=" + name + ", screen_name=" + screen_name + "}";
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
dest.writeLong(id);
dest.writeString(name);
dest.writeString(screen_name);
}
public static ParcelableUserMention[] fromUserMentionEntities(final UserMentionEntity[] entities) {
if (entities == null) return null;
final ParcelableUserMention[] mentions = new ParcelableUserMention[entities.length];
for (int i = 0, j = entities.length; i < j; i++) {
mentions[i] = new ParcelableUserMention(entities[i]);
public static final Creator<ParcelableUserMention> CREATOR = new Creator<ParcelableUserMention>() {
public ParcelableUserMention createFromParcel(Parcel source) {
ParcelableUserMention target = new ParcelableUserMention();
ParcelableUserMentionParcelablePlease.readFromParcel(target, source);
return target;
}
return mentions;
}
public ParcelableUserMention[] newArray(int size) {
return new ParcelableUserMention[size];
}
};
}

View File

@ -19,17 +19,17 @@ import java.util.List;
*/
@JsonObject
@ParcelablePlease
public class AccountKey implements Comparable<AccountKey>, Parcelable {
public class UserKey implements Comparable<UserKey>, Parcelable {
public static final Creator<AccountKey> CREATOR = new Creator<AccountKey>() {
public AccountKey createFromParcel(Parcel source) {
AccountKey target = new AccountKey();
AccountKeyParcelablePlease.readFromParcel(target, source);
public static final Creator<UserKey> CREATOR = new Creator<UserKey>() {
public UserKey createFromParcel(Parcel source) {
UserKey target = new UserKey();
UserKeyParcelablePlease.readFromParcel(target, source);
return target;
}
public AccountKey[] newArray(int size) {
return new AccountKey[size];
public UserKey[] newArray(int size) {
return new UserKey[size];
}
};
@ -40,12 +40,12 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
@ParcelableThisPlease
String host;
public AccountKey(long id, String host) {
public UserKey(long id, String host) {
this.id = id;
this.host = host;
}
AccountKey() {
UserKey() {
}
@ -64,7 +64,7 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
}
@Override
public int compareTo(@NonNull AccountKey another) {
public int compareTo(@NonNull UserKey another) {
if (this.id == another.id) {
if (this.host != null && another.host != null) {
return this.host.compareTo(another.host);
@ -83,7 +83,7 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AccountKey accountKey = (AccountKey) o;
UserKey accountKey = (UserKey) o;
return id == accountKey.id;
@ -101,25 +101,25 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
AccountKeyParcelablePlease.writeToParcel(this, dest, flags);
UserKeyParcelablePlease.writeToParcel(this, dest, flags);
}
public boolean isAccount(long accountId, String accountHost) {
public boolean check(long accountId, String accountHost) {
return this.id == accountId;
}
@Nullable
public static AccountKey valueOf(@Nullable String str) {
public static UserKey valueOf(@Nullable String str) {
if (str == null) return null;
int idxOfAt = str.indexOf("@");
try {
if (idxOfAt != -1) {
final String idStr = str.substring(0, idxOfAt);
return new AccountKey(Long.parseLong(idStr),
return new UserKey(Long.parseLong(idStr),
str.substring(idxOfAt + 1, str.length()));
} else {
return new AccountKey(Long.parseLong(str), null);
return new UserKey(Long.parseLong(str), null);
}
} catch (NumberFormatException e) {
return null;
@ -127,10 +127,10 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
}
@Nullable
public static AccountKey[] arrayOf(@Nullable String str) {
public static UserKey[] arrayOf(@Nullable String str) {
if (str == null) return null;
List<String> split = TwitterDateConverter.split(str, ",");
AccountKey[] keys = new AccountKey[split.size()];
UserKey[] keys = new UserKey[split.size()];
for (int i = 0, splitLength = split.size(); i < splitLength; i++) {
keys[i] = valueOf(split.get(i));
if (keys[i] == null) return null;
@ -138,11 +138,15 @@ public class AccountKey implements Comparable<AccountKey>, Parcelable {
return keys;
}
public static long[] getIds(AccountKey[] ids) {
public static long[] getIds(UserKey[] ids) {
long[] result = new long[ids.length];
for (int i = 0, idsLength = ids.length; i < idsLength; i++) {
result[i] = ids[i].getId();
}
return result;
}
public boolean maybeEquals(@Nullable UserKey another) {
return another != null && another.getId() == id;
}
}

View File

@ -1,28 +0,0 @@
package org.mariotaku.twidere.model.util;
import android.content.ContentValues;
import android.database.Cursor;
import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter;
import org.mariotaku.library.objectcursor.converter.CursorFieldConverter;
import org.mariotaku.twidere.model.AccountKey;
import java.lang.reflect.ParameterizedType;
/**
* Created by mariotaku on 16/3/7.
*/
public class AccountKeyConverter extends StringBasedTypeConverter<AccountKey> {
@Override
public AccountKey getFromString(String string) {
return AccountKey.valueOf(string);
}
@Override
public String convertToString(AccountKey object) {
if (object == null) return null;
return object.toString();
}
}

View File

@ -1,26 +0,0 @@
package org.mariotaku.twidere.model.util;
import android.content.ContentValues;
import android.database.Cursor;
import org.mariotaku.library.objectcursor.converter.CursorFieldConverter;
import org.mariotaku.twidere.model.AccountKey;
import java.lang.reflect.ParameterizedType;
/**
* Created by mariotaku on 16/3/7.
*/
public class AccountKeyCursorFieldConverter implements CursorFieldConverter<AccountKey> {
@Override
public AccountKey parseField(Cursor cursor, int columnIndex, ParameterizedType fieldType) {
return AccountKey.valueOf(cursor.getString(columnIndex));
}
@Override
public void writeField(ContentValues values, AccountKey object, String columnName, ParameterizedType fieldType) {
if (object == null) return;
values.put(columnName, object.toString());
}
}

View File

@ -1,19 +0,0 @@
package org.mariotaku.twidere.model.util;
import org.mariotaku.twidere.model.AccountKey;
/**
* Created by mariotaku on 16/3/7.
*/
public class AccountKeysCursorFieldConverter extends AbsObjectArrayConverter<AccountKey> {
@Override
protected AccountKey[] newArray(int size) {
return new AccountKey[size];
}
@Override
protected AccountKey parseItem(String s) {
return AccountKey.valueOf(s);
}
}

View File

@ -0,0 +1,22 @@
package org.mariotaku.twidere.model.util;
import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter;
import org.mariotaku.twidere.model.UserKey;
/**
* Created by mariotaku on 16/3/7.
*/
public class UserKeyConverter extends StringBasedTypeConverter<UserKey> {
@Override
public UserKey getFromString(String string) {
return UserKey.valueOf(string);
}
@Override
public String convertToString(UserKey object) {
if (object == null) return null;
return object.toString();
}
}

View File

@ -0,0 +1,26 @@
package org.mariotaku.twidere.model.util;
import android.content.ContentValues;
import android.database.Cursor;
import org.mariotaku.library.objectcursor.converter.CursorFieldConverter;
import org.mariotaku.twidere.model.UserKey;
import java.lang.reflect.ParameterizedType;
/**
* Created by mariotaku on 16/3/7.
*/
public class UserKeyCursorFieldConverter implements CursorFieldConverter<UserKey> {
@Override
public UserKey parseField(Cursor cursor, int columnIndex, ParameterizedType fieldType) {
return UserKey.valueOf(cursor.getString(columnIndex));
}
@Override
public void writeField(ContentValues values, UserKey object, String columnName, ParameterizedType fieldType) {
if (object == null) return;
values.put(columnName, object.toString());
}
}

View File

@ -0,0 +1,19 @@
package org.mariotaku.twidere.model.util;
import org.mariotaku.twidere.model.UserKey;
/**
* Created by mariotaku on 16/3/7.
*/
public class UserKeysCursorFieldConverter extends AbsObjectArrayConverter<UserKey> {
@Override
protected UserKey[] newArray(int size) {
return new UserKey[size];
}
@Override
protected UserKey parseItem(String s) {
return UserKey.valueOf(s);
}
}

View File

@ -237,7 +237,7 @@ public interface TwidereDataStore {
Uri CONTENT_URI_WITH_SCORE = Uri.withAppendedPath(BASE_CONTENT_URI,
CONTENT_PATH_WITH_SCORE);
String USER_ID = "user_id";
String USER_KEY = "user_id";
String CREATED_AT = "created_at";
@ -300,13 +300,13 @@ public interface TwidereDataStore {
String USER_HOST = "user_host";
String[] COLUMNS = {_ID, USER_ID, CREATED_AT, NAME, SCREEN_NAME, DESCRIPTION_PLAIN, LOCATION,
String[] COLUMNS = {_ID, USER_KEY, CREATED_AT, NAME, SCREEN_NAME, DESCRIPTION_PLAIN, LOCATION,
URL, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING,
FOLLOWERS_COUNT, FRIENDS_COUNT, STATUSES_COUNT, FAVORITES_COUNT, LISTED_COUNT,
MEDIA_COUNT, DESCRIPTION_HTML, DESCRIPTION_EXPANDED, URL_EXPANDED, BACKGROUND_COLOR,
LINK_COLOR, TEXT_COLOR, LAST_SEEN, DESCRIPTION_UNESCAPED, EXTRAS, USER_HOST};
String[] BASIC_COLUMNS = {_ID, USER_ID, NAME, SCREEN_NAME, PROFILE_IMAGE_URL};
String[] BASIC_COLUMNS = {_ID, USER_KEY, NAME, SCREEN_NAME, PROFILE_IMAGE_URL};
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT,
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN,
@ -639,7 +639,7 @@ public interface TwidereDataStore {
String[] COLUMNS = {_ID, USER_ID, NAME, SCREEN_NAME};
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT_UNIQUE, TYPE_TEXT_NOT_NULL,
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL,
TYPE_TEXT_NOT_NULL};
}
}
@ -857,7 +857,7 @@ public interface TwidereDataStore {
String QUOTED_MEDIA_JSON = "quoted_media_json";
String QUOTED_TIMESTAMP = "quoted_timestamp";
String QUOTED_SOURCE = "quoted_source";
String QUOTED_USER_ID = "quoted_user_id";
String QUOTED_USER_KEY = "quoted_user_id";
String QUOTED_USER_NAME = "quoted_user_name";
String QUOTED_USER_SCREEN_NAME = "quoted_user_screen_name";
String QUOTED_USER_PROFILE_IMAGE = "quoted_user_profile_image";
@ -876,7 +876,7 @@ public interface TwidereDataStore {
IN_REPLY_TO_USER_SCREEN_NAME, SOURCE, LOCATION, RETWEET_COUNT, FAVORITE_COUNT, REPLY_COUNT,
RETWEET_ID, RETWEET_TIMESTAMP, RETWEETED_BY_USER_ID, RETWEETED_BY_USER_NAME,
RETWEETED_BY_USER_SCREEN_NAME, RETWEETED_BY_USER_PROFILE_IMAGE, QUOTED_ID, QUOTED_TEXT_HTML,
QUOTED_TEXT_PLAIN, QUOTED_TEXT_UNESCAPED, QUOTED_TIMESTAMP, QUOTED_SOURCE, QUOTED_USER_ID,
QUOTED_TEXT_PLAIN, QUOTED_TEXT_UNESCAPED, QUOTED_TIMESTAMP, QUOTED_SOURCE, QUOTED_USER_KEY,
QUOTED_USER_NAME, QUOTED_USER_SCREEN_NAME, QUOTED_USER_PROFILE_IMAGE,
QUOTED_USER_IS_VERIFIED, QUOTED_USER_IS_PROTECTED, MY_RETWEET_ID, IS_RETWEET,
IS_QUOTE, IS_FAVORITE, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, IS_GAP,

View File

@ -40,18 +40,6 @@ public class TwitterContentUtils {
public static final int TWITTER_BULK_QUERY_COUNT = 100;
@NonNull
public static String getInReplyToName(@NonNull final Status status) {
final Status orig = status.isRetweet() ? status.getRetweetedStatus() : status;
final long inReplyToUserId = status.getInReplyToUserId();
final UserMentionEntity[] entities = status.getUserMentionEntities();
if (entities == null) return orig.getInReplyToScreenName();
for (final UserMentionEntity entity : entities) {
if (inReplyToUserId == entity.getId()) return entity.getName();
}
return orig.getInReplyToScreenName();
}
public static boolean isOfficialKey(final Context context, final String consumerKey,
final String consumerSecret) {
if (context == null || consumerKey == null || consumerSecret == null) return false;

View File

@ -1,46 +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.util.content;
import android.content.ContentValues;
public class ContentValuesUtils {
public static boolean getAsBoolean(final ContentValues values, final String key, final boolean def) {
if (values == null || key == null) return def;
final Object value = values.get(key);
if (value == null) return def;
return Boolean.valueOf(value.toString());
}
public static long getAsInteger(final ContentValues values, final String key, final int def) {
if (values == null || key == null) return def;
final Object value = values.get(key);
if (value == null) return def;
return Integer.valueOf(value.toString());
}
public static long getAsLong(final ContentValues values, final String key, final long def) {
if (values == null || key == null) return def;
final Object value = values.get(key);
if (value == null) return def;
return Long.valueOf(value.toString());
}
}

View File

@ -22,8 +22,7 @@ package org.mariotaku.twidere.extension.shortener.gist;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusUpdate;
import org.mariotaku.twidere.model.StatusShortenResult;
@ -35,7 +34,7 @@ import org.mariotaku.twidere.service.StatusShortenerService;
public class GistStatusShortenerService extends StatusShortenerService {
@Override
protected StatusShortenResult shorten(ParcelableStatusUpdate status, AccountKey currentAccountKey, String overrideStatusText) {
protected StatusShortenResult shorten(ParcelableStatusUpdate status, UserKey currentAccountKey, String overrideStatusText) {
final Github github = GithubFactory.getInstance(getApiKey());
final NewGist newGist = new NewGist();
newGist.setDescription("long tweet");

View File

@ -9,7 +9,7 @@ import android.support.annotation.Nullable;
import android.util.Log;
import org.mariotaku.twidere.Twidere;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusUpdate;
@ -31,7 +31,7 @@ public class TwitLongerStatusShortenerService extends StatusShortenerService imp
*/
@Override
protected StatusShortenResult shorten(final ParcelableStatusUpdate status,
final AccountKey currentAccountKey,
final UserKey currentAccountKey,
final String overrideStatusText) {
final int granted = Twidere.isPermissionGranted(this);
if (granted == Twidere.Permission.DENIED) {
@ -119,7 +119,7 @@ public class TwitLongerStatusShortenerService extends StatusShortenerService imp
}
@Nullable
private ParcelableCredentials getOAuthCredentials(AccountKey accountId) {
private ParcelableCredentials getOAuthCredentials(UserKey accountId) {
ParcelableCredentials credentials = Twidere.getCredentials(this, accountId);
if (credentials == null) return null;
switch (credentials.auth_type) {

View File

@ -33,7 +33,7 @@ import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ComposingStatus;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableCredentialsCursorIndices;
@ -234,7 +234,7 @@ public final class Twidere implements TwidereConstants {
@Nullable
public static ParcelableCredentials getCredentials(@NonNull final Context context,
@NonNull final AccountKey accountId)
@NonNull final UserKey accountId)
throws SecurityException {
final String selection = Accounts.ACCOUNT_KEY + " = ?";
final String[] selectionArgs = {String.valueOf(accountId)};

View File

@ -7,7 +7,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import org.mariotaku.twidere.IStatusShortener;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusUpdate;
import org.mariotaku.twidere.model.StatusShortenResult;
@ -29,7 +29,7 @@ public abstract class StatusShortenerService extends Service {
}
protected abstract StatusShortenResult shorten(ParcelableStatusUpdate status,
AccountKey currentAccountKey,
UserKey currentAccountKey,
String overrideStatusText);
protected abstract boolean callback(StatusShortenResult result, ParcelableStatus status);
@ -54,7 +54,7 @@ public abstract class StatusShortenerService extends Service {
try {
final ParcelableStatusUpdate statusUpdate = LoganSquareMapperFinder.mapperFor(ParcelableStatusUpdate.class)
.parse(statusJson);
final AccountKey currentAccountId = AccountKey.valueOf(currentAccountIdStr);
final UserKey currentAccountId = UserKey.valueOf(currentAccountIdStr);
final StatusShortenResult shorten = mService.get().shorten(statusUpdate, currentAccountId,
overrideStatusText);
return LoganSquareMapperFinder.mapperFor(StatusShortenResult.class).serialize(shorten);

View File

@ -28,7 +28,7 @@ import android.util.Log;
import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.util.dagger.DependencyHolder;
import java.io.File;
@ -91,7 +91,7 @@ public class HotMobiLogger implements HotMobiConstants {
return DependencyHolder.get(context).getHotMobiLogger();
}
public static File getLogFile(Context context, @Nullable AccountKey accountKey, String type) {
public static File getLogFile(Context context, @Nullable UserKey accountKey, String type) {
final File logsDir = getLogsDir(context);
final File todayLogDir = new File(logsDir, DATE_FORMAT.format(new Date()));
if (!todayLogDir.exists()) {
@ -127,11 +127,11 @@ public class HotMobiLogger implements HotMobiConstants {
return false;
}
public <T extends LogModel> void log(AccountKey accountId, final T event, final PreProcessing<T> preProcessing) {
public <T extends LogModel> void log(UserKey accountId, final T event, final PreProcessing<T> preProcessing) {
mExecutor.execute(new WriteLogTask<>(mApplication, accountId, event, preProcessing));
}
public <T extends LogModel> void log(AccountKey accountId, final T event) {
public <T extends LogModel> void log(UserKey accountId, final T event) {
log(accountId, event, null);
}
@ -143,11 +143,11 @@ public class HotMobiLogger implements HotMobiConstants {
log(null, event, preProcessing);
}
public <T extends LogModel> void logList(List<T> events, AccountKey accountId, String type) {
public <T extends LogModel> void logList(List<T> events, UserKey accountId, String type) {
logList(events, accountId, type, null);
}
public <T extends LogModel> void logList(List<T> events, AccountKey accountId, String type, final PreProcessing<T> preProcessing) {
public <T extends LogModel> void logList(List<T> events, UserKey accountId, String type, final PreProcessing<T> preProcessing) {
mExecutor.execute(new WriteLogTask<>(mApplication, accountId, type, events, preProcessing));
}

View File

@ -27,7 +27,7 @@ import android.util.Log;
import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.util.JsonSerializer;
import org.mariotaku.twidere.util.Utils;
@ -49,17 +49,17 @@ public class WriteLogTask<T extends LogModel> implements Runnable, Constants {
private static final byte[] LF = {'\n'};
private final Context context;
private final AccountKey accountKey;
private final UserKey accountKey;
private final String type;
private final List<T> events;
@Nullable
private final PreProcessing<T> preProcessing;
public WriteLogTask(Context context, AccountKey accountKey, T event, @Nullable PreProcessing<T> preProcessing) {
public WriteLogTask(Context context, UserKey accountKey, T event, @Nullable PreProcessing<T> preProcessing) {
this(context, accountKey, HotMobiLogger.getLogFilename(event), Collections.singletonList(event), preProcessing);
}
public WriteLogTask(Context context, AccountKey accountKey, String type, List<T> events,
public WriteLogTask(Context context, UserKey accountKey, String type, List<T> events,
@Nullable PreProcessing<T> preProcessing) {
this.context = context;
this.accountKey = accountKey;

View File

@ -76,7 +76,7 @@ public class MediaEvent extends BaseEvent implements Parcelable {
final MediaEvent event = new MediaEvent();
event.markStart(context);
event.setId(status.id);
event.setUserId(status.user_id);
event.setUserId(status.user_key.getId());
event.setMediaUrl(media.media_url);
event.setPreviewUrl(media.preview_url);
event.setPreviewEnabled(previewEnabled);

View File

@ -31,7 +31,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import java.util.TimeZone;
@ -94,7 +94,7 @@ public class NotificationEvent extends BaseEvent implements Parcelable {
}
public static NotificationEvent deleted(Context context, long postTime, String type,
AccountKey accountKey, long itemId, long itemUserId,
UserKey accountKey, long itemId, long itemUserId,
boolean itemUserFollowing) {
return create(context, Action.DELETE, System.currentTimeMillis(), postTime, type, accountKey.getId(),
itemId, itemUserId, itemUserFollowing);

View File

@ -24,7 +24,7 @@ import android.support.annotation.NonNull;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
/**
* Created by mariotaku on 15/8/8.
@ -44,7 +44,7 @@ public class ScrollRecord implements LogModel {
@JsonField(name = "scroll_state")
int scrollState;
public static ScrollRecord create(long id, AccountKey accountKey, long timestamp, long timeOffset, int scrollState) {
public static ScrollRecord create(long id, UserKey accountKey, long timestamp, long timeOffset, int scrollState) {
final ScrollRecord record = new ScrollRecord();
record.setId(id);
record.setAccountId(accountKey.getId());

View File

@ -32,7 +32,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.AccountPreferences;
import org.mariotaku.twidere.util.DataStoreUtils;
@ -98,7 +98,7 @@ public class SessionEvent extends BaseEvent implements Parcelable {
public void dumpPreferences(Context context) {
final HashMap<String, String> preferences = new HashMap<>();
for (AccountPreferences pref : AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context))) {
final AccountKey accountKey = pref.getAccountKey();
final UserKey accountKey = pref.getAccountKey();
preferences.put("notification_" + accountKey + "_home", String.valueOf(pref.isHomeTimelineNotificationEnabled()));
preferences.put("notification_" + accountKey + "_interactions", String.valueOf(pref.isInteractionsNotificationEnabled()));
}

View File

@ -85,7 +85,7 @@ public class TweetEvent extends BaseEvent implements Parcelable {
event.setId(status.id);
event.setAccountId(status.account_key.getId());
event.setAccountHost(status.account_key.getHost());
event.setUserId(status.user_id);
event.setUserId(status.user_key.getId());
event.setTimelineType(timelineType);
event.setTweetType(TwidereDataUtils.getTweetType(status));
event.setFollowing(status.user_is_following);

View File

@ -31,6 +31,9 @@ public class UserEvent extends BaseEvent implements Parcelable {
@JsonField(name = "user_id")
long userId;
@ParcelableThisPlease
@JsonField(name = "user_host")
String userHost;
@ParcelableThisPlease
@JsonField(name = "status_count")
long statusCount;
@ParcelableThisPlease
@ -66,7 +69,8 @@ public class UserEvent extends BaseEvent implements Parcelable {
public void setUser(@NonNull ParcelableUser user) {
accountId = user.account_key.getId();
accountHost = user.account_key.getHost();
userId = user.id;
userId = user.key.getId();
userHost = user.key.toString();
statusCount = user.statuses_count;
followerCount = user.followers_count;
friendCount = user.friends_count;

View File

@ -33,7 +33,7 @@ import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
public interface Constants extends TwidereConstants {
String DATABASES_NAME = "twidere.sqlite";
int DATABASES_VERSION = 130;
int DATABASES_VERSION = 131;
int MENU_GROUP_STATUS_EXTENSION = 10;
int MENU_GROUP_COMPOSE_EXTENSION = 11;

View File

@ -103,7 +103,6 @@ import org.mariotaku.twidere.adapter.ArrayRecyclerAdapter;
import org.mariotaku.twidere.adapter.BaseRecyclerViewAdapter;
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
import org.mariotaku.twidere.fragment.support.SupportProgressDialogFragment;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ConsumerKeyType;
import org.mariotaku.twidere.model.Draft;
import org.mariotaku.twidere.model.DraftValuesCreator;
@ -115,6 +114,7 @@ import org.mariotaku.twidere.model.ParcelableMediaUpdate;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusUpdate;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.draft.UpdateStatusActionExtra;
import org.mariotaku.twidere.model.util.ParcelableAccountUtils;
import org.mariotaku.twidere.preference.ServicePickerPreference;
@ -442,12 +442,12 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
try {
final String action = intent.getAction();
if (INTENT_ACTION_EXTENSION_COMPOSE.equals(action)) {
final AccountKey[] accountKeys = mAccountsAdapter.getSelectedAccountKeys();
final UserKey[] accountKeys = mAccountsAdapter.getSelectedAccountKeys();
intent.putExtra(EXTRA_TEXT, ParseUtils.parseString(mEditText.getText()));
intent.putExtra(EXTRA_ACCOUNT_IDS, AccountKey.getIds(accountKeys));
intent.putExtra(EXTRA_ACCOUNT_IDS, UserKey.getIds(accountKeys));
intent.putExtra(EXTRA_ACCOUNT_KEYS, accountKeys);
if (accountKeys.length > 0) {
final AccountKey accountKey = accountKeys[0];
final UserKey accountKey = accountKeys[0];
intent.putExtra(EXTRA_NAME, DataStoreUtils.getAccountName(this, accountKey));
intent.putExtra(EXTRA_SCREEN_NAME, DataStoreUtils.getAccountScreenName(this, accountKey));
}
@ -628,7 +628,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
finish();
return;
}
final AccountKey[] defaultAccountIds = ParcelableAccountUtils.getAccountKeys(accounts);
final UserKey[] defaultAccountIds = ParcelableAccountUtils.getAccountKeys(accounts);
mMenuBar.setOnMenuItemClickListener(this);
setupEditText();
mAccountSelectorContainer.setOnClickListener(this);
@ -660,7 +660,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
if (savedInstanceState != null) {
// Restore from previous saved state
mAccountsAdapter.setSelectedAccountIds(Utils.newParcelableArray(
savedInstanceState.getParcelableArray(EXTRA_ACCOUNT_KEY), AccountKey.CREATOR));
savedInstanceState.getParcelableArray(EXTRA_ACCOUNT_KEY), UserKey.CREATOR));
mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE);
final ArrayList<ParcelableMediaUpdate> mediaList = savedInstanceState.getParcelableArrayList(EXTRA_MEDIA);
if (mediaList != null) {
@ -675,7 +675,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
} else {
// The context was first created
final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
final AccountKey notificationAccount = intent.getParcelableExtra(EXTRA_NOTIFICATION_ACCOUNT);
final UserKey notificationAccount = intent.getParcelableExtra(EXTRA_NOTIFICATION_ACCOUNT);
if (notificationId != -1) {
mTwitterWrapper.clearNotificationAsync(notificationId, notificationAccount);
}
@ -683,10 +683,10 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
handleDefaultIntent(intent);
}
setLabel(intent);
final AccountKey[] selectedAccountIds = mAccountsAdapter.getSelectedAccountKeys();
final UserKey[] selectedAccountIds = mAccountsAdapter.getSelectedAccountKeys();
if (ArrayUtils.isEmpty(selectedAccountIds)) {
final AccountKey[] idsInPrefs = AccountKey.arrayOf(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null));
AccountKey[] intersection = null;
final UserKey[] idsInPrefs = UserKey.arrayOf(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null));
UserKey[] intersection = null;
if (idsInPrefs != null) {
intersection = TwidereArrayUtils.intersection(idsInPrefs, defaultAccountIds);
}
@ -872,12 +872,12 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
final String action = intent.getAction();
final boolean hasAccountIds;
if (intent.hasExtra(EXTRA_ACCOUNT_KEYS)) {
final AccountKey[] accountKeys = Utils.newParcelableArray(
intent.getParcelableArrayExtra(EXTRA_ACCOUNT_KEYS), AccountKey.CREATOR);
final UserKey[] accountKeys = Utils.newParcelableArray(
intent.getParcelableArrayExtra(EXTRA_ACCOUNT_KEYS), UserKey.CREATOR);
mAccountsAdapter.setSelectedAccountIds(accountKeys);
hasAccountIds = true;
} else if (intent.hasExtra(EXTRA_ACCOUNT_KEY)) {
final AccountKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
mAccountsAdapter.setSelectedAccountIds(accountKey);
hasAccountIds = true;
} else {
@ -1006,7 +1006,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
}
case INTENT_ACTION_REPLY_MULTIPLE: {
final String[] screenNames = intent.getStringArrayExtra(EXTRA_SCREEN_NAMES);
final AccountKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEYS);
final UserKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEYS);
final ParcelableStatus inReplyToStatus = intent.getParcelableExtra(EXTRA_IN_REPLY_TO_STATUS);
return handleReplyMultipleIntent(screenNames, accountKey, inReplyToStatus);
}
@ -1022,7 +1022,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
}
private boolean handleMentionIntent(final ParcelableUser user) {
if (user == null || user.id <= 0) return false;
if (user == null || user.key == null) return false;
final String accountScreenName = DataStoreUtils.getAccountScreenName(this, user.account_key);
if (TextUtils.isEmpty(accountScreenName)) return false;
mEditText.setText(String.format("@%s ", user.screen_name));
@ -1075,7 +1075,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
int selectionStart = 0;
mEditText.append("@" + status.user_screen_name + " ");
// If replying status from current user, just exclude it's screen name from selection.
if (status.account_key.getId() != status.user_id) {
if (!status.account_key.equals(status.user_key)) {
selectionStart = mEditText.length();
}
if (status.is_retweet) {
@ -1102,7 +1102,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
return true;
}
private boolean handleReplyMultipleIntent(final String[] screenNames, final AccountKey accountId,
private boolean handleReplyMultipleIntent(final String[] screenNames, final UserKey accountId,
final ParcelableStatus inReplyToStatus) {
if (screenNames == null || screenNames.length == 0 || accountId == null) return false;
final String myScreenName = DataStoreUtils.getAccountScreenName(this, accountId);
@ -1130,7 +1130,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
private boolean isQuotingProtectedStatus() {
final ParcelableStatus status = mInReplyToStatus;
if (!isQuote() || status == null) return false;
return status.user_is_protected && status.account_key.getId() != status.user_id;
return status.user_is_protected && !status.account_key.equals(status.user_key);
}
private boolean noReplyContent(final String text) {
@ -1338,7 +1338,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
return;
}
final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION, false);
final AccountKey[] accountKeys = mAccountsAdapter.getSelectedAccountKeys();
final UserKey[] accountKeys = mAccountsAdapter.getSelectedAccountKeys();
final ParcelableLocation statusLocation = attachLocation ? mRecentLocation : null;
final boolean isPossiblySensitive = hasMedia && mIsPossiblySensitive;
final ParcelableStatusUpdate update = new ParcelableStatusUpdate();
@ -1480,7 +1480,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
private final ComposeActivity mActivity;
private final LayoutInflater mInflater;
private final Map<AccountKey, Boolean> mSelection;
private final Map<UserKey, Boolean> mSelection;
private final boolean mNameFirst;
private ParcelableCredentials[] mAccounts;
@ -1504,24 +1504,24 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
}
@NonNull
public AccountKey[] getSelectedAccountKeys() {
if (mAccounts == null) return new AccountKey[0];
final AccountKey[] temp = new AccountKey[mAccounts.length];
public UserKey[] getSelectedAccountKeys() {
if (mAccounts == null) return new UserKey[0];
final UserKey[] temp = new UserKey[mAccounts.length];
int selectedCount = 0;
for (ParcelableAccount account : mAccounts) {
if (Boolean.TRUE.equals(mSelection.get(account.account_key))) {
temp[selectedCount++] = account.account_key;
}
}
final AccountKey[] result = new AccountKey[selectedCount];
final UserKey[] result = new UserKey[selectedCount];
System.arraycopy(temp, 0, result, 0, result.length);
return result;
}
public void setSelectedAccountIds(AccountKey... accountKeys) {
public void setSelectedAccountIds(UserKey... accountKeys) {
mSelection.clear();
if (accountKeys != null) {
for (AccountKey accountKey : accountKeys) {
for (UserKey accountKey : accountKeys) {
mSelection.put(accountKey, true);
}
}

View File

@ -50,7 +50,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter;
import org.mariotaku.twidere.adapter.ArrayAdapter;
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.CustomTabConfiguration;
import org.mariotaku.twidere.model.CustomTabConfiguration.ExtraConfiguration;
import org.mariotaku.twidere.model.ParcelableAccount;
@ -223,7 +223,7 @@ public class CustomTabEditorActivity extends BaseSupportDialogActivity implement
icon.setVisibility(displayProfileImage ? View.VISIBLE : View.GONE);
if (value instanceof ParcelableUser) {
final ParcelableUser user = (ParcelableUser) value;
text1.setText(mUserColorNameManager.getUserNickname(user.id, user.name, false));
text1.setText(mUserColorNameManager.getUserNickname(user.key, user.name, false));
text2.setText("@" + user.screen_name);
if (displayProfileImage) {
mImageLoader.displayProfileImage(icon, user);
@ -372,14 +372,14 @@ public class CustomTabEditorActivity extends BaseSupportDialogActivity implement
if (value == null || args == null || conf == null) return;
if (value instanceof ParcelableUser) {
final ParcelableUser user = (ParcelableUser) value;
args.putLong(EXTRA_USER_ID, user.id);
args.putLong(EXTRA_USER_ID, user.key.getId());
args.putString(EXTRA_SCREEN_NAME, user.screen_name);
args.putString(EXTRA_NAME, user.name);
} else if (value instanceof ParcelableUserList) {
final ParcelableUserList user_list = (ParcelableUserList) value;
args.putLong(EXTRA_LIST_ID, user_list.id);
args.putString(EXTRA_LIST_NAME, user_list.name);
args.putLong(EXTRA_USER_ID, user_list.user_id);
args.putLong(EXTRA_USER_ID, user_list.user_key.getId());
args.putString(EXTRA_SCREEN_NAME, user_list.user_screen_name);
} else if (value instanceof CharSequence) {
final String key = conf.getSecondaryFieldTextKey();
@ -392,7 +392,7 @@ public class CustomTabEditorActivity extends BaseSupportDialogActivity implement
addFieldValueToArguments(value, args);
}
private AccountKey getAccountKey() {
private UserKey getAccountKey() {
final int pos = mAccountSpinner.getSelectedItemPosition();
if (mAccountSpinner.getCount() > pos && pos >= 0) {
ParcelableCredentials credentials = mAccountsAdapter.getItem(pos);

View File

@ -75,7 +75,7 @@ import org.mariotaku.twidere.fragment.support.AccountsDashboardFragment;
import org.mariotaku.twidere.fragment.support.DirectMessagesFragment;
import org.mariotaku.twidere.fragment.support.TrendsSuggestionsFragment;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.SupportTabSpec;
import org.mariotaku.twidere.model.message.TaskStateChangedEvent;
@ -150,7 +150,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
}
@NonNull
public AccountKey[] getActivatedAccountKeys() {
public UserKey[] getActivatedAccountKeys() {
final Fragment fragment = getLeftDrawerFragment();
if (fragment instanceof AccountsDashboardFragment) {
return ((AccountsDashboardFragment) fragment).getActivatedAccountIds();
@ -673,7 +673,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
if (Intent.ACTION_SEARCH.equals(action)) {
final String query = intent.getStringExtra(SearchManager.QUERY);
final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA);
final AccountKey accountKey;
final UserKey accountKey;
if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_KEY)) {
accountKey = appSearchData.getParcelable(EXTRA_ACCOUNT_KEY);
} else {
@ -692,7 +692,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
final String tabType = uri != null ? Utils.matchTabType(uri) : null;
int initialTab = -1;
if (tabType != null) {
final AccountKey accountId = AccountKey.valueOf(uri.getQueryParameter(QUERY_PARAM_ACCOUNT_KEY));
final UserKey accountId = UserKey.valueOf(uri.getQueryParameter(QUERY_PARAM_ACCOUNT_KEY));
for (int i = 0, j = mPagerAdapter.getCount(); i < j; i++) {
final SupportTabSpec tab = mPagerAdapter.getTab(i);
if (tabType.equals(CustomTabUtils.getTabTypeAlias(tab.type))) {
@ -924,7 +924,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
}
switch (spec.type) {
case CustomTabType.HOME_TIMELINE: {
final AccountKey[] accountKeys = Utils.getAccountKeys(mContext, spec.args);
final UserKey[] accountKeys = Utils.getAccountKeys(mContext, spec.args);
final String tagWithAccounts = Utils.getReadPositionTagWithAccounts(mContext,
true, ReadPositionTag.HOME_TIMELINE, accountKeys);
final long position = mReadStateManager.getPosition(tagWithAccounts);
@ -935,7 +935,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
break;
}
case CustomTabType.NOTIFICATIONS_TIMELINE: {
final AccountKey[] accountIds = Utils.getAccountKeys(mContext, spec.args);
final UserKey[] accountIds = Utils.getAccountKeys(mContext, spec.args);
final String tagWithAccounts = Utils.getReadPositionTagWithAccounts(mContext,
true, ReadPositionTag.ACTIVITIES_ABOUT_ME, accountIds);
final long position = mReadStateManager.getPosition(tagWithAccounts);

View File

@ -81,7 +81,7 @@ import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.iface.IExtendedActivity;
import org.mariotaku.twidere.fragment.ProgressDialogFragment;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.provider.CacheProvider;
@ -825,7 +825,7 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
@Override
protected Object getDownloadExtra() {
final MediaExtra mediaExtra = new MediaExtra();
mediaExtra.setAccountKey(getArguments().<AccountKey>getParcelable(EXTRA_ACCOUNT_KEY));
mediaExtra.setAccountKey(getArguments().<UserKey>getParcelable(EXTRA_ACCOUNT_KEY));
final Uri origDownloadUri = super.getDownloadUri();
final Uri downloadUri = getDownloadUri();
if (origDownloadUri != null && downloadUri != null) {

View File

@ -56,9 +56,9 @@ import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter;
import org.mariotaku.twidere.fragment.support.UserFragment;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.SearchHistory;
import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions;
import org.mariotaku.twidere.util.DataStoreUtils;
@ -112,7 +112,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
mUsersSearchAdapter.addRemovedPositions(reverseSortedPositions);
final ContentResolver cr = getContentResolver();
ContentResolverUtils.bulkDelete(cr, SearchHistory.CONTENT_URI, SearchHistory._ID, ids,
null, false);
null);
getSupportLoaderManager().restartLoader(0, null, this);
}
@ -143,7 +143,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
final AccountKey accountId = getSelectedAccountKey();
final UserKey accountId = getSelectedAccountKey();
final Uri.Builder builder = Suggestions.Search.CONTENT_URI.buildUpon();
builder.appendQueryParameter(QUERY_PARAM_QUERY, ParseUtils.parseString(mSearchQuery.getText()));
if (accountId != null) {
@ -229,7 +229,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
mAccountSpinner.setOnItemSelectedListener(this);
if (savedInstanceState == null) {
final Intent intent = getIntent();
final AccountKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
final int index = accountsSpinnerAdapter.findItemPosition(System.identityHashCode(accountKey));
if (index != -1) {
mAccountSpinner.setSelection(index);
@ -292,7 +292,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
finish();
}
private AccountKey getSelectedAccountKey() {
private UserKey getSelectedAccountKey() {
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
if (account == null) return null;
return account.account_key;
@ -400,7 +400,9 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
}
case VIEW_TYPE_USER_SUGGESTION_ITEM: {
final UserViewHolder holder = (UserViewHolder) view.getTag();
holder.text1.setText(mUserColorNameManager.getUserNickname(cursor.getLong(mIndices.extra_id),
final UserKey userKey = UserKey.valueOf(cursor.getString(mIndices.extra_id));
assert userKey != null;
holder.text1.setText(mUserColorNameManager.getUserNickname(userKey,
cursor.getString(mIndices.title), false));
holder.text2.setVisibility(View.VISIBLE);
holder.text2.setText(String.format("@%s", cursor.getString(mIndices.summary)));

View File

@ -84,11 +84,12 @@ import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
import org.mariotaku.twidere.fragment.support.SupportProgressDialogFragment;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.StatusNetAccountExtra;
import org.mariotaku.twidere.model.TwitterAccountExtra;
import org.mariotaku.twidere.model.util.UserKeyUtils;
import org.mariotaku.twidere.model.util.ParcelableUserUtils;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
import org.mariotaku.twidere.util.AsyncTaskUtils;
@ -231,7 +232,7 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
final AccountKey[] accountKeys = getActivatedAccountKeys(this);
final UserKey[] accountKeys = getActivatedAccountKeys(this);
if (accountKeys.length > 0) {
onBackPressed();
}
@ -1094,8 +1095,8 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
if (accountType != null) {
values.put(Accounts.ACCOUNT_TYPE, accountType.first);
values.put(Accounts.ACCOUNT_EXTRAS, accountType.second);
final AccountKey accountKey = new AccountKey(user.getId(),
ParcelableUserUtils.getUserHost(user.getOstatusUri()));
final UserKey accountKey = new UserKey(user.getId(),
UserKeyUtils.getUserHost(user.getOstatusUri()));
final ParcelableUser parcelableUser = ParcelableUserUtils.fromUser(user, accountKey);
values.put(Accounts.ACCOUNT_USER, JsonSerializer.serialize(parcelableUser, ParcelableUser.class));
}

View File

@ -48,7 +48,7 @@ import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserList;
import org.mariotaku.twidere.fragment.support.CreateUserListDialogFragment;
import org.mariotaku.twidere.fragment.support.SupportProgressDialogFragment;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.model.SingleResponse;
@ -203,7 +203,7 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
getUserLists(mScreenName);
}
private AccountKey getAccountKey() {
private UserKey getAccountKey() {
return getIntent().getParcelableExtra(EXTRA_ACCOUNT_KEY);
}
@ -280,10 +280,10 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
private static final String FRAGMENT_TAG_GET_USER_LISTS = "get_user_lists";
private final UserListSelectorActivity mActivity;
private final AccountKey mAccountKey;
private final UserKey mAccountKey;
private final String mScreenName;
GetUserListsTask(final UserListSelectorActivity activity, final AccountKey accountKey,
GetUserListsTask(final UserListSelectorActivity activity, final UserKey accountKey,
final String screenName) {
mActivity = activity;
mAccountKey = accountKey;
@ -344,10 +344,10 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
private static final String FRAGMENT_TAG_SEARCH_USERS = "search_users";
private final UserListSelectorActivity mActivity;
private final AccountKey mAccountKey;
private final UserKey mAccountKey;
private final String mName;
SearchUsersTask(final UserListSelectorActivity activity, final AccountKey accountKey,
SearchUsersTask(final UserListSelectorActivity activity, final UserKey accountKey,
final String name) {
mActivity = activity;
mAccountKey = accountKey;

View File

@ -438,7 +438,7 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
final ParcelableActivity activity = adapter.getActivity(position);
final ParcelableStatus status = ParcelableActivityUtils.getActivityStatus(activity);
assert status != null;
IntentUtils.openUserProfile(context, status.account_key, status.user_id,
IntentUtils.openUserProfile(context, status.account_key, status.user_key.getId(),
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
}

View File

@ -24,7 +24,7 @@ import android.database.Cursor;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.library.objectcursor.ObjectCursor;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusCursorIndices;
@ -66,7 +66,7 @@ public abstract class AbsParcelableStatusesAdapter extends AbsStatusesAdapter<Li
if (mData instanceof ObjectCursor) {
final Cursor cursor = ((ObjectCursor) mData).getCursor(dataPosition);
final ParcelableStatusCursorIndices indices = (ParcelableStatusCursorIndices) ((ObjectCursor) mData).getIndices();
final AccountKey accountKey = AccountKey.valueOf(cursor.getString(indices.account_key));
final UserKey accountKey = UserKey.valueOf(cursor.getString(indices.account_key));
final long id = cursor.getLong(indices.id);
return ParcelableStatus.calculateHashCode(accountKey, id);
}
@ -86,13 +86,13 @@ public abstract class AbsParcelableStatusesAdapter extends AbsStatusesAdapter<Li
}
@Override
public AccountKey getAccountKey(int adapterPosition) {
public UserKey getAccountKey(int adapterPosition) {
int dataPosition = adapterPosition - getStatusStartIndex();
if (dataPosition < 0 || dataPosition >= getStatusCount()) return null;
if (mData instanceof ObjectCursor) {
final Cursor cursor = ((ObjectCursor) mData).getCursor(dataPosition);
final ParcelableStatusCursorIndices indices = (ParcelableStatusCursorIndices) ((ObjectCursor) mData).getIndices();
return AccountKey.valueOf(cursor.getString(indices.account_key));
return UserKey.valueOf(cursor.getString(indices.account_key));
}
return mData.get(dataPosition).account_key;
}

View File

@ -12,7 +12,7 @@ import android.view.ViewGroup;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.MediaLoadingHandler;
@ -283,7 +283,7 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
@Nullable
@Override
public ParcelableStatus findStatusById(AccountKey accountKey, long statusId) {
public ParcelableStatus findStatusById(UserKey accountKey, long statusId) {
for (int i = 0, j = getStatusCount(); i < j; i++) {
if (accountKey.equals(getAccountKey(i)) && statusId == getStatusId(i)) {
return getStatus(i);

View File

@ -30,7 +30,7 @@ import com.mobeta.android.dslv.SimpleDragSortCursorAdapter;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccountCursorIndices;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
@ -56,7 +56,7 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
final Object tag = buttonView.getTag();
if (!(tag instanceof String) || mOnAccountToggleListener == null) return;
final AccountKey accountKey = AccountKey.valueOf((String) tag);
final UserKey accountKey = UserKey.valueOf((String) tag);
mOnAccountToggleListener.onAccountToggle(accountKey, isChecked);
}
};
@ -181,6 +181,6 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
}
public interface OnAccountToggleListener {
void onAccountToggle(AccountKey accountId, boolean state);
void onAccountToggle(UserKey accountId, boolean state);
}
}

View File

@ -32,7 +32,7 @@ import android.widget.TextView;
import org.apache.commons.lang3.StringUtils;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
@ -58,7 +58,7 @@ public class ComposeAutoCompleteAdapter extends SimpleCursorAdapter implements C
private final boolean mDisplayProfileImage;
private int mTypeIdx, mIconIdx, mTitleIdx, mSummaryIdx, mExtraIdIdx, mValueIdx;
private AccountKey mAccountKey;
private UserKey mAccountKey;
private char mToken;
public ComposeAutoCompleteAdapter(final Context context) {
@ -77,8 +77,9 @@ public class ComposeAutoCompleteAdapter extends SimpleCursorAdapter implements C
icon.setImageDrawable(null);
if (Suggestions.AutoComplete.TYPE_USERS.equals(cursor.getString(mTypeIdx))) {
text1.setText(mUserColorNameManager.getUserNickname(cursor.getLong(mExtraIdIdx), cursor.getString(mTitleIdx)));
text2.setText('@' + cursor.getString(mSummaryIdx));
text1.setText(mUserColorNameManager.getUserNickname(cursor.getString(mExtraIdIdx),
cursor.getString(mTitleIdx)));
text2.setText(String.format("@%s", cursor.getString(mSummaryIdx)));
if (mDisplayProfileImage) {
final String profileImageUrl = cursor.getString(mIconIdx);
mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
@ -88,7 +89,7 @@ public class ComposeAutoCompleteAdapter extends SimpleCursorAdapter implements C
icon.clearColorFilter();
} else {
text1.setText('#' + cursor.getString(mTitleIdx));
text1.setText(String.format("#%s", cursor.getString(mTitleIdx)));
text2.setText(R.string.hashtag);
icon.setImageResource(R.drawable.ic_action_hashtag);
@ -149,7 +150,7 @@ public class ComposeAutoCompleteAdapter extends SimpleCursorAdapter implements C
}
public void setAccountKey(AccountKey accountKey) {
public void setAccountKey(UserKey accountKey) {
mAccountKey = accountKey;
}

View File

@ -10,7 +10,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.TwidereConstants;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.constant.SharedPreferenceConstants;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
@ -183,13 +183,13 @@ public final class DummyStatusHolderAdapter implements IStatusesAdapter<Object>,
@Override
@Nullable
public AccountKey getAccountKey(int position) {
public UserKey getAccountKey(int position) {
return null;
}
@Nullable
@Override
public ParcelableStatus findStatusById(AccountKey accountId, long statusId) {
public ParcelableStatus findStatusById(UserKey accountId, long statusId) {
return null;
}

View File

@ -29,7 +29,7 @@ import android.view.ViewGroup;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IDirectMessagesAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableDirectMessage;
import org.mariotaku.twidere.model.ParcelableDirectMessageCursorIndices;
import org.mariotaku.twidere.model.ParcelableMedia;
@ -168,7 +168,7 @@ public class MessageConversationAdapter extends BaseRecyclerViewAdapter<ViewHold
final Cursor c = mCursor;
if (c == null || c.isClosed()) return null;
c.moveToPosition(position);
final AccountKey accountKey = AccountKey.valueOf(c.getString(mIndices.account_key));
final UserKey accountKey = UserKey.valueOf(c.getString(mIndices.account_key));
final long messageId = c.getLong(mIndices.id);
return Utils.findDirectMessageInDatabases(getContext(), accountKey, messageId);
}
@ -206,7 +206,7 @@ public class MessageConversationAdapter extends BaseRecyclerViewAdapter<ViewHold
}
@Override
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
public void onMediaClick(View view, ParcelableMedia media, UserKey accountKey, long extraId) {
final MessageConversationAdapter adapter = adapterRef.get();
IntentUtils.openMedia(adapter.getContext(), adapter.getDirectMessage((int) extraId), media,
null, true);

View File

@ -33,7 +33,7 @@ import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IContentCardAdapter;
import org.mariotaku.twidere.annotation.CustomTabType;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.StringLongPair;
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.ConversationEntries;
import org.mariotaku.twidere.util.ReadStateManager.OnReadStateChangeListener;
@ -242,12 +242,12 @@ public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> im
public static class DirectMessageEntry {
public final AccountKey account_key;
public final UserKey account_key;
public final long conversation_id;
public final String screen_name, name;
DirectMessageEntry(Cursor cursor) {
account_key = AccountKey.valueOf(cursor.getString(ConversationEntries.IDX_ACCOUNT_KEY));
account_key = UserKey.valueOf(cursor.getString(ConversationEntries.IDX_ACCOUNT_KEY));
conversation_id = cursor.getLong(ConversationEntries.IDX_CONVERSATION_ID);
screen_name = cursor.getString(ConversationEntries.IDX_SCREEN_NAME);
name = cursor.getString(ConversationEntries.IDX_NAME);

View File

@ -25,7 +25,7 @@ import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.library.objectcursor.ObjectCursor;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableActivity;
import org.mariotaku.twidere.model.ParcelableActivityCursorIndices;
import org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder;
@ -59,7 +59,7 @@ public class ParcelableActivitiesAdapter extends AbsActivitiesAdapter<List<Parce
if (mData instanceof ObjectCursor) {
final Cursor cursor = ((ObjectCursor) mData).getCursor(dataPosition);
final ParcelableActivityCursorIndices indices = (ParcelableActivityCursorIndices) ((ObjectCursor) mData).getIndices();
final AccountKey accountKey = AccountKey.valueOf(cursor.getString(indices.account_key));
final UserKey accountKey = UserKey.valueOf(cursor.getString(indices.account_key));
final long timestamp = cursor.getLong(indices.timestamp);
final long maxPosition = cursor.getLong(indices.max_position);
final long minPosition = cursor.getLong(indices.min_position);

View File

@ -22,7 +22,7 @@ package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.view.holder.UserViewHolder;
@ -86,7 +86,7 @@ public class ParcelableUsersAdapter extends AbsUsersAdapter<List<ParcelableUser>
@Override
public long getUserId(int position) {
if (position == getUserCount()) return -1;
return mData.get(position).id;
return mData.get(position).key.getId();
}
@Override
@ -103,11 +103,11 @@ public class ParcelableUsersAdapter extends AbsUsersAdapter<List<ParcelableUser>
return true;
}
public int findPosition(AccountKey accountKey, long userId) {
public int findPosition(UserKey accountKey, long userId) {
if (mData == null) return RecyclerView.NO_POSITION;
for (int i = getUserStartIndex(), j = i + getUserCount(); i < j; i++) {
final ParcelableUser user = mData.get(i);
if (user.account_key.equals(accountKey) && user.id == userId) {
if (user.account_key.equals(accountKey) && user.key.getId() == userId) {
return i;
}
}

View File

@ -35,21 +35,18 @@ import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> implements IBaseAdapter {
private final Context mContext;
public SimpleParcelableUsersAdapter(final Context context) {
this(context, R.layout.list_item_user);
}
public SimpleParcelableUsersAdapter(final Context context, final int layoutRes) {
super(context, layoutRes);
mContext = context;
configBaseAdapter(context, this);
}
@Override
public long getItemId(final int position) {
return getItem(position) != null ? getItem(position).id : -1;
return getItem(position) != null ? getItem(position).key.getId() : -1;
}
@Override
@ -68,8 +65,8 @@ public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUse
holder.text1.setCompoundDrawablesWithIntrinsicBounds(0, 0,
getUserTypeIconRes(user.is_verified, user.is_protected), 0);
holder.text1.setText(mUserColorNameManager.getUserNickname(user.id, user.name));
holder.text2.setText("@" + user.screen_name);
holder.text1.setText(mUserColorNameManager.getUserNickname(user.key, user.name));
holder.text2.setText(String.format("@%s", user.screen_name));
holder.icon.setVisibility(isProfileImageDisplayed() ? View.VISIBLE : View.GONE);
if (isProfileImageDisplayed()) {
mImageLoader.displayProfileImage(holder.icon, user.profile_image_url);
@ -89,7 +86,7 @@ public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUse
}
if (data == null) return;
for (final ParcelableUser user : data) {
if (clearOld || findItemPosition(user.id) < 0) {
if (clearOld || findItemPosition(user.key.getId()) < 0) {
add(user);
}
}

View File

@ -33,7 +33,7 @@ import com.commonsware.cwac.layouts.AspectLockedFrameLayout;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
@ -137,7 +137,7 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
}
@Override
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
public void onMediaClick(View view, ParcelableMedia media, UserKey accountKey, long extraId) {
}
@Override

View File

@ -34,7 +34,7 @@ import org.mariotaku.sqliteqb.library.OrderBy;
import org.mariotaku.sqliteqb.library.RawItemArray;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
@ -61,7 +61,7 @@ public class UserAutoCompleteAdapter extends SimpleCursorAdapter implements Cons
private final boolean mDisplayProfileImage;
private int mIdIdx, mNameIdx, mScreenNameIdx, mProfileImageIdx;
private AccountKey mAccountKey;
private UserKey mAccountKey;
public UserAutoCompleteAdapter(final Context context) {
super(context, R.layout.list_item_auto_complete, null, FROM, TO, 0);
@ -78,8 +78,8 @@ public class UserAutoCompleteAdapter extends SimpleCursorAdapter implements Cons
// Clear images in order to prevent images in recycled view shown.
icon.setImageDrawable(null);
text1.setText(mUserColorNameManager.getUserNickname(cursor.getLong(mIdIdx), cursor.getString(mNameIdx)));
text2.setText('@' + cursor.getString(mScreenNameIdx));
text1.setText(mUserColorNameManager.getUserNickname(cursor.getString(mIdIdx), cursor.getString(mNameIdx)));
text2.setText(String.format("@%s", cursor.getString(mScreenNameIdx)));
if (mDisplayProfileImage) {
final String profileImageUrl = cursor.getString(mProfileImageIdx);
mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
@ -115,7 +115,7 @@ public class UserAutoCompleteAdapter extends SimpleCursorAdapter implements Cons
final Expression usersSelection = Expression.or(
Expression.likeRaw(new Columns.Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"),
Expression.likeRaw(new Columns.Column(CachedUsers.NAME), "?||'%'", "^"),
Expression.in(new Columns.Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds)));
Expression.in(new Columns.Column(CachedUsers.USER_KEY), new RawItemArray(nicknameIds)));
final String[] selectionArgs = new String[]{queryEscaped, queryEscaped};
final String[] order = {CachedUsers.LAST_SEEN, CachedUsers.SCORE, CachedUsers.SCREEN_NAME,
CachedUsers.NAME};
@ -127,14 +127,14 @@ public class UserAutoCompleteAdapter extends SimpleCursorAdapter implements Cons
}
public void setAccountKey(AccountKey accountKey) {
public void setAccountKey(UserKey accountKey) {
mAccountKey = accountKey;
}
@Override
public Cursor swapCursor(final Cursor cursor) {
if (cursor != null) {
mIdIdx = cursor.getColumnIndex(CachedUsers.USER_ID);
mIdIdx = cursor.getColumnIndex(CachedUsers.USER_KEY);
mNameIdx = cursor.getColumnIndex(CachedUsers.NAME);
mScreenNameIdx = cursor.getColumnIndex(CachedUsers.SCREEN_NAME);
mProfileImageIdx = cursor.getColumnIndex(CachedUsers.PROFILE_IMAGE_URL);

View File

@ -3,7 +3,7 @@ package org.mariotaku.twidere.adapter.iface;
import android.support.annotation.Nullable;
import android.view.View;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.MediaLoadingHandler;
@ -27,10 +27,10 @@ public interface IStatusesAdapter<Data> extends IContentCardAdapter, IGapSupport
long getStatusId(int position);
@Nullable
AccountKey getAccountKey(int position);
UserKey getAccountKey(int position);
@Nullable
ParcelableStatus findStatusById(AccountKey accountKey, long statusId);
ParcelableStatus findStatusById(UserKey accountKey, long statusId);
int getStatusCount();

View File

@ -58,7 +58,7 @@ public abstract class BaseAccountPreferenceFragment extends BasePreferenceFragme
final Intent intent = activity.getIntent();
if (account != null && intent.hasExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT)) {
final boolean nameFirst = prefs.getBoolean(KEY_NAME_FIRST, true);
final String name = mUserColorNameManager.getDisplayName(account.account_key.getId(),
final String name = mUserColorNameManager.getDisplayName(account.account_key,
account.name, account.screen_name, nameFirst, false);
activity.setTitle(name);
}

View File

@ -61,7 +61,7 @@ import org.mariotaku.sqliteqb.library.RawItemArray;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.SettingsActivity;
import org.mariotaku.twidere.activity.support.CustomTabEditorActivity;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.CustomTabConfiguration;
import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfigurationComparator;
import org.mariotaku.twidere.provider.TwidereDataStore.Tabs;
@ -222,7 +222,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
final Resources res = getResources();
final boolean hasOfficialKeyAccounts = Utils.hasAccountSignedWithOfficialKeys(getActivity());
final boolean forcePrivateAPI = mPreferences.getBoolean(KEY_FORCE_USING_PRIVATE_APIS, false);
final AccountKey[] accountIds = DataStoreUtils.getAccountKeys(getActivity());
final UserKey[] accountIds = DataStoreUtils.getAccountKeys(getActivity());
final MenuItem itemAdd = menu.findItem(R.id.add_submenu);
if (itemAdd != null && itemAdd.hasSubMenu()) {
final SubMenu subMenu = itemAdd.getSubMenu();

View File

@ -33,7 +33,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.api.twitter.Twitter;
import org.mariotaku.twidere.api.twitter.TwitterException;
import org.mariotaku.twidere.api.twitter.model.Paging;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
import org.mariotaku.twidere.util.DataStoreUtils;
@ -155,7 +155,7 @@ public class NetworkDiagnosticsFragment extends BaseFragment {
}
publishProgress(LogText.LINEBREAK, LogText.LINEBREAK);
for (AccountKey accountKey : DataStoreUtils.getAccountKeys(mContext)) {
for (UserKey accountKey : DataStoreUtils.getAccountKeys(mContext)) {
final ParcelableCredentials credentials = ParcelableCredentialsUtils.getCredentials(mContext, accountKey);
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mContext, accountKey, false);
if (credentials == null || twitter == null) continue;

View File

@ -47,7 +47,7 @@ import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosi
import org.mariotaku.twidere.annotation.ReadPositionTag;
import org.mariotaku.twidere.fragment.support.AbsStatusesFragment.DefaultOnLikedListener;
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.BaseRefreshTaskParam;
import org.mariotaku.twidere.model.ParcelableActivity;
import org.mariotaku.twidere.model.ParcelableMedia;
@ -91,7 +91,7 @@ public abstract class AbsActivitiesFragment<Data> extends AbsContentListRecycler
public List<ScrollRecord> mRecords;
private long mFirstVisibleTimestamp = -1;
private AccountKey mFirstVisibleAccountId = null;
private UserKey mFirstVisibleAccountId = null;
private int mFirstVisiblePosition = -1;
private int mScrollState;
@ -105,7 +105,7 @@ public abstract class AbsActivitiesFragment<Data> extends AbsContentListRecycler
final ParcelableActivity activity = adapter.getActivity(firstVisiblePosition);
if (activity != null) {
final long timestamp = activity.timestamp;
final AccountKey accountKey = activity.account_key;
final UserKey accountKey = activity.account_key;
if (timestamp != mFirstVisibleTimestamp || !accountKey.equals(mFirstVisibleAccountId)) {
if (mRecords == null) mRecords = new ArrayList<>();
final long time = System.currentTimeMillis();
@ -340,7 +340,7 @@ public abstract class AbsActivitiesFragment<Data> extends AbsContentListRecycler
public void onGapClick(GapViewHolder holder, int position) {
final AbsActivitiesAdapter<Data> adapter = getAdapter();
final ParcelableActivity activity = adapter.getActivity(position);
final AccountKey[] accountIds = {activity.account_key};
final UserKey[] accountIds = {activity.account_key};
final long[] maxIds = {activity.min_position};
getActivities(new BaseRefreshTaskParam(accountIds, maxIds, null));
}
@ -507,7 +507,7 @@ public abstract class AbsActivitiesFragment<Data> extends AbsContentListRecycler
return new StatusesBusCallback();
}
protected abstract AccountKey[] getAccountKeys();
protected abstract UserKey[] getAccountKeys();
protected Data getAdapterData() {
final AbsActivitiesAdapter<Data> adapter = getAdapter();

View File

@ -47,11 +47,11 @@ import org.mariotaku.twidere.adapter.iface.IStatusesAdapter.StatusAdapterListene
import org.mariotaku.twidere.annotation.ReadPositionTag;
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.BaseRefreshTaskParam;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.RefreshTaskParam;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.StatusListChangedEvent;
import org.mariotaku.twidere.task.AbstractTask;
import org.mariotaku.twidere.task.util.TaskStarter;
@ -90,7 +90,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
public List<ScrollRecord> mRecords;
private long mFirstVisibleId = -1;
private AccountKey mFirstVisibleAccountId = null;
private UserKey mFirstVisibleAccountId = null;
private int mFirstVisiblePosition = -1;
private int mScrollState;
@ -104,7 +104,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
final ParcelableStatus status = adapter.getStatus(firstVisiblePosition);
if (status != null) {
final long id = status.id;
final AccountKey accountId = status.account_key;
final UserKey accountId = status.account_key;
if (id != mFirstVisibleId || !accountId.equals(mFirstVisibleAccountId)) {
if (mRecords == null) mRecords = new ArrayList<>();
final long time = System.currentTimeMillis();
@ -321,7 +321,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
final AbsStatusesAdapter<Data> adapter = getAdapter();
final ParcelableStatus status = adapter.getStatus(position);
if (status == null) return;
final AccountKey[] accountIds = {status.account_key};
final UserKey[] accountIds = {status.account_key};
final long[] maxIds = {status.id};
getStatuses(new BaseRefreshTaskParam(accountIds, maxIds, null));
}
@ -405,7 +405,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
@Override
public void onUserProfileClick(IStatusViewHolder holder, ParcelableStatus status, int position) {
final FragmentActivity activity = getActivity();
IntentUtils.openUserProfile(activity, status.account_key, status.user_id,
IntentUtils.openUserProfile(activity, status.account_key, status.user_key.getId(),
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
}
@ -493,7 +493,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
return new StatusesBusCallback();
}
protected abstract AccountKey[] getAccountKeys();
protected abstract UserKey[] getAccountKeys();
protected Data getAdapterData() {
final AbsStatusesAdapter<Data> adapter = getAdapter();

View File

@ -112,8 +112,8 @@ abstract class AbsUsersFragment<Data> extends AbsContentListRecyclerViewFragment
public void onUserClick(UserViewHolder holder, int position) {
final ParcelableUser user = getAdapter().getUser(position);
final FragmentActivity activity = getActivity();
IntentUtils.openUserProfile(activity, user.account_key, user.id, user.screen_name, null,
true, getUserReferral());
IntentUtils.openUserProfile(activity, user.account_key, user.key.getId(),
user.screen_name, null, true, getUserReferral());
}
@UserFragment.Referral

View File

@ -87,9 +87,9 @@ import org.mariotaku.twidere.activity.support.QuickSearchBarActivity;
import org.mariotaku.twidere.adapter.ArrayAdapter;
import org.mariotaku.twidere.annotation.CustomTabType;
import org.mariotaku.twidere.menu.support.AccountToggleProvider;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.SupportTabSpec;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.util.ParcelableAccountUtils;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
import org.mariotaku.twidere.util.CompareUtils;
@ -159,7 +159,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
private boolean mLoaderInitialized;
@NonNull
public AccountKey[] getActivatedAccountIds() {
public UserKey[] getActivatedAccountIds() {
if (mAccountActionProvider != null) {
return mAccountActionProvider.getActivatedAccountIds();
}
@ -278,7 +278,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
mNoAccountContainer.setVisibility(View.VISIBLE);
mAccountProfileContainer.setVisibility(View.INVISIBLE);
}
AccountKey defaultId = null;
UserKey defaultId = null;
for (ParcelableAccount account : accounts) {
if (account.is_activated) {
defaultId = account.account_key;
@ -288,7 +288,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
mUseStarsForLikes = mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK);
mAccountsAdapter.setAccounts(accounts);
AccountKey accountKey = AccountKey.valueOf(mPreferences.getString(KEY_DEFAULT_ACCOUNT_KEY, null));
UserKey accountKey = UserKey.valueOf(mPreferences.getString(KEY_DEFAULT_ACCOUNT_KEY, null));
if (accountKey == null) {
accountKey = defaultId;
}
@ -580,9 +580,9 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
mAccountOptionsAdapter.add(new OptionItem(R.string.lists, R.drawable.ic_action_list, R.id.lists));
}
private boolean hasAccountInTab(SupportTabSpec tab, AccountKey accountId, boolean isActivated) {
private boolean hasAccountInTab(SupportTabSpec tab, UserKey accountId, boolean isActivated) {
if (tab.args == null) return false;
final AccountKey[] accountKeys = Utils.getAccountKeys(getContext(), tab.args);
final UserKey[] accountKeys = Utils.getAccountKeys(getContext(), tab.args);
if (accountKeys == null) return isActivated;
return ArrayUtils.contains(accountKeys, accountId);
}
@ -754,8 +754,8 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
final ParcelableAccount account = mSelectedAccount;
if (account != null && option.id == R.id.compose) {
final Context context = getContext();
final String displayName = mUserColorNameManager.getDisplayName(-1, account.name,
account.screen_name, mNameFirst, false);
final String displayName = UserColorNameManager.getDisplayName(account.name,
account.screen_name, mNameFirst);
return context.getString(R.string.tweet_from_name, displayName);
}
return super.getTitle(position, option);
@ -798,7 +798,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
setHasStableIds(true);
}
private static int indexOfAccount(List<ParcelableAccount> accounts, AccountKey accountId) {
private static int indexOfAccount(List<ParcelableAccount> accounts, UserKey accountId) {
for (int i = 0, j = accounts.size(); i < j; i++) {
if (accounts.get(i).account_key.equals(accountId)) return i;
}
@ -821,13 +821,13 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
}
@Nullable
public AccountKey getSelectedAccountKey() {
public UserKey getSelectedAccountKey() {
final ParcelableAccount selectedAccount = getSelectedAccount();
if (selectedAccount == null) return null;
return selectedAccount.account_key;
}
public void setSelectedAccountKey(@Nullable AccountKey accountKey) {
public void setSelectedAccountKey(@Nullable UserKey accountKey) {
final ParcelableAccount selectedAccount = getSelectedAccount();
if (selectedAccount == null || accountKey == null) return;
swap(accountKey, selectedAccount.account_key);
@ -889,7 +889,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
return mInternalAccounts;
}
private void swap(AccountKey fromId, AccountKey toId) {
private void swap(UserKey fromId, UserKey toId) {
int fromIdx = -1, toIdx = -1;
for (int i = 0, j = mInternalAccounts.length; i < j; i++) {
final ParcelableAccount account = mInternalAccounts[i];

View File

@ -44,7 +44,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
import org.mariotaku.twidere.activity.support.SignInActivity;
import org.mariotaku.twidere.adapter.AccountsAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.provider.TwidereDataStore.AccountSupportColumns;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
@ -71,7 +71,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
private AccountsAdapter mAdapter;
private ParcelableAccount mSelectedAccount;
private SimpleArrayMap<AccountKey, Boolean> mActivatedState = new SimpleArrayMap<>();
private SimpleArrayMap<UserKey, Boolean> mActivatedState = new SimpleArrayMap<>();
private DragSortListView mListView;
private View mEmptyView;
@ -163,7 +163,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
}
private void saveActivatedState() {
final Set<AccountKey> trueIds = new CompactHashSet<>(), falseIds = new CompactHashSet<>();
final Set<UserKey> trueIds = new CompactHashSet<>(), falseIds = new CompactHashSet<>();
for (int i = 0, j = mActivatedState.size(); i < j; i++) {
if (mActivatedState.valueAt(i)) {
trueIds.add(mActivatedState.keyAt(i));
@ -184,7 +184,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
}
@Override
public void onAccountToggle(AccountKey accountId, boolean state) {
public void onAccountToggle(UserKey accountId, boolean state) {
mActivatedState.put(accountId, state);
}
@ -303,7 +303,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
@Override
public void onClick(final DialogInterface dialog, final int which) {
final Bundle args = getArguments();
final AccountKey accountId = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountId = args.getParcelable(EXTRA_ACCOUNT_KEY);
if (accountId == null) return;
final ContentResolver resolver = getContentResolver();
switch (which) {

View File

@ -36,6 +36,7 @@ import com.twitter.Extractor;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableUserMention;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
import org.mariotaku.twidere.util.ContentValuesCreator;
import org.mariotaku.twidere.util.HtmlEscapeHelper;
@ -59,7 +60,7 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
@Override
public void onClick(final DialogInterface dialog, final int which) {
final Set<Long> user_ids = new HashSet<>();
final Set<UserKey> userKeys = new HashSet<>();
final Set<String> keywords = new HashSet<>();
final Set<String> sources = new HashSet<>();
final ArrayList<ContentValues> userValues = new ArrayList<>();
@ -69,11 +70,11 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
final Object value = info.value;
if (value instanceof ParcelableUserMention) {
final ParcelableUserMention mention = (ParcelableUserMention) value;
user_ids.add(mention.id);
userKeys.add(mention.key);
userValues.add(ContentValuesCreator.createFilteredUser(mention));
} else if (value instanceof UserItem) {
final UserItem item = (UserItem) value;
user_ids.add(item.id);
userKeys.add(item.key);
userValues.add(createFilteredUser(item));
} else if (info.type == FilterItemInfo.FILTER_TYPE_KEYWORD) {
if (value != null) {
@ -94,9 +95,9 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
}
}
final ContentResolver resolver = getContentResolver();
ContentResolverUtils.bulkDelete(resolver, Filters.Users.CONTENT_URI, Filters.Users.USER_ID, user_ids, null, false);
ContentResolverUtils.bulkDelete(resolver, Filters.Keywords.CONTENT_URI, Filters.Keywords.VALUE, keywords, null, true);
ContentResolverUtils.bulkDelete(resolver, Filters.Sources.CONTENT_URI, Filters.Sources.VALUE, sources, null, true);
ContentResolverUtils.bulkDelete(resolver, Filters.Users.CONTENT_URI, Filters.Users.USER_ID, userKeys, null);
ContentResolverUtils.bulkDelete(resolver, Filters.Keywords.CONTENT_URI, Filters.Keywords.VALUE, keywords, null);
ContentResolverUtils.bulkDelete(resolver, Filters.Sources.CONTENT_URI, Filters.Sources.VALUE, sources, null);
ContentResolverUtils.bulkInsert(resolver, Filters.Users.CONTENT_URI, userValues);
ContentResolverUtils.bulkInsert(resolver, Filters.Keywords.CONTENT_URI, keywordValues);
ContentResolverUtils.bulkInsert(resolver, Filters.Sources.CONTENT_URI, sourceValues);
@ -154,12 +155,12 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
list.add(new FilterItemInfo(FilterItemInfo.FILTER_TYPE_USER, new UserItem(status.quoted_user_id,
status.quoted_user_name, status.quoted_user_screen_name)));
}
list.add(new FilterItemInfo(FilterItemInfo.FILTER_TYPE_USER, new UserItem(status.user_id,
list.add(new FilterItemInfo(FilterItemInfo.FILTER_TYPE_USER, new UserItem(status.user_key,
status.user_name, status.user_screen_name)));
final ParcelableUserMention[] mentions = status.mentions;
if (mentions != null) {
for (final ParcelableUserMention mention : mentions) {
if (mention.id != status.user_id) {
if (!mention.key.equals(status.user_key)) {
list.add(new FilterItemInfo(FilterItemInfo.FILTER_TYPE_USER, mention));
}
}
@ -177,11 +178,11 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
private String getName(final UserColorNameManager manager, final Object value, boolean nameFirst) {
if (value instanceof ParcelableUserMention) {
final ParcelableUserMention mention = (ParcelableUserMention) value;
return manager.getDisplayName(mention.id, mention.name, mention.screen_name, nameFirst,
return manager.getDisplayName(mention.key, mention.name, mention.screen_name, nameFirst,
true);
} else if (value instanceof UserItem) {
final UserItem item = (UserItem) value;
return manager.getDisplayName(item.id, item.name, item.screen_name, nameFirst, true);
return manager.getDisplayName(item.key, item.name, item.screen_name, nameFirst, true);
} else
return ParseUtils.parseString(value);
}
@ -189,7 +190,7 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
private static ContentValues createFilteredUser(UserItem item) {
if (item == null) return null;
final ContentValues values = new ContentValues();
values.put(Filters.Users.USER_ID, item.id);
values.put(Filters.Users.USER_ID, item.key.toString());
values.put(Filters.Users.NAME, item.name);
values.put(Filters.Users.SCREEN_NAME, item.screen_name);
return values;
@ -248,11 +249,11 @@ public class AddStatusFilterDialogFragment extends BaseSupportDialogFragment imp
}
private static class UserItem {
private final long id;
private final UserKey key;
private final String name, screen_name;
public UserItem(long id, String name, String screen_name) {
this.id = id;
public UserItem(UserKey key, String name, String screen_name) {
this.key = key;
this.name = name;
this.screen_name = screen_name;
}

View File

@ -61,6 +61,7 @@ import org.mariotaku.twidere.activity.support.UserListSelectorActivity;
import org.mariotaku.twidere.adapter.ComposeAutoCompleteAdapter;
import org.mariotaku.twidere.adapter.SourceAutoCompleteAdapter;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
import org.mariotaku.twidere.util.ContentValuesCreator;
import org.mariotaku.twidere.util.ParseUtils;
@ -406,7 +407,9 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
final ParcelableUser user = data.getParcelableExtra(EXTRA_USER);
final ContentValues values = ContentValuesCreator.createFilteredUser(user);
final ContentResolver resolver = getContentResolver();
resolver.delete(Filters.Users.CONTENT_URI, Expression.equals(Filters.Users.USER_ID, user.id).getSQL(), null);
final String where = Expression.equalsArgs(Filters.Users.USER_ID).getSQL();
final String[] whereArgs = {user.key.toString()};
resolver.delete(Filters.Users.CONTENT_URI, where, whereArgs);
resolver.insert(Filters.Users.CONTENT_URI, values);
break;
}
@ -453,7 +456,7 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
private int mUserIdIdx, mNameIdx, mScreenNameIdx;
FilterUsersListAdapter(final Context context) {
super(context, android.R.layout.simple_list_item_activated_1, null, new String[0], new int[0], 0);
super(context, android.R.layout.simple_list_item_activated_2, null, new String[0], new int[0], 0);
GeneralComponentHelper.build(context).inject(this);
mNameFirst = mPreferences.getBoolean(KEY_NAME_FIRST, true);
}
@ -462,12 +465,15 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
public void bindView(@NonNull final View view, final Context context, @NonNull final Cursor cursor) {
super.bindView(view, context, cursor);
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
final long userId = cursor.getLong(mUserIdIdx);
final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
final UserKey userId = UserKey.valueOf(cursor.getString(mUserIdIdx));
assert userId != null;
final String name = cursor.getString(mNameIdx);
final String screenName = cursor.getString(mScreenNameIdx);
final String displayName = mUserColorNameManager.getDisplayName(userId, name, screenName,
mNameFirst, false);
text1.setText(displayName);
text2.setText(userId.getHost());
}
@Override

View File

@ -29,7 +29,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
@ -45,7 +44,7 @@ public class CreateUserBlockDialogFragment extends BaseSupportDialogFragment imp
final ParcelableUser user = getUser();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (user == null || twitter == null) return;
twitter.createBlockAsync(user.account_key, user.id);
twitter.createBlockAsync(user.account_key, user.key.getId());
break;
default:
break;

View File

@ -30,7 +30,7 @@ import android.widget.CheckBox;
import com.rengwuxian.materialedittext.MaterialEditText;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.text.validator.UserListNameValidator;
import org.mariotaku.twidere.util.ParseUtils;
@ -42,7 +42,7 @@ public class CreateUserListDialogFragment extends BaseSupportDialogFragment impl
case DialogInterface.BUTTON_POSITIVE: {
final AlertDialog alertDialog = (AlertDialog) dialog;
final Bundle args = getArguments();
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final MaterialEditText mEditName = (MaterialEditText) alertDialog.findViewById(R.id.name);
final MaterialEditText mEditDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
final CheckBox mPublicCheckBox = (CheckBox) alertDialog.findViewById(R.id.is_public);

View File

@ -44,7 +44,7 @@ public class CreateUserMuteDialogFragment extends BaseSupportDialogFragment impl
final ParcelableUser user = getUser();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (user == null || twitter == null) return;
twitter.createMuteAsync(user.account_key, user.id);
twitter.createMuteAsync(user.account_key, user.key.getId());
break;
default:
break;

View File

@ -42,7 +42,7 @@ import org.mariotaku.twidere.activity.support.HomeActivity;
import org.mariotaku.twidere.adapter.AbsActivitiesAdapter;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.loader.support.ExtendedObjectCursorLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.BaseRefreshTaskParam;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableActivity;
@ -76,7 +76,7 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
@Override
protected void onLoadingFinished() {
final AccountKey[] accountIds = getAccountKeys();
final UserKey[] accountIds = getAccountKeys();
final AbsActivitiesAdapter<List<ParcelableActivity>> adapter = getAdapter();
if (adapter.getItemCount() > 0) {
showContent();
@ -107,7 +107,7 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
final Uri uri = getContentUri();
final String table = getTableNameByUri(uri);
final String sortOrder = getSortOrder();
final AccountKey[] accountKeys = getAccountKeys();
final UserKey[] accountKeys = getAccountKeys();
final Expression accountWhere = Expression.in(new Column(Activities.ACCOUNT_KEY),
new ArgsArray(accountKeys.length));
final Expression filterWhere = getFiltersWhere(table), where;
@ -133,9 +133,9 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
}
@Override
protected AccountKey[] getAccountKeys() {
protected UserKey[] getAccountKeys() {
final Bundle args = getArguments();
final AccountKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
final UserKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
if (accountKeys != null) {
return accountKeys;
}
@ -198,7 +198,7 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
TaskStarter.execute(new AbstractTask<Object, RefreshTaskParam, CursorActivitiesFragment>() {
@Override
public RefreshTaskParam doLongOperation(Object o) {
final AccountKey[] accountKeys = getAccountKeys();
final UserKey[] accountKeys = getAccountKeys();
final long[] maxIds = getOldestActivityIds(accountKeys);
return new BaseRefreshTaskParam(accountKeys, maxIds, null);
}
@ -219,7 +219,7 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
if (getActivity() == null) {
return null;
}
final AccountKey[] accountKeys = getAccountKeys();
final UserKey[] accountKeys = getAccountKeys();
final long[] sinceIds = getNewestActivityIds(accountKeys);
return new BaseRefreshTaskParam(accountKeys, sinceIds, null);
}
@ -238,7 +238,7 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
return DataStoreUtils.buildActivityFilterWhereClause(table, null);
}
protected long[] getNewestActivityIds(AccountKey[] accountKeys) {
protected long[] getNewestActivityIds(UserKey[] accountKeys) {
return DataStoreUtils.getNewestActivityMaxPositions(getActivity(), getContentUri(), accountKeys);
}
@ -248,13 +248,13 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
for (AccountKey accountKey : getAccountKeys()) {
for (UserKey accountKey : getAccountKeys()) {
mTwitterWrapper.clearNotificationAsync(getNotificationType(), accountKey);
}
}
}
protected long[] getOldestActivityIds(AccountKey[] accountKeys) {
protected long[] getOldestActivityIds(UserKey[] accountKeys) {
return DataStoreUtils.getOldestActivityMaxPositions(getActivity(), getContentUri(), accountKeys);
}
@ -325,11 +325,11 @@ public abstract class CursorActivitiesFragment extends AbsActivitiesFragment<Lis
}
public static class CursorActivitiesLoader extends ExtendedObjectCursorLoader<ParcelableActivity> {
private final AccountKey[] mAccountKeys;
private final UserKey[] mAccountKeys;
public CursorActivitiesLoader(Context context, Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder,
boolean fromUser, AccountKey[] accountKeys) {
boolean fromUser, UserKey[] accountKeys) {
super(context, ParcelableActivityCursorIndices.class, uri, projection, selection, selectionArgs, sortOrder, fromUser);
mAccountKeys = accountKeys;
}

View File

@ -43,7 +43,7 @@ import org.mariotaku.twidere.adapter.AbsStatusesAdapter;
import org.mariotaku.twidere.adapter.ListParcelableStatusesAdapter;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.loader.support.ExtendedObjectCursorLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusCursorIndices;
@ -75,7 +75,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
@Override
protected void onLoadingFinished() {
final AccountKey[] accountKeys = getAccountKeys();
final UserKey[] accountKeys = getAccountKeys();
final AbsStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
if (adapter.getItemCount() > 0) {
showContent();
@ -106,7 +106,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
final Uri uri = getContentUri();
final String table = getTableNameByUri(uri);
final String sortOrder = Statuses.DEFAULT_SORT_ORDER;
final AccountKey[] accountKeys = getAccountKeys();
final UserKey[] accountKeys = getAccountKeys();
final Expression accountWhere = Expression.in(new Column(Statuses.ACCOUNT_KEY),
new ArgsArray(accountKeys.length));
final Expression filterWhere = getFiltersWhere(table), where;
@ -186,9 +186,9 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
}
@Override
protected AccountKey[] getAccountKeys() {
protected UserKey[] getAccountKeys() {
final Bundle args = getArguments();
final AccountKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
final UserKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
if (accountKeys != null) {
return accountKeys;
}
@ -257,7 +257,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
getStatuses(new SimpleRefreshTaskParam() {
@NonNull
@Override
public AccountKey[] getAccountKeys() {
public UserKey[] getAccountKeys() {
return CursorStatusesFragment.this.getAccountKeys();
}
@ -280,7 +280,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
getStatuses(new SimpleRefreshTaskParam() {
@NonNull
@Override
public AccountKey[] getAccountKeys() {
public UserKey[] getAccountKeys() {
return CursorStatusesFragment.this.getAccountKeys();
}
@ -303,7 +303,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
return buildStatusFilterWhereClause(table, null);
}
protected long[] getNewestStatusIds(AccountKey[] accountKeys) {
protected long[] getNewestStatusIds(UserKey[] accountKeys) {
final Context context = getContext();
if (context == null) return null;
return DataStoreUtils.getNewestStatusIds(context, getContentUri(), accountKeys);
@ -315,13 +315,13 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
for (AccountKey accountId : getAccountKeys()) {
for (UserKey accountId : getAccountKeys()) {
mTwitterWrapper.clearNotificationAsync(getNotificationType(), accountId);
}
}
}
protected long[] getOldestStatusIds(AccountKey[] accountKeys) {
protected long[] getOldestStatusIds(UserKey[] accountKeys) {
final Context context = getContext();
if (context == null) return null;
return DataStoreUtils.getOldestStatusIds(context, getContentUri(), accountKeys);
@ -336,11 +336,11 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
protected abstract void updateRefreshState();
public static class CursorStatusesLoader extends ExtendedObjectCursorLoader<ParcelableStatus> {
private final AccountKey[] mAccountKeys;
private final UserKey[] mAccountKeys;
public CursorStatusesLoader(Context context, Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder,
boolean fromUser, AccountKey[] accountKeys) {
boolean fromUser, UserKey[] accountKeys) {
super(context, ParcelableStatusCursorIndices.class, uri, projection, selection, selectionArgs, sortOrder, fromUser);
mAccountKeys = accountKeys;
}

View File

@ -45,7 +45,7 @@ public class DestroyFriendshipDialogFragment extends BaseSupportDialogFragment i
final ParcelableUser user = getUser();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (user == null || twitter == null) return;
twitter.destroyFriendshipAsync(user.account_key, user.id);
twitter.destroyFriendshipAsync(user.account_key, user.key.getId());
break;
default:
break;

View File

@ -28,7 +28,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
@ -41,7 +41,7 @@ public class DestroySavedSearchDialogFragment extends BaseSupportDialogFragment
public void onClick(final DialogInterface dialog, final int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
final AccountKey accountKey = getAccountKey();
final UserKey accountKey = getAccountKey();
final long searchId = getSearchId();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (searchId <= 0 || twitter == null) return;
@ -67,7 +67,7 @@ public class DestroySavedSearchDialogFragment extends BaseSupportDialogFragment
return builder.create();
}
private AccountKey getAccountKey() {
private UserKey getAccountKey() {
final Bundle args = getArguments();
return args.getParcelable(EXTRA_ACCOUNT_KEY);
}
@ -85,7 +85,7 @@ public class DestroySavedSearchDialogFragment extends BaseSupportDialogFragment
}
public static DestroySavedSearchDialogFragment show(final FragmentManager fm,
final AccountKey accountKey,
final UserKey accountKey,
final long searchId, final String name) {
final Bundle args = new Bundle();
args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey);

View File

@ -54,7 +54,7 @@ import org.mariotaku.twidere.adapter.MessageEntriesAdapter.DirectMessageEntry;
import org.mariotaku.twidere.adapter.MessageEntriesAdapter.MessageEntriesAdapterListener;
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.BaseRefreshTaskParam;
import org.mariotaku.twidere.model.RefreshTaskParam;
import org.mariotaku.twidere.model.message.GetMessagesTaskEvent;
@ -89,7 +89,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
private RecyclerViewNavigationHelper mNavigationHelper;
// Data fields
private final SimpleArrayMap<AccountKey, Set<Long>> mUnreadCountsToRemove = new SimpleArrayMap<>();
private final SimpleArrayMap<UserKey, Set<Long>> mUnreadCountsToRemove = new SimpleArrayMap<>();
private final Set<Integer> mReadPositions = Collections.synchronizedSet(new HashSet<Integer>());
private int mFirstVisibleItem;
@ -121,7 +121,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
return twitter != null && (twitter.isReceivedDirectMessagesRefreshing() || twitter.isSentDirectMessagesRefreshing());
}
public final SimpleArrayMap<AccountKey, Set<Long>> getUnreadCountsToRemove() {
public final SimpleArrayMap<UserKey, Set<Long>> getUnreadCountsToRemove() {
return mUnreadCountsToRemove;
}
@ -153,7 +153,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
final Uri uri = DirectMessages.ConversationEntries.CONTENT_URI;
final AccountKey[] accountIds = getAccountKeys();
final UserKey[] accountIds = getAccountKeys();
final String selection = Expression.in(new Column(Statuses.ACCOUNT_KEY),
new ArgsArray(accountIds.length)).getSQL();
final String[] selectionArgs = TwidereArrayUtils.toStringArray(accountIds, 0, accountIds.length);
@ -169,7 +169,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
adapter.setCursor(cursor);
adapter.setLoadMoreIndicatorPosition(IndicatorPosition.NONE);
adapter.setLoadMoreSupportedPosition(hasMoreData(cursor) ? IndicatorPosition.END : IndicatorPosition.NONE);
final AccountKey[] accountIds = getAccountKeys();
final UserKey[] accountIds = getAccountKeys();
adapter.setShowAccountsColor(accountIds.length > 1);
setRefreshEnabled(true);
@ -242,7 +242,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
protected RefreshTaskParam doInBackground(final Object... params) {
final Context context = getContext();
if (context == null) return null;
AccountKey[] accountIds = getAccountKeys();
UserKey[] accountIds = getAccountKeys();
long[] ids = DataStoreUtils.getNewestMessageIds(context,
DirectMessages.Inbox.CONTENT_URI, accountIds);
return new BaseRefreshTaskParam(accountIds, ids, null);
@ -323,7 +323,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
}
public void openNewMessageConversation() {
final AccountKey[] accountIds = getAccountKeys();
final UserKey[] accountIds = getAccountKeys();
if (accountIds.length == 1) {
IntentUtils.openMessageConversation(getActivity(), accountIds[0], -1);
} else {
@ -336,7 +336,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
super.setUserVisibleHint(isVisibleToUser);
final FragmentActivity activity = getActivity();
if (isVisibleToUser && activity != null) {
for (AccountKey accountKey : getAccountKeys()) {
for (UserKey accountKey : getAccountKeys()) {
final String tag = "messages_" + accountKey;
mNotificationManager.cancel(tag, NOTIFICATION_ID_DIRECT_MESSAGES);
}
@ -344,9 +344,9 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
}
@NonNull
protected AccountKey[] getAccountKeys() {
protected UserKey[] getAccountKeys() {
final Bundle args = getArguments();
AccountKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
UserKey[] accountKeys = Utils.getAccountKeys(getContext(), args);
if (accountKeys != null) {
return accountKeys;
}
@ -368,7 +368,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
mFirstVisibleItem = firstVisibleItem;
}
private void addUnreadCountsToRemove(final AccountKey accountId, final long id) {
private void addUnreadCountsToRemove(final UserKey accountId, final long id) {
if (mUnreadCountsToRemove.indexOfKey(accountId) < 0) {
final Set<Long> counts = new HashSet<>();
counts.add(id);
@ -390,7 +390,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
final Context context = getContext();
if (context == null) return null;
RefreshTaskParam[] result = new RefreshTaskParam[2];
AccountKey[] accountKeys = getAccountKeys();
UserKey[] accountKeys = getAccountKeys();
result[0] = new BaseRefreshTaskParam(accountKeys, DataStoreUtils.getOldestMessageIds(context,
DirectMessages.Inbox.CONTENT_URI, accountKeys), null);
result[1] = new BaseRefreshTaskParam(accountKeys, DataStoreUtils.getOldestMessageIds(context,
@ -432,7 +432,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
for (final int pos : read_positions) {
final DirectMessageEntry entry = adapter.getEntry(pos);
final long id = entry.conversation_id;
final AccountKey accountKey = entry.account_key;
final UserKey accountKey = entry.account_key;
fragment.addUnreadCountsToRemove(accountKey, id);
}
return null;

View File

@ -63,7 +63,7 @@ import org.mariotaku.sqliteqb.library.RawItemArray;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.DraftsAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.Draft;
import org.mariotaku.twidere.model.DraftCursorIndices;
import org.mariotaku.twidere.model.ParcelableMediaUpdate;
@ -295,7 +295,7 @@ public class DraftsFragment extends BaseSupportFragment implements Constants, Lo
if (ArrayUtils.isEmpty(item.account_ids) || recipientId <= 0) {
continue;
}
final AccountKey accountId = item.account_ids[0];
final UserKey accountId = item.account_ids[0];
final String imageUri = item.media != null && item.media.length > 0 ? item.media[0].uri : null;
twitter.sendDirectMessageAsync(accountId, recipientId, item.text, imageUri);
break;

View File

@ -24,7 +24,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import org.mariotaku.twidere.annotation.ReadPositionTag;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.RefreshTaskParam;
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
@ -84,7 +84,7 @@ public class HomeTimelineFragment extends CursorStatusesFragment {
super.setUserVisibleHint(isVisibleToUser);
final FragmentActivity activity = getActivity();
if (isVisibleToUser && activity != null) {
for (AccountKey accountId : getAccountKeys()) {
for (UserKey accountId : getAccountKeys()) {
final String tag = "home_" + accountId;
mNotificationManager.cancel(tag, NOTIFICATION_ID_HOME_TIMELINE);
}

View File

@ -30,7 +30,7 @@ import org.mariotaku.twidere.adapter.ParcelableUsersAdapter;
import org.mariotaku.twidere.adapter.iface.IUsersAdapter;
import org.mariotaku.twidere.loader.support.IDsUsersLoader;
import org.mariotaku.twidere.loader.support.IncomingFriendshipsLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.message.FollowRequestTaskEvent;
import org.mariotaku.twidere.view.holder.UserViewHolder;
@ -53,7 +53,7 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
@Override
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args,
final boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final IncomingFriendshipsLoader loader = new IncomingFriendshipsLoader(context, accountKey,
getData(), fromUser);
loader.setCursor(getNextCursor());
@ -73,7 +73,7 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
final AbsUsersAdapter<List<ParcelableUser>> adapter = getAdapter();
final ParcelableUser user = adapter.getUser(position);
if (user == null) return;
mTwitterWrapper.acceptFriendshipAsync(user.account_key, user.id);
mTwitterWrapper.acceptFriendshipAsync(user.account_key, user.key);
}
@Override
@ -81,7 +81,7 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
final AbsUsersAdapter<List<ParcelableUser>> adapter = getAdapter();
final ParcelableUser user = adapter.getUser(position);
if (user == null) return;
mTwitterWrapper.denyFriendshipAsync(user.account_key, user.id);
mTwitterWrapper.denyFriendshipAsync(user.account_key, user.key);
}
@Subscribe

View File

@ -83,11 +83,11 @@ import org.mariotaku.twidere.adapter.SimpleParcelableUsersAdapter;
import org.mariotaku.twidere.adapter.iface.IBaseCardAdapter.MenuButtonClickListener;
import org.mariotaku.twidere.annotation.CustomTabType;
import org.mariotaku.twidere.loader.support.UserSearchLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableDirectMessage;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.ParcelableUserCursorIndices;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.TaskStateChangedEvent;
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
import org.mariotaku.twidere.provider.TwidereDataStore;
@ -139,7 +139,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
mUsersSearchList.setVisibility(View.GONE);
mUsersSearchEmpty.setVisibility(View.GONE);
mUsersSearchProgress.setVisibility(View.VISIBLE);
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final String query = args.getString(EXTRA_QUERY);
final boolean fromCache = args.getBoolean(EXTRA_FROM_CACHE);
final boolean fromUser = args.getBoolean(EXTRA_FROM_USER, false);
@ -304,7 +304,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
account = args.getParcelable(EXTRA_ACCOUNT);
recipient = args.getParcelable(EXTRA_USER);
} else if (args.containsKey(EXTRA_ACCOUNT_KEY)) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_RECIPIENT_ID, -1);
final int accountPos = accountsSpinnerAdapter.findItemPosition(accountKey.getId());
if (accountPos >= 0) {
@ -319,7 +319,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
}
showConversation(account, recipient);
if (account != null && recipient != null) {
final String key = getDraftsTextKey(account.account_key, recipient.id);
final String key = getDraftsTextKey(account.account_key, recipient.key.getId());
mEditText.setText(mMessageDrafts.getString(key, null));
}
}
@ -373,7 +373,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
final ParcelableCredentials account = mAccount;
final ParcelableUser recipient = mRecipient;
if (account != null && recipient != null) {
final String key = getDraftsTextKey(account.account_key, recipient.id);
final String key = getDraftsTextKey(account.account_key, recipient.key.getId());
final SharedPreferences.Editor editor = mMessageDrafts.edit();
final String text = ParseUtils.parseString(mEditText.getText());
if (TextUtils.isEmpty(text)) {
@ -405,7 +405,8 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
case R.id.delete_all: {
final ParcelableCredentials account = mAccount;
if (account == null || mRecipient == null) return true;
mTwitterWrapper.destroyMessageConversationAsync(account.account_key, mRecipient.id);
mTwitterWrapper.destroyMessageConversationAsync(account.account_key,
mRecipient.key.getId());
return true;
}
}
@ -432,7 +433,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
final AccountKey accountId = args != null ? args.<AccountKey>getParcelable(EXTRA_ACCOUNT_KEY) : null;
final UserKey accountId = args != null ? args.<UserKey>getParcelable(EXTRA_ACCOUNT_KEY) : null;
final long recipientId = args != null ? args.getLong(EXTRA_RECIPIENT_ID, -1) : -1;
final String[] cols = DirectMessages.COLUMNS;
final boolean isValid = accountId != null && recipientId > 0;
@ -567,7 +568,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
final LoaderManager lm = getLoaderManager();
final Bundle args = new Bundle();
args.putParcelable(EXTRA_ACCOUNT_KEY, account.account_key);
args.putLong(EXTRA_RECIPIENT_ID, recipient.id);
args.putLong(EXTRA_RECIPIENT_ID, recipient.key.getId());
if (mLoaderInitialized) {
lm.restartLoader(0, args, this);
} else {
@ -584,11 +585,11 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
return mConversationContainer.getVisibility() == View.VISIBLE;
}
private String getDraftsTextKey(AccountKey accountKey, long userId) {
private String getDraftsTextKey(UserKey accountKey, long userId) {
return String.format(Locale.ROOT, "text_%s_to_%d", accountKey, userId);
}
private void searchUsers(AccountKey accountKey, String query, boolean fromCache) {
private void searchUsers(UserKey accountKey, String query, boolean fromCache) {
final Bundle args = new Bundle();
args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey);
args.putString(EXTRA_QUERY, query);
@ -638,8 +639,8 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
if (TextUtils.isEmpty(message)) {
mEditText.setError(getString(R.string.error_message_no_content));
} else {
mTwitterWrapper.sendDirectMessageAsync(account.account_key, recipient.id, message,
mImageUri);
mTwitterWrapper.sendDirectMessageAsync(account.account_key, recipient.key.getId(),
message, mImageUri);
mEditText.setText(null);
mImageUri = null;
updateAddImageButton();
@ -834,7 +835,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
private final boolean mFromCache;
private final UserColorNameManager mUserColorNameManager;
public CacheUserSearchLoader(MessagesConversationFragment fragment, AccountKey accountKey,
public CacheUserSearchLoader(MessagesConversationFragment fragment, UserKey accountKey,
String query, boolean fromCache, boolean fromUser) {
super(fragment.getContext(), accountKey, query, 0, null, fromUser);
mUserColorNameManager = fragment.mUserColorNameManager;
@ -855,7 +856,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
final long[] nicknameIds = Utils.getMatchedNicknameIds(query, mUserColorNameManager);
selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"),
Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"),
Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds)));
Expression.in(new Column(CachedUsers.USER_KEY), new RawItemArray(nicknameIds)));
selectionArgs = new String[]{queryEscaped, queryEscaped};
} else {
selection = null;
@ -902,7 +903,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
final ParcelableUser user = args.getParcelable(EXTRA_USER);
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (account == null || user == null || twitter == null) return;
twitter.destroyMessageConversationAsync(account.account_key, user.id);
twitter.destroyMessageConversationAsync(account.account_key, user.key.getId());
break;
}
}
@ -933,7 +934,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
Expression.equalsArgs(ConversationEntries.CONVERSATION_ID)
).getSQL();
final String[] selectionArgs = {String.valueOf(mAccount.account_key),
String.valueOf(mRecipient.id)};
String.valueOf(mRecipient.key)};
final String orderBy = new OrderBy(ConversationEntries.MESSAGE_ID, false).getSQL();
return resolver.query(ConversationEntries.CONTENT_URI, projection, selection,
selectionArgs, orderBy);
@ -943,7 +944,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
protected void onPostExecute(Cursor cursor) {
if (cursor.moveToFirst()) {
final int messageIdIdx = cursor.getColumnIndex(ConversationEntries.MESSAGE_ID);
final String key = mAccount.account_key + "-" + mRecipient.id;
final String key = mAccount.account_key + "-" + mRecipient.key;
mReadStateManager.setPosition(CustomTabType.DIRECT_MESSAGES, key, cursor.getLong(messageIdIdx), false);
}
cursor.close();

View File

@ -25,13 +25,13 @@ import android.support.annotation.NonNull;
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
import org.mariotaku.twidere.loader.support.MutesUsersLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
public class MutesUsersListFragment extends CursorSupportUsersListFragment {
@Override
public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final MutesUsersLoader loader = new MutesUsersLoader(context, accountKey, getData(), fromUser);
loader.setCursor(getNextCursor());
return loader;

View File

@ -30,7 +30,7 @@ import org.mariotaku.twidere.adapter.AbsStatusesAdapter;
import org.mariotaku.twidere.adapter.ListParcelableStatusesAdapter;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.BaseRefreshTaskParam;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.RefreshTaskParam;
@ -104,7 +104,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
}
@Override
protected AccountKey[] getAccountKeys() {
protected UserKey[] getAccountKeys() {
return Utils.getAccountKeys(getContext(), getArguments());
}
@ -137,7 +137,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
final AbsStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
final ParcelableStatus status = adapter.getStatus(adapter.getStatusStartIndex() +
adapter.getStatusCount() - 1);
AccountKey[] accountKeys = {status.account_key};
UserKey[] accountKeys = {status.account_key};
final long[] maxIds = {status.id};
getStatuses(new BaseRefreshTaskParam(accountKeys, maxIds, null));
}
@ -157,7 +157,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
public boolean triggerRefresh() {
super.triggerRefresh();
final IStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
final AccountKey[] accountIds = getAccountKeys();
final UserKey[] accountIds = getAccountKeys();
if (adapter.getStatusCount() > 0) {
final long[] sinceIds = new long[]{adapter.getStatus(0).id};
getStatuses(new BaseRefreshTaskParam(accountIds, null, sinceIds));

View File

@ -28,7 +28,7 @@ import android.support.v4.content.Loader;
import org.mariotaku.twidere.adapter.ParcelableUserListsAdapter;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableUserList;
import java.util.List;
@ -49,7 +49,7 @@ public abstract class ParcelableUserListsFragment extends AbsUserListsFragment<L
}
@Nullable
protected AccountKey getAccountKey() {
protected UserKey getAccountKey() {
final Bundle args = getArguments();
return args.getParcelable(EXTRA_ACCOUNT_KEY);
}

View File

@ -44,7 +44,7 @@ public class ReportSpamDialogFragment extends BaseSupportDialogFragment implemen
final ParcelableUser user = getUser();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (user == null || twitter == null) return;
twitter.reportSpamAsync(user.account_key, user.id);
twitter.reportSpamAsync(user.account_key, user.key.getId());
break;
default:
break;

View File

@ -25,7 +25,7 @@ import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import org.mariotaku.twidere.loader.support.RetweetsOfMeLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import java.util.List;
@ -38,7 +38,7 @@ public class RetweetsOfMeFragment extends ParcelableStatusesFragment {
protected Loader<List<ParcelableStatus>> onCreateStatusesLoader(final Context context,
final Bundle args,
final boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
@ -59,7 +59,7 @@ public class RetweetsOfMeFragment extends ParcelableStatusesFragment {
protected String[] getSavedStatusesFileArgs() {
final Bundle args = getArguments();
if (args == null) return null;
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
return new String[]{AUTHORITY_RETWEETS_OF_ME, "account" + accountKey};
}

View File

@ -34,7 +34,7 @@ import org.mariotaku.twidere.adapter.SavedSearchesAdapter;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.loader.support.SavedSearchesLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.SavedSearchDestroyedEvent;
import java.util.Collections;
@ -87,7 +87,7 @@ public class SavedSearchesListFragment extends AbsContentListViewFragment<SavedS
return new SavedSearchesLoader(getActivity(), getAccountKey());
}
public AccountKey getAccountKey() {
public UserKey getAccountKey() {
return getArguments().getParcelable(EXTRA_ACCOUNT_KEY);
}

View File

@ -35,7 +35,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.LoadMoreSupportAdapter;
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
import org.mariotaku.twidere.loader.support.ScheduledStatusesLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
import java.util.List;
@ -60,7 +60,7 @@ public class ScheduledStatusesFragment extends AbsContentListRecyclerViewFragmen
@Override
public Loader<List<ScheduledStatus>> onCreateLoader(int id, Bundle args) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final String[] states = {ScheduledStatus.State.SCHEDULED, ScheduledStatus.State.FAILED};

View File

@ -51,7 +51,7 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCal
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.RecentSearchProvider;
import org.mariotaku.twidere.provider.TwidereDataStore.SearchHistory;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
@ -74,7 +74,7 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
private int mControlBarOffsetPixels;
private int mControlBarHeight;
public AccountKey getAccountKey() {
public UserKey getAccountKey() {
return getArguments().getParcelable(EXTRA_ACCOUNT_KEY);
}

View File

@ -26,7 +26,7 @@ import android.support.v4.content.Loader;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.loader.support.UserSearchLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableUser;
import java.util.List;
@ -45,7 +45,7 @@ public class SearchUsersFragment extends ParcelableUsersFragment {
@Override
public Loader<List<ParcelableUser>> onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final String query = args.getString(EXTRA_QUERY);
final int page = args.getInt(EXTRA_PAGE, 1);
return new UserSearchLoader(context, accountKey, query, page, getData(), fromUser);

View File

@ -27,7 +27,7 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.IntentUtils;
@ -44,7 +44,7 @@ public class SensitiveContentWarningDialogFragment extends BaseSupportDialogFrag
final Context context = getActivity();
final Bundle args = getArguments();
if (args == null || context == null) return;
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final ParcelableMedia current = args.getParcelable(EXTRA_CURRENT_MEDIA);
final ParcelableStatus status = args.getParcelable(EXTRA_STATUS);
final Bundle option = args.getBundle(EXTRA_ACTIVITY_OPTIONS);

View File

@ -33,6 +33,7 @@ import android.widget.EditText;
import android.widget.FrameLayout;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
@ -44,9 +45,10 @@ public class SetUserNicknameDialogFragment extends BaseSupportDialogFragment imp
@Override
public void onClick(final DialogInterface dialog, final int which) {
final Bundle args = getArguments();
assert args != null;
final String text = ParseUtils.parseString(mEditText.getText());
final long userId = args != null ? args.getLong(EXTRA_USER_ID, -1) : -1;
if (userId == -1) return;
final UserKey userId = args.getParcelable(EXTRA_USER_ID);
assert userId != null;
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
if (TextUtils.isEmpty(text)) {
@ -89,10 +91,10 @@ public class SetUserNicknameDialogFragment extends BaseSupportDialogFragment imp
return builder.create();
}
public static SetUserNicknameDialogFragment show(final FragmentManager fm, final long user_id, final String nickname) {
public static SetUserNicknameDialogFragment show(final FragmentManager fm, final UserKey userKey, final String nickname) {
final SetUserNicknameDialogFragment f = new SetUserNicknameDialogFragment();
final Bundle args = new Bundle();
args.putLong(EXTRA_USER_ID, user_id);
args.putParcelable(EXTRA_USER_KEY, userKey);
args.putString(EXTRA_NAME, nickname);
f.setArguments(args);
f.show(fm, FRAGMENT_TAG_SET_USER_NICKNAME);

View File

@ -25,13 +25,13 @@ import android.support.annotation.NonNull;
import org.mariotaku.twidere.loader.support.IDsUsersLoader;
import org.mariotaku.twidere.loader.support.StatusFavoritersLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
public class StatusFavoritersListFragment extends CursorSupportUsersListFragment {
@Override
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
final StatusFavoritersLoader loader = new StatusFavoritersLoader(context, accountKey,
statusId, getData(), false);

View File

@ -105,7 +105,6 @@ import org.mariotaku.twidere.fragment.support.AbsStatusesFragment.DefaultOnLiked
import org.mariotaku.twidere.loader.support.ConversationLoader;
import org.mariotaku.twidere.loader.support.ParcelableStatusLoader;
import org.mariotaku.twidere.menu.support.FavoriteItemProvider;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.ParcelableActivity;
import org.mariotaku.twidere.model.ParcelableActivityCursorIndices;
import org.mariotaku.twidere.model.ParcelableActivityValuesCreator;
@ -116,6 +115,7 @@ import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatusValuesCreator;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.FavoriteTaskEvent;
import org.mariotaku.twidere.model.message.StatusListChangedEvent;
import org.mariotaku.twidere.model.util.ParcelableActivityUtils;
@ -223,7 +223,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
assert status != null;
final ConversationLoader loader = new ConversationLoader(getActivity(), status, sinceId,
maxId, mStatusAdapter.getData(), true);
loader.setComparator(ParcelableStatus.REVERSE_ID_COMPARATOR);
loader.setComparator(ParcelableStatus.REVERSE_TIMESTAMP_COMPARATOR);
return loader;
}
@ -248,8 +248,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
mStatusAdapter.setLoadMoreSupportedPosition(supportedPositions);
setConversation(data);
final ParcelableCredentials account = mStatusAdapter.getStatusAccount();
if (Utils.hasOfficialAPIAccess(loader.getContext(), account)) {
final boolean canLoadAllReplies = ((ConversationLoader) loader).canLoadAllReplies();
if (canLoadAllReplies) {
mStatusAdapter.setReplyError(null);
} else {
final SpannableStringBuilder error = SpannableStringBuilder.valueOf(
@ -289,7 +289,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
private LoaderCallbacks<StatusActivity> mStatusActivityLoaderCallback = new LoaderCallbacks<StatusActivity>() {
@Override
public Loader<StatusActivity> onCreateLoader(int id, Bundle args) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
return new StatusActivitySummaryLoader(getActivity(), accountKey, statusId);
}
@ -317,9 +317,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
if (resultCode == Activity.RESULT_OK) {
if (data == null) return;
final int color = data.getIntExtra(EXTRA_COLOR, Color.TRANSPARENT);
mUserColorNameManager.setUserColor(status.user_id, color);
mUserColorNameManager.setUserColor(status.user_key, color);
} else if (resultCode == ColorPickerDialogActivity.RESULT_CLEARED) {
mUserColorNameManager.clearUserColor(status.user_id);
mUserColorNameManager.clearUserColor(status.user_key);
}
break;
}
@ -328,7 +328,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
if (status == null) return;
if (resultCode == Activity.RESULT_OK) {
if (data == null || !data.hasExtra(EXTRA_ID)) return;
final AccountKey accountKey = data.getParcelableExtra(EXTRA_KEY);
final UserKey accountKey = data.getParcelableExtra(EXTRA_KEY);
IntentUtils.openStatus(activity, accountKey, status.id);
}
break;
@ -461,12 +461,12 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
@Override
public void onUserProfileClick(IStatusViewHolder holder, ParcelableStatus status, int position) {
final FragmentActivity activity = getActivity();
IntentUtils.openUserProfile(activity, status.account_key, status.user_id,
IntentUtils.openUserProfile(activity, status.account_key, status.user_key.getId(),
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
}
@Override
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
public void onMediaClick(View view, ParcelableMedia media, UserKey accountKey, long extraId) {
final ParcelableStatus status = mStatusAdapter.getStatus();
if (status == null) return;
IntentUtils.openMediaDirectly(getActivity(), accountKey, status, media, null, true);
@ -543,7 +543,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
@Override
public Loader<SingleResponse<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
final Bundle fragmentArgs = getArguments();
final AccountKey accountKey = fragmentArgs.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = fragmentArgs.getParcelable(EXTRA_ACCOUNT_KEY);
final long statusId = fragmentArgs.getLong(EXTRA_STATUS_ID, -1);
return new ParcelableStatusLoader(getActivity(), false, fragmentArgs, accountKey, statusId);
}
@ -590,7 +590,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
final TweetEvent event = mStatusEvent;
if (event == null) return;
event.markEnd();
final AccountKey accountKey = new AccountKey(event.getAccountId(), event.getAccountHost());
final UserKey accountKey = new UserKey(event.getAccountId(), event.getAccountHost());
HotMobiLogger.getInstance(getActivity()).log(accountKey, event);
}
@ -989,7 +989,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
if (status.retweet_id > 0) {
final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id,
status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false);
status.retweeted_by_user_name, status.retweeted_by_user_screen_name,
nameFirst, false);
retweetedByView.setText(context.getString(R.string.name_retweeted, retweetedBy));
retweetedByView.setVisibility(View.VISIBLE);
} else {
@ -1018,7 +1019,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
layoutPosition, status.is_possibly_sensitive, skipLinksInText));
}
quoteIndicator.setColor(manager.getUserColor(status.user_id, false));
quoteIndicator.setColor(manager.getUserColor(status.user_key, false));
profileContainer.drawStart(manager.getUserColor(status.quoted_user_id, false));
} else {
quoteOriginalLink.setVisibility(View.GONE);
@ -1026,7 +1027,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
quotedTextView.setVisibility(View.GONE);
quoteIndicator.setVisibility(View.GONE);
profileContainer.drawStart(manager.getUserColor(status.user_id, false));
profileContainer.drawStart(manager.getUserColor(status.user_key, false));
}
final long timestamp;
@ -1037,7 +1038,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
timestamp = status.timestamp;
}
nameView.setText(manager.getUserNickname(status.user_id, status.user_name, false));
nameView.setText(manager.getUserNickname(status.user_key, status.user_name, false));
screenNameView.setText(String.format("@%s", status.user_screen_name));
loader.displayProfileImage(profileImageView, status);
@ -1200,14 +1201,14 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
case R.id.profile_container: {
final FragmentActivity activity = fragment.getActivity();
IntentUtils.openUserProfile(activity, status.account_key, status.user_id,
IntentUtils.openUserProfile(activity, status.account_key, status.user_key.getId(),
status.user_screen_name, null, true, UserFragment.Referral.STATUS);
break;
}
case R.id.retweeted_by: {
if (status.retweet_id > 0) {
IntentUtils.openUserProfile(adapter.getContext(), status.account_key,
status.retweeted_by_user_id, status.retweeted_by_user_screen_name,
status.retweeted_by_user_id.getId(), status.retweeted_by_user_screen_name,
null, true, UserFragment.Referral.STATUS);
}
break;
@ -1220,8 +1221,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
case R.id.quoted_name_container: {
IntentUtils.openUserProfile(adapter.getContext(), status.account_key,
status.quoted_user_id, status.quoted_user_screen_name, null, true,
UserFragment.Referral.STATUS);
status.quoted_user_id.getId(), status.quoted_user_screen_name, null,
true, UserFragment.Referral.STATUS);
break;
}
case R.id.quote_original_link: {
@ -1592,7 +1593,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
@Override
public void onLinkClick(final String link, final String orig, final AccountKey accountKey,
public void onLinkClick(final String link, final String orig, final UserKey accountKey,
long extraId, int type, boolean sensitive, int start, int end) {
final ParcelableStatus status = adapter.getStatus();
ParcelableMedia current;
@ -1814,13 +1815,13 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
@Override
public AccountKey getAccountKey(int position) {
public UserKey getAccountKey(int position) {
final ParcelableStatus status = getStatus(position);
return status != null ? status.account_key : null;
}
@Override
public ParcelableStatus findStatusById(AccountKey accountId, long statusId) {
public ParcelableStatus findStatusById(UserKey accountId, long statusId) {
if (mStatus != null && accountId.equals(mStatus.account_key) && statusId == mStatus.id) {
return mStatus;
}
@ -2426,10 +2427,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
}
public static class StatusActivitySummaryLoader extends AsyncTaskLoader<StatusActivity> {
private final AccountKey mAccountKey;
private final UserKey mAccountKey;
private final long mStatusId;
public StatusActivitySummaryLoader(Context context, AccountKey accountKey, long statusId) {
public StatusActivitySummaryLoader(Context context, UserKey accountKey, long statusId) {
super(context);
mAccountKey = accountKey;
mStatusId = statusId;

View File

@ -25,13 +25,13 @@ import android.support.annotation.NonNull;
import org.mariotaku.twidere.loader.support.IDsUsersLoader;
import org.mariotaku.twidere.loader.support.StatusRetweetersLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
public class StatusRetweetersListFragment extends CursorSupportUsersListFragment {
@Override
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
final StatusRetweetersLoader loader = new StatusRetweetersLoader(context, accountKey, statusId,
getData(), fromUser);

View File

@ -26,7 +26,7 @@ import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import org.mariotaku.twidere.loader.support.TweetSearchLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import java.io.UnsupportedEncodingException;
@ -52,7 +52,7 @@ public class StatusesSearchFragment extends ParcelableStatusesFragment {
final Bundle args,
final boolean fromUser) {
setRefreshing(true);
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final String query = args.getString(EXTRA_QUERY);

View File

@ -34,7 +34,7 @@ import android.widget.ListView;
import com.squareup.otto.Subscribe;
import org.mariotaku.twidere.adapter.TrendsAdapter;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore.CachedTrends;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.model.message.TaskStateChangedEvent;
@ -46,7 +46,7 @@ import static org.mariotaku.twidere.util.IntentUtils.openTweetSearch;
public class TrendsSuggestionsFragment extends AbsContentListViewFragment<TrendsAdapter>
implements LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
private AccountKey mAccountId;
private UserKey mAccountId;
@Override
public void onActivityCreated(final Bundle savedInstanceState) {

View File

@ -25,13 +25,13 @@ import android.support.annotation.NonNull;
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
import org.mariotaku.twidere.loader.support.UserBlocksLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
public class UserBlocksListFragment extends CursorSupportUsersListFragment {
@Override
public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserBlocksLoader loader = new UserBlocksLoader(context, accountKey, getData(), fromUser);
loader.setCursor(getNextCursor());
return loader;

View File

@ -25,7 +25,7 @@ import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import org.mariotaku.twidere.loader.support.UserFavoritesLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.ParcelableStatus;
import java.util.List;
@ -42,7 +42,7 @@ public class UserFavoritesFragment extends ParcelableStatusesFragment {
final Bundle args,
final boolean fromUser) {
setRefreshing(true);
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final long userId = args.getLong(EXTRA_USER_ID, -1);
@ -56,7 +56,7 @@ public class UserFavoritesFragment extends ParcelableStatusesFragment {
protected String[] getSavedStatusesFileArgs() {
final Bundle args = getArguments();
if (args == null) return null;
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
return new String[]{AUTHORITY_USER_FAVORITES, "account" + accountKey, "user" + userId, "name" + screenName};

View File

@ -27,7 +27,7 @@ import com.squareup.otto.Subscribe;
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
import org.mariotaku.twidere.loader.support.UserFollowersLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.UsersBlockedEvent;
import static org.mariotaku.twidere.util.DataStoreUtils.getAccountScreenName;
@ -37,7 +37,7 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment {
@Override
public CursorSupportUsersLoader onCreateUsersLoader(final Context context,
@NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
final UserFollowersLoader loader = new UserFollowersLoader(context, accountKey, userId,
@ -60,7 +60,7 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment {
@Subscribe
public void onUsersBlocked(UsersBlockedEvent event) {
final AccountKey accountKey = event.getAccountKey();
final UserKey accountKey = event.getAccountKey();
final String screen_name = getAccountScreenName(getActivity(), accountKey);
final Bundle args = getArguments();
if (args == null) return;

View File

@ -102,7 +102,6 @@ import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
import org.mariotaku.twidere.graphic.ActionBarColorDrawable;
import org.mariotaku.twidere.graphic.ActionIconDrawable;
import org.mariotaku.twidere.loader.support.ParcelableUserLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.CachedRelationship;
import org.mariotaku.twidere.model.CachedRelationshipValuesCreator;
import org.mariotaku.twidere.model.ConsumerKeyType;
@ -112,6 +111,7 @@ import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.model.ParcelableUserValuesCreator;
import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.model.SupportTabSpec;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.message.FriendshipUpdatedEvent;
import org.mariotaku.twidere.model.message.FriendshipUserUpdatedEvent;
import org.mariotaku.twidere.model.message.ProfileUpdatedEvent;
@ -236,7 +236,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.VISIBLE);
mFollowingYouIndicator.setVisibility(View.GONE);
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_USER_ID, -1);
return new UserRelationshipLoader(getActivity(), accountKey, userId);
}
@ -261,7 +261,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Override
public Loader<SingleResponse<ParcelableUser>> onCreateLoader(final int id, final Bundle args) {
final boolean omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
if (mUser == null && (!omitIntentExtra || !args.containsKey(EXTRA_USER))) {
@ -274,8 +274,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
setProgressBarIndeterminateVisibility(true);
final ParcelableUser user = mUser;
final boolean loadFromCache = user == null || !user.is_cache && userId != user.key.getId();
return new ParcelableUserLoader(getActivity(), accountKey, userId, screenName, getArguments(),
omitIntentExtra, user == null || !user.is_cache && userId != user.id);
omitIntentExtra, loadFromCache);
}
@Override
@ -297,7 +298,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (user.is_cache) {
final Bundle args = new Bundle();
args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key);
args.putLong(EXTRA_USER_ID, user.id);
args.putLong(EXTRA_USER_ID, user.key.getId());
args.putString(EXTRA_SCREEN_NAME, user.screen_name);
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
getLoaderManager().restartLoader(LOADER_ID_USER, args, this);
@ -340,7 +341,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mRelationship = null;
return;
}
if (user.account_key.isAccount(user.id, user.user_host)) {
if (user.account_key.maybeEquals(user.key)) {
mFollowButton.setText(R.string.edit);
mFollowButton.setVisibility(View.VISIBLE);
mRelationship = null;
@ -513,7 +514,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
public void displayUser(final ParcelableUser user) {
mUser = user;
final FragmentActivity activity = getActivity();
if (user == null || user.id <= 0 || activity == null) return;
if (user == null || user.key == null || activity == null) return;
final Resources resources = getResources();
final LoaderManager lm = getLoaderManager();
lm.destroyLoader(LOADER_ID_USER);
@ -522,10 +523,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mHeaderErrorContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
mUser = user;
final int userColor = mUserColorNameManager.getUserColor(user.id, true);
final int userColor = mUserColorNameManager.getUserColor(user.key, true);
mProfileImageView.setBorderColor(userColor != 0 ? userColor : Color.WHITE);
mProfileNameContainer.drawEnd(user.account_color);
final String nick = mUserColorNameManager.getUserNickname(user.id, true);
final String nick = mUserColorNameManager.getUserNickname(user.key, true);
mNameView.setText(mBidiFormatter.unicodeWrap(TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick)));
final int typeIconRes = Utils.getUserTypeIconRes(user.is_verified, user.is_protected);
if (typeIconRes != 0) {
@ -615,7 +616,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return mUser;
}
public void getUserInfo(final AccountKey accountId, final long userId, final String screenName,
public void getUserInfo(final UserKey accountId, final long userId, final String screenName,
final boolean omitIntentExtra) {
final LoaderManager lm = getLoaderManager();
lm.destroyLoader(LOADER_ID_USER);
@ -640,7 +641,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Subscribe
public void notifyFriendshipUpdated(FriendshipUpdatedEvent event) {
final ParcelableUser user = getUser();
if (user == null || !event.isAccount(user.account_key) || !event.isUser(user.id)) return;
if (user == null || !event.isAccount(user.account_key) || !event.isUser(user.key.getId()))
return;
getFriendship();
}
@ -672,9 +674,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (resultCode == Activity.RESULT_OK) {
if (data == null) return;
final int color = data.getIntExtra(EXTRA_COLOR, Color.TRANSPARENT);
mUserColorNameManager.setUserColor(mUser.id, color);
mUserColorNameManager.setUserColor(mUser.key, color);
} else if (resultCode == ColorPickerDialogActivity.RESULT_CLEARED) {
mUserColorNameManager.clearUserColor(mUser.id);
mUserColorNameManager.clearUserColor(mUser.key);
}
break;
}
@ -692,10 +694,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (user == null) return;
if (resultCode == Activity.RESULT_OK) {
if (data == null || !data.hasExtra(EXTRA_ID)) return;
final AccountKey accountKey = data.getParcelableExtra(EXTRA_KEY);
final UserKey accountKey = data.getParcelableExtra(EXTRA_KEY);
@Referral
final String referral = getArguments().getString(EXTRA_REFERRAL);
IntentUtils.openUserProfile(getActivity(), accountKey, user.id,
IntentUtils.openUserProfile(getActivity(), accountKey, user.key.getId(),
user.screen_name, null, true, referral);
}
break;
@ -732,7 +734,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
ThemeUtils.getUserThemeBackgroundAlpha(activity));
mActionBarShadowColor = 0xA0000000;
final Bundle args = getArguments();
AccountKey accountId = null;
UserKey accountId = null;
long userId = -1;
String screenName = null;
if (savedInstanceState != null) {
@ -894,7 +896,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (twitter == null || user == null || userRelationship == null) return;
final Relationship relationship = userRelationship.relationship;
final boolean isMyself = user.account_key.getId() == user.id;
final boolean isMyself = user.account_key.equals(user.key);
final MenuItem mentionItem = menu.findItem(R.id.mention);
if (mentionItem != null) {
final String displayName = mUserColorNameManager.getDisplayName(user, mNameFirst, true);
@ -975,7 +977,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
case R.id.block: {
if (userRelationship == null) return true;
if (userRelationship.relationship.isSourceBlockingTarget()) {
twitter.destroyBlockAsync(user.account_key, user.id);
twitter.destroyBlockAsync(user.account_key, user.key.getId());
} else {
CreateUserBlockDialogFragment.show(getFragmentManager(), user);
}
@ -989,8 +991,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (userRelationship == null) return true;
final ContentResolver cr = getContentResolver();
if (userRelationship.isFiltering) {
final Expression where = Expression.equals(Filters.Users.USER_ID, user.id);
cr.delete(Filters.Users.CONTENT_URI, where.getSQL(), null);
final String where = Expression.equalsArgs(Filters.Users.USER_ID).getSQL();
final String[] whereArgs = {user.key.toString()};
cr.delete(Filters.Users.CONTENT_URI, where, whereArgs);
Utils.showInfoMessage(getActivity(), R.string.message_user_unmuted, false);
} else {
cr.insert(Filters.Users.CONTENT_URI, ContentValuesCreator.createFilteredUser(user));
@ -1001,7 +1004,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
case R.id.mute_user: {
if (userRelationship == null) return true;
if (userRelationship.relationship.isSourceMutingTarget()) {
twitter.destroyMuteAsync(user.account_key, user.id);
twitter.destroyMuteAsync(user.account_key, user.key.getId());
} else {
CreateUserMuteDialogFragment.show(getFragmentManager(), user);
}
@ -1020,7 +1023,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
builder.scheme(SCHEME_TWIDERE);
builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION);
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(user.account_key));
builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user.id));
builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user.key));
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
intent.putExtra(EXTRA_ACCOUNT, ParcelableCredentialsUtils.getCredentials(getActivity(), user.account_key));
intent.putExtra(EXTRA_USER, user);
@ -1029,19 +1032,19 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
case R.id.set_color: {
final Intent intent = new Intent(getActivity(), ColorPickerDialogActivity.class);
intent.putExtra(EXTRA_COLOR, mUserColorNameManager.getUserColor(user.id, true));
intent.putExtra(EXTRA_COLOR, mUserColorNameManager.getUserColor(user.key, true));
intent.putExtra(EXTRA_ALPHA_SLIDER, false);
intent.putExtra(EXTRA_CLEAR_BUTTON, true);
startActivityForResult(intent, REQUEST_SET_COLOR);
break;
}
case R.id.clear_nickname: {
mUserColorNameManager.clearUserNickname(user.id);
mUserColorNameManager.clearUserNickname(user.key);
break;
}
case R.id.set_nickname: {
final String nick = mUserColorNameManager.getUserNickname(user.id, true);
SetUserNicknameDialogFragment.show(getFragmentManager(), user.id, nick);
final String nick = mUserColorNameManager.getUserNickname(user.key, true);
SetUserNicknameDialogFragment.show(getFragmentManager(), user.key, nick);
break;
}
case R.id.add_to_list: {
@ -1063,13 +1066,15 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
case R.id.follow: {
if (userRelationship == null) return true;
final boolean isFollowing = userRelationship.relationship.isSourceFollowingTarget();
final boolean isCreatingFriendship = twitter.isCreatingFriendship(user.account_key, user.id);
final boolean isDestroyingFriendship = twitter.isDestroyingFriendship(user.account_key, user.id);
final boolean isCreatingFriendship = twitter.isCreatingFriendship(user.account_key,
user.key.getId());
final boolean isDestroyingFriendship = twitter.isDestroyingFriendship(user.account_key,
user.key.getId());
if (!isCreatingFriendship && !isDestroyingFriendship) {
if (isFollowing) {
DestroyFriendshipDialogFragment.show(getFragmentManager(), user);
} else {
twitter.createFriendshipAsync(user.account_key, user.id);
twitter.createFriendshipAsync(user.account_key, user.key.getId());
}
}
return true;
@ -1078,7 +1083,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final boolean newState = !item.isChecked();
final FriendshipUpdate update = new FriendshipUpdate();
update.retweets(newState);
twitter.updateFriendship(user.account_key, user.id, update);
twitter.updateFriendship(user.account_key, user.key.getId(), update);
item.setChecked(newState);
return true;
}
@ -1280,7 +1285,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
break;
}
case R.id.follow: {
if (user.account_key.isAccount(user.id, user.user_host)) {
if (user.account_key.equals(user.key)) {
Utils.openProfileEditor(getActivity(), user.account_key);
break;
}
@ -1288,11 +1293,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (userRelationship == null || twitter == null) return;
if (userRelationship.relationship.isSourceBlockingTarget()) {
twitter.destroyBlockAsync(user.account_key, user.id);
twitter.destroyBlockAsync(user.account_key, user.key.getId());
} else if (userRelationship.relationship.isSourceFollowingTarget()) {
DestroyFriendshipDialogFragment.show(getFragmentManager(), user);
} else {
twitter.createFriendshipAsync(user.account_key, user.id);
twitter.createFriendshipAsync(user.account_key, user.key.getId());
}
break;
}
@ -1314,19 +1319,22 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
break;
}
case R.id.listed_container: {
IntentUtils.openUserLists(getActivity(), user.account_key, user.id, user.screen_name);
IntentUtils.openUserLists(getActivity(), user.account_key, user.key.getId(),
user.screen_name);
break;
}
case R.id.followers_container: {
IntentUtils.openUserFollowers(getActivity(), user.account_key, user.id, user.screen_name);
IntentUtils.openUserFollowers(getActivity(), user.account_key, user.key.getId(),
user.screen_name);
break;
}
case R.id.friends_container: {
IntentUtils.openUserFriends(getActivity(), user.account_key, user.id, user.screen_name);
IntentUtils.openUserFriends(getActivity(), user.account_key, user.key.getId(),
user.screen_name);
break;
}
case R.id.name_container: {
if (user.account_key.isAccount(user.id, user.user_host)) return;
if (user.account_key.equals(user.key)) return;
Utils.openProfileEditor(getActivity(), user.account_key);
break;
}
@ -1341,7 +1349,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
@Override
public void onLinkClick(final String link, final String orig, final AccountKey accountKey, long extraId, final int type,
public void onLinkClick(final String link, final String orig, final UserKey accountKey, long extraId, final int type,
final boolean sensitive, int start, int end) {
final ParcelableUser user = getUser();
if (user == null) return;
@ -1382,14 +1390,14 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
@Override
public void onUserNicknameChanged(long userId, String nick) {
if (mUser == null || mUser.id != userId) return;
public void onUserNicknameChanged(@NonNull UserKey userId, String nick) {
if (mUser == null || !mUser.key.equals(userId)) return;
displayUser(mUser);
}
@Override
public void onUserColorChanged(long userId, int color) {
if (mUser == null || mUser.id != userId) return;
public void onUserColorChanged(@NonNull UserKey userId, int color) {
if (mUser == null || !mUser.key.equals(userId)) return;
displayUser(mUser);
}
@ -1439,7 +1447,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
lm.destroyLoader(LOADER_ID_FRIENDSHIP);
final Bundle args = new Bundle();
args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key);
args.putLong(EXTRA_USER_ID, user.id);
args.putLong(EXTRA_USER_ID, user.key.getId());
if (!mGetFriendShipLoaderInitialized) {
lm.initLoader(LOADER_ID_FRIENDSHIP, args, mFriendshipLoaderCallbacks);
mGetFriendShipLoaderInitialized = true;
@ -1451,7 +1459,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private void getUserInfo(final boolean omitIntentExtra) {
final ParcelableUser user = mUser;
if (user == null) return;
getUserInfo(user.account_key, user.id, user.screen_name, omitIntentExtra);
getUserInfo(user.account_key, user.key.getId(), user.screen_name, omitIntentExtra);
}
private void setUiColor(int color) {
@ -1516,15 +1524,13 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private void setupUserPages() {
final Context context = getActivity();
final Bundle args = getArguments(), tabArgs = new Bundle();
final AccountKey accountId;
final ParcelableUser user = args.getParcelable(EXTRA_USER);
if (user != null) {
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, accountId = user.account_key);
tabArgs.putLong(EXTRA_USER_ID, user.id);
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key);
tabArgs.putLong(EXTRA_USER_ID, user.key.getId());
tabArgs.putString(EXTRA_SCREEN_NAME, user.screen_name);
} else {
accountId = args.getParcelable(EXTRA_ACCOUNT_KEY);
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, accountId);
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, args.getParcelable(EXTRA_ACCOUNT_KEY));
tabArgs.putLong(EXTRA_USER_ID, args.getLong(EXTRA_USER_ID, -1));
tabArgs.putString(EXTRA_SCREEN_NAME, args.getString(EXTRA_SCREEN_NAME));
}
@ -1551,11 +1557,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
final LoaderManager lm = getLoaderManager();
final boolean loadingRelationship = lm.getLoader(LOADER_ID_FRIENDSHIP) != null;
final AccountKey accountKey = user.account_key;
final boolean creatingFriendship = twitter.isCreatingFriendship(accountKey, user.id);
final boolean destroyingFriendship = twitter.isDestroyingFriendship(accountKey, user.id);
final boolean creatingBlock = twitter.isCreatingFriendship(accountKey, user.id);
final boolean destroyingBlock = twitter.isDestroyingFriendship(accountKey, user.id);
final UserKey accountKey = user.account_key;
final boolean creatingFriendship = twitter.isCreatingFriendship(accountKey, user.key.getId());
final boolean destroyingFriendship = twitter.isDestroyingFriendship(accountKey, user.key.getId());
final boolean creatingBlock = twitter.isCreatingFriendship(accountKey, user.key.getId());
final boolean destroyingBlock = twitter.isDestroyingFriendship(accountKey, user.key.getId());
if (loadingRelationship || creatingFriendship || destroyingFriendship || creatingBlock || destroyingBlock) {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.VISIBLE);
@ -1572,9 +1578,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final ParcelableUser user = getUser();
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (user == null || twitter == null) return;
final AccountKey accountKey = user.account_key;
final boolean isCreatingFriendship = twitter.isCreatingFriendship(accountKey, user.id);
final boolean destroyingFriendship = twitter.isDestroyingFriendship(accountKey, user.id);
final UserKey accountKey = user.account_key;
final boolean isCreatingFriendship = twitter.isCreatingFriendship(accountKey, user.key.getId());
final boolean destroyingFriendship = twitter.isDestroyingFriendship(accountKey, user.key.getId());
setProgressBarIndeterminateVisibility(isCreatingFriendship || destroyingFriendship);
invalidateOptionsMenu();
}
@ -1750,10 +1756,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
static class UserRelationshipLoader extends AsyncTaskLoader<SingleResponse<UserRelationship>> {
private final Context context;
private final AccountKey mAccountKey;
private final UserKey mAccountKey;
private final long mUserId;
public UserRelationshipLoader(final Context context, @NonNull final AccountKey accountKey,
public UserRelationshipLoader(final Context context, @Nullable final UserKey accountKey,
final long userId) {
super(context);
this.context = context;
@ -1763,17 +1769,23 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Override
public SingleResponse<UserRelationship> loadInBackground() {
if (mAccountKey == null) {
return SingleResponse.getInstance(new TwitterException("No Account"));
}
final boolean isFiltering = DataStoreUtils.isFilteringUser(context, mUserId);
if (mAccountKey.getId() == mUserId)
return SingleResponse.getInstance();
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, mAccountKey, false);
if (twitter == null) return SingleResponse.getInstance();
if (twitter == null) {
return SingleResponse.getInstance(new TwitterException("No Account"));
}
try {
final Relationship relationship = twitter.showFriendship(mUserId);
final UserKey userKey = new UserKey(mUserId, mAccountKey.getHost());
if (relationship.isSourceBlockingTarget() || relationship.isSourceBlockedByTarget()) {
Utils.setLastSeen(context, mUserId, -1);
Utils.setLastSeen(context, userKey, -1);
} else {
Utils.setLastSeen(context, mUserId, System.currentTimeMillis());
Utils.setLastSeen(context, userKey, System.currentTimeMillis());
}
Utils.updateRelationship(context, relationship, mAccountKey);
return SingleResponse.getInstance(new UserRelationship(relationship, isFiltering));
@ -1800,7 +1812,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
public boolean check(@NonNull ParcelableUser user) {
return relationship.getSourceUserId() == user.account_key.getId()
&& relationship.getTargetUserId() == user.id;
&& user.key.check(relationship.getTargetUserId(), null);
}
}
@ -1817,7 +1829,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final ParcelableUser user = args.first;
resolver.insert(CachedUsers.CONTENT_URI, ParcelableUserValuesCreator.create(user));
resolver.insert(CachedRelationships.CONTENT_URI, CachedRelationshipValuesCreator.create(
new CachedRelationship(user.account_key, user.id, args.second)));
new CachedRelationship(user.account_key, user.key.getId(), args.second)));
return null;
}
}

View File

@ -25,14 +25,14 @@ import android.support.annotation.NonNull;
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
import org.mariotaku.twidere.loader.support.UserFriendsLoader;
import org.mariotaku.twidere.model.AccountKey;
import org.mariotaku.twidere.model.UserKey;
public class UserFriendsFragment extends CursorSupportUsersListFragment {
@Override
public CursorSupportUsersLoader onCreateUsersLoader(final Context context,
@NonNull final Bundle args, boolean fromUser) {
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
final UserFriendsLoader loader = new UserFriendsLoader(context, accountKey, userId,

Some files were not shown because too many files have changed in this diff Show More