migrating account
This commit is contained in:
parent
305ff7cbd3
commit
1a2914f86e
|
@ -38,11 +38,11 @@ android {
|
|||
dependencies {
|
||||
apt 'com.bluelinelabs:logansquare-compiler:1.3.4'
|
||||
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2'
|
||||
apt 'com.github.mariotaku.ObjectCursor:processor:0.9.6-SNAPSHOT'
|
||||
apt 'com.github.mariotaku.ObjectCursor:processor:0.9.6'
|
||||
compile 'com.android.support:support-annotations:23.2.0'
|
||||
compile 'com.bluelinelabs:logansquare:1.3.4'
|
||||
compile 'com.github.mariotaku.RestFu:library:0.9.24'
|
||||
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2'
|
||||
compile 'com.github.mariotaku.ObjectCursor:core:0.9.6-SNAPSHOT'
|
||||
compile 'com.github.mariotaku.ObjectCursor:core:0.9.6'
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ dependencies {
|
|||
androidTestApt 'com.bluelinelabs:logansquare-compiler:1.3.4'
|
||||
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2'
|
||||
apt 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
apt "com.github.mariotaku.ObjectCursor:processor:0.9.6-SNAPSHOT"
|
||||
apt "com.github.mariotaku.ObjectCursor:processor:0.9.6"
|
||||
|
||||
compile 'com.android.support:multidex:1.0.1'
|
||||
compile 'com.android.support:support-v13:23.2.0'
|
||||
|
@ -117,7 +117,7 @@ dependencies {
|
|||
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.12'
|
||||
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.12'
|
||||
compile 'com.github.mariotaku.SQLiteQB:library:0.9.5'
|
||||
compile 'com.github.mariotaku.ObjectCursor:core:0.9.6-SNAPSHOT'
|
||||
compile 'com.github.mariotaku.ObjectCursor:core:0.9.6'
|
||||
|
||||
compile project(':twidere.component.common')
|
||||
compile project(':twidere.component.nyan')
|
||||
|
|
|
@ -47,6 +47,9 @@ public class TweetEvent extends BaseEvent implements Parcelable {
|
|||
@JsonField(name = "account_id")
|
||||
long accountId;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "account_host")
|
||||
String accountHost;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "user_id")
|
||||
long userId;
|
||||
@ParcelableThisPlease
|
||||
|
@ -81,6 +84,7 @@ public class TweetEvent extends BaseEvent implements Parcelable {
|
|||
event.markStart(context);
|
||||
event.setId(status.id);
|
||||
event.setAccountId(status.account_id);
|
||||
event.setAccountHost(status.account_host);
|
||||
event.setUserId(status.user_id);
|
||||
event.setTimelineType(timelineType);
|
||||
event.setTweetType(TwidereDataUtils.getTweetType(status));
|
||||
|
@ -116,19 +120,28 @@ public class TweetEvent extends BaseEvent implements Parcelable {
|
|||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
public void setAccountId(long accountKey) {
|
||||
this.accountId = accountKey;
|
||||
}
|
||||
|
||||
public String getAccountHost() {
|
||||
return accountHost;
|
||||
}
|
||||
|
||||
public void setAccountHost(String accountHost) {
|
||||
this.accountHost = accountHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TweetEvent{" +
|
||||
"id=" + id +
|
||||
", mAccountKey=" + accountId +
|
||||
", accountKey=" + accountId +
|
||||
", userId=" + userId +
|
||||
", tweetType=" + tweetType +
|
||||
", timelineType=" + timelineType +
|
||||
", action=" + action +
|
||||
", tweetType='" + tweetType + '\'' +
|
||||
", timelineType='" + timelineType + '\'' +
|
||||
", action='" + action + '\'' +
|
||||
", following=" + following +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -819,7 +819,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
|
|||
if (mPagerAdapter.getCount() == 0) return;
|
||||
final SupportTabSpec tab = mPagerAdapter.getTab(position);
|
||||
if (DirectMessagesFragment.class == tab.cls) {
|
||||
Utils.openMessageConversation(this, -1, -1);
|
||||
Utils.openMessageConversation(this, null, -1);
|
||||
} else if (TrendsSuggestionsFragment.class == tab.cls) {
|
||||
openSearchView(null);
|
||||
} else {
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -81,6 +82,7 @@ import org.mariotaku.twidere.Constants;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IExtendedActivity;
|
||||
import org.mariotaku.twidere.fragment.ProgressDialogFragment;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.provider.CacheProvider;
|
||||
|
@ -824,7 +826,7 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
|
|||
@Override
|
||||
protected Object getDownloadExtra() {
|
||||
final MediaExtra mediaExtra = new MediaExtra();
|
||||
mediaExtra.setAccountId(getArguments().getLong(EXTRA_ACCOUNT_ID, -1));
|
||||
mediaExtra.setAccountKey(getArguments().<AccountKey>getParcelable(EXTRA_ACCOUNT_KEY));
|
||||
final Uri origDownloadUri = super.getDownloadUri();
|
||||
final Uri downloadUri = getDownloadUri();
|
||||
if (origDownloadUri != null && downloadUri != null) {
|
||||
|
|
|
@ -56,6 +56,8 @@ import android.widget.TextView;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.SearchHistory;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions;
|
||||
|
@ -142,10 +144,12 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
|||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
final long accountId = getAccountId();
|
||||
final AccountKey accountId = getSelectedAccountKey();
|
||||
final Uri.Builder builder = Suggestions.Search.CONTENT_URI.buildUpon();
|
||||
builder.appendQueryParameter(QUERY_PARAM_QUERY, ParseUtils.parseString(mSearchQuery.getText()));
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, ParseUtils.parseString(accountId));
|
||||
if (accountId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountId.toString());
|
||||
}
|
||||
return new CursorLoader(this, builder.build(), Suggestions.Search.COLUMNS, null, null, null);
|
||||
}
|
||||
|
||||
|
@ -170,20 +174,20 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
|||
final SuggestionItem item = mUsersSearchAdapter.getSuggestionItem(position);
|
||||
switch (mUsersSearchAdapter.getItemViewType(position)) {
|
||||
case SuggestionsAdapter.VIEW_TYPE_USER_SUGGESTION_ITEM: {
|
||||
IntentUtils.openUserProfile(this, getAccountId(), item.extra_id, item.summary, null,
|
||||
IntentUtils.openUserProfile(this, getSelectedAccountKey(), item.extra_id, item.summary, null,
|
||||
true, UserFragment.Referral.DIRECT);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
case SuggestionsAdapter.VIEW_TYPE_USER_SCREEN_NAME: {
|
||||
IntentUtils.openUserProfile(this, getAccountId(), -1, item.title, null, true,
|
||||
IntentUtils.openUserProfile(this, getSelectedAccountKey(), -1, item.title, null, true,
|
||||
UserFragment.Referral.DIRECT);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
case SuggestionsAdapter.VIEW_TYPE_SAVED_SEARCH:
|
||||
case SuggestionsAdapter.VIEW_TYPE_SEARCH_HISTORY: {
|
||||
Utils.openSearch(this, getAccountId(), item.title);
|
||||
Utils.openSearch(this, getSelectedAccountKey(), item.title);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
|
@ -284,13 +288,13 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
|||
if (isFinishing()) return;
|
||||
final String query = ParseUtils.parseString(mSearchQuery.getText());
|
||||
if (TextUtils.isEmpty(query)) return;
|
||||
final long accountId = mAccountSpinner.getSelectedItemId();
|
||||
Utils.openSearch(this, accountId, query);
|
||||
Utils.openSearch(this, getSelectedAccountKey(), query);
|
||||
finish();
|
||||
}
|
||||
|
||||
private long getAccountId() {
|
||||
return mAccountSpinner.getSelectedItemId();
|
||||
private AccountKey getSelectedAccountKey() {
|
||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||
return new AccountKey(account.account_id, account.account_host);
|
||||
}
|
||||
|
||||
private void updateWindowAttributes() {
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.mariotaku.twidere.adapter.iface.IActivitiesAdapter;
|
|||
import org.mariotaku.twidere.api.twitter.model.Activity;
|
||||
import org.mariotaku.twidere.fragment.support.CursorActivitiesFragment;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
|
@ -438,8 +439,9 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
|
|||
final ParcelableActivity activity = adapter.getActivity(position);
|
||||
final ParcelableStatus status = ParcelableActivity.getActivityStatus(activity);
|
||||
assert status != null;
|
||||
IntentUtils.openUserProfile(context, status.account_id, status.user_id,
|
||||
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
|
||||
IntentUtils.openUserProfile(context, new AccountKey(status.account_id,
|
||||
status.account_host), status.user_id, status.user_screen_name, null, true,
|
||||
UserFragment.Referral.TIMELINE_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,7 +87,7 @@ public class DraftsAdapter extends SimpleCursorAdapter implements Constants {
|
|||
case Draft.Action.QUOTE: {
|
||||
final ParcelableMedia[] media = ParcelableMediaUtils.fromMediaUpdates(mediaUpdates);
|
||||
holder.media_preview_container.setVisibility(View.VISIBLE);
|
||||
holder.media_preview_container.displayMedia(media, mImageLoader, -1, -1, null,
|
||||
holder.media_preview_container.displayMedia(media, mImageLoader, null, -1, null,
|
||||
mMediaLoadingHandler);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.view.ViewGroup;
|
|||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IDirectMessagesAdapter;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessageCursorIndices;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
|
@ -205,7 +206,7 @@ public class MessageConversationAdapter extends BaseRecyclerViewAdapter<ViewHold
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId, long extraId) {
|
||||
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
|
||||
final MessageConversationAdapter adapter = adapterRef.get();
|
||||
IntentUtils.openMedia(adapter.getContext(), adapter.getDirectMessage((int) extraId), media,
|
||||
null, true);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.adapter;
|
|||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.view.holder.UserViewHolder;
|
||||
|
||||
|
@ -102,7 +103,11 @@ public class ParcelableUsersAdapter extends AbsUsersAdapter<List<ParcelableUser>
|
|||
return true;
|
||||
}
|
||||
|
||||
public int findPosition(long accountId, long userId) {
|
||||
public int findPosition(AccountKey accountKey, long userId) {
|
||||
return findPosition(accountKey.getId(), accountKey.getHost(), userId);
|
||||
}
|
||||
|
||||
public int findPosition(long accountId, String accountHost, long userId) {
|
||||
if (mData == null) return RecyclerView.NO_POSITION;
|
||||
for (int i = getUserStartIndex(), j = i + getUserCount(); i < j; i++) {
|
||||
final ParcelableUser user = mData.get(i);
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.commonsware.cwac.layouts.AspectLockedFrameLayout;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
|
||||
|
@ -100,7 +101,8 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
|||
mediaImageView.setHasPlayIcon(ParcelableMediaUtils.hasPlayIcon(firstMedia.type));
|
||||
loader.displayProfileImage(mediaProfileImageView, status.user_profile_image_url);
|
||||
loader.displayPreviewImageWithCredentials(mediaImageView, firstMedia.preview_url,
|
||||
status.account_id, adapter.getMediaLoadingHandler());
|
||||
new AccountKey(status.account_id, status.account_host),
|
||||
adapter.getMediaLoadingHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,7 +138,7 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId, long extraId) {
|
||||
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -406,8 +406,9 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
|
|||
@Override
|
||||
public void onUserProfileClick(IStatusViewHolder holder, ParcelableStatus status, int position) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
IntentUtils.openUserProfile(activity, status.account_id, status.user_id,
|
||||
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
|
||||
IntentUtils.openUserProfile(activity, new AccountKey(status.account_id, status.account_host),
|
||||
status.user_id, status.user_screen_name, null, true,
|
||||
UserFragment.Referral.TIMELINE_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.mariotaku.twidere.adapter.AbsUsersAdapter;
|
|||
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
|
||||
import org.mariotaku.twidere.adapter.iface.IUsersAdapter.UserAdapterListener;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.util.IntentUtils;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
|
@ -112,8 +113,8 @@ abstract class AbsUsersFragment<Data> extends AbsContentListRecyclerViewFragment
|
|||
public void onUserClick(UserViewHolder holder, int position) {
|
||||
final ParcelableUser user = getAdapter().getUser(position);
|
||||
final FragmentActivity activity = getActivity();
|
||||
IntentUtils.openUserProfile(activity, user.account_id, user.id, user.screen_name, null,
|
||||
true, getUserReferral());
|
||||
IntentUtils.openUserProfile(activity, new AccountKey(user.account_id, user.account_host),
|
||||
user.id, user.screen_name, null, true, getUserReferral());
|
||||
}
|
||||
|
||||
@UserFragment.Referral
|
||||
|
|
|
@ -248,8 +248,9 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
final ParcelableAccount account = mAccountsAdapter.getSelectedAccount();
|
||||
if (account == null) return;
|
||||
final FragmentActivity activity = getActivity();
|
||||
IntentUtils.openUserProfile(activity, account.account_id, account.account_id,
|
||||
account.screen_name, null, true, UserFragment.Referral.SELF_PROFILE);
|
||||
IntentUtils.openUserProfile(activity, new AccountKey(account.account_id,
|
||||
account.account_host), account.account_id, account.screen_name, null, true,
|
||||
UserFragment.Referral.SELF_PROFILE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
|
||||
import org.mariotaku.twidere.activity.support.SignInActivity;
|
||||
import org.mariotaku.twidere.adapter.AccountsAdapter;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
|
||||
|
@ -148,8 +149,9 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final ParcelableAccount account = mAdapter.getAccount(position);
|
||||
IntentUtils.openUserProfile(getActivity(), account.account_id, account.account_id, account.screen_name,
|
||||
null, true, UserFragment.Referral.SELF_PROFILE);
|
||||
IntentUtils.openUserProfile(getActivity(), new AccountKey(account.account_id,
|
||||
account.account_host), account.account_id, account.screen_name, null, true,
|
||||
UserFragment.Referral.SELF_PROFILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -258,6 +258,11 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
|
|||
public long[] getMaxIds() {
|
||||
return getOldestStatusIds(getAccountKeys());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxIds() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -271,6 +276,11 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
|
|||
return CursorStatusesFragment.this.getAccountKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public long[] getSinceIds() {
|
||||
|
|
|
@ -201,8 +201,8 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
|
|||
|
||||
@Override
|
||||
public void onUserClick(int position, DirectMessageEntry entry) {
|
||||
IntentUtils.openUserProfile(getActivity(), entry.account_id, entry.conversation_id,
|
||||
entry.screen_name, null, true, null);
|
||||
IntentUtils.openUserProfile(getActivity(), new AccountKey(entry.account_id, entry.account_host),
|
||||
entry.conversation_id, entry.screen_name, null, true, null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import org.mariotaku.twidere.annotation.ReadPositionTag;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ErrorInfoStore;
|
||||
|
@ -70,11 +72,11 @@ public class HomeTimelineFragment extends CursorStatusesFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getStatuses(long[] accountIds, long[] maxIds, long[] sinceIds) {
|
||||
public boolean getStatuses(RefreshTaskParam param) {
|
||||
final AsyncTwitterWrapper twitter = mTwitterWrapper;
|
||||
if (twitter == null) return false;
|
||||
if (maxIds == null) return twitter.refreshAll(accountIds);
|
||||
return twitter.getHomeTimelineAsync(accountIds, maxIds, sinceIds);
|
||||
if (!param.hasMaxIds()) return twitter.refreshAll(param.getAccountKeys());
|
||||
return twitter.getHomeTimelineAsync(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +84,7 @@ public class HomeTimelineFragment extends CursorStatusesFragment {
|
|||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (isVisibleToUser && activity != null) {
|
||||
for (long accountId : getAccountKeys()) {
|
||||
for (AccountKey accountId : getAccountKeys()) {
|
||||
final String tag = "home_" + accountId;
|
||||
mNotificationManager.cancel(tag, NOTIFICATION_ID_HOME_TIMELINE);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.mariotaku.twidere.adapter.ParcelableUsersAdapter;
|
|||
import org.mariotaku.twidere.adapter.iface.IUsersAdapter;
|
||||
import org.mariotaku.twidere.loader.support.IDsUsersLoader;
|
||||
import org.mariotaku.twidere.loader.support.IncomingFriendshipsLoader;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.message.FollowRequestTaskEvent;
|
||||
import org.mariotaku.twidere.view.holder.UserViewHolder;
|
||||
|
@ -50,9 +51,11 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
|
||||
public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args,
|
||||
final boolean fromUser) {
|
||||
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final IncomingFriendshipsLoader loader = new IncomingFriendshipsLoader(context, accountId, getData(), fromUser);
|
||||
final IncomingFriendshipsLoader loader = new IncomingFriendshipsLoader(context, accountKey,
|
||||
getData(), fromUser);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
|
@ -70,7 +73,8 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
|
|||
final AbsUsersAdapter<List<ParcelableUser>> adapter = getAdapter();
|
||||
final ParcelableUser user = adapter.getUser(position);
|
||||
if (user == null) return;
|
||||
mTwitterWrapper.acceptFriendshipAsync(user.account_id, user.id);
|
||||
mTwitterWrapper.acceptFriendshipAsync(new AccountKey(user.account_id, user.account_host),
|
||||
user.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +82,8 @@ public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment
|
|||
final AbsUsersAdapter<List<ParcelableUser>> adapter = getAdapter();
|
||||
final ParcelableUser user = adapter.getUser(position);
|
||||
if (user == null) return;
|
||||
mTwitterWrapper.denyFriendshipAsync(user.account_id, user.id);
|
||||
mTwitterWrapper.denyFriendshipAsync(new AccountKey(user.account_id, user.account_host),
|
||||
user.id);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.mariotaku.sqliteqb.library.Expression;
|
|||
import org.mariotaku.twidere.adapter.ParcelableActivitiesAdapter;
|
||||
import org.mariotaku.twidere.annotation.ReadPositionTag;
|
||||
import org.mariotaku.twidere.api.twitter.model.Activity;
|
||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
|
||||
import org.mariotaku.twidere.util.ErrorInfoStore;
|
||||
|
||||
|
@ -38,8 +39,8 @@ import edu.tsinghua.hotmobi.model.TimelineType;
|
|||
public class InteractionsTimelineFragment extends CursorActivitiesFragment {
|
||||
|
||||
@Override
|
||||
public boolean getActivities(long[] accountIds, long[] maxIds, long[] sinceIds) {
|
||||
mTwitterWrapper.getActivitiesAboutMeAsync(accountIds, maxIds, sinceIds);
|
||||
public boolean getActivities(RefreshTaskParam param) {
|
||||
mTwitterWrapper.getActivitiesAboutMeAsync(param);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ import org.mariotaku.twidere.adapter.SimpleParcelableUsersAdapter;
|
|||
import org.mariotaku.twidere.adapter.iface.IBaseCardAdapter.MenuButtonClickListener;
|
||||
import org.mariotaku.twidere.annotation.CustomTabType;
|
||||
import org.mariotaku.twidere.loader.support.UserSearchLoader;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
|
@ -137,11 +138,11 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
mUsersSearchList.setVisibility(View.GONE);
|
||||
mUsersSearchEmpty.setVisibility(View.GONE);
|
||||
mUsersSearchProgress.setVisibility(View.VISIBLE);
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID);
|
||||
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final String query = args.getString(EXTRA_QUERY);
|
||||
final boolean fromCache = args.getBoolean(EXTRA_FROM_CACHE);
|
||||
final boolean fromUser = args.getBoolean(EXTRA_FROM_USER, false);
|
||||
return new CacheUserSearchLoader(MessagesConversationFragment.this, accountId, query,
|
||||
return new CacheUserSearchLoader(MessagesConversationFragment.this, accountKey, query,
|
||||
fromCache, fromUser);
|
||||
}
|
||||
|
||||
|
@ -304,13 +305,13 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
} else if (args.containsKey(EXTRA_ACCOUNT_ID)) {
|
||||
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final long userId = args.getLong(EXTRA_RECIPIENT_ID, -1);
|
||||
final int accountPos = accountsSpinnerAdapter.findItemPosition(accountId);
|
||||
final int accountPos = accountsSpinnerAdapter.findItemPosition(accountKey.getId());
|
||||
if (accountPos >= 0) {
|
||||
mAccountSpinner.setSelection(accountPos);
|
||||
}
|
||||
account = accountPos >= 0 ? accountsSpinnerAdapter.getItem(accountPos) :
|
||||
DataStoreUtils.getCredentials(activity, accountId);
|
||||
recipient = Utils.getUserForConversation(activity, accountId, userId);
|
||||
DataStoreUtils.getCredentials(activity, accountKey);
|
||||
recipient = Utils.getUserForConversation(activity, accountKey, userId);
|
||||
} else {
|
||||
account = null;
|
||||
recipient = null;
|
||||
|
@ -401,8 +402,10 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete_all: {
|
||||
if (mAccount == null || mRecipient == null) return true;
|
||||
mTwitterWrapper.destroyMessageConversationAsync(mAccount.account_id, mRecipient.id);
|
||||
final ParcelableCredentials account = mAccount;
|
||||
if (account == null || mRecipient == null) return true;
|
||||
mTwitterWrapper.destroyMessageConversationAsync(new AccountKey(account.account_id,
|
||||
account.account_host), mRecipient.id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -489,16 +492,16 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
if (mSelectedDirectMessage != null) {
|
||||
final long message_id = mSelectedDirectMessage.id;
|
||||
final long account_id = mSelectedDirectMessage.account_id;
|
||||
final ParcelableDirectMessage message = mSelectedDirectMessage;
|
||||
if (message != null) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete: {
|
||||
mTwitterWrapper.destroyDirectMessageAsync(account_id, message_id);
|
||||
mTwitterWrapper.destroyDirectMessageAsync(new AccountKey(message.account_id,
|
||||
message.account_host), message.id);
|
||||
break;
|
||||
}
|
||||
case R.id.copy: {
|
||||
if (ClipboardUtils.setText(getActivity(), mSelectedDirectMessage.text_plain)) {
|
||||
if (ClipboardUtils.setText(getActivity(), message.text_plain)) {
|
||||
Utils.showOkMessage(getActivity(), R.string.text_copied, false);
|
||||
}
|
||||
break;
|
||||
|
@ -659,7 +662,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
if (((BaseAppCompatActivity) activity).getKeyMetaState() != 0) return false;
|
||||
final ParcelableCredentials account = (ParcelableCredentials) mAccountSpinner.getSelectedItem();
|
||||
if (account == null) return false;
|
||||
mEditText.setAccountKey(account.account_id);
|
||||
mEditText.setAccountKey(new AccountKey(account.account_id, account.account_host));
|
||||
searchUsers(account.account_id, ParseUtils.parseString(mEditUserQuery.getText()), false);
|
||||
return true;
|
||||
}
|
||||
|
@ -678,7 +681,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
public void afterTextChanged(Editable s) {
|
||||
final ParcelableCredentials account = (ParcelableCredentials) mAccountSpinner.getSelectedItem();
|
||||
if (account == null) return;
|
||||
mEditText.setAccountKey(account.account_id);
|
||||
mEditText.setAccountKey(new AccountKey(account.account_id, account.account_host));
|
||||
searchUsers(account.account_id, ParseUtils.parseString(s), true);
|
||||
}
|
||||
});
|
||||
|
@ -831,8 +834,9 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
private final boolean mFromCache;
|
||||
private final UserColorNameManager mUserColorNameManager;
|
||||
|
||||
public CacheUserSearchLoader(MessagesConversationFragment fragment, long accountId, String query, boolean fromCache, boolean fromUser) {
|
||||
super(fragment.getContext(), accountId, query, 0, null, fromUser);
|
||||
public CacheUserSearchLoader(MessagesConversationFragment fragment, AccountKey accountKey,
|
||||
String query, boolean fromCache, boolean fromUser) {
|
||||
super(fragment.getContext(), accountKey, query, 0, null, fromUser);
|
||||
mUserColorNameManager = fragment.mUserColorNameManager;
|
||||
mFromCache = fromCache;
|
||||
}
|
||||
|
@ -896,9 +900,10 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
final Bundle args = getArguments();
|
||||
final ParcelableCredentials account = args.getParcelable(EXTRA_ACCOUNT);
|
||||
final ParcelableUser user = args.getParcelable(EXTRA_USER);
|
||||
if (account == null || user == null) return;
|
||||
final AsyncTwitterWrapper twitter = mTwitterWrapper;
|
||||
twitter.destroyMessageConversationAsync(account.account_id, user.id);
|
||||
if (account == null || user == null || twitter == null) return;
|
||||
twitter.destroyMessageConversationAsync(new AccountKey(account.account_id,
|
||||
account.account_host), user.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,16 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader;
|
||||
import org.mariotaku.twidere.loader.support.MutesUsersLoader;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
|
||||
public class MutesUsersListFragment extends CursorSupportUsersListFragment {
|
||||
|
||||
@Override
|
||||
public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) {
|
||||
final AccountKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
return new MutesUsersLoader(context, accountId, getNextCursor(), getData(), fromUser);
|
||||
final MutesUsersLoader loader = new MutesUsersLoader(context, accountKey, getData(), fromUser);
|
||||
loader.setCursor(getNextCursor());
|
||||
return loader;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -462,15 +462,15 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
@Override
|
||||
public void onUserProfileClick(IStatusViewHolder holder, ParcelableStatus status, int position) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
IntentUtils.openUserProfile(activity, status.account_id, status.user_id,
|
||||
status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
|
||||
IntentUtils.openUserProfile(activity, new AccountKey(status.account_id, status.account_host),
|
||||
status.user_id, status.user_screen_name, null, true, UserFragment.Referral.TIMELINE_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId, long extraId) {
|
||||
public void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId) {
|
||||
final ParcelableStatus status = mStatusAdapter.getStatus();
|
||||
if (status == null) return;
|
||||
IntentUtils.openMediaDirectly(getActivity(), accountId, status, media, null, true);
|
||||
IntentUtils.openMediaDirectly(getActivity(), accountKey, status, media, null, true);
|
||||
// BEGIN HotMobi
|
||||
MediaEvent event = MediaEvent.create(getActivity(), status, media, TimelineType.OTHER,
|
||||
mStatusAdapter.isMediaPreviewEnabled());
|
||||
|
@ -545,9 +545,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
@Override
|
||||
public Loader<SingleResponse<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
|
||||
final Bundle fragmentArgs = getArguments();
|
||||
final long accountId = fragmentArgs.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final AccountKey accountKey = fragmentArgs.getParcelable(EXTRA_ACCOUNT_KEY);
|
||||
final long statusId = fragmentArgs.getLong(EXTRA_STATUS_ID, -1);
|
||||
return new ParcelableStatusLoader(getActivity(), false, fragmentArgs, accountId, statusId);
|
||||
return new ParcelableStatusLoader(getActivity(), false, fragmentArgs, accountKey, statusId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -592,7 +592,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
final TweetEvent event = mStatusEvent;
|
||||
if (event == null) return;
|
||||
event.markEnd();
|
||||
HotMobiLogger.getInstance(getActivity()).log(event.getAccountId(), event);
|
||||
final AccountKey accountKey = new AccountKey(event.getAccountId(), event.getAccountHost());
|
||||
HotMobiLogger.getInstance(getActivity()).log(accountKey, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -673,7 +674,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private void loadConversation(ParcelableStatus status, long sinceId, long maxId) {
|
||||
if (status == null) return;
|
||||
final Bundle args = new Bundle();
|
||||
args.putLong(EXTRA_ACCOUNT_ID, status.account_id);
|
||||
args.putParcelable(EXTRA_ACCOUNT_KEY, new AccountKey(status.account_id, status.account_host));
|
||||
args.putLong(EXTRA_STATUS_ID, status.is_retweet ? status.retweet_id : status.id);
|
||||
args.putLong(EXTRA_SINCE_ID, sinceId);
|
||||
args.putLong(EXTRA_MAX_ID, maxId);
|
||||
|
@ -1016,7 +1017,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
final CharSequence quotedText = HtmlSpanBuilder.fromHtml(status.quoted_text_html,
|
||||
status.text_unescaped);
|
||||
if (quotedText instanceof Spanned) {
|
||||
quotedTextView.setText(linkify.applyAllLinks(quotedText, status.account_id,
|
||||
quotedTextView.setText(linkify.applyAllLinks(quotedText,
|
||||
new AccountKey(status.account_id, status.account_host),
|
||||
layoutPosition, status.is_possibly_sensitive, skipLinksInText));
|
||||
}
|
||||
|
||||
|
@ -1070,8 +1072,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
final CharSequence text = HtmlSpanBuilder.fromHtml(status.text_html,
|
||||
status.text_unescaped);
|
||||
if (text instanceof Spanned) {
|
||||
textView.setText(linkify.applyAllLinks(text, status.account_id, layoutPosition,
|
||||
status.is_possibly_sensitive, skipLinksInText));
|
||||
textView.setText(linkify.applyAllLinks(text, new AccountKey(status.account_id,
|
||||
status.account_host), layoutPosition, status.is_possibly_sensitive, skipLinksInText));
|
||||
}
|
||||
|
||||
final ParcelableLocation location;
|
||||
|
@ -1125,8 +1127,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
mediaPreviewContainer.setVisibility(View.VISIBLE);
|
||||
mediaPreview.setVisibility(View.VISIBLE);
|
||||
mediaPreviewLoad.setVisibility(View.GONE);
|
||||
mediaPreview.displayMedia(media, loader, status.account_id, -1, adapter.getFragment(),
|
||||
adapter.getMediaLoadingHandler());
|
||||
mediaPreview.displayMedia(media, loader, new AccountKey(status.account_id,
|
||||
status.account_host), -1, adapter.getFragment(), adapter.getMediaLoadingHandler());
|
||||
} else {
|
||||
mediaPreviewContainer.setVisibility(View.VISIBLE);
|
||||
mediaPreview.setVisibility(View.GONE);
|
||||
|
@ -1190,6 +1192,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
final ParcelableStatus status = adapter.getStatus(getLayoutPosition());
|
||||
final StatusFragment fragment = adapter.getFragment();
|
||||
if (status == null || fragment == null) return;
|
||||
final AccountKey accountKey = new AccountKey(status.account_id, status.account_host);
|
||||
switch (v.getId()) {
|
||||
case R.id.media_preview_load: {
|
||||
if (adapter.isSensitiveContentEnabled() || !status.is_possibly_sensitive) {
|
||||
|
@ -1202,13 +1205,13 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
}
|
||||
case R.id.profile_container: {
|
||||
final FragmentActivity activity = fragment.getActivity();
|
||||
IntentUtils.openUserProfile(activity, status.account_id, status.user_id,
|
||||
IntentUtils.openUserProfile(activity, accountKey, status.user_id,
|
||||
status.user_screen_name, null, true, UserFragment.Referral.STATUS);
|
||||
break;
|
||||
}
|
||||
case R.id.retweeted_by: {
|
||||
if (status.retweet_id > 0) {
|
||||
IntentUtils.openUserProfile(adapter.getContext(), status.account_id,
|
||||
IntentUtils.openUserProfile(adapter.getContext(), accountKey,
|
||||
status.retweeted_by_user_id, status.retweeted_by_user_screen_name,
|
||||
null, true, UserFragment.Referral.STATUS);
|
||||
}
|
||||
|
@ -1221,13 +1224,13 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
break;
|
||||
}
|
||||
case R.id.quoted_name_container: {
|
||||
IntentUtils.openUserProfile(adapter.getContext(), status.account_id,
|
||||
IntentUtils.openUserProfile(adapter.getContext(), accountKey,
|
||||
status.quoted_user_id, status.quoted_user_screen_name, null, true,
|
||||
UserFragment.Referral.STATUS);
|
||||
break;
|
||||
}
|
||||
case R.id.quote_original_link: {
|
||||
Utils.openStatus(adapter.getContext(), status.account_id, status.quoted_id);
|
||||
Utils.openStatus(adapter.getContext(), accountKey, status.quoted_id);
|
||||
break;
|
||||
}
|
||||
case R.id.translate_label: {
|
||||
|
@ -1590,7 +1593,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String link, String orig, long accountId, long extraId, int type, boolean sensitive, int start, int end) {
|
||||
public void onLinkClick(final String link, final String orig, final AccountKey accountKey,
|
||||
long extraId, int type, boolean sensitive, int start, int end) {
|
||||
final ParcelableStatus status = adapter.getStatus();
|
||||
ParcelableMedia current;
|
||||
if ((current = ParcelableMediaUtils.findByUrl(status.media, link)) != null &&
|
||||
|
@ -1607,7 +1611,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
expandOrOpenMedia(null);
|
||||
return;
|
||||
}
|
||||
super.onLinkClick(link, orig, accountId, extraId, type, sensitive, start, end);
|
||||
super.onLinkClick(link, orig, accountKey, extraId, type, sensitive, start, end);
|
||||
}
|
||||
|
||||
private void expandOrOpenMedia(ParcelableMedia current) {
|
||||
|
|
|
@ -41,11 +41,11 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment {
|
|||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_MULTI_BLOCKSTATE_CHANGED.equals(action)) {
|
||||
final long account_id = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
final String screen_name = getAccountScreenName(getActivity(), account_id);
|
||||
final AccountKey accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY);
|
||||
final String screen_name = getAccountScreenName(getActivity(), accountKey);
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return;
|
||||
if (account_id > 0 && args.getLong(EXTRA_USER_ID, -1) == account_id || screen_name != null
|
||||
if (accountKey != null && accountKey.getId() == args.getLong(EXTRA_USER_ID, -1) || screen_name != null
|
||||
&& screen_name.equalsIgnoreCase(args.getString(EXTRA_SCREEN_NAME))) {
|
||||
removeUsers(intent.getLongArrayExtra(EXTRA_USER_IDS));
|
||||
}
|
||||
|
|
|
@ -1318,7 +1318,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
ParcelableMedia profileImage = ParcelableMediaUtils.image(url);
|
||||
profileImage.type = ParcelableMedia.Type.IMAGE;
|
||||
final ParcelableMedia[] media = {profileImage};
|
||||
IntentUtils.openMedia(activity, user.account_id, false, null, media, null, true);
|
||||
IntentUtils.openMedia(activity, new AccountKey(user.account_id, user.account_host),
|
||||
false, null, media, null, true);
|
||||
break;
|
||||
}
|
||||
case R.id.profile_banner: {
|
||||
|
@ -1327,7 +1328,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
ParcelableMedia profileBanner = ParcelableMediaUtils.image(url);
|
||||
profileBanner.type = ParcelableMedia.Type.IMAGE;
|
||||
final ParcelableMedia[] media = {profileBanner};
|
||||
IntentUtils.openMedia(activity, user.account_id, false, null, media, null, true);
|
||||
IntentUtils.openMedia(activity, new AccountKey(user.account_id, user.account_host),
|
||||
false, null, media, null, true);
|
||||
break;
|
||||
}
|
||||
case R.id.listed_container: {
|
||||
|
@ -1364,8 +1366,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
if (user == null) return;
|
||||
switch (type) {
|
||||
case TwidereLinkify.LINK_TYPE_MENTION: {
|
||||
IntentUtils.openUserProfile(getActivity(), user.account_id, -1, link, null,
|
||||
true, Referral.USER_MENTION);
|
||||
IntentUtils.openUserProfile(getActivity(), new AccountKey(user.account_id,
|
||||
user.account_host), -1, link, null, true, Referral.USER_MENTION);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_HASHTAG: {
|
||||
|
|
|
@ -354,8 +354,9 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
case R.id.profile_image: {
|
||||
final ParcelableUserList userList = mUserList;
|
||||
if (userList == null) return;
|
||||
IntentUtils.openUserProfile(getActivity(), userList.account_id, userList.user_id,
|
||||
userList.user_screen_name, null, true, null);
|
||||
IntentUtils.openUserProfile(getActivity(), new AccountKey(userList.account_id,
|
||||
userList.account_host), userList.user_id, userList.user_screen_name, null,
|
||||
true, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
|
|||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.SearchQuery;
|
||||
import org.mariotaku.twidere.api.twitter.model.Status;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.util.ParcelableStatusUtils;
|
||||
|
@ -50,7 +51,8 @@ public class ConversationLoader extends TwitterAPIStatusesLoader {
|
|||
public ConversationLoader(final Context context, @NonNull final ParcelableStatus status,
|
||||
final long sinceId, final long maxId, final List<ParcelableStatus> data,
|
||||
final boolean fromUser) {
|
||||
super(context, status.account_id, sinceId, maxId, data, null, -1, fromUser);
|
||||
super(context, new AccountKey(status.account_id, status.account_host), sinceId, maxId, data,
|
||||
null, -1, fromUser);
|
||||
mStatus = Nullables.assertNonNull(ParcelUtils.clone(status));
|
||||
ParcelableStatusUtils.makeOriginalStatus(mStatus);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.loader.support;
|
|||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -34,9 +35,9 @@ import org.mariotaku.twidere.api.twitter.model.User;
|
|||
|
||||
public class MutesUsersLoader extends CursorSupportUsersLoader {
|
||||
|
||||
public MutesUsersLoader(final Context context, final long accountId, final long cursor,
|
||||
public MutesUsersLoader(final Context context, final AccountKey accountKey,
|
||||
final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountId, data, fromUser);
|
||||
super(context, accountKey, data, fromUser);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.content.AsyncTaskLoader;
|
||||
|
||||
import org.mariotaku.twidere.constant.IntentConstants;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
|
@ -41,10 +42,11 @@ public class ParcelableStatusLoader extends AsyncTaskLoader<SingleResponse<Parce
|
|||
|
||||
private final boolean mOmitIntentExtra;
|
||||
private final Bundle mExtras;
|
||||
private final long mAccountId, mStatusId;
|
||||
private final AccountKey mAccountId;
|
||||
private final long mStatusId;
|
||||
|
||||
public ParcelableStatusLoader(final Context context, final boolean omitIntentExtra, final Bundle extras,
|
||||
final long accountId, final long statusId) {
|
||||
final AccountKey accountId, final long statusId) {
|
||||
super(context);
|
||||
mOmitIntentExtra = omitIntentExtra;
|
||||
mExtras = extras;
|
||||
|
@ -64,7 +66,7 @@ public class ParcelableStatusLoader extends AsyncTaskLoader<SingleResponse<Parce
|
|||
}
|
||||
}
|
||||
try {
|
||||
final ParcelableStatus status = findStatus(getContext(), mAccountId, accountHost, mStatusId);
|
||||
final ParcelableStatus status = findStatus(getContext(), mAccountId, mStatusId);
|
||||
final ParcelableCredentials credentials = DataStoreUtils.getCredentials(getContext(), mAccountId);
|
||||
final SingleResponse<ParcelableStatus> response = SingleResponse.getInstance(status);
|
||||
final Bundle extras = response.getExtras();
|
||||
|
|
|
@ -44,9 +44,9 @@ import org.mariotaku.twidere.util.DataStoreUtils;
|
|||
import org.mariotaku.twidere.util.JsonSerializer;
|
||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
import org.mariotaku.twidere.util.TwitterWrapper;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.createCachedUser;
|
||||
import static org.mariotaku.twidere.util.Utils.isMyAccount;
|
||||
|
||||
public final class ParcelableUserLoader extends AsyncTaskLoader<SingleResponse<ParcelableUser>> implements Constants {
|
||||
|
||||
|
@ -72,7 +72,8 @@ public final class ParcelableUserLoader extends AsyncTaskLoader<SingleResponse<P
|
|||
public SingleResponse<ParcelableUser> loadInBackground() {
|
||||
final Context context = getContext();
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
int accountColor = DataStoreUtils.getAccountColor(context, mAccountId);
|
||||
final AccountKey accountKey = mAccountId;
|
||||
int accountColor = DataStoreUtils.getAccountColor(context, accountKey);
|
||||
if (!mOmitIntentExtra && mExtras != null) {
|
||||
final ParcelableUser user = mExtras.getParcelable(EXTRA_USER);
|
||||
if (user != null) {
|
||||
|
@ -82,7 +83,7 @@ public final class ParcelableUserLoader extends AsyncTaskLoader<SingleResponse<P
|
|||
return SingleResponse.getInstance(user);
|
||||
}
|
||||
}
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, mAccountId, true);
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, accountKey, true);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
if (mLoadFromCache) {
|
||||
final Expression where;
|
||||
|
@ -101,7 +102,8 @@ public final class ParcelableUserLoader extends AsyncTaskLoader<SingleResponse<P
|
|||
if (cur.moveToFirst()) {
|
||||
final ParcelableUserCursorIndices indices = new ParcelableUserCursorIndices(cur);
|
||||
final ParcelableUser user = indices.newObject(cur);
|
||||
user.account_id = mAccountId;
|
||||
user.account_id = accountKey.getId();
|
||||
user.account_host = accountKey.getHost();
|
||||
user.account_color = accountColor;
|
||||
return SingleResponse.getInstance(user);
|
||||
}
|
||||
|
@ -115,8 +117,8 @@ public final class ParcelableUserLoader extends AsyncTaskLoader<SingleResponse<P
|
|||
final ContentValues cachedUserValues = createCachedUser(twitterUser);
|
||||
final long userId = twitterUser.getId();
|
||||
resolver.insert(CachedUsers.CONTENT_URI, cachedUserValues);
|
||||
final ParcelableUser user = ParcelableUserUtils.fromUser(twitterUser, mAccountId);
|
||||
if (isMyAccount(context, userId)) {
|
||||
final ParcelableUser user = ParcelableUserUtils.fromUser(twitterUser, accountKey);
|
||||
if (Utils.isMyAccount(context, user.id, user.user_host)) {
|
||||
final ContentValues accountValues = new ContentValues();
|
||||
accountValues.put(Accounts.NAME, user.name);
|
||||
accountValues.put(Accounts.SCREEN_NAME, user.screen_name);
|
||||
|
|
|
@ -29,6 +29,7 @@ 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.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.InternalTwitterContentUtils;
|
||||
|
||||
|
@ -37,10 +38,11 @@ import java.util.List;
|
|||
|
||||
public class RetweetsOfMeLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
public RetweetsOfMeLoader(final Context context, final long accountId, final long sinceId, final long maxId,
|
||||
public RetweetsOfMeLoader(final Context context, final AccountKey accountKey,
|
||||
final long sinceId, final long maxId,
|
||||
final List<ParcelableStatus> data, final String[] savedStatusesArgs,
|
||||
final int tabPosition, boolean fromUser) {
|
||||
super(context, accountId, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
super(context, accountKey, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -27,22 +27,24 @@ import org.mariotaku.twidere.api.twitter.Twitter;
|
|||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
|
||||
import static org.mariotaku.twidere.TwidereConstants.LOGTAG;
|
||||
|
||||
public class SavedSearchesLoader extends AsyncTaskLoader<ResponseList<SavedSearch>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final AccountKey mAccountId;
|
||||
|
||||
public SavedSearchesLoader(final Context context, final long account_id) {
|
||||
public SavedSearchesLoader(final Context context, final AccountKey accountKey) {
|
||||
super(context);
|
||||
mAccountId = account_id;
|
||||
mAccountId = accountKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseList<SavedSearch> loadInBackground() {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(getContext(), mAccountId, accountHost, false);
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(getContext(), mAccountId,
|
||||
false);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
return twitter.getSavedSearches();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.mariotaku.twidere.api.twitter.Twitter;
|
|||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -35,13 +36,13 @@ import java.util.List;
|
|||
*/
|
||||
public class ScheduledStatusesLoader extends AsyncTaskLoader<List<ScheduledStatus>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final AccountKey mAccountId;
|
||||
private final long mSinceId;
|
||||
private final long mMaxId;
|
||||
@ScheduledStatus.State
|
||||
private final String[] mStates;
|
||||
|
||||
public ScheduledStatusesLoader(Context context, long accountId, long sinceId, long maxId,
|
||||
public ScheduledStatusesLoader(Context context, AccountKey accountId, long sinceId, long maxId,
|
||||
@ScheduledStatus.State String[] states, List<ScheduledStatus> data) {
|
||||
super(context);
|
||||
mAccountId = accountId;
|
||||
|
@ -53,7 +54,8 @@ public class ScheduledStatusesLoader extends AsyncTaskLoader<List<ScheduledStatu
|
|||
|
||||
@Override
|
||||
public List<ScheduledStatus> loadInBackground() {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(getContext(), mAccountId, accountHost, true);
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(getContext(), mAccountId, true);
|
||||
if (twitter == null) return null;
|
||||
final Paging paging = new Paging();
|
||||
if (mSinceId > 0) {
|
||||
paging.setSinceId(mSinceId);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.mariotaku.twidere.api.twitter.Twitter;
|
|||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -35,9 +36,9 @@ public class UserSearchLoader extends TwitterAPIUsersLoader {
|
|||
private final String mQuery;
|
||||
private final int mPage;
|
||||
|
||||
public UserSearchLoader(final Context context, final long accountId, final String query, final int page,
|
||||
final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountId, data, fromUser);
|
||||
public UserSearchLoader(final Context context, final AccountKey accountKey, final String query,
|
||||
final int page, final List<ParcelableUser> data, boolean fromUser) {
|
||||
super(context, accountKey, data, fromUser);
|
||||
mQuery = query;
|
||||
mPage = page;
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ import android.support.annotation.Nullable;
|
|||
*/
|
||||
public class BaseRefreshTaskParam implements RefreshTaskParam {
|
||||
|
||||
private final AccountKey[] mAccountKeys;
|
||||
private final AccountKey[] accountKeys;
|
||||
private final long[] maxIds;
|
||||
private final long[] sinceIds;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AccountKey[] getAccountKeys() {
|
||||
return mAccountKeys;
|
||||
return accountKeys;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -30,8 +30,18 @@ public class BaseRefreshTaskParam implements RefreshTaskParam {
|
|||
return sinceIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxIds() {
|
||||
return maxIds != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSinceIds() {
|
||||
return sinceIds != null;
|
||||
}
|
||||
|
||||
public BaseRefreshTaskParam(AccountKey[] accountKeys, long[] maxIds, long[] sinceIds) {
|
||||
this.mAccountKeys = accountKeys;
|
||||
this.accountKeys = accountKeys;
|
||||
this.maxIds = maxIds;
|
||||
this.sinceIds = sinceIds;
|
||||
}
|
||||
|
|
|
@ -16,4 +16,8 @@ public interface RefreshTaskParam {
|
|||
@Nullable
|
||||
long[] getSinceIds();
|
||||
|
||||
boolean hasMaxIds();
|
||||
|
||||
boolean hasSinceIds();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,14 @@ public abstract class SimpleRefreshTaskParam implements RefreshTaskParam {
|
|||
public long[] getSinceIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxIds() {
|
||||
return getMaxIds() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSinceIds() {
|
||||
return getSinceIds() != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.mariotaku.twidere.model.util;
|
|||
|
||||
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
|
||||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage;
|
||||
import org.mariotaku.twidere.util.InternalTwitterContentUtils;
|
||||
import org.mariotaku.twidere.util.TwitterContentUtils;
|
||||
|
@ -14,9 +15,14 @@ import static org.mariotaku.twidere.util.HtmlEscapeHelper.toPlainText;
|
|||
* Created by mariotaku on 16/2/13.
|
||||
*/
|
||||
public class ParcelableDirectMessageUtils {
|
||||
public static ParcelableDirectMessage fromDirectMessage(DirectMessage message, long accountId, boolean isOutgoing) {
|
||||
public static ParcelableDirectMessage fromDirectMessage(DirectMessage message, AccountKey accountKey, boolean isOutgoing) {
|
||||
return fromDirectMessage(message, accountKey.getId(), accountKey.getHost(), isOutgoing);
|
||||
}
|
||||
|
||||
public static ParcelableDirectMessage fromDirectMessage(DirectMessage message, long accountId, String accountHost, boolean isOutgoing) {
|
||||
ParcelableDirectMessage result = new ParcelableDirectMessage();
|
||||
result.account_id = accountId;
|
||||
result.account_host = accountHost;
|
||||
result.is_outgoing = isOutgoing;
|
||||
final User sender = message.getSender(), recipient = message.getRecipient();
|
||||
assert sender != null && recipient != null;
|
||||
|
|
|
@ -134,7 +134,7 @@ public class ParcelableMediaUtils {
|
|||
if ("animated_gif".equals(name) || "player".equals(name)) {
|
||||
final ParcelableMedia media = new ParcelableMedia();
|
||||
final CardEntity.BindingValue playerStreamUrl = card.getBindingValue("player_stream_url");
|
||||
media.card = ParcelableCardEntityUtils.fromCardEntity(card, -1);
|
||||
media.card = ParcelableCardEntityUtils.fromCardEntity(card, null);
|
||||
CardEntity.StringValue appUrlResolved = (CardEntity.StringValue) card.getBindingValue("app_url_resolved");
|
||||
media.url = checkUrl(appUrlResolved) ? appUrlResolved.getValue() : card.getUrl();
|
||||
if ("animated_gif".equals(name)) {
|
||||
|
@ -179,7 +179,7 @@ public class ParcelableMediaUtils {
|
|||
|
||||
final ParcelableMedia media = new ParcelableMedia();
|
||||
media.url = card.getUrl();
|
||||
media.card = ParcelableCardEntityUtils.fromCardEntity(card, -1);
|
||||
media.card = ParcelableCardEntityUtils.fromCardEntity(card, null);
|
||||
media.type = ParcelableMedia.Type.IMAGE;
|
||||
media.media_url = ((CardEntity.ImageValue) photoImageFullSize).getUrl();
|
||||
media.width = ((CardEntity.ImageValue) photoImageFullSize).getWidth();
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.mariotaku.twidere.api.twitter.model.Status;
|
|||
import org.mariotaku.twidere.api.twitter.model.StatusUpdate;
|
||||
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.Draft;
|
||||
import org.mariotaku.twidere.model.DraftCursorIndices;
|
||||
import org.mariotaku.twidere.model.DraftValuesCreator;
|
||||
|
@ -288,15 +289,15 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
}
|
||||
|
||||
private void handleSendDirectMessageIntent(final Intent intent) {
|
||||
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
final AccountKey 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 text = intent.getStringExtra(EXTRA_TEXT);
|
||||
sendMessage(accountId, recipientId, text, imageUri);
|
||||
}
|
||||
|
||||
private void sendMessage(long accountId, long recipientId, String text, String imageUri) {
|
||||
if (accountId <= 0 || recipientId <= 0 || isEmpty(text)) return;
|
||||
private void sendMessage(AccountKey accountId, long recipientId, String text, String imageUri) {
|
||||
if (accountId == null || recipientId <= 0 || isEmpty(text)) return;
|
||||
final String title = getString(R.string.sending_direct_message);
|
||||
final Builder builder = new Builder(this);
|
||||
builder.setSmallIcon(R.drawable.ic_stat_send);
|
||||
|
@ -376,7 +377,8 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
boolean failed = false;
|
||||
Exception exception = null;
|
||||
final Expression where = Expression.equals(Drafts._ID, draftId);
|
||||
final List<Long> failedAccountIds = TwidereListUtils.fromArray(DataStoreUtils.getAccountKeys(item.accounts));
|
||||
final List<AccountKey> failedAccountIds = new ArrayList<>();
|
||||
Collections.addAll(failedAccountIds, DataStoreUtils.getAccountKeys(item.accounts));
|
||||
|
||||
for (final SingleResponse<ParcelableStatus> response : result) {
|
||||
final ParcelableStatus data = response.getData();
|
||||
|
@ -386,11 +388,12 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
exception = response.getException();
|
||||
}
|
||||
} else if (data.account_id > 0) {
|
||||
failedAccountIds.remove(data.account_id);
|
||||
failedAccountIds.remove(new AccountKey(data.account_id, data.account_host));
|
||||
// BEGIN HotMobi
|
||||
final TweetEvent event = TweetEvent.create(this, data, TimelineType.OTHER);
|
||||
event.setAction(TweetEvent.Action.TWEET);
|
||||
HotMobiLogger.getInstance(this).log(data.account_id, event);
|
||||
HotMobiLogger.getInstance(this).log(new AccountKey(data.account_id,
|
||||
data.account_host), event);
|
||||
// END HotMobi
|
||||
}
|
||||
}
|
||||
|
@ -442,10 +445,10 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
|
||||
|
||||
private SingleResponse<ParcelableDirectMessage> sendDirectMessage(final NotificationCompat.Builder builder,
|
||||
final long accountId, final long recipientId,
|
||||
final AccountKey accountKey, final long recipientId,
|
||||
final String text, final String imageUri) {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(this, accountId, true, true);
|
||||
final TwitterUpload twitterUpload = TwitterAPIFactory.getTwitterInstance(this, accountId, accountHost, true, true, TwitterUpload.class);
|
||||
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();
|
||||
try {
|
||||
final ParcelableDirectMessage directMessage;
|
||||
|
@ -462,12 +465,12 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
// final MediaUploadResponse uploadResp = twitter.uploadMedia(file.getName(), is, o.outMimeType);
|
||||
final MediaUploadResponse uploadResp = twitterUpload.uploadMedia(file);
|
||||
directMessage = ParcelableDirectMessageUtils.fromDirectMessage(twitter.sendDirectMessage(recipientId, text,
|
||||
uploadResp.getId()), accountId, true);
|
||||
uploadResp.getId()), accountKey, true);
|
||||
if (!file.delete()) {
|
||||
Log.d(LOGTAG, String.format("unable to delete %s", path));
|
||||
}
|
||||
} else {
|
||||
directMessage = ParcelableDirectMessageUtils.fromDirectMessage(twitter.sendDirectMessage(recipientId, text), accountId, true);
|
||||
directMessage = ParcelableDirectMessageUtils.fromDirectMessage(twitter.sendDirectMessage(recipientId, text), accountKey, true);
|
||||
}
|
||||
Utils.setLastSeen(this, recipientId, System.currentTimeMillis());
|
||||
|
||||
|
@ -581,12 +584,14 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
shortener.waitForService();
|
||||
}
|
||||
for (final ParcelableAccount account : statusUpdate.accounts) {
|
||||
final ParcelableCredentials credentials = DataStoreUtils.getCredentials(this, account.account_id);
|
||||
final AccountKey accountKey = new AccountKey(account.account_id, account.account_host);
|
||||
final ParcelableCredentials credentials = DataStoreUtils.getCredentials(this,
|
||||
accountKey);
|
||||
// Get Twitter instance corresponding to account
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(this, account.account_id,
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(this, accountKey,
|
||||
true, true);
|
||||
final TwitterUpload upload = TwitterAPIFactory.getTwitterInstance(this, account.account_id,
|
||||
accountHost, true, true, TwitterUpload.class);
|
||||
final TwitterUpload upload = TwitterAPIFactory.getTwitterInstance(this,
|
||||
accountKey, true, true, TwitterUpload.class);
|
||||
|
||||
// Shouldn't happen
|
||||
if (twitter == null || upload == null || credentials == null) {
|
||||
|
@ -621,7 +626,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
StatusShortenResult shortenedResult = null;
|
||||
if (shouldShorten && shortener != null) {
|
||||
try {
|
||||
shortenedResult = shortener.shorten(statusUpdate, account.account_id,
|
||||
shortenedResult = shortener.shorten(statusUpdate, accountKey.getId(),
|
||||
statusText);
|
||||
} catch (final Exception e) {
|
||||
throw new ShortenException(getString(R.string.error_message_tweet_shorten_failed), e);
|
||||
|
@ -701,7 +706,8 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
notReplyToOther = true;
|
||||
}
|
||||
}
|
||||
final ParcelableStatus result = ParcelableStatusUtils.fromStatus(resultStatus, account.account_id, accountHost, false);
|
||||
final ParcelableStatus result = ParcelableStatusUtils.fromStatus(resultStatus,
|
||||
accountKey, false);
|
||||
if (shouldShorten && shortener != null && shortenedResult != null) {
|
||||
shortener.callback(shortenedResult, result);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ 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.AccountKey;
|
||||
import org.mariotaku.twidere.model.AccountPreferences;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
|
@ -61,7 +62,7 @@ public class StreamingService extends Service implements Constants {
|
|||
|
||||
private NotificationManager mNotificationManager;
|
||||
|
||||
private long[] mAccountIds;
|
||||
private AccountKey[] mAccountKeys;
|
||||
|
||||
private static final Uri[] MESSAGES_URIS = new Uri[]{DirectMessages.Inbox.CONTENT_URI,
|
||||
DirectMessages.Outbox.CONTENT_URI};
|
||||
|
@ -75,7 +76,7 @@ public class StreamingService extends Service implements Constants {
|
|||
|
||||
@Override
|
||||
public void onChange(final boolean selfChange, final Uri uri) {
|
||||
if (!TwidereArrayUtils.contentMatch(mAccountIds, DataStoreUtils.getActivatedAccountKeys(StreamingService.this))) {
|
||||
if (!TwidereArrayUtils.contentMatch(mAccountKeys, DataStoreUtils.getActivatedAccountKeys(StreamingService.this))) {
|
||||
initStreaming();
|
||||
}
|
||||
}
|
||||
|
@ -126,19 +127,20 @@ public class StreamingService extends Service implements Constants {
|
|||
|
||||
private boolean setTwitterInstances() {
|
||||
final List<ParcelableCredentials> accountsList = DataStoreUtils.getCredentialsList(this, true);
|
||||
final long[] accountIds = new long[accountsList.size()];
|
||||
for (int i = 0, j = accountIds.length; i < j; i++) {
|
||||
accountIds[i] = accountsList.get(i).account_id;
|
||||
final AccountKey[] accountKeys = new AccountKey[accountsList.size()];
|
||||
for (int i = 0, j = accountKeys.length; i < j; i++) {
|
||||
final ParcelableCredentials credentials = accountsList.get(i);
|
||||
accountKeys[i] = new AccountKey(credentials.account_id, credentials.account_host);
|
||||
}
|
||||
final AccountPreferences[] activitedPreferences = AccountPreferences.getAccountPreferences(this, accountIds);
|
||||
final AccountPreferences[] activatedPreferences = AccountPreferences.getAccountPreferences(this, accountKeys);
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(Constants.LOGTAG, "Setting up twitter stream instances");
|
||||
}
|
||||
mAccountIds = accountIds;
|
||||
mAccountKeys = accountKeys;
|
||||
clearTwitterInstances();
|
||||
boolean result = false;
|
||||
for (int i = 0, j = accountsList.size(); i < j; i++) {
|
||||
final AccountPreferences preferences = activitedPreferences[i];
|
||||
final AccountPreferences preferences = activatedPreferences[i];
|
||||
if (!preferences.isStreamingEnabled()) continue;
|
||||
final ParcelableCredentials account = accountsList.get(i);
|
||||
final Endpoint endpoint = TwitterAPIFactory.getEndpoint(account, TwitterUserStream.class);
|
||||
|
@ -246,14 +248,14 @@ public class StreamingService extends Service implements Constants {
|
|||
final User sender = directMessage.getSender(), recipient = directMessage.getRecipient();
|
||||
if (sender.getId() == account.account_id) {
|
||||
final ContentValues values = ContentValuesCreator.createDirectMessage(directMessage,
|
||||
account.account_id, true);
|
||||
account.account_id, account.account_host, true);
|
||||
if (values != null) {
|
||||
resolver.insert(DirectMessages.Outbox.CONTENT_URI, values);
|
||||
}
|
||||
}
|
||||
if (recipient.getId() == account.account_id) {
|
||||
final ContentValues values = ContentValuesCreator.createDirectMessage(directMessage,
|
||||
account.account_id, false);
|
||||
account.account_id, account.account_host, false);
|
||||
final Uri.Builder builder = DirectMessages.Inbox.CONTENT_URI.buildUpon();
|
||||
builder.appendQueryParameter(QUERY_PARAM_NOTIFY, "true");
|
||||
if (values != null) {
|
||||
|
@ -332,8 +334,8 @@ public class StreamingService extends Service implements Constants {
|
|||
|
||||
@Override
|
||||
public void onStatus(final Status status) {
|
||||
final ContentValues values = ContentValuesCreator.createStatus(status, account.account_id,
|
||||
account.account_host);
|
||||
final ContentValues values = ContentValuesCreator.createStatus(status,
|
||||
new AccountKey(account.account_id, account.account_host));
|
||||
if (!statusStreamStarted) {
|
||||
statusStreamStarted = true;
|
||||
values.put(Statuses.IS_GAP, true);
|
||||
|
|
|
@ -66,8 +66,7 @@ public class CacheUsersStatusesTask extends AbstractTask<TwitterListResponse<Sta
|
|||
final Set<ContentValues> hashTagValues = new HashSet<>();
|
||||
|
||||
final AccountKey accountKey = params.mAccountKey;
|
||||
statusesValues.add(ContentValuesCreator.createStatus(status, accountKey.getId(),
|
||||
accountKey.getHost()));
|
||||
statusesValues.add(ContentValuesCreator.createStatus(status, accountKey));
|
||||
final String text = InternalTwitterContentUtils.unescapeTwitterStatusText(status.getText());
|
||||
for (final String hashtag : extractor.extractHashtags(text)) {
|
||||
final ContentValues values = new ContentValues();
|
||||
|
|
|
@ -35,8 +35,7 @@ public class GetSavedSearchesTask extends AbstractTask<AccountKey[], SingleRespo
|
|||
public SingleResponse<Object> doLongOperation(AccountKey[] params) {
|
||||
final ContentResolver cr = mContext.getContentResolver();
|
||||
for (AccountKey accountKey : params) {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mContext, accountKey.getId(),
|
||||
accountKey.getHost(), true);
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mContext, accountKey, true);
|
||||
if (twitter == null) continue;
|
||||
try {
|
||||
final ResponseList<SavedSearch> searches = twitter.getSavedSearches();
|
||||
|
|
|
@ -78,15 +78,14 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
@NonNull
|
||||
protected abstract Uri getContentUri();
|
||||
|
||||
private void storeStatus(final long accountId, final String accountHost,
|
||||
final List<Status> statuses,
|
||||
private void storeStatus(final AccountKey accountKey, final List<Status> statuses,
|
||||
final long sinceId, final long maxId, final boolean notify) {
|
||||
if (statuses == null || statuses.isEmpty() || accountId <= 0) {
|
||||
if (statuses == null || statuses.isEmpty() || accountKey == null) {
|
||||
return;
|
||||
}
|
||||
final Uri uri = getContentUri();
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final boolean noItemsBefore = DataStoreUtils.getStatusCount(context, uri, accountId) <= 0;
|
||||
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;
|
||||
|
@ -94,7 +93,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
boolean hasIntersection = false;
|
||||
for (int i = 0, j = statuses.size(); i < j; i++) {
|
||||
final Status status = statuses.get(i);
|
||||
values[i] = ContentValuesCreator.createStatus(status, accountId, accountHost);
|
||||
values[i] = ContentValuesCreator.createStatus(status, accountKey);
|
||||
values[i].put(Statuses.INSERTED_DATE, System.currentTimeMillis());
|
||||
final long id = status.getId();
|
||||
if (sinceId > 0 && id <= sinceId) {
|
||||
|
@ -107,13 +106,14 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
statusIds[i] = id;
|
||||
}
|
||||
// Delete all rows conflicting before new data inserted.
|
||||
final Expression accountWhere = Expression.equals(Statuses.ACCOUNT_ID, accountId);
|
||||
final Expression accountWhere = Utils.getAccountCompareExpression();
|
||||
final Expression statusWhere = Expression.in(new Columns.Column(Statuses.STATUS_ID),
|
||||
new RawItemArray(statusIds));
|
||||
final String countWhere = Expression.and(accountWhere, statusWhere).getSQL();
|
||||
String[] whereArgs = {String.valueOf(accountKey.getId()), accountKey.getHost()};
|
||||
final String[] projection = {SQLFunctions.COUNT()};
|
||||
final int rowsDeleted;
|
||||
final Cursor countCur = resolver.query(uri, projection, countWhere, null, null);
|
||||
final Cursor countCur = resolver.query(uri, projection, countWhere, whereArgs, null);
|
||||
try {
|
||||
if (countCur != null && countCur.moveToFirst()) {
|
||||
rowsDeleted = countCur.getInt(0);
|
||||
|
@ -126,7 +126,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
|
||||
// BEGIN HotMobi
|
||||
final RefreshEvent event = RefreshEvent.create(context, statusIds, getTimelineType());
|
||||
HotMobiLogger.getInstance(context).log(accountId, event);
|
||||
HotMobiLogger.getInstance(context).log(accountKey, event);
|
||||
// END HotMobi
|
||||
|
||||
// Insert a gap.
|
||||
|
@ -166,8 +166,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
int idx = 0;
|
||||
final int loadItemLimit = preferences.getInt(KEY_LOAD_ITEM_LIMIT, DEFAULT_LOAD_ITEM_LIMIT);
|
||||
for (final AccountKey accountKey : accountKeys) {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, accountKey.getId(),
|
||||
accountKey.getHost(), true);
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, accountKey, true);
|
||||
if (twitter == null) continue;
|
||||
try {
|
||||
final Paging paging = new Paging();
|
||||
|
@ -190,7 +189,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
|
|||
}
|
||||
final List<Status> statuses = getStatuses(twitter, paging);
|
||||
InternalTwitterContentUtils.getStatusesWithQuoteData(twitter, statuses);
|
||||
storeStatus(accountKey.getId(), accountKey.getHost(), statuses, sinceId, maxId, true);
|
||||
storeStatus(accountKey, statuses, sinceId, maxId, true);
|
||||
// TODO cache related data and preload
|
||||
final CacheUsersStatusesTask cacheTask = new CacheUsersStatusesTask(context);
|
||||
cacheTask.setParams(new TwitterWrapper.StatusListResponse(accountKey, statuses));
|
||||
|
|
|
@ -25,25 +25,26 @@ import android.text.style.URLSpan;
|
|||
import android.view.View;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||
|
||||
public class TwidereURLSpan extends URLSpan implements Constants {
|
||||
|
||||
private final int type, highlightStyle;
|
||||
private final long accountId;
|
||||
private final AccountKey accountKey;
|
||||
private final long extraId;
|
||||
private final String url, orig;
|
||||
private final boolean sensitive;
|
||||
private final OnLinkClickListener listener;
|
||||
private final int start, end;
|
||||
|
||||
public TwidereURLSpan(final String url, final String orig, final long accountId, final long extraId,
|
||||
public TwidereURLSpan(final String url, final String orig, final AccountKey accountKey, final long extraId,
|
||||
final int type, final boolean sensitive, final int highlightStyle, int start, int end,
|
||||
final OnLinkClickListener listener) {
|
||||
super(url);
|
||||
this.url = url;
|
||||
this.orig = orig;
|
||||
this.accountId = accountId;
|
||||
this.accountKey = accountKey;
|
||||
this.extraId = extraId;
|
||||
this.type = type;
|
||||
this.sensitive = sensitive;
|
||||
|
@ -56,7 +57,7 @@ public class TwidereURLSpan extends URLSpan implements Constants {
|
|||
@Override
|
||||
public void onClick(@NonNull final View widget) {
|
||||
if (listener != null) {
|
||||
listener.onLinkClick(url, orig, accountId, extraId, type, sensitive, start, end);
|
||||
listener.onLinkClick(url, orig, accountKey, extraId, type, sensitive, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -222,12 +222,13 @@ public final class ContentValuesCreator implements TwidereConstants {
|
|||
return values;
|
||||
}
|
||||
|
||||
public static ContentValues createMessageDraft(final long accountId, final long recipientId,
|
||||
public static ContentValues createMessageDraft(final AccountKey accountKey, final long 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[]{accountId}, ',', false));
|
||||
values.put(Drafts.ACCOUNT_IDS, TwidereArrayUtils.toString(new long[]{accountKey.getId()},
|
||||
',', false));
|
||||
values.put(Drafts.TIMESTAMP, System.currentTimeMillis());
|
||||
if (imageUri != null) {
|
||||
final ParcelableMediaUpdate[] mediaArray = {new ParcelableMediaUpdate(imageUri, 0)};
|
||||
|
|
|
@ -241,9 +241,10 @@ public class DataStoreUtils implements Constants {
|
|||
Activities.MAX_POSITION, new OrderBy(SQLFunctions.MIN(Activities.TIMESTAMP)));
|
||||
}
|
||||
|
||||
public static int getStatusCount(final Context context, final Uri uri, final long accountId) {
|
||||
final String where = Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL();
|
||||
return queryCount(context, uri, where, null);
|
||||
public static int getStatusCount(final Context context, final Uri uri, final AccountKey accountId) {
|
||||
final String where = Utils.getAccountCompareExpression().getSQL();
|
||||
final String[] whereArgs = {String.valueOf(accountId.getId()), accountId.getHost()};
|
||||
return queryCount(context, uri, where, whereArgs);
|
||||
}
|
||||
|
||||
public static int getActivitiesCount(final Context context, final Uri uri, final AccountKey accountKey) {
|
||||
|
|
|
@ -79,11 +79,11 @@ public class IntentUtils implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
public static void openUserProfile(final Context context, final long accountId, final long userId,
|
||||
final String screenName, final Bundle activityOptions,
|
||||
final boolean newDocument,
|
||||
public static void openUserProfile(final Context context, @Nullable final AccountKey accountId,
|
||||
final long userId, final String screenName,
|
||||
final Bundle activityOptions, final boolean newDocument,
|
||||
@UserFragment.Referral final String referral) {
|
||||
if (context == null || accountId <= 0 || userId <= 0 && isEmpty(screenName)) return;
|
||||
if (context == null || userId <= 0 && isEmpty(screenName)) return;
|
||||
final Uri uri = LinkCreator.getTwidereUserLink(accountId, userId, screenName);
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
intent.putExtra(EXTRA_REFERRAL, referral);
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
|
||||
/**
|
||||
|
@ -42,23 +44,23 @@ public class LinkCreator implements Constants {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public static Uri getTwidereStatusLink(long accountId, long statusId) {
|
||||
public static Uri getTwidereStatusLink(AccountKey accountKey, long statusId) {
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_STATUS);
|
||||
if (accountId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString());
|
||||
}
|
||||
builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(statusId));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static Uri getTwidereUserLink(long accountId, long userId, String screenName) {
|
||||
public static Uri getTwidereUserLink(@Nullable AccountKey accountId, long userId, String screenName) {
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_USER);
|
||||
if (accountId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
|
||||
if (accountId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountId.toString());
|
||||
}
|
||||
if (userId > 0) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
|||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
|
@ -109,16 +110,17 @@ public class MediaLoaderWrapper implements Constants {
|
|||
mImageLoader.displayImage(url, view, mImageDisplayOptions, loadingHandler, loadingHandler);
|
||||
}
|
||||
|
||||
public void displayPreviewImageWithCredentials(final ImageView view, final String url, final long accountId,
|
||||
public void displayPreviewImageWithCredentials(final ImageView view, final String url,
|
||||
final AccountKey accountKey,
|
||||
final MediaLoadingHandler loadingHandler) {
|
||||
if (accountId <= 0) {
|
||||
if (accountKey == null) {
|
||||
displayPreviewImage(view, url, loadingHandler);
|
||||
return;
|
||||
}
|
||||
final DisplayImageOptions.Builder b = new DisplayImageOptions.Builder();
|
||||
b.cloneFrom(mImageDisplayOptions);
|
||||
MediaExtra extra = new MediaExtra();
|
||||
extra.setAccountId(accountId);
|
||||
extra.setAccountKey(accountKey);
|
||||
b.extraForDownloader(extra);
|
||||
mImageLoader.displayImage(url, view, b.build(), loadingHandler, loadingHandler);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.support.annotation.Nullable;
|
|||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||
|
@ -50,30 +51,30 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLinkClick(final String link, final String orig, final long accountId,
|
||||
public void onLinkClick(final String link, final String orig, final AccountKey accountKey,
|
||||
final long extraId, final int type, final boolean sensitive,
|
||||
final int start, final int end) {
|
||||
if (manager != null && manager.isActive()) return;
|
||||
if (!isPrivateData()) {
|
||||
// BEGIN HotMobi
|
||||
final LinkEvent event = LinkEvent.create(context, link, type);
|
||||
HotMobiLogger.getInstance(context).log(accountId, event);
|
||||
HotMobiLogger.getInstance(context).log(accountKey, event);
|
||||
// END HotMobi
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TwidereLinkify.LINK_TYPE_MENTION: {
|
||||
IntentUtils.openUserProfile(context, accountId, -1, link, null, true,
|
||||
IntentUtils.openUserProfile(context, accountKey, -1, link, null, true,
|
||||
UserFragment.Referral.USER_MENTION);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_HASHTAG: {
|
||||
Utils.openTweetSearch(context, accountId, "#" + link);
|
||||
Utils.openTweetSearch(context, accountKey, "#" + link);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_ENTITY_URL: {
|
||||
if (PreviewMediaExtractor.isSupported(link)) {
|
||||
openMedia(accountId, extraId, sensitive, link, start, end);
|
||||
openMedia(accountKey, extraId, sensitive, link, start, end);
|
||||
} else {
|
||||
openLink(link);
|
||||
}
|
||||
|
@ -84,20 +85,20 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
|||
if (mentionList.length != 2) {
|
||||
break;
|
||||
}
|
||||
Utils.openUserListDetails(context, accountId, -1, -1, mentionList[0], mentionList[1]);
|
||||
Utils.openUserListDetails(context, accountKey, -1, -1, mentionList[0], mentionList[1]);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_CASHTAG: {
|
||||
Utils.openTweetSearch(context, accountId, link);
|
||||
Utils.openTweetSearch(context, accountKey, link);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_USER_ID: {
|
||||
IntentUtils.openUserProfile(context, accountId, NumberUtils.toLong(link, -1), null,
|
||||
IntentUtils.openUserProfile(context, accountKey, NumberUtils.toLong(link, -1), null,
|
||||
null, true, UserFragment.Referral.USER_MENTION);
|
||||
break;
|
||||
}
|
||||
case TwidereLinkify.LINK_TYPE_STATUS: {
|
||||
Utils.openStatus(context, accountId, NumberUtils.toLong(link, -1));
|
||||
Utils.openStatus(context, accountKey, NumberUtils.toLong(link, -1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -107,9 +108,9 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
|
||||
protected void openMedia(AccountKey accountKey, long extraId, boolean sensitive, String link, int start, int end) {
|
||||
final ParcelableMedia[] media = {ParcelableMediaUtils.image(link)};
|
||||
IntentUtils.openMedia(context, accountId, sensitive, null, media, null, true);
|
||||
IntentUtils.openMedia(context, accountKey, sensitive, null, media, null, true);
|
||||
}
|
||||
|
||||
protected void openLink(final String link) {
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
|
||||
|
@ -32,7 +33,8 @@ public class StatusLinkClickHandler extends OnLinkClickHandler {
|
|||
private ParcelableStatus mStatus;
|
||||
|
||||
@Override
|
||||
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
|
||||
protected void openMedia(final AccountKey accountId, final long extraId, final boolean sensitive,
|
||||
final String link, final int start, final int end) {
|
||||
final ParcelableStatus status = mStatus;
|
||||
final ParcelableMedia current = findByLink(status.media, link);
|
||||
if (current.open_browser) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.twitter.Extractor.Entity;
|
|||
import com.twitter.Regex;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.text.TwidereURLSpan;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -61,6 +62,7 @@ public final class TwidereLinkify implements Constants {
|
|||
|
||||
public static final int LINK_TYPE_MENTION = 1;
|
||||
public static final int LINK_TYPE_HASHTAG = 2;
|
||||
public static final int LINK_TYPE_BANGTAG = 3;
|
||||
public static final int LINK_TYPE_ENTITY_URL = 4;
|
||||
public static final int LINK_TYPE_LINK_IN_TEXT = 5;
|
||||
public static final int LINK_TYPE_LIST = 6;
|
||||
|
@ -108,47 +110,47 @@ public final class TwidereLinkify implements Constants {
|
|||
setHighlightOption(highlightOption);
|
||||
}
|
||||
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId,
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final AccountKey accountKey,
|
||||
final long extraId, final boolean sensitive,
|
||||
final boolean skipLinksInText) {
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive,
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive,
|
||||
mHighlightOption, skipLinksInText);
|
||||
}
|
||||
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId,
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final AccountKey accountKey,
|
||||
final boolean sensitive, final boolean skipLinksInText) {
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountId, -1, sensitive, mHighlightOption, skipLinksInText);
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountKey, -1, sensitive, mHighlightOption, skipLinksInText);
|
||||
}
|
||||
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId,
|
||||
public SpannableString applyAllLinks(@Nullable CharSequence text, final AccountKey accountKey,
|
||||
final long extraId, final boolean sensitive,
|
||||
final int highlightOption, final boolean skipLinksInText) {
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive, highlightOption, skipLinksInText);
|
||||
return applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive, highlightOption, skipLinksInText);
|
||||
}
|
||||
|
||||
public SpannableString applyAllLinks(@Nullable final CharSequence text, final OnLinkClickListener listener,
|
||||
final long accountId, final long extraId, final boolean sensitive,
|
||||
final AccountKey accountKey, final long extraId, final boolean sensitive,
|
||||
final int highlightOption, boolean skipLinksInText) {
|
||||
if (text == null) return null;
|
||||
final SpannableString string = SpannableString.valueOf(text);
|
||||
for (final int type : ALL_LINK_TYPES) {
|
||||
if (type == LINK_TYPE_LINK_IN_TEXT && skipLinksInText) continue;
|
||||
addLinks(string, accountId, extraId, type, sensitive, listener, highlightOption);
|
||||
addLinks(string, accountKey, extraId, type, sensitive, listener, highlightOption);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public SpannableString applyUserProfileLink(final CharSequence text, final long accountId, final long extraId,
|
||||
public SpannableString applyUserProfileLink(final CharSequence text, final AccountKey accountKey, final long extraId,
|
||||
final long userId, final String screenName) {
|
||||
return applyUserProfileLink(text, accountId, extraId, userId, screenName, mHighlightOption);
|
||||
return applyUserProfileLink(text, accountKey, extraId, userId, screenName, mHighlightOption);
|
||||
}
|
||||
|
||||
public SpannableString applyUserProfileLink(final CharSequence text, final long accountId, final long extraId,
|
||||
public SpannableString applyUserProfileLink(final CharSequence text, final AccountKey accountKey, final long extraId,
|
||||
final long userId, final String screenName, final int highlightOption) {
|
||||
return applyUserProfileLink(text, accountId, extraId, userId, screenName, highlightOption, mOnLinkClickListener);
|
||||
return applyUserProfileLink(text, accountKey, extraId, userId, screenName, highlightOption, mOnLinkClickListener);
|
||||
}
|
||||
|
||||
public final SpannableString applyUserProfileLink(final CharSequence text, final long accountId,
|
||||
public final SpannableString applyUserProfileLink(final CharSequence text, final AccountKey accountKey,
|
||||
final long extraId, final long userId,
|
||||
final String screenName, final int highlightOption,
|
||||
final OnLinkClickListener listener) {
|
||||
|
@ -158,10 +160,10 @@ public final class TwidereLinkify implements Constants {
|
|||
string.removeSpan(span);
|
||||
}
|
||||
if (userId > 0) {
|
||||
applyLink(String.valueOf(userId), 0, string.length(), string, accountId, extraId,
|
||||
applyLink(String.valueOf(userId), 0, string.length(), string, accountKey, extraId,
|
||||
LINK_TYPE_USER_ID, false, highlightOption, listener);
|
||||
} else if (screenName != null) {
|
||||
applyLink(screenName, 0, string.length(), string, accountId, extraId,
|
||||
applyLink(screenName, 0, string.length(), string, accountKey, extraId,
|
||||
LINK_TYPE_MENTION, false, highlightOption, listener);
|
||||
}
|
||||
return string;
|
||||
|
@ -171,20 +173,20 @@ public final class TwidereLinkify implements Constants {
|
|||
mHighlightOption = style;
|
||||
}
|
||||
|
||||
private boolean addCashtagLinks(final Spannable spannable, final long accountId, final long extraId,
|
||||
private boolean addCashtagLinks(final Spannable spannable, final AccountKey accountKey, final long extraId,
|
||||
final OnLinkClickListener listener, final int highlightOption) {
|
||||
boolean hasMatches = false;
|
||||
for (final Entity entity : mExtractor.extractCashtagsWithIndices(spannable.toString())) {
|
||||
final int start = entity.getStart();
|
||||
final int end = entity.getEnd();
|
||||
applyLink(entity.getValue(), start, end, spannable, accountId, extraId, LINK_TYPE_CASHTAG,
|
||||
applyLink(entity.getValue(), start, end, spannable, accountKey, extraId, LINK_TYPE_CASHTAG,
|
||||
false, highlightOption, listener);
|
||||
hasMatches = true;
|
||||
}
|
||||
return hasMatches;
|
||||
}
|
||||
|
||||
private boolean addHashtagLinks(final Spannable spannable, final long accountId, final long extraId,
|
||||
private boolean addHashtagLinks(final Spannable spannable, final AccountKey accountId, final long extraId,
|
||||
final OnLinkClickListener listener, final int highlightOption) {
|
||||
boolean hasMatches = false;
|
||||
for (final Entity entity : mExtractor.extractHashtagsWithIndices(spannable.toString())) {
|
||||
|
@ -200,15 +202,15 @@ public final class TwidereLinkify implements Constants {
|
|||
/**
|
||||
* Applies a regex to the text of a TextView turning the matches into links.
|
||||
*/
|
||||
private void addLinks(final SpannableString string, final long accountId, final long extraId, final int type,
|
||||
private void addLinks(final SpannableString string, final AccountKey accountKey, final long extraId, final int type,
|
||||
final boolean sensitive, final OnLinkClickListener listener, final int highlightOption) {
|
||||
switch (type) {
|
||||
case LINK_TYPE_MENTION: {
|
||||
addMentionOrListLinks(string, accountId, extraId, highlightOption, listener);
|
||||
addMentionOrListLinks(string, accountKey, extraId, highlightOption, listener);
|
||||
break;
|
||||
}
|
||||
case LINK_TYPE_HASHTAG: {
|
||||
addHashtagLinks(string, accountId, extraId, listener, highlightOption);
|
||||
addHashtagLinks(string, accountKey, extraId, listener, highlightOption);
|
||||
break;
|
||||
}
|
||||
case LINK_TYPE_ENTITY_URL: {
|
||||
|
@ -220,7 +222,7 @@ public final class TwidereLinkify implements Constants {
|
|||
continue;
|
||||
}
|
||||
string.removeSpan(span);
|
||||
applyLink(span.getURL(), start, end, string, accountId, extraId, LINK_TYPE_ENTITY_URL, sensitive, highlightOption, listener);
|
||||
applyLink(span.getURL(), start, end, string, accountKey, extraId, LINK_TYPE_ENTITY_URL, sensitive, highlightOption, listener);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -232,7 +234,7 @@ public final class TwidereLinkify implements Constants {
|
|||
|| string.getSpans(start, end, URLSpan.class).length > 0) {
|
||||
continue;
|
||||
}
|
||||
applyLink(entity.getValue(), start, end, string, accountId, extraId, LINK_TYPE_ENTITY_URL, sensitive, highlightOption, listener);
|
||||
applyLink(entity.getValue(), start, end, string, accountKey, extraId, LINK_TYPE_ENTITY_URL, sensitive, highlightOption, listener);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -245,19 +247,19 @@ public final class TwidereLinkify implements Constants {
|
|||
final int end = string.getSpanEnd(span);
|
||||
final String url = matcherGroup(matcher, GROUP_ID_TWITTER_STATUS_STATUS_ID);
|
||||
string.removeSpan(span);
|
||||
applyLink(url, start, end, string, accountId, extraId, LINK_TYPE_STATUS, sensitive, highlightOption, listener);
|
||||
applyLink(url, start, end, string, accountKey, extraId, LINK_TYPE_STATUS, sensitive, highlightOption, listener);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LINK_TYPE_CASHTAG: {
|
||||
addCashtagLinks(string, accountId, extraId, listener, highlightOption);
|
||||
addCashtagLinks(string, accountKey, extraId, listener, highlightOption);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addMentionOrListLinks(final Spannable spannable, final long accountId,
|
||||
private boolean addMentionOrListLinks(final Spannable spannable, final AccountKey accountKey,
|
||||
final long extraId, final int highlightOption, final OnLinkClickListener listener) {
|
||||
boolean hasMatches = false;
|
||||
// Extract lists from status text
|
||||
|
@ -269,11 +271,11 @@ public final class TwidereLinkify implements Constants {
|
|||
final int listEnd = matcherEnd(matcher, Regex.VALID_MENTION_OR_LIST_GROUP_LIST);
|
||||
final String username = matcherGroup(matcher, Regex.VALID_MENTION_OR_LIST_GROUP_USERNAME);
|
||||
final String list = matcherGroup(matcher, Regex.VALID_MENTION_OR_LIST_GROUP_LIST);
|
||||
applyLink(username, start, username_end, spannable, accountId, extraId, LINK_TYPE_MENTION,
|
||||
applyLink(username, start, username_end, spannable, accountKey, extraId, LINK_TYPE_MENTION,
|
||||
false, highlightOption, listener);
|
||||
if (listStart >= 0 && listEnd >= 0 && list != null) {
|
||||
applyLink(String.format("%s/%s", username, list.substring(list.startsWith("/") ? 1 : 0)), listStart,
|
||||
listEnd, spannable, accountId, extraId, LINK_TYPE_LIST, false, highlightOption, listener);
|
||||
listEnd, spannable, accountKey, extraId, LINK_TYPE_LIST, false, highlightOption, listener);
|
||||
}
|
||||
hasMatches = true;
|
||||
}
|
||||
|
@ -287,7 +289,7 @@ public final class TwidereLinkify implements Constants {
|
|||
final String screenName = matcherGroup(m, GROUP_ID_TWITTER_LIST_SCREEN_NAME);
|
||||
final String listName = matcherGroup(m, GROUP_ID_TWITTER_LIST_LIST_NAME);
|
||||
spannable.removeSpan(span);
|
||||
applyLink(screenName + "/" + listName, start, end, spannable, accountId, extraId,
|
||||
applyLink(screenName + "/" + listName, start, end, spannable, accountKey, extraId,
|
||||
LINK_TYPE_LIST, false, highlightOption, listener);
|
||||
hasMatches = true;
|
||||
}
|
||||
|
@ -296,17 +298,17 @@ public final class TwidereLinkify implements Constants {
|
|||
}
|
||||
|
||||
private void applyLink(final String url, final String orig, final int start, final int end,
|
||||
final Spannable text, final long accountId, final long extraId, final int type, final boolean sensitive,
|
||||
final Spannable text, final AccountKey accountKey, final long extraId, final int type, final boolean sensitive,
|
||||
final int highlightOption, final OnLinkClickListener listener) {
|
||||
final TwidereURLSpan span = new TwidereURLSpan(url, orig, accountId, extraId, type, sensitive,
|
||||
final TwidereURLSpan span = new TwidereURLSpan(url, orig, accountKey, extraId, type, sensitive,
|
||||
highlightOption, start, end, listener);
|
||||
text.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
private void applyLink(final String url, final int start, final int end, final Spannable text,
|
||||
final long accountId, final long extraId, final int type, final boolean sensitive,
|
||||
final AccountKey accountKey, final long extraId, final int type, final boolean sensitive,
|
||||
final int highlightOption, final OnLinkClickListener listener) {
|
||||
applyLink(url, null, start, end, text, accountId, extraId, type, sensitive, highlightOption,
|
||||
applyLink(url, null, start, end, text, accountKey, extraId, type, sensitive, highlightOption,
|
||||
listener);
|
||||
}
|
||||
|
||||
|
@ -318,7 +320,7 @@ public final class TwidereLinkify implements Constants {
|
|||
}
|
||||
|
||||
public interface OnLinkClickListener {
|
||||
void onLinkClick(String link, String orig, long accountId, long extraId, int type,
|
||||
void onLinkClick(String link, String orig, AccountKey accountKey, long extraId, int type,
|
||||
boolean sensitive, int start, int end);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -866,7 +866,7 @@ public final class Utils implements Constants {
|
|||
|
||||
@NonNull
|
||||
public static ParcelableStatus findStatus(final Context context, final AccountKey accountKey,
|
||||
final String accountHost, final long statusId)
|
||||
final long statusId)
|
||||
throws TwitterException {
|
||||
if (context == null) throw new NullPointerException();
|
||||
final ParcelableStatus cached = findStatusInDatabases(context, accountKey, statusId);
|
||||
|
@ -1793,23 +1793,24 @@ public final class Utils implements Constants {
|
|||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void openStatus(final Context context, final long accountId, final long statusId) {
|
||||
if (context == null || accountId <= 0 || statusId <= 0) return;
|
||||
final Uri uri = LinkCreator.getTwidereStatusLink(accountId, statusId);
|
||||
public static void openStatus(final Context context, final AccountKey accountKey, final long statusId) {
|
||||
if (context == null || statusId <= 0) return;
|
||||
final Uri uri = LinkCreator.getTwidereStatusLink(accountKey, statusId);
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void openStatus(final Context context, final ParcelableStatus status, Bundle activityOptions) {
|
||||
if (context == null || status == null) return;
|
||||
final long account_id = status.account_id, status_id = status.id;
|
||||
final AccountKey accountKey = new AccountKey(status.account_id, status.account_host);
|
||||
final long statusId = status.id;
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putParcelable(EXTRA_STATUS, status);
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(SCHEME_TWIDERE);
|
||||
builder.authority(AUTHORITY_STATUS);
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
|
||||
builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString());
|
||||
builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(statusId));
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||
intent.setExtrasClassLoader(context.getClassLoader());
|
||||
intent.putExtras(extras);
|
||||
|
@ -1921,7 +1922,7 @@ public final class Utils implements Constants {
|
|||
|
||||
}
|
||||
|
||||
public static void openUserListDetails(final Context context, final long accountId, final long listId,
|
||||
public static void openUserListDetails(final Context context, final AccountKey accountId, final long listId,
|
||||
final long userId, final String screenName, final String listName) {
|
||||
if (context == null) return;
|
||||
final Uri.Builder builder = new Uri.Builder();
|
||||
|
@ -2505,12 +2506,15 @@ public final class Utils implements Constants {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static ParcelableUser getUserForConversation(Context context, long accountId,
|
||||
public static ParcelableUser getUserForConversation(Context context, AccountKey accountKey,
|
||||
long conversationId) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final Expression where = Expression.and(Expression.equals(ConversationEntries.ACCOUNT_ID, accountId),
|
||||
Expression.equals(ConversationEntries.CONVERSATION_ID, conversationId));
|
||||
final Cursor c = cr.query(ConversationEntries.CONTENT_URI, null, where.getSQL(), null, null);
|
||||
final Expression where = Expression.and(getAccountCompareExpression(),
|
||||
Expression.equalsArgs(ConversationEntries.CONVERSATION_ID));
|
||||
final String[] whereArgs = {String.valueOf(accountKey.getId()), accountKey.getHost(),
|
||||
String.valueOf(conversationId)};
|
||||
final Cursor c = cr.query(ConversationEntries.CONTENT_URI, null, where.getSQL(), whereArgs,
|
||||
null);
|
||||
if (c == null) return null;
|
||||
try {
|
||||
if (c.moveToFirst()) return ParcelableUserUtils.fromDirectMessageConversationEntry(c);
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package org.mariotaku.twidere.util.media;
|
||||
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/1/28.
|
||||
*/
|
||||
public class MediaExtra {
|
||||
long accountId;
|
||||
AccountKey accountKey;
|
||||
boolean useThumbor = true;
|
||||
String fallbackUrl;
|
||||
boolean skipUrlReplacing;
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
public AccountKey getAccountKey() {
|
||||
return accountKey;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
public void setAccountKey(AccountKey accountKey) {
|
||||
this.accountKey = accountKey;
|
||||
}
|
||||
|
||||
public boolean isUseThumbor() {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class TwidereMediaDownloader implements MediaDownloader, Constants {
|
|||
final boolean useThumbor;
|
||||
if (extra instanceof MediaExtra) {
|
||||
useThumbor = ((MediaExtra) extra).isUseThumbor();
|
||||
account = DataStoreUtils.getCredentials(mContext, ((MediaExtra) extra).getAccountId());
|
||||
account = DataStoreUtils.getCredentials(mContext, ((MediaExtra) extra).getAccountKey());
|
||||
auth = TwitterAPIFactory.getAuthorization(account);
|
||||
} else {
|
||||
useThumbor = true;
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.widget.TextView;
|
|||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
|
@ -90,7 +91,7 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
|
||||
public void displayMedia(@Nullable final ParcelableMedia[] mediaArray,
|
||||
@NonNull final MediaLoaderWrapper loader,
|
||||
final long accountId, final long extraId,
|
||||
final AccountKey accountId, final long extraId,
|
||||
final OnMediaClickListener mediaClickListener,
|
||||
final MediaLoadingHandler loadingHandler) {
|
||||
displayMedia(mediaArray, loader, accountId, extraId, false, mediaClickListener,
|
||||
|
@ -99,7 +100,7 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
|
||||
public void displayMedia(@Nullable final ParcelableMedia[] mediaArray,
|
||||
@NonNull final MediaLoaderWrapper loader,
|
||||
final long accountId, final long extraId, boolean withCredentials,
|
||||
final AccountKey accountId, final long extraId, boolean withCredentials,
|
||||
final OnMediaClickListener mediaClickListener,
|
||||
final MediaLoadingHandler loadingHandler) {
|
||||
if (mediaArray == null || mMediaPreviewStyle == VALUE_MEDIA_PREVIEW_STYLE_CODE_NONE) {
|
||||
|
@ -300,18 +301,18 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
}
|
||||
|
||||
public interface OnMediaClickListener {
|
||||
void onMediaClick(View view, ParcelableMedia media, long accountId, long id);
|
||||
void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long id);
|
||||
}
|
||||
|
||||
private static class ImageGridClickListener implements View.OnClickListener {
|
||||
private final WeakReference<OnMediaClickListener> mListenerRef;
|
||||
private final long mAccountId;
|
||||
private final AccountKey mAccountKey;
|
||||
private final long mExtraId;
|
||||
|
||||
ImageGridClickListener(final OnMediaClickListener listener, final long accountId,
|
||||
ImageGridClickListener(final OnMediaClickListener listener, final AccountKey accountKey,
|
||||
final long extraId) {
|
||||
mListenerRef = new WeakReference<>(listener);
|
||||
mAccountId = accountId;
|
||||
mAccountKey = accountKey;
|
||||
mExtraId = extraId;
|
||||
}
|
||||
|
||||
|
@ -319,7 +320,7 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
public void onClick(final View v) {
|
||||
final OnMediaClickListener listener = mListenerRef.get();
|
||||
if (listener == null) return;
|
||||
listener.onMediaClick(v, (ParcelableMedia) v.getTag(), mAccountId, mExtraId);
|
||||
listener.onMediaClick(v, (ParcelableMedia) v.getTag(), mAccountKey, mExtraId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.ImageView;
|
|||
|
||||
import org.mariotaku.twidere.adapter.iface.ContentCardClickListener;
|
||||
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
|
||||
import org.mariotaku.twidere.model.AccountKey;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer;
|
||||
|
@ -47,7 +48,7 @@ public interface IStatusViewHolder extends CardMediaContainer.OnMediaClickListen
|
|||
ImageView getProfileTypeView();
|
||||
|
||||
@Override
|
||||
void onMediaClick(View view, ParcelableMedia media, long accountId, long extraId);
|
||||
void onMediaClick(View view, ParcelableMedia media, AccountKey accountKey, long extraId);
|
||||
|
||||
void setStatusClickListener(StatusClickListener listener);
|
||||
|
||||
|
|
Loading…
Reference in New Issue