mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-08 07:48:45 +01:00
migrating to string ids
This commit is contained in:
parent
444a8df11d
commit
2456f710e5
@ -18,5 +18,5 @@ public interface StatusNetResources {
|
||||
StatusNetConfig getStatusNetConfig() throws TwitterException;
|
||||
|
||||
@GET("/statusnet/conversation/{id}.json")
|
||||
ResponseList<Status> getStatusNetConversation(@Path("id") long statusId, @Query Paging paging) throws TwitterException;
|
||||
ResponseList<Status> getStatusNetConversation(@Path("id") String statusId, @Query Paging paging) throws TwitterException;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class Attention {
|
||||
@JsonField(name = "fullname")
|
||||
String fullName;
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
@JsonField(name = "ostatus_uri")
|
||||
String ostatusUri;
|
||||
@JsonField(name = "profileurl")
|
||||
@ -24,7 +24,7 @@ public class Attention {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public interface DirectMessagesResources {
|
||||
|
||||
@POST("/direct_messages/destroy.json")
|
||||
@BodyType(BodyType.FORM)
|
||||
DirectMessage destroyDirectMessage(@Param("id") long id) throws TwitterException;
|
||||
DirectMessage destroyDirectMessage(@Param("id") String id) throws TwitterException;
|
||||
|
||||
@GET("/direct_messages.json")
|
||||
ResponseList<DirectMessage> getDirectMessages(@Query Paging paging) throws TwitterException;
|
||||
@ -50,24 +50,24 @@ public interface DirectMessagesResources {
|
||||
|
||||
@POST("/direct_messages/new.json")
|
||||
@BodyType(BodyType.FORM)
|
||||
DirectMessage sendDirectMessage(@Param("user_id") long userId, @Param("text") String text)
|
||||
DirectMessage sendDirectMessage(@Param("user_id") String userId, @Param("text") String text)
|
||||
throws TwitterException;
|
||||
|
||||
@POST("/direct_messages/new.json")
|
||||
@BodyType(BodyType.FORM)
|
||||
DirectMessage sendDirectMessage(@Param("user_id") long userId, @Param("text") String text,
|
||||
DirectMessage sendDirectMessage(@Param("user_id") String userId, @Param("text") String text,
|
||||
@Param("media_id") long mediaId) throws TwitterException;
|
||||
|
||||
@POST("/direct_messages/new.json")
|
||||
@BodyType(BodyType.FORM)
|
||||
DirectMessage sendDirectMessage(@Param("screen_name") String screenName, @Param("text") String text)
|
||||
DirectMessage sendDirectMessageForScreenName(@Param("screen_name") String screenName, @Param("text") String text)
|
||||
throws TwitterException;
|
||||
|
||||
@POST("/direct_messages/new.json")
|
||||
@BodyType(BodyType.FORM)
|
||||
DirectMessage sendDirectMessage(@Param("screen_name") String screenName, @Param("text") String text,
|
||||
@Param("media_id") long mediaId) throws TwitterException;
|
||||
DirectMessage sendDirectMessageForScreenName(@Param("screen_name") String screenName, @Param("text") String text,
|
||||
@Param("media_id") long mediaId) throws TwitterException;
|
||||
|
||||
@GET("/direct_messages/show.json")
|
||||
DirectMessage showDirectMessage(@Query("id") long id) throws TwitterException;
|
||||
DirectMessage showDirectMessage(@Query("id") String id) throws TwitterException;
|
||||
}
|
||||
|
@ -21,9 +21,11 @@ package org.mariotaku.twidere.api.twitter.model;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
|
||||
|
||||
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -48,9 +50,9 @@ public class DirectMessage extends TwitterResponseObject implements TwitterRespo
|
||||
String text;
|
||||
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
|
||||
public long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -109,4 +111,9 @@ public class DirectMessage extends TwitterResponseObject implements TwitterRespo
|
||||
public String getRecipientScreenName() {
|
||||
return recipient.screenName;
|
||||
}
|
||||
|
||||
@OnJsonParseComplete
|
||||
void onJsonParseComplete() throws IOException {
|
||||
if (id == null || recipient == null || sender == null) throw new IOException("Malformed DirectMessage object");
|
||||
}
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ public class IDs$$JsonObjectMapper extends JsonMapper<IDs> {
|
||||
}
|
||||
|
||||
private void parseIDsArray(IDs instance, JsonParser jsonParser) throws IOException {
|
||||
List<Long> collection1 = new ArrayList<>();
|
||||
List<String> collection1 = new ArrayList<>();
|
||||
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
|
||||
collection1.add(jsonParser.getValueAsLong());
|
||||
collection1.add(jsonParser.getValueAsString());
|
||||
}
|
||||
long[] array = new long[collection1.size()];
|
||||
String[] array = new String[collection1.size()];
|
||||
int i = 0;
|
||||
for (long value : collection1) {
|
||||
for (String value : collection1) {
|
||||
array[i++] = value;
|
||||
}
|
||||
instance.ids = array;
|
||||
|
@ -34,7 +34,7 @@ public class IDs extends TwitterResponseObject implements TwitterResponse, Curso
|
||||
|
||||
long previousCursor;
|
||||
long nextCursor;
|
||||
long[] ids;
|
||||
String[] ids;
|
||||
|
||||
@Override
|
||||
public long getNextCursor() {
|
||||
@ -56,7 +56,7 @@ public class IDs extends TwitterResponseObject implements TwitterResponse, Curso
|
||||
return previousCursor != 0;
|
||||
}
|
||||
|
||||
public long[] getIDs() {
|
||||
public String[] getIDs() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
@ -231,8 +231,8 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
|
||||
* <i>Perspectival</i>. Only surfaces on methods supporting the <code>include_my_retweet</code> parameter,
|
||||
* when set to true. Details the Tweet ID of the user’s own retweet (if existent) of this Tweet.
|
||||
*/
|
||||
public long getCurrentUserRetweet() {
|
||||
if (currentUserRetweet == null) return -1;
|
||||
public String getCurrentUserRetweet() {
|
||||
if (currentUserRetweet == null) return null;
|
||||
return currentUserRetweet.id;
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
|
||||
@JsonObject
|
||||
public static class CurrentUserRetweet {
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class StatusUpdate extends SimpleValueMap {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setInReplyToStatusId(final long inReplyToStatusId) {
|
||||
public void setInReplyToStatusId(final String inReplyToStatusId) {
|
||||
put("in_reply_to_status_id", inReplyToStatusId);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class StatusUpdate extends SimpleValueMap {
|
||||
put("place_id", placeId);
|
||||
}
|
||||
|
||||
public StatusUpdate inReplyToStatusId(final long inReplyToStatusId) {
|
||||
public StatusUpdate inReplyToStatusId(final String inReplyToStatusId) {
|
||||
setInReplyToStatusId(inReplyToStatusId);
|
||||
return this;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
public class TranslationResult extends TwitterResponseObject implements TwitterResponse {
|
||||
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
@JsonField(name = "lang")
|
||||
String lang;
|
||||
@JsonField(name = "translated_lang")
|
||||
@ -39,7 +39,7 @@ public class TranslationResult extends TwitterResponseObject implements TwitterR
|
||||
@JsonField(name = "text")
|
||||
String text;
|
||||
|
||||
public long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -58,4 +58,15 @@ public class TranslationResult extends TwitterResponseObject implements TwitterR
|
||||
public String getTranslationType() {
|
||||
return translationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TranslationResult{" +
|
||||
"id='" + id + '\'' +
|
||||
", lang='" + lang + '\'' +
|
||||
", translatedLang='" + translatedLang + '\'' +
|
||||
", translationType='" + translationType + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
"} " + super.toString();
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class UserMentionEntity {
|
||||
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
|
||||
Indices indices;
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
@JsonField(name = "name")
|
||||
String name;
|
||||
@JsonField(name = "screen_name")
|
||||
@ -50,7 +50,7 @@ public class UserMentionEntity {
|
||||
return indices.getEnd();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -42,18 +42,6 @@ import java.util.Arrays;
|
||||
@CursorObject(valuesCreator = true)
|
||||
public class ParcelableDirectMessage implements Parcelable, Comparable<ParcelableDirectMessage> {
|
||||
|
||||
public static final Creator<ParcelableDirectMessage> CREATOR = new Creator<ParcelableDirectMessage>() {
|
||||
public ParcelableDirectMessage createFromParcel(Parcel source) {
|
||||
ParcelableDirectMessage target = new ParcelableDirectMessage();
|
||||
ParcelableDirectMessageParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public ParcelableDirectMessage[] newArray(int size) {
|
||||
return new ParcelableDirectMessage[size];
|
||||
}
|
||||
};
|
||||
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "account_id", typeConverter = UserKeyConverter.class)
|
||||
@CursorField(value = DirectMessages.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
|
||||
@ -61,7 +49,7 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "id")
|
||||
@CursorField(DirectMessages.MESSAGE_ID)
|
||||
public long id;
|
||||
public String id;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "timestamp")
|
||||
@CursorField(DirectMessages.MESSAGE_TIMESTAMP)
|
||||
@ -70,11 +58,11 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "sender_id")
|
||||
@CursorField(DirectMessages.SENDER_ID)
|
||||
public long sender_id;
|
||||
public String sender_id;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "recipient_id")
|
||||
@CursorField(DirectMessages.RECIPIENT_ID)
|
||||
public long recipient_id;
|
||||
public String recipient_id;
|
||||
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "is_outgoing")
|
||||
@ -130,9 +118,7 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull final ParcelableDirectMessage another) {
|
||||
final long diff = another.id - id;
|
||||
if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE;
|
||||
if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE;
|
||||
final long diff = another.timestamp - timestamp;
|
||||
return (int) diff;
|
||||
}
|
||||
|
||||
@ -143,15 +129,15 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
|
||||
|
||||
ParcelableDirectMessage that = (ParcelableDirectMessage) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
return account_key.equals(that.account_key);
|
||||
if (!account_key.equals(that.account_key)) return false;
|
||||
return id.equals(that.id);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = account_key.hashCode();
|
||||
result = 31 * result + (int) (id ^ (id >>> 32));
|
||||
result = 31 * result + id.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -186,4 +172,16 @@ public class ParcelableDirectMessage implements Parcelable, Comparable<Parcelabl
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
ParcelableDirectMessageParcelablePlease.writeToParcel(this, dest, flags);
|
||||
}
|
||||
|
||||
public static final Creator<ParcelableDirectMessage> CREATOR = new Creator<ParcelableDirectMessage>() {
|
||||
public ParcelableDirectMessage createFromParcel(Parcel source) {
|
||||
ParcelableDirectMessage target = new ParcelableDirectMessage();
|
||||
ParcelableDirectMessageParcelablePlease.readFromParcel(target, source);
|
||||
return target;
|
||||
}
|
||||
|
||||
public ParcelableDirectMessage[] newArray(int size) {
|
||||
return new ParcelableDirectMessage[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -128,6 +128,9 @@ public class UserKey implements Comparable<UserKey>, Parcelable {
|
||||
escaping = true;
|
||||
} else if (ch == '@') {
|
||||
idFinished = true;
|
||||
} else if (ch == ',') {
|
||||
// end of item
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSpecialChar(ch) || !escaping) {
|
||||
@ -180,7 +183,7 @@ public class UserKey implements Comparable<UserKey>, Parcelable {
|
||||
}
|
||||
|
||||
private static boolean isSpecialChar(char ch) {
|
||||
return ch == '\\' || ch == '@';
|
||||
return ch == '\\' || ch == '@' || ch == ',';
|
||||
}
|
||||
|
||||
public boolean maybeEquals(@Nullable UserKey another) {
|
||||
|
@ -15,13 +15,13 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
|
||||
public class SendDirectMessageActionExtra implements ActionExtra {
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "recipient_id")
|
||||
long recipientId;
|
||||
String recipientId;
|
||||
|
||||
public long getRecipientId() {
|
||||
public String getRecipientId() {
|
||||
return recipientId;
|
||||
}
|
||||
|
||||
public void setRecipientId(long recipientId) {
|
||||
public void setRecipientId(String recipientId) {
|
||||
this.recipientId = recipientId;
|
||||
}
|
||||
|
||||
|
@ -407,8 +407,8 @@ public interface TwidereDataStore {
|
||||
SENDER_ID, RECIPIENT_ID, CONVERSATION_ID, IS_OUTGOING, TEXT_HTML, TEXT_PLAIN, TEXT_UNESCAPED,
|
||||
SENDER_NAME, RECIPIENT_NAME, SENDER_SCREEN_NAME, RECIPIENT_SCREEN_NAME, SENDER_PROFILE_IMAGE_URL,
|
||||
RECIPIENT_PROFILE_IMAGE_URL, MEDIA_JSON, INSERTED_DATE};
|
||||
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_INT, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_INT,
|
||||
TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_INT, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, INSERTED_DATE_TYPE};
|
||||
|
||||
String DEFAULT_SORT_ORDER = MESSAGE_ID + " DESC";
|
||||
@ -890,10 +890,10 @@ public interface TwidereDataStore {
|
||||
|
||||
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_INT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_INT, TYPE_BOOLEAN,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_BOOLEAN,
|
||||
TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN,
|
||||
TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, INSERTED_DATE_TYPE,
|
||||
|
@ -39,14 +39,14 @@ import java.util.Arrays;
|
||||
public class RefreshEvent extends BaseEvent implements Parcelable {
|
||||
@JsonField(name = "ids")
|
||||
@ParcelableThisPlease
|
||||
long[] ids;
|
||||
String[] ids;
|
||||
|
||||
@JsonField(name = "timeline_type")
|
||||
@ParcelableThisPlease
|
||||
@TimelineType
|
||||
String timelineType;
|
||||
|
||||
public static RefreshEvent create(final Context context, long[] ids, @TimelineType String timelineType) {
|
||||
public static RefreshEvent create(final Context context, String[] ids, @TimelineType String timelineType) {
|
||||
final RefreshEvent event = new RefreshEvent();
|
||||
event.markStart(context);
|
||||
event.setIds(ids);
|
||||
@ -54,7 +54,7 @@ public class RefreshEvent extends BaseEvent implements Parcelable {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setIds(long[] ids) {
|
||||
public void setIds(String[] ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.mariotaku.twidere.model.UserKey;
|
||||
@JsonObject
|
||||
public class ScrollRecord implements LogModel {
|
||||
@JsonField(name = "id")
|
||||
long id;
|
||||
String id;
|
||||
@JsonField(name = "account_id")
|
||||
String accountId;
|
||||
@JsonField(name = "account_host")
|
||||
@ -44,7 +44,7 @@ public class ScrollRecord implements LogModel {
|
||||
@JsonField(name = "scroll_state")
|
||||
int scrollState;
|
||||
|
||||
public static ScrollRecord create(long id, UserKey accountKey, long timestamp, long timeOffset, int scrollState) {
|
||||
public static ScrollRecord create(String id, UserKey accountKey, long timestamp, long timeOffset, int scrollState) {
|
||||
final ScrollRecord record = new ScrollRecord();
|
||||
record.setId(id);
|
||||
record.setAccountId(accountKey.getId());
|
||||
@ -67,7 +67,7 @@ public class ScrollRecord implements LogModel {
|
||||
this.timeOffset = timeOffset;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere;
|
||||
|
||||
import org.mariotaku.twidere.annotation.Preference;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.BOOLEAN;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
|
||||
@ -83,7 +84,7 @@ public interface Constants extends TwidereConstants {
|
||||
String TWIDERE_PREVIEW_TEXT_UNESCAPED = "Twidere is an open source twitter client for Android, see github.com/mariotak…";
|
||||
String TWIDERE_PREVIEW_SOURCE = "Twidere for Android";
|
||||
|
||||
long HONDAJOJO_ID = 514378421;
|
||||
UserKey HONDAJOJO_ID = new UserKey("514378421", USER_TYPE_TWITTER_COM);
|
||||
String HONDAJOJO_SCREEN_NAME = "HondaJOJO";
|
||||
String EASTER_EGG_TRIGGER_TEXT = "\u718A\u5B69\u5B50";
|
||||
String EASTER_EGG_RESTORE_TEXT_PART1 = "\u5927\u738B";
|
||||
|
@ -1034,7 +1034,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
|
||||
}
|
||||
|
||||
private boolean handleQuoteIntent(final ParcelableStatus status) {
|
||||
if (status == null || status.id <= 0) return false;
|
||||
if (status == null) return false;
|
||||
mEditText.setText(Utils.getQuoteStatus(this, status.id, status.user_screen_name, status.text_plain));
|
||||
mEditText.setSelection(0);
|
||||
mAccountsAdapter.setSelectedAccountIds(status.account_key);
|
||||
@ -1070,7 +1070,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
|
||||
}
|
||||
|
||||
private boolean handleReplyIntent(final ParcelableStatus status) {
|
||||
if (status == null || status.id <= 0) return false;
|
||||
if (status == null || status.id == null) return false;
|
||||
final String myScreenName = DataStoreUtils.getAccountScreenName(this, status.account_key);
|
||||
if (TextUtils.isEmpty(myScreenName)) return false;
|
||||
int selectionStart = 0;
|
||||
|
@ -817,7 +817,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
|
||||
if (mPagerAdapter.getCount() == 0) return;
|
||||
final SupportTabSpec tab = mPagerAdapter.getTab(position);
|
||||
if (DirectMessagesFragment.class == tab.cls) {
|
||||
IntentUtils.openMessageConversation(this, null, -1);
|
||||
IntentUtils.openMessageConversation(this, null, null);
|
||||
} else if (TrendsSuggestionsFragment.class == tab.cls) {
|
||||
openSearchView(null);
|
||||
} else {
|
||||
|
@ -179,7 +179,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
||||
break;
|
||||
}
|
||||
case SuggestionsAdapter.VIEW_TYPE_USER_SCREEN_NAME: {
|
||||
IntentUtils.openUserProfile(this, getSelectedAccountKey(), -1, item.title, null, true,
|
||||
IntentUtils.openUserProfile(this, getSelectedAccountKey(), null, item.title, null, true,
|
||||
UserFragment.Referral.DIRECT);
|
||||
finish();
|
||||
break;
|
||||
@ -316,13 +316,14 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
||||
|
||||
|
||||
public final String title, summary;
|
||||
public final long _id, extra_id;
|
||||
public final long _id;
|
||||
public final String extra_id;
|
||||
|
||||
public SuggestionItem(Cursor cursor, SuggestionsAdapter.Indices indices) {
|
||||
_id = cursor.getLong(indices._id);
|
||||
title = cursor.getString(indices.title);
|
||||
summary = cursor.getString(indices.summary);
|
||||
extra_id = cursor.getLong(indices.extra_id);
|
||||
extra_id = cursor.getString(indices.extra_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,8 +1095,7 @@ 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 UserKey accountKey = new UserKey(user.getId(),
|
||||
UserKeyUtils.getUserHost(user.getOstatusUri()));
|
||||
final UserKey accountKey = UserKeyUtils.fromUser(user);
|
||||
final ParcelableUser parcelableUser = ParcelableUserUtils.fromUser(user, accountKey);
|
||||
values.put(Accounts.ACCOUNT_USER, JsonSerializer.serialize(parcelableUser, ParcelableUser.class));
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@ -126,9 +127,9 @@ public class AccountsSpinnerAdapter extends ArrayAdapter<ParcelableCredentials>
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int findPositionByKey(UserKey key) {
|
||||
public int findPositionByKey(@NonNull UserKey key) {
|
||||
for (int i = 0, j = getCount(); i < j; i++) {
|
||||
if (getItem(i).account_key.equals(key)) {
|
||||
if (key.equals(getItem(i).account_key)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,11 @@ public final class DummyStatusHolderAdapter implements IStatusesAdapter<Object>,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStatusTimestamp(int adapterPosition) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public UserKey getAccountKey(int position) {
|
||||
|
@ -243,12 +243,12 @@ public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> im
|
||||
public static class DirectMessageEntry {
|
||||
|
||||
public final UserKey account_key;
|
||||
public final long conversation_id;
|
||||
public final String conversation_id;
|
||||
public final String screen_name, name;
|
||||
|
||||
DirectMessageEntry(Cursor cursor) {
|
||||
account_key = UserKey.valueOf(cursor.getString(ConversationEntries.IDX_ACCOUNT_KEY));
|
||||
conversation_id = cursor.getLong(ConversationEntries.IDX_CONVERSATION_ID);
|
||||
conversation_id = cursor.getString(ConversationEntries.IDX_CONVERSATION_ID);
|
||||
screen_name = cursor.getString(ConversationEntries.IDX_SCREEN_NAME);
|
||||
name = cursor.getString(ConversationEntries.IDX_NAME);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class ParcelableActivitiesAdapter extends LoadMoreSupportAdapter<Recycler
|
||||
private List<ParcelableActivity> mData;
|
||||
private final boolean mIsByFriends;
|
||||
private ActivityAdapterListener mActivityAdapterListener;
|
||||
private long[] mFilteredUserIds;
|
||||
private String[] mFilteredUserIds;
|
||||
private boolean mFollowingOnly;
|
||||
private boolean mMentionsOnly;
|
||||
|
||||
|
@ -152,6 +152,19 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
|
||||
return mData.get(dataPosition).id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getStatusTimestamp(int adapterPosition) {
|
||||
int dataPosition = adapterPosition - getStatusStartIndex();
|
||||
if (dataPosition < 0 || dataPosition >= getStatusCount()) return -1;
|
||||
if (mData instanceof ObjectCursor) {
|
||||
final Cursor cursor = ((ObjectCursor) mData).getCursor(dataPosition);
|
||||
final ParcelableStatusCursorIndices indices = (ParcelableStatusCursorIndices) ((ObjectCursor) mData).getIndices();
|
||||
return cursor.getLong(indices.timestamp);
|
||||
}
|
||||
return mData.get(dataPosition).timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserKey getAccountKey(int adapterPosition) {
|
||||
int dataPosition = adapterPosition - getStatusStartIndex();
|
||||
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.adapter;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -109,9 +110,10 @@ public class ParcelableUsersAdapter extends LoadMoreSupportAdapter<RecyclerView.
|
||||
return start;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long getUserId(int position) {
|
||||
if (position == getUserCount()) return -1;
|
||||
public String getUserId(int position) {
|
||||
if (position == getUserCount()) return null;
|
||||
return mData.get(position).key.getId();
|
||||
}
|
||||
|
||||
@ -129,11 +131,11 @@ public class ParcelableUsersAdapter extends LoadMoreSupportAdapter<RecyclerView.
|
||||
return true;
|
||||
}
|
||||
|
||||
public int findPosition(UserKey accountKey, long userId) {
|
||||
public int findPosition(UserKey accountKey, String 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.key.getId() == userId) {
|
||||
if (user.account_key.equals(accountKey) && TextUtils.equals(user.key.getId(), userId)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/29.
|
||||
@ -77,7 +78,7 @@ public class SavedSearchesAdapter extends BaseAdapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public boolean removeItem(long accountId, long searchId) {
|
||||
public boolean removeItem(UserKey accountId, long searchId) {
|
||||
if (mData == null) return false;
|
||||
for (int i = 0, mDataSize = mData.size(); i < mDataSize; i++) {
|
||||
SavedSearch search = mData.get(i);
|
||||
|
@ -20,12 +20,14 @@
|
||||
package org.mariotaku.twidere.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.view.holder.TwoLineWithIconViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
@ -91,10 +93,17 @@ public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUse
|
||||
}
|
||||
if (data == null) return;
|
||||
for (final ParcelableUser user : data) {
|
||||
if (clearOld || findItemPosition(user.key.getId()) < 0) {
|
||||
if (clearOld || findUserPosition(user.key) < 0) {
|
||||
add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int findUserPosition(@NonNull UserKey userKey) {
|
||||
for (int i = 0, j = getCount(); i < j; i++) {
|
||||
if (userKey.equals(getItem(i).key)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ public interface IStatusesAdapter<Data> extends IContentCardAdapter, IGapSupport
|
||||
@Nullable
|
||||
String getStatusId(int position);
|
||||
|
||||
long getStatusTimestamp(int adapterPosition);
|
||||
|
||||
@Nullable
|
||||
UserKey getAccountKey(int position);
|
||||
|
||||
|
@ -33,7 +33,8 @@ public interface IUsersAdapter<Data> extends IContentCardAdapter {
|
||||
|
||||
ParcelableUser getUser(int position);
|
||||
|
||||
long getUserId(int position);
|
||||
@Nullable
|
||||
String getUserId(int position);
|
||||
|
||||
int getUserCount();
|
||||
|
||||
|
@ -109,7 +109,7 @@ public abstract class AbsActivitiesFragment extends AbsContentListRecyclerViewFr
|
||||
if (timestamp != mFirstVisibleTimestamp || !accountKey.equals(mFirstVisibleAccountId)) {
|
||||
if (mRecords == null) mRecords = new ArrayList<>();
|
||||
final long time = System.currentTimeMillis();
|
||||
mRecords.add(ScrollRecord.create(timestamp, accountKey, time,
|
||||
mRecords.add(ScrollRecord.create(String.valueOf(timestamp), accountKey, time,
|
||||
TimeZone.getDefault().getOffset(time), mScrollState));
|
||||
}
|
||||
mFirstVisibleTimestamp = timestamp;
|
||||
@ -341,7 +341,7 @@ public abstract class AbsActivitiesFragment extends AbsContentListRecyclerViewFr
|
||||
final ParcelableActivitiesAdapter adapter = getAdapter();
|
||||
final ParcelableActivity activity = adapter.getActivity(position);
|
||||
final UserKey[] accountIds = {activity.account_key};
|
||||
final long[] maxIds = {activity.min_position};
|
||||
final String[] maxIds = {activity.min_position};
|
||||
getActivities(new BaseRefreshTaskParam(accountIds, maxIds, null));
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.OnScrollListener;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuInflater;
|
||||
@ -72,6 +73,7 @@ import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import edu.tsinghua.hotmobi.HotMobiLogger;
|
||||
@ -89,7 +91,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
private final OnScrollListener mHotMobiScrollTracker = new OnScrollListener() {
|
||||
|
||||
public List<ScrollRecord> mRecords;
|
||||
private long mFirstVisibleId = -1;
|
||||
private String mFirstVisibleId;
|
||||
private UserKey mFirstVisibleAccountId = null;
|
||||
private int mFirstVisiblePosition = -1;
|
||||
private int mScrollState;
|
||||
@ -103,9 +105,9 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
final ParcelableStatusesAdapter adapter = (ParcelableStatusesAdapter) recyclerView.getAdapter();
|
||||
final ParcelableStatus status = adapter.getStatus(firstVisiblePosition);
|
||||
if (status != null) {
|
||||
final long id = status.id;
|
||||
final String id = status.id;
|
||||
final UserKey accountId = status.account_key;
|
||||
if (id != mFirstVisibleId || !accountId.equals(mFirstVisibleAccountId)) {
|
||||
if (!TextUtils.equals(id, mFirstVisibleId) || !accountId.equals(mFirstVisibleAccountId)) {
|
||||
if (mRecords == null) mRecords = new ArrayList<>();
|
||||
final long time = System.currentTimeMillis();
|
||||
mRecords.add(ScrollRecord.create(id, accountId, time,
|
||||
@ -248,7 +250,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
final ParcelableStatusesAdapter adapter = getAdapter();
|
||||
final boolean rememberPosition = mPreferences.getBoolean(KEY_REMEMBER_POSITION, false);
|
||||
final boolean readFromBottom = mPreferences.getBoolean(KEY_READ_FROM_BOTTOM, false);
|
||||
long lastReadId;
|
||||
long lastReadTimestamp;
|
||||
final int lastVisiblePos, lastVisibleTop;
|
||||
final String tag = getCurrentReadPositionTag();
|
||||
final LinearLayoutManager layoutManager = getLayoutManager();
|
||||
@ -261,14 +263,14 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
final int statusStartIndex = adapter.getStatusStartIndex();
|
||||
final int statusEndIndex = statusStartIndex + adapter.getStatusCount();
|
||||
final int lastItemIndex = Math.min(statusEndIndex, lastVisiblePos);
|
||||
lastReadId = adapter.getStatusId(lastItemIndex);
|
||||
lastReadTimestamp = adapter.getStatusTimestamp(lastItemIndex);
|
||||
final View positionView = layoutManager.findViewByPosition(lastItemIndex);
|
||||
lastVisibleTop = positionView != null ? positionView.getTop() : 0;
|
||||
} else if (rememberPosition && tag != null) {
|
||||
lastReadId = mReadStateManager.getPosition(tag);
|
||||
lastReadTimestamp = mReadStateManager.getPosition(tag);
|
||||
lastVisibleTop = 0;
|
||||
} else {
|
||||
lastReadId = -1;
|
||||
lastReadTimestamp = -1;
|
||||
lastVisibleTop = 0;
|
||||
}
|
||||
adapter.setData(data);
|
||||
@ -276,10 +278,10 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
// The last status is statusEndExclusiveIndex - 1
|
||||
final int statusEndExclusiveIndex = statusStartIndex + adapter.getStatusCount();
|
||||
if (statusEndExclusiveIndex >= 0 && rememberPosition && tag != null) {
|
||||
final long lastItemId = adapter.getStatusId(statusEndExclusiveIndex - 1);
|
||||
final long lastItemId = adapter.getStatusTimestamp(statusEndExclusiveIndex - 1);
|
||||
// Status corresponds to last read id was deleted, use last item id instead
|
||||
if (lastItemId > 0 && lastReadId > 0 && lastReadId < lastItemId) {
|
||||
lastReadId = lastItemId;
|
||||
if (lastItemId != -1 && lastReadTimestamp > 0 && lastReadTimestamp < lastItemId) {
|
||||
lastReadTimestamp = lastItemId;
|
||||
}
|
||||
}
|
||||
setRefreshEnabled(true);
|
||||
@ -295,7 +297,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
for (int i = statusStartIndex; i < statusEndExclusiveIndex; i++) {
|
||||
// Assume statuses are descend sorted by id, so break at first status with id
|
||||
// lesser equals than read position
|
||||
if (lastReadId != -1 && adapter.getStatusId(i) <= lastReadId) {
|
||||
if (lastReadTimestamp != -1 && adapter.getStatusTimestamp(i) <= lastReadTimestamp) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
@ -330,7 +332,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
final ParcelableStatus status = adapter.getStatus(position);
|
||||
if (status == null) return;
|
||||
final UserKey[] accountIds = {status.account_key};
|
||||
final long[] maxIds = {status.id};
|
||||
final String[] maxIds = {status.id};
|
||||
getStatuses(new BaseRefreshTaskParam(accountIds, maxIds, null));
|
||||
}
|
||||
|
||||
@ -540,8 +542,8 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||
final ParcelableStatusesAdapter adapter = getAdapter();
|
||||
final ParcelableStatus status = adapter.getStatus(position);
|
||||
if (status == null) return;
|
||||
mReadStateManager.setPosition(readPositionTag, status.id);
|
||||
mReadStateManager.setPosition(getCurrentReadPositionTag(), status.id, true);
|
||||
mReadStateManager.setPosition(readPositionTag, status.timestamp);
|
||||
mReadStateManager.setPosition(getCurrentReadPositionTag(), status.timestamp, true);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -89,7 +89,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
||||
private RecyclerViewNavigationHelper mNavigationHelper;
|
||||
|
||||
// Data fields
|
||||
private final SimpleArrayMap<UserKey, Set<Long>> mUnreadCountsToRemove = new SimpleArrayMap<>();
|
||||
private final SimpleArrayMap<UserKey, Set<String>> 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<UserKey, Set<Long>> getUnreadCountsToRemove() {
|
||||
public final SimpleArrayMap<UserKey, Set<String>> getUnreadCountsToRemove() {
|
||||
return mUnreadCountsToRemove;
|
||||
}
|
||||
|
||||
@ -243,8 +243,8 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
||||
final Context context = getContext();
|
||||
if (context == null) return null;
|
||||
UserKey[] accountIds = getAccountKeys();
|
||||
long[] ids = DataStoreUtils.getNewestMessageIds(context,
|
||||
DirectMessages.Inbox.CONTENT_URI, accountIds);
|
||||
String[] ids = DataStoreUtils.getNewestMessageIds(context,
|
||||
Inbox.CONTENT_URI, accountIds);
|
||||
return new BaseRefreshTaskParam(accountIds, ids, null);
|
||||
}
|
||||
|
||||
@ -325,9 +325,9 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
||||
public void openNewMessageConversation() {
|
||||
final UserKey[] accountIds = getAccountKeys();
|
||||
if (accountIds.length == 1) {
|
||||
IntentUtils.openMessageConversation(getActivity(), accountIds[0], -1);
|
||||
IntentUtils.openMessageConversation(getActivity(), accountIds[0], null);
|
||||
} else {
|
||||
IntentUtils.openMessageConversation(getActivity(), null, -1);
|
||||
IntentUtils.openMessageConversation(getActivity(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,13 +368,13 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
||||
mFirstVisibleItem = firstVisibleItem;
|
||||
}
|
||||
|
||||
private void addUnreadCountsToRemove(final UserKey accountId, final long id) {
|
||||
private void addUnreadCountsToRemove(final UserKey accountId, final String id) {
|
||||
if (mUnreadCountsToRemove.indexOfKey(accountId) < 0) {
|
||||
final Set<Long> counts = new HashSet<>();
|
||||
final Set<String> counts = new HashSet<>();
|
||||
counts.add(id);
|
||||
mUnreadCountsToRemove.put(accountId, counts);
|
||||
} else {
|
||||
final Set<Long> counts = mUnreadCountsToRemove.get(accountId);
|
||||
final Set<String> counts = mUnreadCountsToRemove.get(accountId);
|
||||
counts.add(id);
|
||||
}
|
||||
}
|
||||
@ -431,7 +431,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
||||
protected Object doInBackground(final Object... params) {
|
||||
for (final int pos : read_positions) {
|
||||
final DirectMessageEntry entry = adapter.getEntry(pos);
|
||||
final long id = entry.conversation_id;
|
||||
final String id = entry.conversation_id;
|
||||
final UserKey accountKey = entry.account_key;
|
||||
fragment.addUnreadCountsToRemove(accountKey, id);
|
||||
}
|
||||
|
@ -288,11 +288,11 @@ public class DraftsFragment extends BaseSupportFragment implements Constants, Lo
|
||||
}
|
||||
case Draft.Action.SEND_DIRECT_MESSAGE_COMPAT:
|
||||
case Draft.Action.SEND_DIRECT_MESSAGE: {
|
||||
long recipientId = -1;
|
||||
String recipientId = null;
|
||||
if (item.action_extras instanceof SendDirectMessageActionExtra) {
|
||||
recipientId = ((SendDirectMessageActionExtra) item.action_extras).getRecipientId();
|
||||
}
|
||||
if (ArrayUtils.isEmpty(item.account_ids) || recipientId <= 0) {
|
||||
if (ArrayUtils.isEmpty(item.account_ids) || recipientId == null) {
|
||||
continue;
|
||||
}
|
||||
final UserKey accountId = item.account_ids[0];
|
||||
|
@ -305,11 +305,15 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
recipient = args.getParcelable(EXTRA_USER);
|
||||
} else if (args.containsKey(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 (accountKey == null) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
final int accountPos = accountsSpinnerAdapter.findPositionByKey(accountKey);
|
||||
if (accountPos >= 0) {
|
||||
mAccountSpinner.setSelection(accountPos);
|
||||
}
|
||||
final String userId = args.getString(EXTRA_RECIPIENT_ID);
|
||||
account = accountPos >= 0 ? accountsSpinnerAdapter.getItem(accountPos) :
|
||||
ParcelableCredentialsUtils.getCredentials(activity, accountKey);
|
||||
recipient = Utils.getUserForConversation(activity, accountKey, userId);
|
||||
@ -319,7 +323,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
}
|
||||
showConversation(account, recipient);
|
||||
if (account != null && recipient != null) {
|
||||
final String key = getDraftsTextKey(account.account_key, recipient.key.getId());
|
||||
final String key = getDraftsTextKey(account.account_key, recipient.key);
|
||||
mEditText.setText(mMessageDrafts.getString(key, null));
|
||||
}
|
||||
}
|
||||
@ -373,7 +377,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.key.getId());
|
||||
final String key = getDraftsTextKey(account.account_key, recipient.key);
|
||||
final SharedPreferences.Editor editor = mMessageDrafts.edit();
|
||||
final String text = ParseUtils.parseString(mEditText.getText());
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
@ -568,7 +572,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.key.getId());
|
||||
args.putString(EXTRA_RECIPIENT_ID, recipient.key.getId());
|
||||
if (mLoaderInitialized) {
|
||||
lm.restartLoader(0, args, this);
|
||||
} else {
|
||||
@ -585,8 +589,8 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
return mConversationContainer.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
private String getDraftsTextKey(UserKey accountKey, long userId) {
|
||||
return String.format(Locale.ROOT, "text_%s_to_%d", accountKey, userId);
|
||||
private String getDraftsTextKey(UserKey accountKey, UserKey userId) {
|
||||
return String.format(Locale.ROOT, "text_%s_to_%s", accountKey, userId);
|
||||
}
|
||||
|
||||
private void searchUsers(UserKey accountKey, String query, boolean fromCache) {
|
||||
@ -748,7 +752,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
final Menu menu = mPopupMenu.getMenu();
|
||||
final MenuItem view_profile_item = menu.findItem(R.id.view_profile);
|
||||
if (view_profile_item != null && dm != null) {
|
||||
view_profile_item.setVisible(dm.account_key.getId() != dm.sender_id);
|
||||
view_profile_item.setVisible(!TextUtils.equals(dm.account_key.getId(), dm.sender_id));
|
||||
}
|
||||
mPopupMenu.setOnMenuItemClickListener(this);
|
||||
mPopupMenu.show();
|
||||
|
@ -24,6 +24,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
@ -50,19 +51,19 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
|
||||
private long mLastId;
|
||||
private String mLastId;
|
||||
private int mPage = 1, mPageDelta;
|
||||
|
||||
public final void deleteStatus(final long statusId) {
|
||||
public final void deleteStatus(@NonNull final String statusId) {
|
||||
final List<ParcelableStatus> list = getAdapterData();
|
||||
if (statusId <= 0 || list == null) return;
|
||||
if (list == null) return;
|
||||
final Set<ParcelableStatus> dataToRemove = new HashSet<>();
|
||||
for (int i = 0, j = list.size(); i < j; i++) {
|
||||
final ParcelableStatus status = list.get(i);
|
||||
if (status.id == statusId || status.retweet_id > 0 && status.retweet_id == statusId) {
|
||||
if (TextUtils.equals(status.id, statusId) || TextUtils.equals(status.retweet_id, statusId)) {
|
||||
dataToRemove.add(status);
|
||||
} else if (status.my_retweet_id == statusId) {
|
||||
status.my_retweet_id = -1;
|
||||
} else if (TextUtils.equals(status.my_retweet_id, statusId)) {
|
||||
status.my_retweet_id = null;
|
||||
status.retweet_count = status.retweet_count - 1;
|
||||
}
|
||||
}
|
||||
@ -81,14 +82,14 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
@Override
|
||||
public boolean getStatuses(RefreshTaskParam param) {
|
||||
final Bundle args = new Bundle(getArguments());
|
||||
long[] maxIds = param.getMaxIds();
|
||||
String[] maxIds = param.getMaxIds();
|
||||
if (maxIds != null) {
|
||||
args.putLong(EXTRA_MAX_ID, maxIds[0]);
|
||||
args.putString(EXTRA_MAX_ID, maxIds[0]);
|
||||
args.putBoolean(EXTRA_MAKE_GAP, false);
|
||||
}
|
||||
long[] sinceIds = param.getSinceIds();
|
||||
String[] sinceIds = param.getSinceIds();
|
||||
if (sinceIds != null) {
|
||||
args.putLong(EXTRA_SINCE_ID, sinceIds[0]);
|
||||
args.putString(EXTRA_SINCE_ID, sinceIds[0]);
|
||||
}
|
||||
if (mPage > 0) {
|
||||
args.putInt(EXTRA_PAGE, mPage);
|
||||
@ -113,7 +114,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
@Override
|
||||
protected boolean hasMoreData(List<ParcelableStatus> list) {
|
||||
if (list == null || list.isEmpty()) return false;
|
||||
return (mLastId != (mLastId = list.get(list.size() - 1).id));
|
||||
return (!TextUtils.equals(mLastId, mLastId = list.get(list.size() - 1).id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,7 +152,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
final ParcelableStatus status = adapter.getStatus(adapter.getStatusStartIndex() +
|
||||
adapter.getStatusCount() - 1);
|
||||
UserKey[] accountKeys = {status.account_key};
|
||||
final long[] maxIds = {status.id};
|
||||
final String[] maxIds = {status.id};
|
||||
mPage += mPageDelta;
|
||||
getStatuses(new BaseRefreshTaskParam(accountKeys, maxIds, null));
|
||||
}
|
||||
@ -173,7 +174,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
|
||||
final UserKey[] accountIds = getAccountKeys();
|
||||
if (adapter.getStatusCount() > 0) {
|
||||
final long[] sinceIds = new long[]{adapter.getStatus(0).id};
|
||||
final String[] sinceIds = new String[]{adapter.getStatus(0).id};
|
||||
getStatuses(new BaseRefreshTaskParam(accountIds, null, sinceIds));
|
||||
} else {
|
||||
getStatuses(new BaseRefreshTaskParam(accountIds, null, null));
|
||||
@ -211,10 +212,10 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment {
|
||||
|
||||
private void updateRetweetedStatuses(ParcelableStatus status) {
|
||||
final List<ParcelableStatus> data = getAdapterData();
|
||||
if (status == null || status.retweet_id <= 0 || data == null) return;
|
||||
if (status == null || status.retweet_id == null || data == null) return;
|
||||
for (int i = 0, j = data.size(); i < j; i++) {
|
||||
final ParcelableStatus orig = data.get(i);
|
||||
if (orig.account_key.equals(status.account_key) && orig.id == status.retweet_id) {
|
||||
if (orig.account_key.equals(status.account_key) && TextUtils.equals(orig.id, status.retweet_id)) {
|
||||
orig.my_retweet_id = status.my_retweet_id;
|
||||
orig.retweet_count = status.retweet_count;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public abstract class ParcelableUsersFragment extends AbsContentListRecyclerView
|
||||
setLoadMoreIndicatorPosition(IndicatorPosition.NONE);
|
||||
}
|
||||
|
||||
protected void removeUsers(long... ids) {
|
||||
protected void removeUsers(String... ids) {
|
||||
//TODO remove from adapter
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ public class RetweetQuoteDialogFragment extends BaseSupportDialogFragment implem
|
||||
mPopupMenu.inflate(R.menu.menu_dialog_comment);
|
||||
final Menu menu = mPopupMenu.getMenu();
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.quote_original_status,
|
||||
status.retweet_id > 0 || status.quoted_id > 0);
|
||||
status.retweet_id != null || status.quoted_id != null);
|
||||
mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
@ -25,8 +25,8 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.Loader;
|
||||
|
||||
import org.mariotaku.twidere.loader.support.RetweetsOfMeLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,8 +39,8 @@ public class RetweetsOfMeFragment extends ParcelableStatusesFragment {
|
||||
final Bundle args,
|
||||
final boolean fromUser) {
|
||||
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 maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
return new RetweetsOfMeLoader(context, accountKey, sinceId, maxId, getAdapterData(),
|
||||
getSavedStatusesFileArgs(), tabPosition, fromUser);
|
||||
|
@ -135,6 +135,6 @@ public class SavedSearchesListFragment extends AbsContentListViewFragment<SavedS
|
||||
@Subscribe
|
||||
public void onSavedSearchDestroyed(SavedSearchDestroyedEvent event) {
|
||||
SavedSearchesAdapter adapter = getAdapter();
|
||||
adapter.removeItem(event.getAccountKey().getId(), event.getSearchId());
|
||||
adapter.removeItem(event.getAccountKey(), event.getSearchId());
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ public class ScheduledStatusesFragment extends AbsContentListRecyclerViewFragmen
|
||||
@Override
|
||||
public Loader<List<ScheduledStatus>> onCreateLoader(int id, Bundle args) {
|
||||
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 sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String[] states = {ScheduledStatus.State.SCHEDULED, ScheduledStatus.State.FAILED};
|
||||
return new ScheduledStatusesLoader(getActivity(), accountKey, sinceId, maxId, states, null);
|
||||
}
|
||||
@ -91,13 +91,11 @@ public class ScheduledStatusesFragment extends AbsContentListRecyclerViewFragmen
|
||||
public static class ScheduledStatusesAdapter extends LoadMoreSupportAdapter<RecyclerView.ViewHolder> {
|
||||
public static final int ITEM_VIEW_TYPE_SCHEDULED_STATUS = 2;
|
||||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private List<ScheduledStatus> mData;
|
||||
|
||||
public ScheduledStatusesAdapter(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
setLoadMoreSupportedPosition(IndicatorPosition.NONE);
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ 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 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);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
@Override
|
||||
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
|
||||
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final String statusId = args.getString(EXTRA_STATUS_ID);
|
||||
final StatusFavoritersLoader loader = new StatusFavoritersLoader(context, accountKey,
|
||||
statusId, getData(), false);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,8 +218,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
mStatusAdapter.setConversationsLoading(true);
|
||||
mStatusAdapter.updateItemDecoration();
|
||||
final ParcelableStatus status = args.getParcelable(EXTRA_STATUS);
|
||||
final String maxId = args.getLong(EXTRA_MAX_ID, -1);
|
||||
final String sinceId = args.getLong(EXTRA_SINCE_ID, -1);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
assert status != null;
|
||||
final ConversationLoader loader = new ConversationLoader(getActivity(), status, sinceId,
|
||||
maxId, mStatusAdapter.getData(), true);
|
||||
@ -544,7 +544,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
public Loader<SingleResponse<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
|
||||
final Bundle fragmentArgs = getArguments();
|
||||
final UserKey accountKey = fragmentArgs.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final long statusId = fragmentArgs.getLong(EXTRA_STATUS_ID, -1);
|
||||
final String statusId = fragmentArgs.getString(EXTRA_STATUS_ID);
|
||||
return new ParcelableStatusLoader(getActivity(), false, fragmentArgs, accountKey, statusId);
|
||||
}
|
||||
|
||||
@ -2086,8 +2086,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
}
|
||||
|
||||
public void setTranslationResult(@Nullable TranslationResult translation) {
|
||||
if (mStatus == null || translation == null || InternalTwitterContentUtils.getOriginalId(mStatus)
|
||||
!= translation.getId()) {
|
||||
if (mStatus == null || translation == null || !TextUtils.equals(InternalTwitterContentUtils
|
||||
.getOriginalId(mStatus), translation.getId())) {
|
||||
mTranslationResult = null;
|
||||
} else {
|
||||
mTranslationResult = translation;
|
||||
|
@ -29,14 +29,14 @@ 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 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);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
@Override
|
||||
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
|
||||
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final String statusId = args.getString(EXTRA_STATUS_ID);
|
||||
final StatusRetweetersLoader loader = new StatusRetweetersLoader(context, accountKey, statusId,
|
||||
getData(), fromUser);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ public class StatusesSearchFragment extends ParcelableStatusesFragment {
|
||||
final boolean fromUser) {
|
||||
setRefreshing(true);
|
||||
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 maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final int page = args.getInt(EXTRA_PAGE, -1);
|
||||
final String query = args.getString(EXTRA_QUERY);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
|
@ -25,8 +25,8 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.Loader;
|
||||
|
||||
import org.mariotaku.twidere.loader.support.UserFavoritesLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -43,9 +43,9 @@ public class UserFavoritesFragment extends ParcelableStatusesFragment {
|
||||
final boolean fromUser) {
|
||||
setRefreshing(true);
|
||||
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);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
return new UserFavoritesLoader(context, accountKey, userId, screenName, sinceId, maxId,
|
||||
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.fragment.support;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
@ -36,9 +37,10 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment {
|
||||
|
||||
@Override
|
||||
public CursorSupportUsersLoader onCreateUsersLoader(final Context context,
|
||||
@NonNull final Bundle args, boolean fromUser) {
|
||||
@NonNull final Bundle args,
|
||||
final boolean fromUser) {
|
||||
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final long userId = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final UserFollowersLoader loader = new UserFollowersLoader(context, accountKey, userId,
|
||||
screenName, getData(), fromUser);
|
||||
@ -62,11 +64,11 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment {
|
||||
@Subscribe
|
||||
public void onUsersBlocked(UsersBlockedEvent event) {
|
||||
final UserKey accountKey = event.getAccountKey();
|
||||
final String screen_name = getAccountScreenName(getActivity(), accountKey);
|
||||
final String screenName = getAccountScreenName(getActivity(), accountKey);
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return;
|
||||
if (accountKey != null && accountKey.getId() == args.getLong(EXTRA_USER_ID, -1) || screen_name != null
|
||||
&& screen_name.equalsIgnoreCase(args.getString(EXTRA_SCREEN_NAME))) {
|
||||
if (accountKey != null && TextUtils.equals(accountKey.getId(), args.getString(EXTRA_USER_ID))
|
||||
|| screenName != null && screenName.equalsIgnoreCase(args.getString(EXTRA_SCREEN_NAME))) {
|
||||
removeUsers(event.getUserIds());
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,6 @@ import android.widget.TextView;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
@ -1390,7 +1389,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_STATUS: {
|
||||
IntentUtils.openStatus(getActivity(), accountKey, NumberUtils.toLong(link, -1));
|
||||
IntentUtils.openStatus(getActivity(), accountKey, link);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class UserFriendsFragment extends CursorSupportUsersListFragment {
|
||||
public CursorSupportUsersLoader onCreateUsersLoader(final Context context,
|
||||
@NonNull final Bundle args, boolean fromUser) {
|
||||
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final long userId = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final UserFriendsLoader loader = new UserFriendsLoader(context, accountKey, userId,
|
||||
screenName, getData(), fromUser);
|
||||
|
@ -406,7 +406,7 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
||||
final ParcelableUserList userList = args.getParcelable(EXTRA_USER_LIST);
|
||||
assert userList != null;
|
||||
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, userList.account_key);
|
||||
tabArgs.putLong(EXTRA_USER_ID, userList.user_key.getId());
|
||||
tabArgs.putString(EXTRA_USER_ID, userList.user_key.getId());
|
||||
tabArgs.putString(EXTRA_SCREEN_NAME, userList.user_screen_name);
|
||||
tabArgs.putLong(EXTRA_LIST_ID, userList.id);
|
||||
tabArgs.putString(EXTRA_LIST_NAME, userList.name);
|
||||
|
@ -33,9 +33,9 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.UserList;
|
||||
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
|
||||
import org.mariotaku.twidere.loader.support.UserListMembersLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserListUtils;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
@ -53,7 +53,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment {
|
||||
if (BROADCAST_USER_LIST_MEMBERS_DELETED.equals(action)) {
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (mUserList != null && list != null && list.id == mUserList.id) {
|
||||
removeUsers(intent.getLongArrayExtra(EXTRA_USER_IDS));
|
||||
removeUsers(intent.getStringExtra(EXTRA_USER_IDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.Loader;
|
||||
|
||||
import org.mariotaku.twidere.loader.support.UserListTimelineLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -52,9 +52,9 @@ public class UserListTimelineFragment extends ParcelableStatusesFragment {
|
||||
if (args == null) return null;
|
||||
final long listId = args.getLong(EXTRA_LIST_ID, -1);
|
||||
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);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final String listName = args.getString(EXTRA_LIST_NAME);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
|
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -32,8 +33,8 @@ import com.squareup.otto.Subscribe;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.ParcelableUserListsAdapter;
|
||||
import org.mariotaku.twidere.loader.support.UserListsLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.message.UserListDestroyedEvent;
|
||||
import org.mariotaku.twidere.util.MenuUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
@ -82,8 +83,8 @@ public class UserListsFragment extends ParcelableUserListsFragment {
|
||||
final MenuItem item = menu.findItem(R.id.new_user_list);
|
||||
final UserKey accountId = getAccountKey();
|
||||
if (accountId == null || item == null) return;
|
||||
final long userId = getUserId();
|
||||
if (accountId.getId() == userId) {
|
||||
final String userId = getUserId();
|
||||
if (TextUtils.equals(accountId.getId(), userId)) {
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.new_user_list, true);
|
||||
} else {
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.new_user_list, Utils.isMyAccount(getActivity(), getScreenName()));
|
||||
@ -94,8 +95,8 @@ public class UserListsFragment extends ParcelableUserListsFragment {
|
||||
return getArguments().getString(EXTRA_SCREEN_NAME);
|
||||
}
|
||||
|
||||
private long getUserId() {
|
||||
return getArguments().getLong(EXTRA_USER_ID);
|
||||
private String getUserId() {
|
||||
return getArguments().getString(EXTRA_USER_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,9 +19,9 @@ import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosi
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
import org.mariotaku.twidere.loader.support.MediaTimelineLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.util.IntentUtils;
|
||||
import org.mariotaku.twidere.view.HeaderDrawerLayout.DrawerCallback;
|
||||
import org.mariotaku.twidere.view.holder.GapViewHolder;
|
||||
@ -72,12 +72,12 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
|
||||
}
|
||||
|
||||
|
||||
public int getStatuses(final long maxId, final long sinceId) {
|
||||
public int getStatuses(final String maxId, final String sinceId) {
|
||||
if (getContext() == null) return -1;
|
||||
final Bundle args = new Bundle(getArguments());
|
||||
args.putBoolean(EXTRA_MAKE_GAP, false);
|
||||
args.putLong(EXTRA_MAX_ID, maxId);
|
||||
args.putLong(EXTRA_SINCE_ID, sinceId);
|
||||
args.putString(EXTRA_MAX_ID, maxId);
|
||||
args.putString(EXTRA_SINCE_ID, sinceId);
|
||||
args.putBoolean(EXTRA_FROM_USER, true);
|
||||
getLoaderManager().restartLoader(0, args, this);
|
||||
return 0;
|
||||
@ -99,9 +99,9 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
|
||||
public Loader<List<ParcelableStatus>> onCreateLoader(int id, Bundle args) {
|
||||
final Context context = getActivity();
|
||||
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);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
final boolean fromUser = args.getBoolean(EXTRA_FROM_USER);
|
||||
@ -151,8 +151,8 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
|
||||
super.onLoadMoreContents(position);
|
||||
if (position == 0) return;
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
|
||||
final long maxId = adapter.getStatusId(adapter.getStatusCount() - 1);
|
||||
getStatuses(maxId, -1);
|
||||
final String maxId = adapter.getStatusId(adapter.getStatusCount() - 1);
|
||||
getStatuses(maxId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,8 +41,8 @@ public class UserMentionsFragment extends StatusesSearchFragment {
|
||||
if (args == null) return null;
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
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 maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final int page = args.getInt(EXTRA_PAGE, -1);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
final boolean makeGap = args.getBoolean(EXTRA_MAKE_GAP, true);
|
||||
|
@ -25,8 +25,8 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.Loader;
|
||||
|
||||
import org.mariotaku.twidere.loader.support.UserTimelineLoader;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -51,9 +51,9 @@ public class UserTimelineFragment extends ParcelableStatusesFragment {
|
||||
setRefreshing(true);
|
||||
final List<ParcelableStatus> data = getAdapterData();
|
||||
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);
|
||||
final String maxId = args.getString(EXTRA_MAX_ID);
|
||||
final String sinceId = args.getString(EXTRA_SINCE_ID);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
return new UserTimelineLoader(context, accountKey, userId, screenName, sinceId, maxId, data,
|
||||
@ -78,9 +78,9 @@ public class UserTimelineFragment extends ParcelableStatusesFragment {
|
||||
StringBuilder sb = new StringBuilder("user_timeline_");
|
||||
if (tabPosition < 0) return null;
|
||||
|
||||
final long userId = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String userId = args.getString(EXTRA_USER_ID);
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
if (userId > 0) {
|
||||
if (userId != null) {
|
||||
sb.append(userId);
|
||||
} else if (screenName != null) {
|
||||
sb.append(screenName);
|
||||
|
@ -160,7 +160,7 @@ public class CardPollFragment extends BaseSupportFragment implements
|
||||
choiceRadioButton.setChecked(checked);
|
||||
if (checked) {
|
||||
final CardDataMap cardData = new CardDataMap();
|
||||
cardData.putLong("original_tweet_id", status.id);
|
||||
cardData.putLong("original_tweet_id", NumberUtils.toLong(status.id));
|
||||
cardData.putString("card_uri", card.url);
|
||||
cardData.putString("cards_platform", TwitterAPIFactory.CARDS_PLATFORM_ANDROID_12);
|
||||
cardData.putString("response_card_name", card.name);
|
||||
|
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.api.twitter.Twitter;
|
||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
@ -40,6 +41,7 @@ import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConversationLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
@ -92,7 +94,7 @@ public class ConversationLoader extends TwitterAPIStatusesLoader {
|
||||
query.sinceId(sinceId != null ? sinceId : status.id);
|
||||
try {
|
||||
for (Status item : twitter.search(query)) {
|
||||
if (item.getInReplyToStatusId() == status.id) {
|
||||
if (TextUtils.equals(item.getInReplyToStatusId(), status.id)) {
|
||||
statuses.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mariotaku.twidere.api.twitter.Twitter;
|
||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
@ -51,7 +53,7 @@ public class MediaTimelineLoader extends TwitterAPIStatusesLoader {
|
||||
private User mUser;
|
||||
|
||||
public MediaTimelineLoader(final Context context, final UserKey accountKey, final String userId,
|
||||
final String screenName, final long sinceId, final long maxId,
|
||||
final String screenName, final String sinceId, final String maxId,
|
||||
final List<ParcelableStatus> data, final String[] savedStatusesArgs,
|
||||
final int tabPosition, final boolean fromUser) {
|
||||
super(context, accountKey, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
@ -92,7 +94,8 @@ public class MediaTimelineLoader extends TwitterAPIStatusesLoader {
|
||||
final ResponseList<Status> result = new ResponseList<>();
|
||||
for (Status status : twitter.search(query)) {
|
||||
final User user = status.getUser();
|
||||
if (user.getId() == mUserId || user.getScreenName().equalsIgnoreCase(mUserScreenName)) {
|
||||
if (TextUtils.equals(user.getId(), mUserId) ||
|
||||
StringUtils.endsWithIgnoreCase(user.getScreenName(), mUserScreenName)) {
|
||||
result.add(status);
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ public class ParcelableStatusLoader extends AsyncTaskLoader<SingleResponse<Parce
|
||||
private final boolean mOmitIntentExtra;
|
||||
private final Bundle mExtras;
|
||||
private final UserKey mAccountId;
|
||||
private final long mStatusId;
|
||||
private final String mStatusId;
|
||||
|
||||
public ParcelableStatusLoader(final Context context, final boolean omitIntentExtra, final Bundle extras,
|
||||
final UserKey accountId, final long statusId) {
|
||||
final UserKey accountId, final String statusId) {
|
||||
super(context);
|
||||
mOmitIntentExtra = omitIntentExtra;
|
||||
mExtras = extras;
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.loader.support;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
@ -64,9 +65,9 @@ public abstract class ParcelableUsersLoader extends AsyncTaskLoader<List<Parcela
|
||||
return mData;
|
||||
}
|
||||
|
||||
protected boolean hasId(final long id) {
|
||||
protected boolean hasId(final String id) {
|
||||
for (final ParcelableUser user : mData) {
|
||||
if (user.key.getId() == id) return true;
|
||||
if (TextUtils.equals(user.key.getId(), id)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import java.util.List;
|
||||
public class RetweetsOfMeLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
public RetweetsOfMeLoader(final Context context, final UserKey accountKey,
|
||||
final long sinceId, final long maxId,
|
||||
final String sinceId, final String maxId,
|
||||
final List<ParcelableStatus> data, final String[] savedStatusesArgs,
|
||||
final int tabPosition, boolean fromUser) {
|
||||
super(context, accountKey, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
|
@ -33,7 +33,7 @@ import java.util.Locale;
|
||||
public class UserMentionsLoader extends TweetSearchLoader {
|
||||
|
||||
public UserMentionsLoader(final Context context, final UserKey accountId, final String screenName,
|
||||
final long maxId, final long sinceId, int page, final List<ParcelableStatus> data,
|
||||
final String maxId, final String sinceId, int page, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser,
|
||||
boolean makeGap) {
|
||||
super(context, accountId, screenName, sinceId, maxId, page, data, savedStatusesArgs, tabPosition,
|
||||
|
@ -19,16 +19,16 @@ import java.util.Arrays;
|
||||
@JsonObject
|
||||
public class TabArguments implements TwidereConstants {
|
||||
@JsonField(name = "account_id")
|
||||
long accountId = -1;
|
||||
String accountId = null;
|
||||
|
||||
@JsonField(name = "account_keys")
|
||||
UserKey[] accountKeys;
|
||||
|
||||
public long getAccountId() {
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@ -42,8 +42,8 @@ public class TabArguments implements TwidereConstants {
|
||||
|
||||
@CallSuper
|
||||
public void copyToBundle(@NonNull Bundle bundle) {
|
||||
if (accountId > 0) {
|
||||
bundle.putLong(EXTRA_ACCOUNT_ID, accountId);
|
||||
if (accountId != null) {
|
||||
bundle.putString(EXTRA_ACCOUNT_ID, accountId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class ParcelableActivityUtils {
|
||||
* @param followingOnly Limit following users in sources
|
||||
* @return true if source ids changed, false otherwise
|
||||
*/
|
||||
public static boolean initAfterFilteredSourceIds(ParcelableActivity activity, long[] filteredUserIds,
|
||||
public static boolean initAfterFilteredSourceIds(ParcelableActivity activity, String[] filteredUserIds,
|
||||
boolean followingOnly) {
|
||||
if (activity.after_filtered_source_ids != null) return false;
|
||||
if (followingOnly || !ArrayUtils.isEmpty(filteredUserIds)) {
|
||||
|
@ -2,6 +2,7 @@ package org.mariotaku.twidere.model.util;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.api.statusnet.model.Attention;
|
||||
import org.mariotaku.twidere.api.twitter.model.Place;
|
||||
@ -29,7 +30,7 @@ public class ParcelableStatusUtils {
|
||||
status.retweeted_by_user_screen_name = null;
|
||||
status.retweeted_by_user_profile_image = null;
|
||||
status.retweet_timestamp = -1;
|
||||
status.retweet_id = -1;
|
||||
status.retweet_id = null;
|
||||
}
|
||||
|
||||
public static ParcelableStatus fromStatus(final Status orig, final UserKey accountKey,
|
||||
@ -134,11 +135,11 @@ public class ParcelableStatusUtils {
|
||||
}
|
||||
|
||||
private static UserKey getInReplyToUserId(Status status, UserKey accountKey) {
|
||||
final long inReplyToUserId = status.getInReplyToUserId();
|
||||
final String inReplyToUserId = status.getInReplyToUserId();
|
||||
final UserMentionEntity[] entities = status.getUserMentionEntities();
|
||||
if (entities != null) {
|
||||
for (final UserMentionEntity entity : entities) {
|
||||
if (inReplyToUserId == entity.getId()) {
|
||||
if (TextUtils.equals(inReplyToUserId, entity.getId())) {
|
||||
return new UserKey(inReplyToUserId, accountKey.getHost());
|
||||
}
|
||||
}
|
||||
@ -146,11 +147,10 @@ public class ParcelableStatusUtils {
|
||||
final Attention[] attentions = status.getAttentions();
|
||||
if (attentions != null) {
|
||||
for (Attention attention : attentions) {
|
||||
if (inReplyToUserId == attention.getId()) {
|
||||
final String host = UserKeyUtils.getUserHost(attention.getOstatusUri());
|
||||
if (host != null) {
|
||||
return new UserKey(inReplyToUserId, host);
|
||||
}
|
||||
if (TextUtils.equals(inReplyToUserId, attention.getId())) {
|
||||
final String host = UserKeyUtils.getUserHost(attention.getOstatusUri(),
|
||||
accountKey.getHost());
|
||||
return new UserKey(inReplyToUserId, host);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,17 +179,19 @@ public class ParcelableStatusUtils {
|
||||
|
||||
@NonNull
|
||||
public static String getInReplyToName(@NonNull final Status status) {
|
||||
final long inReplyToUserId = status.getInReplyToUserId();
|
||||
final String inReplyToUserId = status.getInReplyToUserId();
|
||||
final UserMentionEntity[] entities = status.getUserMentionEntities();
|
||||
if (entities != null) {
|
||||
for (final UserMentionEntity entity : entities) {
|
||||
if (inReplyToUserId == entity.getId()) return entity.getName();
|
||||
if (TextUtils.equals(inReplyToUserId, entity.getId())) return entity.getName();
|
||||
}
|
||||
}
|
||||
final Attention[] attentions = status.getAttentions();
|
||||
if (attentions != null) {
|
||||
for (Attention attention : attentions) {
|
||||
if (inReplyToUserId == attention.getId()) return attention.getFullName();
|
||||
if (TextUtils.equals(inReplyToUserId, attention.getId())) {
|
||||
return attention.getFullName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return status.getInReplyToScreenName();
|
||||
|
@ -72,11 +72,6 @@ public class ParcelableUserUtils implements TwidereConstants {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static String getUserHost(ParcelableUser user) {
|
||||
if (user.extras == null) return USER_TYPE_TWITTER_COM;
|
||||
return UserKeyUtils.getUserHost(user.extras.ostatus_uri);
|
||||
}
|
||||
|
||||
public static ParcelableUser fromDirectMessageConversationEntry(final Cursor cursor) {
|
||||
final UserKey accountId = UserKey.valueOf(cursor.getString(DirectMessages.ConversationEntries.IDX_ACCOUNT_KEY));
|
||||
final UserKey id = UserKey.valueOf(cursor.getString(DirectMessages.ConversationEntries.IDX_CONVERSATION_ID));
|
||||
|
@ -56,14 +56,17 @@ public class UserKeyUtils {
|
||||
}
|
||||
|
||||
public static String getUserHost(User user) {
|
||||
return getUserHost(user.getOstatusUri());
|
||||
return getUserHost(user.getOstatusUri(), TwidereConstants.USER_TYPE_TWITTER_COM);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getUserHost(@Nullable String uri) {
|
||||
if (uri == null) return TwidereConstants.USER_TYPE_TWITTER_COM;
|
||||
public static String getUserHost(@Nullable String uri, @Nullable String def) {
|
||||
if (def == null) {
|
||||
def = TwidereConstants.USER_TYPE_TWITTER_COM;
|
||||
}
|
||||
if (uri == null) return def;
|
||||
final String authority = PreviewMediaExtractor.getAuthority(uri);
|
||||
if (authority == null) return TwidereConstants.USER_TYPE_TWITTER_COM;
|
||||
if (authority == null) return def;
|
||||
return authority.replaceAll("[^\\w\\d\\.]", "-");
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
@ -85,7 +86,6 @@ import org.mariotaku.twidere.model.util.ParcelableDirectMessageUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableLocationUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableStatusUpdateUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableStatusUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserMentionUtils;
|
||||
import org.mariotaku.twidere.preference.ServicePickerPreference;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedHashtags;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
|
||||
@ -121,7 +121,6 @@ import edu.tsinghua.hotmobi.HotMobiLogger;
|
||||
import edu.tsinghua.hotmobi.model.TimelineType;
|
||||
import edu.tsinghua.hotmobi.model.TweetEvent;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.createMessageDraft;
|
||||
import static org.mariotaku.twidere.util.Utils.getImagePathFromUri;
|
||||
import static org.mariotaku.twidere.util.Utils.getImageUploadStatus;
|
||||
@ -263,11 +262,11 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
}
|
||||
case Draft.Action.SEND_DIRECT_MESSAGE_COMPAT:
|
||||
case Draft.Action.SEND_DIRECT_MESSAGE: {
|
||||
long recipientId = -1;
|
||||
String recipientId = null;
|
||||
if (item.action_extras instanceof SendDirectMessageActionExtra) {
|
||||
recipientId = ((SendDirectMessageActionExtra) item.action_extras).getRecipientId();
|
||||
}
|
||||
if (ArrayUtils.isEmpty(item.account_ids) || recipientId <= 0) {
|
||||
if (ArrayUtils.isEmpty(item.account_ids) || recipientId == null) {
|
||||
return;
|
||||
}
|
||||
final UserKey accountKey = item.account_ids[0];
|
||||
@ -291,14 +290,15 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
|
||||
private void handleSendDirectMessageIntent(final Intent intent) {
|
||||
final UserKey accountId = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
|
||||
final long recipientId = intent.getLongExtra(EXTRA_RECIPIENT_ID, -1);
|
||||
final String imageUri = intent.getStringExtra(EXTRA_IMAGE_URI);
|
||||
final String recipientId = intent.getStringExtra(EXTRA_RECIPIENT_ID);
|
||||
final String text = intent.getStringExtra(EXTRA_TEXT);
|
||||
final String imageUri = intent.getStringExtra(EXTRA_IMAGE_URI);
|
||||
if (accountId == null || recipientId == null || text == null) return;
|
||||
sendMessage(accountId, recipientId, text, imageUri);
|
||||
}
|
||||
|
||||
private void sendMessage(UserKey accountId, long recipientId, String text, String imageUri) {
|
||||
if (accountId == null || recipientId <= 0 || isEmpty(text)) return;
|
||||
private void sendMessage(@NonNull UserKey accountId, @NonNull String recipientId,
|
||||
@NonNull String text, @Nullable String imageUri) {
|
||||
final String title = getString(R.string.sending_direct_message);
|
||||
final Builder builder = new Builder(this);
|
||||
builder.setSmallIcon(R.drawable.ic_stat_send);
|
||||
@ -314,7 +314,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
recipientId, text, imageUri);
|
||||
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
if (result.getData() != null && result.getData().id > 0) {
|
||||
if (result.getData() != null && result.getData().id != null) {
|
||||
final ContentValues values = ContentValuesCreator.createDirectMessage(result.getData());
|
||||
final String delete_where = DirectMessages.ACCOUNT_KEY + " = " + accountId + " AND "
|
||||
+ DirectMessages.MESSAGE_ID + " = " + result.getData().id;
|
||||
@ -445,8 +445,10 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
|
||||
|
||||
private SingleResponse<ParcelableDirectMessage> sendDirectMessage(final NotificationCompat.Builder builder,
|
||||
final UserKey accountKey, final long recipientId,
|
||||
final String text, final String imageUri) {
|
||||
final UserKey accountKey,
|
||||
final String recipientId,
|
||||
final String text,
|
||||
final String imageUri) {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(this, accountKey, true, true);
|
||||
final TwitterUpload twitterUpload = TwitterAPIFactory.getTwitterInstance(this, accountKey, true, true, TwitterUpload.class);
|
||||
if (twitter == null || twitterUpload == null) return SingleResponse.getInstance();
|
||||
@ -690,24 +692,23 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
|
||||
try {
|
||||
final Status resultStatus = twitter.updateStatus(status);
|
||||
final ParcelableStatus result = ParcelableStatusUtils.fromStatus(resultStatus,
|
||||
account.account_key, false);
|
||||
if (!mentionedHondaJOJO) {
|
||||
ParcelableUserMention[] mentions = ParcelableUserMentionUtils.fromUserMentionEntities(resultStatus.getUser(),
|
||||
resultStatus.getUserMentionEntities());
|
||||
final ParcelableUserMention[] mentions = result.mentions;
|
||||
if (ArrayUtils.isEmpty(mentions)) {
|
||||
mentionedHondaJOJO = statusUpdate.text.contains("@" + HONDAJOJO_SCREEN_NAME);
|
||||
} else if (mentions.length == 1 && mentions[0].key.getId() == HONDAJOJO_ID) {
|
||||
} else if (mentions.length == 1 && mentions[0].key.equals(HONDAJOJO_ID)) {
|
||||
mentionedHondaJOJO = true;
|
||||
}
|
||||
Utils.setLastSeen(this, mentions, System.currentTimeMillis());
|
||||
}
|
||||
if (!notReplyToOther) {
|
||||
final long inReplyToUserId = resultStatus.getInReplyToUserId();
|
||||
if (inReplyToUserId <= 0 || inReplyToUserId == HONDAJOJO_ID) {
|
||||
final String inReplyToUserId = resultStatus.getInReplyToUserId();
|
||||
if (inReplyToUserId == null || HONDAJOJO_ID.check(inReplyToUserId, null)) {
|
||||
notReplyToOther = true;
|
||||
}
|
||||
}
|
||||
final ParcelableStatus result = ParcelableStatusUtils.fromStatus(resultStatus,
|
||||
account.account_key, false);
|
||||
if (shouldShorten && shortener != null && shortenedResult != null) {
|
||||
shortener.callback(shortenedResult, result);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class RefreshService extends Service implements Constants {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestStatusIds(context,
|
||||
Statuses.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
@ -125,7 +125,7 @@ public class RefreshService extends Service implements Constants {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestActivityMaxPositions(context,
|
||||
Activities.AboutMe.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
@ -146,7 +146,7 @@ public class RefreshService extends Service implements Constants {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestMessageIds(context,
|
||||
DirectMessages.Inbox.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.util.SimpleArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mariotaku.restfu.http.Authorization;
|
||||
@ -34,10 +35,10 @@ import org.mariotaku.twidere.api.twitter.model.Status;
|
||||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.api.twitter.model.UserList;
|
||||
import org.mariotaku.twidere.api.twitter.model.Warning;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.AccountPreferences;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.AccountSupportColumns;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
|
||||
@ -240,21 +241,22 @@ public class StreamingService extends Service implements Constants {
|
||||
|
||||
@Override
|
||||
public void onDirectMessage(final DirectMessage directMessage) {
|
||||
if (directMessage == null || directMessage.getId() <= 0) return;
|
||||
if (directMessage == null || directMessage.getId() == null) return;
|
||||
final String where = Expression.and(Expression.equalsArgs(DirectMessages.ACCOUNT_KEY),
|
||||
Expression.equalsArgs(DirectMessages.MESSAGE_ID)).getSQL();
|
||||
final String[] whereArgs = {account.account_key.toString(), directMessage.getId()};
|
||||
for (final Uri uri : MESSAGES_URIS) {
|
||||
final String where = DirectMessages.ACCOUNT_KEY + " = " + account.account_key + " AND "
|
||||
+ DirectMessages.MESSAGE_ID + " = " + directMessage.getId();
|
||||
resolver.delete(uri, where, null);
|
||||
resolver.delete(uri, where, whereArgs);
|
||||
}
|
||||
final User sender = directMessage.getSender(), recipient = directMessage.getRecipient();
|
||||
if (sender.getId() == account.account_key.getId()) {
|
||||
if (TextUtils.equals(sender.getId(), account.account_key.getId())) {
|
||||
final ContentValues values = ContentValuesCreator.createDirectMessage(directMessage,
|
||||
account.account_key, true);
|
||||
if (values != null) {
|
||||
resolver.insert(DirectMessages.Outbox.CONTENT_URI, values);
|
||||
}
|
||||
}
|
||||
if (recipient.getId() == account.account_key.getId()) {
|
||||
if (TextUtils.equals(recipient.getId(), account.account_key.getId())) {
|
||||
final ContentValues values = ContentValuesCreator.createDirectMessage(directMessage,
|
||||
account.account_key, false);
|
||||
final Uri.Builder builder = DirectMessages.Inbox.CONTENT_URI.buildUpon();
|
||||
|
@ -65,7 +65,7 @@ public class CacheUsersStatusesTask extends AbstractTask<TwitterListResponse<Sta
|
||||
final Set<ContentValues> statusesValues = new HashSet<>();
|
||||
final Set<ContentValues> hashTagValues = new HashSet<>();
|
||||
|
||||
final UserKey accountKey = params.mAccountKey;
|
||||
final UserKey accountKey = params.accountKey;
|
||||
statusesValues.add(ContentValuesCreator.createStatus(status, accountKey));
|
||||
final String text = InternalTwitterContentUtils.unescapeTwitterStatusText(status.getText());
|
||||
for (final String hashtag : extractor.extractHashtags(text)) {
|
||||
|
@ -7,6 +7,7 @@ import android.util.Log;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.TwidereConstants;
|
||||
@ -16,8 +17,8 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.message.GetMessagesTaskEvent;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ContentValuesCreator;
|
||||
@ -74,19 +75,25 @@ public abstract class GetDirectMessagesTask extends AbstractTask<RefreshTaskPara
|
||||
try {
|
||||
final Paging paging = new Paging();
|
||||
paging.setCount(loadItemLimit);
|
||||
String max_id = null, sinceId = null;
|
||||
if (maxIds != null && maxIds[idx] > 0) {
|
||||
max_id = maxIds[idx];
|
||||
paging.setMaxId(max_id);
|
||||
String maxId = null, sinceId = null;
|
||||
if (maxIds != null && maxIds[idx] != null) {
|
||||
maxId = maxIds[idx];
|
||||
paging.setMaxId(maxId);
|
||||
}
|
||||
if (sinceIds != null && sinceIds[idx] > 0) {
|
||||
if (sinceIds != null && sinceIds[idx] != null) {
|
||||
sinceId = sinceIds[idx];
|
||||
paging.setSinceId(sinceId - 1);
|
||||
long sinceIdLong = NumberUtils.toLong(sinceId, -1);
|
||||
//TODO handle non-twitter case
|
||||
if (sinceIdLong != -1) {
|
||||
paging.sinceId(String.valueOf(sinceIdLong - 1));
|
||||
} else {
|
||||
paging.sinceId(sinceId);
|
||||
}
|
||||
}
|
||||
final List<DirectMessage> messages = new ArrayList<>();
|
||||
final boolean truncated = Utils.truncateMessages(getDirectMessages(twitter, paging), messages,
|
||||
sinceId);
|
||||
result.add(new TwitterWrapper.MessageListResponse(accountKey, max_id, sinceId, messages,
|
||||
result.add(new TwitterWrapper.MessageListResponse(accountKey, maxId, sinceId, messages,
|
||||
truncated));
|
||||
storeMessages(accountKey, messages, isOutgoing(), true);
|
||||
errorInfoStore.remove(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountKey);
|
||||
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
@ -84,9 +85,9 @@ public class UpdateAccountInfoTask extends AbstractTask<Pair<UserKey, Parcelable
|
||||
Tab tab = indices.newObject(tabsCursor);
|
||||
TabArguments arguments = tab.getArguments();
|
||||
if (arguments != null) {
|
||||
final long accountId = arguments.getAccountId();
|
||||
final String accountId = arguments.getAccountId();
|
||||
final UserKey[] keys = arguments.getAccountKeys();
|
||||
if (accountKey.getId() == accountId && keys == null) {
|
||||
if (TextUtils.equals(accountKey.getId(), accountId) && keys == null) {
|
||||
arguments.setAccountKeys(new UserKey[]{accountKey});
|
||||
values.put(tab.getId(), TabValuesCreator.create(tab));
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.Activity;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.message.GetActivitiesTaskEvent;
|
||||
import org.mariotaku.twidere.model.util.ParcelableActivityUtils;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
|
||||
@ -64,8 +64,8 @@ public abstract class GetActivitiesTask extends AbstractTask<RefreshTaskParam, O
|
||||
@Override
|
||||
public Object doLongOperation(RefreshTaskParam param) {
|
||||
final UserKey[] accountIds = param.getAccountKeys();
|
||||
final long[] maxIds = param.getMaxIds();
|
||||
final long[] sinceIds = param.getSinceIds();
|
||||
final String[] maxIds = param.getMaxIds();
|
||||
final String[] sinceIds = param.getSinceIds();
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final int loadItemLimit = preferences.getInt(KEY_LOAD_ITEM_LIMIT);
|
||||
boolean saveReadPosition = false;
|
||||
@ -77,12 +77,12 @@ public abstract class GetActivitiesTask extends AbstractTask<RefreshTaskParam, O
|
||||
if (twitter == null) continue;
|
||||
final Paging paging = new Paging();
|
||||
paging.count(loadItemLimit);
|
||||
if (maxIds != null && maxIds[i] > 0) {
|
||||
if (maxIds != null && maxIds[i] != null) {
|
||||
paging.maxId(maxIds[i]);
|
||||
}
|
||||
if (sinceIds != null && sinceIds[i] > 0) {
|
||||
if (sinceIds != null && sinceIds[i] != null) {
|
||||
paging.sinceId(sinceIds[i]);
|
||||
if (maxIds == null || maxIds[i] <= 0) {
|
||||
if (maxIds == null || maxIds[i] == null) {
|
||||
paging.setLatestResults(true);
|
||||
saveReadPosition = true;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import android.util.Log;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.mariotaku.sqliteqb.library.Columns;
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
import org.mariotaku.sqliteqb.library.RawItemArray;
|
||||
@ -23,8 +24,8 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||
import org.mariotaku.twidere.api.twitter.model.Status;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.message.GetStatusesTaskEvent;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.AccountSupportColumns;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
@ -80,7 +81,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
||||
protected abstract Uri getContentUri();
|
||||
|
||||
private void storeStatus(final UserKey accountKey, final List<Status> statuses,
|
||||
final long sinceId, final long maxId, final boolean notify) {
|
||||
final String sinceId, final String maxId, final boolean notify) {
|
||||
if (statuses == null || statuses.isEmpty() || accountKey == null) {
|
||||
return;
|
||||
}
|
||||
@ -88,19 +89,19 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final boolean noItemsBefore = DataStoreUtils.getStatusCount(context, uri, accountKey) <= 0;
|
||||
final ContentValues[] values = new ContentValues[statuses.size()];
|
||||
final long[] statusIds = new long[statuses.size()];
|
||||
long minId = -1;
|
||||
final String[] statusIds = new String[statuses.size()];
|
||||
String minId = null;
|
||||
int minIdx = -1;
|
||||
boolean hasIntersection = false;
|
||||
for (int i = 0, j = statuses.size(); i < j; i++) {
|
||||
final Status status = statuses.get(i);
|
||||
values[i] = ContentValuesCreator.createStatus(status, accountKey);
|
||||
values[i].put(Statuses.INSERTED_DATE, System.currentTimeMillis());
|
||||
final long id = status.getId();
|
||||
if (sinceId > 0 && id <= sinceId) {
|
||||
final String id = status.getId();
|
||||
if (sinceId != null && id <= sinceId) {
|
||||
hasIntersection = true;
|
||||
}
|
||||
if (minId == -1 || id < minId) {
|
||||
if (minId == null || id < minId) {
|
||||
minId = id;
|
||||
minIdx = i;
|
||||
}
|
||||
@ -133,7 +134,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
||||
// Insert a gap.
|
||||
final boolean deletedOldGap = rowsDeleted > 0 && ArrayUtils.contains(statusIds, maxId);
|
||||
final boolean noRowsDeleted = rowsDeleted == 0;
|
||||
final boolean insertGap = minId > 0 && (noRowsDeleted || deletedOldGap) && !noItemsBefore
|
||||
final boolean insertGap = minId != null && (noRowsDeleted || deletedOldGap) && !noItemsBefore
|
||||
&& !hasIntersection;
|
||||
if (insertGap && minIdx != -1) {
|
||||
values[minIdx].put(Statuses.IS_GAP, true);
|
||||
@ -161,8 +162,8 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
||||
@Override
|
||||
public List<TwitterWrapper.StatusListResponse> doLongOperation(final RefreshTaskParam param) {
|
||||
final UserKey[] accountKeys = param.getAccountKeys();
|
||||
final long[] maxIds = param.getMaxIds();
|
||||
final long[] sinceIds = param.getSinceIds();
|
||||
final String[] maxIds = param.getMaxIds();
|
||||
final String[] sinceIds = param.getSinceIds();
|
||||
final List<TwitterWrapper.StatusListResponse> result = new ArrayList<>();
|
||||
int idx = 0;
|
||||
final int loadItemLimit = preferences.getInt(KEY_LOAD_ITEM_LIMIT, DEFAULT_LOAD_ITEM_LIMIT);
|
||||
@ -172,21 +173,27 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
||||
try {
|
||||
final Paging paging = new Paging();
|
||||
paging.count(loadItemLimit);
|
||||
final long maxId, sinceId;
|
||||
if (maxIds != null && maxIds[idx] > 0) {
|
||||
final String maxId, sinceId;
|
||||
if (maxIds != null && maxIds[idx] != null) {
|
||||
maxId = maxIds[idx];
|
||||
paging.maxId(maxId);
|
||||
} else {
|
||||
maxId = -1;
|
||||
maxId = null;
|
||||
}
|
||||
if (sinceIds != null && sinceIds[idx] > 0) {
|
||||
if (sinceIds != null && sinceIds[idx] != null) {
|
||||
sinceId = sinceIds[idx];
|
||||
paging.sinceId(sinceId - 1);
|
||||
if (maxIds == null || sinceIds[idx] <= 0) {
|
||||
long sinceIdLong = NumberUtils.toLong(sinceId, -1);
|
||||
//TODO handle non-twitter case
|
||||
if (sinceIdLong != -1) {
|
||||
paging.sinceId(String.valueOf(sinceIdLong - 1));
|
||||
} else {
|
||||
paging.sinceId(sinceId);
|
||||
}
|
||||
if (maxIds == null || sinceIds[idx] == null) {
|
||||
paging.setLatestResults(true);
|
||||
}
|
||||
} else {
|
||||
sinceId = -1;
|
||||
sinceId = null;
|
||||
}
|
||||
final List<Status> statuses = getStatuses(twitter, paging);
|
||||
InternalTwitterContentUtils.getStatusesWithQuoteData(twitter, statuses);
|
||||
|
@ -231,7 +231,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int destroyDirectMessageAsync(final UserKey accountKey, final long messageId) {
|
||||
public int destroyDirectMessageAsync(final UserKey accountKey, final String messageId) {
|
||||
final DestroyDirectMessageTask task = new DestroyDirectMessageTask(accountKey, messageId);
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
@ -396,7 +396,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestStatusIds(mContext, Statuses.CONTENT_URI,
|
||||
getAccountKeys());
|
||||
}
|
||||
@ -410,7 +410,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestActivityMaxPositions(mContext,
|
||||
Activities.AboutMe.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
@ -440,7 +440,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUnreadCountsAsync(final int position, final SimpleArrayMap<UserKey, Set<Long>> counts) {
|
||||
public void removeUnreadCountsAsync(final int position, final SimpleArrayMap<UserKey, Set<String>> counts) {
|
||||
final RemoveUnreadCountsTask task = new RemoveUnreadCountsTask(position, counts);
|
||||
AsyncTaskUtils.executeTask(task);
|
||||
}
|
||||
@ -459,7 +459,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int sendDirectMessageAsync(final UserKey accountKey, final long recipientId, final String text,
|
||||
public int sendDirectMessageAsync(final UserKey accountKey, final String recipientId, final String text,
|
||||
final String imageUri) {
|
||||
final Intent intent = new Intent(mContext, BackgroundOperationService.class);
|
||||
intent.setAction(INTENT_ACTION_SEND_DIRECT_MESSAGE);
|
||||
@ -1404,18 +1404,20 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
class DestroyDirectMessageTask extends ManagedAsyncTask<Object, Object, SingleResponse<DirectMessage>> {
|
||||
|
||||
private final UserKey mAccountKey;
|
||||
private final long mMessageId;
|
||||
private final String mMessageId;
|
||||
|
||||
public DestroyDirectMessageTask(final UserKey accountKey, final long messageId) {
|
||||
public DestroyDirectMessageTask(final UserKey accountKey, final String messageId) {
|
||||
super(mContext);
|
||||
mAccountKey = accountKey;
|
||||
mMessageId = messageId;
|
||||
}
|
||||
|
||||
private void deleteMessages(final long message_id) {
|
||||
final String where = DirectMessages.MESSAGE_ID + " = " + message_id;
|
||||
mResolver.delete(DirectMessages.Inbox.CONTENT_URI, where, null);
|
||||
mResolver.delete(DirectMessages.Outbox.CONTENT_URI, where, null);
|
||||
private void deleteMessages() {
|
||||
final String where = Expression.and(Expression.equalsArgs(DirectMessages.ACCOUNT_KEY),
|
||||
Expression.equalsArgs(DirectMessages.MESSAGE_ID)).getSQL();
|
||||
final String[] whereArgs = new String[]{mAccountKey.toString(), mMessageId};
|
||||
mResolver.delete(DirectMessages.Inbox.CONTENT_URI, where, whereArgs);
|
||||
mResolver.delete(DirectMessages.Outbox.CONTENT_URI, where, whereArgs);
|
||||
}
|
||||
|
||||
private boolean isMessageNotFound(final Exception e) {
|
||||
@ -1431,11 +1433,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
final DirectMessage message = twitter.destroyDirectMessage(mMessageId);
|
||||
deleteMessages(mMessageId);
|
||||
deleteMessages();
|
||||
return SingleResponse.getInstance(message, null);
|
||||
} catch (final TwitterException e) {
|
||||
if (isMessageNotFound(e)) {
|
||||
deleteMessages(mMessageId);
|
||||
deleteMessages();
|
||||
}
|
||||
return SingleResponse.getInstance(null, e);
|
||||
}
|
||||
@ -1939,9 +1941,9 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
final class RemoveUnreadCountsTask extends AsyncTask<Object, Object, Integer> {
|
||||
private final int position;
|
||||
private final SimpleArrayMap<UserKey, Set<Long>> counts;
|
||||
private final SimpleArrayMap<UserKey, Set<String>> counts;
|
||||
|
||||
RemoveUnreadCountsTask(final int position, final SimpleArrayMap<UserKey, Set<Long>> counts) {
|
||||
RemoveUnreadCountsTask(final int position, final SimpleArrayMap<UserKey, Set<String>> counts) {
|
||||
this.position = position;
|
||||
this.counts = counts;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import org.mariotaku.twidere.api.twitter.model.Status;
|
||||
import org.mariotaku.twidere.api.twitter.model.Trend;
|
||||
import org.mariotaku.twidere.api.twitter.model.Trends;
|
||||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.Draft;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableActivityValuesCreator;
|
||||
@ -43,6 +42,7 @@ import org.mariotaku.twidere.model.ParcelableStatusValuesCreator;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.ParcelableUserMention;
|
||||
import org.mariotaku.twidere.model.ParcelableUserValuesCreator;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.draft.SendDirectMessageActionExtra;
|
||||
import org.mariotaku.twidere.model.util.ParcelableActivityUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
|
||||
@ -155,13 +155,12 @@ public final class ContentValuesCreator implements TwidereConstants {
|
||||
return values;
|
||||
}
|
||||
|
||||
public static ContentValues createMessageDraft(final UserKey accountKey, final long recipientId,
|
||||
public static ContentValues createMessageDraft(final UserKey accountKey, final String recipientId,
|
||||
final String text, final String imageUri) {
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(Drafts.ACTION_TYPE, Draft.Action.SEND_DIRECT_MESSAGE);
|
||||
values.put(Drafts.TEXT, text);
|
||||
values.put(Drafts.ACCOUNT_IDS, TwidereArrayUtils.toString(new long[]{accountKey.getId()},
|
||||
',', false));
|
||||
values.put(Drafts.ACCOUNT_IDS, accountKey.toString());
|
||||
values.put(Drafts.TIMESTAMP, System.currentTimeMillis());
|
||||
if (imageUri != null) {
|
||||
final ParcelableMediaUpdate[] mediaArray = {new ParcelableMediaUpdate(imageUri, 0)};
|
||||
@ -244,32 +243,4 @@ public final class ContentValuesCreator implements TwidereConstants {
|
||||
return resultList.toArray(new ContentValues[resultList.size()]);
|
||||
}
|
||||
|
||||
public static ContentValues makeCachedUserContentValues(final ParcelableUser user) {
|
||||
if (user == null) return null;
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(CachedUsers.USER_KEY, String.valueOf(user.key));
|
||||
values.put(CachedUsers.NAME, user.name);
|
||||
values.put(CachedUsers.SCREEN_NAME, user.screen_name);
|
||||
values.put(CachedUsers.PROFILE_IMAGE_URL, user.profile_image_url);
|
||||
values.put(CachedUsers.CREATED_AT, user.created_at);
|
||||
values.put(CachedUsers.IS_PROTECTED, user.is_protected);
|
||||
values.put(CachedUsers.IS_VERIFIED, user.is_verified);
|
||||
values.put(CachedUsers.LISTED_COUNT, user.listed_count);
|
||||
values.put(CachedUsers.FAVORITES_COUNT, user.favorites_count);
|
||||
values.put(CachedUsers.FOLLOWERS_COUNT, user.followers_count);
|
||||
values.put(CachedUsers.FRIENDS_COUNT, user.friends_count);
|
||||
values.put(CachedUsers.STATUSES_COUNT, user.statuses_count);
|
||||
values.put(CachedUsers.LOCATION, user.location);
|
||||
values.put(CachedUsers.DESCRIPTION_PLAIN, user.description_plain);
|
||||
values.put(CachedUsers.DESCRIPTION_HTML, user.description_html);
|
||||
values.put(CachedUsers.DESCRIPTION_EXPANDED, user.description_expanded);
|
||||
values.put(CachedUsers.URL, user.url);
|
||||
values.put(CachedUsers.URL_EXPANDED, user.url_expanded);
|
||||
values.put(CachedUsers.PROFILE_BANNER_URL, user.profile_banner_url);
|
||||
values.put(CachedUsers.IS_FOLLOWING, user.is_following);
|
||||
values.put(CachedUsers.BACKGROUND_COLOR, user.background_color);
|
||||
values.put(CachedUsers.LINK_COLOR, user.link_color);
|
||||
values.put(CachedUsers.TEXT_COLOR, user.text_color);
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
@ -242,14 +242,14 @@ public class IntentUtils implements Constants {
|
||||
|
||||
public static void openMessageConversation(@NonNull final Context context,
|
||||
@Nullable final UserKey accountKey,
|
||||
final long recipientId) {
|
||||
final String recipientId) {
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION);
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString());
|
||||
if (recipientId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_RECIPIENT_ID, String.valueOf(recipientId));
|
||||
if (recipientId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_RECIPIENT_ID, recipientId);
|
||||
}
|
||||
}
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||
@ -428,15 +428,15 @@ public class IntentUtils implements Constants {
|
||||
|
||||
public static void openUserFavorites(@NonNull final Context context,
|
||||
@Nullable final UserKey accountKey,
|
||||
final long userId, final String screenName) {
|
||||
final String userId, final String screenName) {
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_USER_FAVORITES);
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString());
|
||||
}
|
||||
if (userId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
|
||||
if (userId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_ID, userId);
|
||||
}
|
||||
if (screenName != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName);
|
||||
@ -487,7 +487,7 @@ public class IntentUtils implements Constants {
|
||||
|
||||
public static void openUserListDetails(@NonNull final Context context,
|
||||
@Nullable final UserKey accountKey, final long listId,
|
||||
final long userId, final String screenName, final String listName) {
|
||||
final String userId, final String screenName, final String listName) {
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_USER_LIST);
|
||||
@ -497,8 +497,8 @@ public class IntentUtils implements Constants {
|
||||
if (listId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
|
||||
}
|
||||
if (userId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
|
||||
if (userId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_ID, userId);
|
||||
}
|
||||
if (screenName != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName);
|
||||
|
@ -170,7 +170,7 @@ public class KeyboardShortcutsHandler implements Constants, KeyboardShortcutCons
|
||||
return true;
|
||||
}
|
||||
case ACTION_MESSAGE: {
|
||||
IntentUtils.openMessageConversation(context, null, -1);
|
||||
IntentUtils.openMessageConversation(context, null, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ public class LinkCreator implements Constants {
|
||||
|
||||
private static final String AUTHORITY_TWITTER = "twitter.com";
|
||||
|
||||
public static Uri getTwitterStatusLink(String screenName, long statusId) {
|
||||
public static Uri getTwitterStatusLink(String screenName, String statusId) {
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_HTTPS);
|
||||
builder.authority(AUTHORITY_TWITTER);
|
||||
builder.appendPath(screenName);
|
||||
builder.appendPath("status");
|
||||
builder.appendPath(String.valueOf(statusId));
|
||||
builder.appendPath(statusId);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||
import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor;
|
||||
@ -64,7 +64,7 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
||||
|
||||
switch (type) {
|
||||
case TwidereLinkify.LINK_TYPE_MENTION: {
|
||||
IntentUtils.openUserProfile(context, accountKey, -1, link, null, true,
|
||||
IntentUtils.openUserProfile(context, accountKey, null, link, null, true,
|
||||
UserFragment.Referral.USER_MENTION);
|
||||
break;
|
||||
}
|
||||
@ -81,11 +81,12 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_LIST: {
|
||||
final String[] mentionList = link.split("/");
|
||||
final String[] mentionList = StringUtils.split(link, "/");
|
||||
if (mentionList.length != 2) {
|
||||
break;
|
||||
}
|
||||
IntentUtils.openUserListDetails(context, accountKey, -1, -1, mentionList[0], mentionList[1]);
|
||||
IntentUtils.openUserListDetails(context, accountKey, -1, null, mentionList[0],
|
||||
mentionList[1]);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_CASHTAG: {
|
||||
@ -93,12 +94,12 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_USER_ID: {
|
||||
IntentUtils.openUserProfile(context, accountKey, NumberUtils.toLong(link, -1), null,
|
||||
null, true, UserFragment.Referral.USER_MENTION);
|
||||
IntentUtils.openUserProfile(context, accountKey, link, null, null, true,
|
||||
UserFragment.Referral.USER_MENTION);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_STATUS: {
|
||||
IntentUtils.openStatus(context, accountKey, NumberUtils.toLong(link, -1));
|
||||
IntentUtils.openStatus(context, accountKey, link);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class TwitterWrapper implements Constants {
|
||||
@ -91,12 +90,12 @@ public class TwitterWrapper implements Constants {
|
||||
}
|
||||
|
||||
public static int removeUnreadCounts(final Context context, final int position,
|
||||
final SimpleArrayMap<UserKey, Set<Long>> counts) {
|
||||
final SimpleArrayMap<UserKey, Set<String>> counts) {
|
||||
if (context == null || position < 0 || counts == null) return 0;
|
||||
int result = 0;
|
||||
for (int i = 0, j = counts.size(); i < j; i++) {
|
||||
final UserKey key = counts.keyAt(i);
|
||||
final Set<Long> value = counts.valueAt(i);
|
||||
final Set<String> value = counts.valueAt(i);
|
||||
final Uri.Builder builder = UnreadCounts.CONTENT_URI.buildUpon();
|
||||
builder.appendPath(String.valueOf(position));
|
||||
builder.appendPath(String.valueOf(key));
|
||||
@ -204,19 +203,19 @@ public class TwitterWrapper implements Constants {
|
||||
public final boolean truncated;
|
||||
|
||||
public MessageListResponse(final UserKey accountKey, final Exception exception) {
|
||||
this(accountKey, -1, -1, null, false, exception);
|
||||
this(accountKey, null, null, null, false, exception);
|
||||
}
|
||||
|
||||
public MessageListResponse(final UserKey accountKey, final List<DirectMessage> list) {
|
||||
this(accountKey, -1, -1, list, false, null);
|
||||
this(accountKey, null, null, list, false, null);
|
||||
}
|
||||
|
||||
public MessageListResponse(final UserKey accountKey, final long maxId, final long sinceId,
|
||||
public MessageListResponse(final UserKey accountKey, final String maxId, final String sinceId,
|
||||
final List<DirectMessage> list, final boolean truncated) {
|
||||
this(accountKey, maxId, sinceId, list, truncated, null);
|
||||
}
|
||||
|
||||
MessageListResponse(final UserKey accountKey, final long maxId, final long sinceId,
|
||||
MessageListResponse(final UserKey accountKey, final String maxId, final String sinceId,
|
||||
final List<DirectMessage> list, final boolean truncated, final Exception exception) {
|
||||
super(accountKey, maxId, sinceId, list, exception);
|
||||
this.truncated = truncated;
|
||||
@ -229,19 +228,19 @@ public class TwitterWrapper implements Constants {
|
||||
public final boolean truncated;
|
||||
|
||||
public StatusListResponse(final UserKey accountKey, final Exception exception) {
|
||||
this(accountKey, -1, -1, null, false, exception);
|
||||
this(accountKey, null, null, null, false, exception);
|
||||
}
|
||||
|
||||
public StatusListResponse(final UserKey accountKey, final List<Status> list) {
|
||||
this(accountKey, -1, -1, list, false, null);
|
||||
this(accountKey, null, null, list, false, null);
|
||||
}
|
||||
|
||||
public StatusListResponse(final UserKey accountKey, final long maxId, final long sinceId,
|
||||
public StatusListResponse(final UserKey accountKey, final String maxId, final String sinceId,
|
||||
final List<Status> list, final boolean truncated) {
|
||||
this(accountKey, maxId, sinceId, list, truncated, null);
|
||||
}
|
||||
|
||||
StatusListResponse(final UserKey accountKey, final long maxId, final long sinceId, final List<Status> list,
|
||||
StatusListResponse(final UserKey accountKey, final String maxId, final String sinceId, final List<Status> list,
|
||||
final boolean truncated, final Exception exception) {
|
||||
super(accountKey, maxId, sinceId, list, exception);
|
||||
this.truncated = truncated;
|
||||
@ -251,24 +250,24 @@ public class TwitterWrapper implements Constants {
|
||||
|
||||
public static class TwitterListResponse<Data> extends ListResponse<Data> {
|
||||
|
||||
public final UserKey mAccountKey;
|
||||
public final long maxId;
|
||||
public final long sinceId;
|
||||
public final UserKey accountKey;
|
||||
public final String maxId;
|
||||
public final String sinceId;
|
||||
|
||||
public TwitterListResponse(final UserKey accountKey,
|
||||
final Exception exception) {
|
||||
this(accountKey, -1, -1, null, exception);
|
||||
this(accountKey, null, null, null, exception);
|
||||
}
|
||||
|
||||
public TwitterListResponse(final UserKey accountKey, final long maxId,
|
||||
final long sinceId, final List<Data> list) {
|
||||
public TwitterListResponse(final UserKey accountKey, final String maxId,
|
||||
final String sinceId, final List<Data> list) {
|
||||
this(accountKey, maxId, sinceId, list, null);
|
||||
}
|
||||
|
||||
TwitterListResponse(final UserKey accountKey, final long maxId,
|
||||
final long sinceId, final List<Data> list, final Exception exception) {
|
||||
TwitterListResponse(final UserKey accountKey, final String maxId, final String sinceId,
|
||||
final List<Data> list, final Exception exception) {
|
||||
super(list, exception);
|
||||
this.mAccountKey = accountKey;
|
||||
this.accountKey = accountKey;
|
||||
this.maxId = maxId;
|
||||
this.sinceId = sinceId;
|
||||
}
|
||||
|
@ -1384,15 +1384,15 @@ public final class Utils implements Constants {
|
||||
return VALUE_MEDIA_PREVIEW_STYLE_CODE_CROP;
|
||||
}
|
||||
|
||||
public static String getQuoteStatus(final Context context, long statusId, final String screen_name, final String text) {
|
||||
public static String getQuoteStatus(final Context context, String statusId, final String screenName, final String text) {
|
||||
if (context == null) return null;
|
||||
String quoteFormat = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getString(
|
||||
KEY_QUOTE_FORMAT, DEFAULT_QUOTE_FORMAT);
|
||||
if (isEmpty(quoteFormat)) {
|
||||
quoteFormat = DEFAULT_QUOTE_FORMAT;
|
||||
}
|
||||
String result = quoteFormat.replace(FORMAT_PATTERN_LINK, LinkCreator.getTwitterStatusLink(screen_name, statusId).toString());
|
||||
result = result.replace(FORMAT_PATTERN_NAME, screen_name);
|
||||
String result = quoteFormat.replace(FORMAT_PATTERN_LINK, LinkCreator.getTwitterStatusLink(screenName, statusId).toString());
|
||||
result = result.replace(FORMAT_PATTERN_NAME, screenName);
|
||||
result = result.replace(FORMAT_PATTERN_TEXT, text);
|
||||
return result;
|
||||
}
|
||||
@ -2001,10 +2001,10 @@ public final class Utils implements Constants {
|
||||
}
|
||||
|
||||
public static boolean truncateMessages(final List<DirectMessage> in, final List<DirectMessage> out,
|
||||
final long sinceId) {
|
||||
final String sinceId) {
|
||||
if (in == null) return false;
|
||||
for (final DirectMessage message : in) {
|
||||
if (sinceId > 0 && message.getId() <= sinceId) {
|
||||
if (sinceId != null && message.getId() <= sinceId) {
|
||||
continue;
|
||||
}
|
||||
out.add(message);
|
||||
@ -2013,10 +2013,10 @@ public final class Utils implements Constants {
|
||||
}
|
||||
|
||||
public static boolean truncateStatuses(final List<Status> in, final List<Status> out,
|
||||
final long sinceId) {
|
||||
final String sinceId) {
|
||||
if (in == null) return false;
|
||||
for (final Status status : in) {
|
||||
if (sinceId > 0 && status.getId() <= sinceId) {
|
||||
if (sinceId != null && status.getId() <= sinceId) {
|
||||
continue;
|
||||
}
|
||||
out.add(status);
|
||||
@ -2100,11 +2100,11 @@ public final class Utils implements Constants {
|
||||
@Nullable
|
||||
public static ParcelableUser getUserForConversation(@NonNull final Context context,
|
||||
@NonNull final UserKey accountKey,
|
||||
final long conversationId) {
|
||||
final String conversationId) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final Expression where = Expression.and(Expression.equalsArgs(ConversationEntries.ACCOUNT_KEY),
|
||||
Expression.equalsArgs(ConversationEntries.CONVERSATION_ID));
|
||||
final String[] whereArgs = {accountKey.toString(), String.valueOf(conversationId)};
|
||||
final String[] whereArgs = {accountKey.toString(), conversationId};
|
||||
final Cursor c = cr.query(ConversationEntries.CONTENT_URI, null, where.getSQL(), whereArgs,
|
||||
null);
|
||||
if (c == null) return null;
|
||||
|
@ -76,7 +76,7 @@ public class GroupViewHolder extends ViewHolder implements View.OnClickListener,
|
||||
nameView.setScreenName("!" + group.nickname);
|
||||
|
||||
nameView.updateText(formatter);
|
||||
final String groupHost = UserKeyUtils.getUserHost(group.url);
|
||||
final String groupHost = UserKeyUtils.getUserHost(group.url, group.account_key.getHost());
|
||||
if (UserKeyUtils.isSameHost(group.account_key.getHost(), groupHost)) {
|
||||
externalIndicator.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
@ -221,7 +221,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, IStatusVi
|
||||
if (statusContentUpperSpace != null) {
|
||||
statusContentUpperSpace.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (status.retweet_id > 0) {
|
||||
} else if (status.retweet_id != null) {
|
||||
final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id,
|
||||
status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false);
|
||||
statusInfoLabel.setText(context.getString(R.string.name_retweeted, formatter.unicodeWrap(retweetedBy)));
|
||||
@ -232,7 +232,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, IStatusVi
|
||||
if (statusContentUpperSpace != null) {
|
||||
statusContentUpperSpace.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (status.in_reply_to_status_id > 0 && status.in_reply_to_user_id != null && displayInReplyTo) {
|
||||
} else if (status.in_reply_to_status_id != null && status.in_reply_to_user_id != null && displayInReplyTo) {
|
||||
final String inReplyTo = manager.getDisplayName(status.in_reply_to_user_id,
|
||||
status.in_reply_to_name, status.in_reply_to_screen_name, nameFirst, false);
|
||||
statusInfoLabel.setText(context.getString(R.string.in_reply_to_name, formatter.unicodeWrap(inReplyTo)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user