improved status interactions
This commit is contained in:
parent
4e6d3f7dee
commit
400b33d485
|
@ -86,13 +86,13 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
|
|||
Contributor[] contributors;
|
||||
|
||||
@JsonField(name = "retweet_count")
|
||||
long retweetCount;
|
||||
long retweetCount = -1;
|
||||
|
||||
@JsonField(name = "favorite_count")
|
||||
long favoriteCount;
|
||||
long favoriteCount = -1;
|
||||
|
||||
@JsonField(name = "reply_count")
|
||||
long replyCount;
|
||||
long replyCount = -1;
|
||||
|
||||
@JsonField(name = "favorited")
|
||||
boolean favorited;
|
||||
|
|
|
@ -43,6 +43,9 @@ import java.util.Arrays;
|
|||
@CursorObject(valuesCreator = true)
|
||||
public class ParcelableActivity implements Comparable<ParcelableActivity>, Parcelable {
|
||||
|
||||
@ParcelableThisPlease
|
||||
@CursorField(value = Activities._ID, excludeWrite = true)
|
||||
public long _id;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "account_id")
|
||||
@CursorField(value = Activities.ACCOUNT_ID)
|
||||
|
|
|
@ -889,6 +889,7 @@ public interface TwidereDataStore {
|
|||
String RAW_ACTION = "raw_action";
|
||||
String TIMESTAMP = "timestamp";
|
||||
String STATUS_ID = "status_id";
|
||||
String STATUS_RETWEET_ID = "status_retweet_id";
|
||||
String STATUS_USER_ID = "status_user_id";
|
||||
String STATUS_RETWEETED_BY_USER_ID = "status_retweeted_by_user_id";
|
||||
String STATUS_QUOTED_USER_ID = "status_quoted_user_id";
|
||||
|
@ -914,11 +915,12 @@ public interface TwidereDataStore {
|
|||
STATUS_RETWEETED_BY_USER_ID, STATUS_QUOTED_USER_ID, STATUS_SOURCE, STATUS_QUOTE_SOURCE,
|
||||
STATUS_TEXT_PLAIN, STATUS_QUOTE_TEXT_PLAIN, STATUS_TEXT_HTML, STATUS_QUOTE_TEXT_HTML,
|
||||
IS_GAP, MIN_POSITION, MAX_POSITION, SOURCES, SOURCE_IDS, TARGET_STATUSES, TARGET_USERS,
|
||||
TARGET_USER_LISTS, TARGET_OBJECT_STATUSES, TARGET_OBJECT_USER_LISTS, TARGET_OBJECT_USERS};
|
||||
TARGET_USER_LISTS, TARGET_OBJECT_STATUSES, TARGET_OBJECT_USER_LISTS, TARGET_OBJECT_USERS,
|
||||
STATUS_RETWEET_ID};
|
||||
String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_BOOLEAN, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT};
|
||||
TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT};
|
||||
|
||||
String DEFAULT_SORT_ORDER = TIMESTAMP + " DESC";
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import static org.mariotaku.twidere.annotation.Preference.Type.STRING;
|
|||
public interface Constants extends TwidereConstants {
|
||||
|
||||
String DATABASES_NAME = "twidere.sqlite";
|
||||
int DATABASES_VERSION = 115;
|
||||
int DATABASES_VERSION = 116;
|
||||
|
||||
int MENU_GROUP_STATUS_EXTENSION = 10;
|
||||
int MENU_GROUP_COMPOSE_EXTENSION = 11;
|
||||
|
|
|
@ -22,11 +22,14 @@ package org.mariotaku.twidere.fragment.support;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.nfc.NdefMessage;
|
||||
|
@ -43,6 +46,7 @@ import android.support.v4.app.FragmentManager;
|
|||
import android.support.v4.app.FragmentManagerTrojan;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.ActionMenuView;
|
||||
|
@ -76,25 +80,34 @@ import android.widget.TextView;
|
|||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
|
||||
import org.mariotaku.twidere.adapter.AbsStatusesAdapter.StatusAdapterListener;
|
||||
import org.mariotaku.twidere.adapter.ArrayRecyclerAdapter;
|
||||
import org.mariotaku.twidere.adapter.BaseRecyclerViewAdapter;
|
||||
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
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.Status;
|
||||
import org.mariotaku.twidere.api.twitter.model.TranslationResult;
|
||||
import org.mariotaku.twidere.constant.IntentConstants;
|
||||
import org.mariotaku.twidere.loader.support.ParcelableStatusLoader;
|
||||
import org.mariotaku.twidere.loader.support.StatusRepliesLoader;
|
||||
import org.mariotaku.twidere.model.ListResponse;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableActivityCursorIndices;
|
||||
import org.mariotaku.twidere.model.ParcelableActivityValuesCreator;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableLocation;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.CompareUtils;
|
||||
|
@ -150,6 +163,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
// Constants
|
||||
private static final int LOADER_ID_DETAIL_STATUS = 1;
|
||||
private static final int LOADER_ID_STATUS_REPLIES = 2;
|
||||
private static final int LOADER_ID_STATUS_ACTIVITY = 3;
|
||||
private static final int STATE_LOADED = 1;
|
||||
private static final int STATE_LOADING = 2;
|
||||
private static final int STATE_ERROR = 3;
|
||||
|
@ -172,6 +186,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
|
||||
// Data fields
|
||||
private boolean mRepliesLoaderInitialized;
|
||||
private boolean mActivityLoaderInitialized;
|
||||
private ParcelableStatus mSelectedStatus;
|
||||
private TweetEvent mStatusEvent;
|
||||
|
||||
|
@ -234,6 +249,25 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
|
||||
}
|
||||
};
|
||||
private LoaderCallbacks<StatusActivity> mStatusActivityLoaderCallback = new LoaderCallbacks<StatusActivity>() {
|
||||
@Override
|
||||
public Loader<StatusActivity> onCreateLoader(int id, Bundle args) {
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
|
||||
return new StatusActivitySummaryLoader(getActivity(), accountId, statusId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<StatusActivity> loader, StatusActivity data) {
|
||||
mStatusAdapter.updateItemDecoration();
|
||||
mStatusAdapter.setStatusActivity(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<StatusActivity> loader) {
|
||||
|
||||
}
|
||||
};
|
||||
private OnMenuItemClickListener mOnStatusMenuItemClickListener = new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
@ -509,6 +543,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
mStatusAdapter.setReplies(null);
|
||||
loadConversation(status);
|
||||
loadReplies(status);
|
||||
loadActivity(status);
|
||||
|
||||
final int position = mStatusAdapter.getFirstPositionOfItem(StatusAdapter.ITEM_IDX_STATUS);
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
|
@ -606,6 +641,20 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
mRepliesLoaderInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
private void loadActivity(ParcelableStatus status) {
|
||||
if (status == null) return;
|
||||
final Bundle args = new Bundle();
|
||||
args.putLong(EXTRA_ACCOUNT_ID, status.account_id);
|
||||
args.putLong(EXTRA_STATUS_ID, status.is_retweet ? status.retweet_id : status.id);
|
||||
if (mActivityLoaderInitialized) {
|
||||
getLoaderManager().restartLoader(LOADER_ID_STATUS_ACTIVITY, args, mStatusActivityLoaderCallback);
|
||||
return;
|
||||
}
|
||||
getLoaderManager().initLoader(LOADER_ID_STATUS_ACTIVITY, args, mStatusActivityLoaderCallback);
|
||||
mActivityLoaderInitialized = true;
|
||||
}
|
||||
|
||||
private void loadTranslation(@Nullable ParcelableStatus status) {
|
||||
if (status == null) return;
|
||||
if (AsyncTaskUtils.isTaskRunning(mLoadTranslationTask)) {
|
||||
|
@ -875,8 +924,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private final ImageView profileTypeView;
|
||||
private final TextView timeSourceView;
|
||||
private final TextView retweetedByView;
|
||||
private final View repliesContainer, retweetsContainer, favoritesContainer;
|
||||
private final TextView repliesCountView, retweetsCountView, favoritesCountView;
|
||||
private final View retweetsContainer, favoritesContainer;
|
||||
private final TextView retweetsCountView, favoritesCountView;
|
||||
private final View countsContainer;
|
||||
|
||||
private final TextView quoteOriginalLink;
|
||||
private final ColorLabelRelativeLayout profileContainer;
|
||||
|
@ -892,9 +942,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private final TwitterCardContainer twitterCard;
|
||||
private final StatusLinkClickHandler linkClickHandler;
|
||||
private final TwidereLinkify linkify;
|
||||
private final TextView favoritesLabel;
|
||||
private final TextView retweetsLabel, favoritesLabel;
|
||||
private final View translateContainer;
|
||||
private final TextView translateResultView;
|
||||
private final RecyclerView interactUsersView;
|
||||
|
||||
public DetailStatusViewHolder(StatusAdapter adapter, View itemView) {
|
||||
super(itemView);
|
||||
|
@ -909,10 +960,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
profileTypeView = (ImageView) itemView.findViewById(R.id.profile_type);
|
||||
timeSourceView = (TextView) itemView.findViewById(R.id.time_source);
|
||||
retweetedByView = (TextView) itemView.findViewById(R.id.retweeted_by);
|
||||
repliesContainer = itemView.findViewById(R.id.replies_container);
|
||||
retweetsContainer = itemView.findViewById(R.id.retweets_container);
|
||||
favoritesContainer = itemView.findViewById(R.id.favorites_container);
|
||||
repliesCountView = (TextView) itemView.findViewById(R.id.replies_count);
|
||||
retweetsCountView = (TextView) itemView.findViewById(R.id.retweets_count);
|
||||
favoritesCountView = (TextView) itemView.findViewById(R.id.favorites_count);
|
||||
mediaPreviewContainer = itemView.findViewById(R.id.media_preview_container);
|
||||
|
@ -922,8 +971,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
quoteOriginalLink = (TextView) itemView.findViewById(R.id.quote_original_link);
|
||||
profileContainer = (ColorLabelRelativeLayout) itemView.findViewById(R.id.profile_container);
|
||||
twitterCard = (TwitterCardContainer) itemView.findViewById(R.id.twitter_card);
|
||||
retweetsLabel = (TextView) itemView.findViewById(R.id.retweets_label);
|
||||
favoritesLabel = (TextView) itemView.findViewById(R.id.favorites_label);
|
||||
|
||||
countsContainer = itemView.findViewById(R.id.counts_container);
|
||||
|
||||
quotedTextView = (TextView) itemView.findViewById(R.id.quoted_text);
|
||||
quotedNameView = (TextView) itemView.findViewById(R.id.quoted_name);
|
||||
quotedScreenNameView = (TextView) itemView.findViewById(R.id.quoted_screen_name);
|
||||
|
@ -933,12 +985,14 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
translateContainer = itemView.findViewById(R.id.translate_container);
|
||||
translateResultView = (TextView) itemView.findViewById(R.id.translate_result);
|
||||
|
||||
setIsRecyclable(false);
|
||||
interactUsersView = (RecyclerView) itemView.findViewById(R.id.interact_users);
|
||||
|
||||
initViews();
|
||||
}
|
||||
|
||||
public void displayStatus(@Nullable final ParcelableCredentials account,
|
||||
@Nullable final ParcelableStatus status,
|
||||
@Nullable final StatusActivity statusActivity,
|
||||
@Nullable final TranslationResult translation) {
|
||||
if (account == null || status == null) return;
|
||||
final StatusFragment fragment = adapter.getFragment();
|
||||
|
@ -1041,13 +1095,33 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
locationView.setText(null);
|
||||
}
|
||||
|
||||
retweetsContainer.setVisibility(!status.user_is_protected ? View.VISIBLE : View.GONE);
|
||||
repliesContainer.setVisibility(status.reply_count < 0 ? View.GONE : View.VISIBLE);
|
||||
favoritesContainer.setVisibility(status.favorite_count < 0 ? View.GONE : View.VISIBLE);
|
||||
final long retweetCount, favoriteCount;
|
||||
if (statusActivity != null) {
|
||||
retweetCount = statusActivity.getRetweetCount();
|
||||
favoriteCount = statusActivity.getFavoriteCount();
|
||||
} else {
|
||||
retweetCount = status.retweet_count;
|
||||
favoriteCount = status.favorite_count;
|
||||
}
|
||||
|
||||
retweetsContainer.setVisibility(!status.user_is_protected && retweetCount > 0 ? View.VISIBLE : View.GONE);
|
||||
favoritesContainer.setVisibility(favoriteCount > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (retweetsContainer.getVisibility() == View.VISIBLE || favoritesContainer.getVisibility() == View.VISIBLE) {
|
||||
countsContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
countsContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final Locale locale = context.getResources().getConfiguration().locale;
|
||||
repliesCountView.setText(Utils.getLocalizedNumber(locale, status.reply_count));
|
||||
retweetsCountView.setText(Utils.getLocalizedNumber(locale, status.retweet_count));
|
||||
favoritesCountView.setText(Utils.getLocalizedNumber(locale, status.favorite_count));
|
||||
|
||||
retweetsCountView.setText(Utils.getLocalizedNumber(locale, retweetCount));
|
||||
favoritesCountView.setText(Utils.getLocalizedNumber(locale, favoriteCount));
|
||||
final UserProfileImagesAdapter interactUsersAdapter = (UserProfileImagesAdapter) interactUsersView.getAdapter();
|
||||
interactUsersAdapter.clear();
|
||||
if (statusActivity != null && statusActivity.retweeters != null) {
|
||||
interactUsersAdapter.addAll(statusActivity.retweeters);
|
||||
}
|
||||
|
||||
final ParcelableMedia[] media = Utils.getPrimaryMedia(status);
|
||||
|
||||
|
@ -1236,17 +1310,67 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
translateLabelView.setTextSize(defaultTextSize * 0.85f);
|
||||
translateResultView.setTextSize(defaultTextSize * 1.05f);
|
||||
|
||||
retweetsCountView.setTextSize(defaultTextSize * 1.25f);
|
||||
favoritesCountView.setTextSize(defaultTextSize * 1.25f);
|
||||
|
||||
retweetsLabel.setTextSize(defaultTextSize * 0.85f);
|
||||
favoritesLabel.setTextSize(defaultTextSize * 0.85f);
|
||||
|
||||
mediaPreview.setStyle(adapter.getMediaPreviewStyle());
|
||||
|
||||
quotedTextView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(quotedTextView, activity));
|
||||
textView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(textView, activity));
|
||||
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(adapter.getContext());
|
||||
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
interactUsersView.setLayoutManager(layoutManager);
|
||||
|
||||
if (adapter.isProfileImageEnabled()) {
|
||||
interactUsersView.setAdapter(new UserProfileImagesAdapter(adapter.getContext()));
|
||||
} else {
|
||||
interactUsersView.setAdapter(null);
|
||||
}
|
||||
|
||||
if (adapter.shouldUseStarsForLikes()) {
|
||||
favoritesLabel.setText(R.string.favorites);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class UserProfileImagesAdapter extends ArrayRecyclerAdapter<ParcelableUser, ViewHolder> {
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
public UserProfileImagesAdapter(Context context) {
|
||||
super(context);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position, ParcelableUser item) {
|
||||
((ProfileImageViewHolder) holder).displayUser(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ProfileImageViewHolder(this, mInflater.inflate(R.layout.adapter_item_status_interact_user, parent, false));
|
||||
}
|
||||
|
||||
static class ProfileImageViewHolder extends ViewHolder {
|
||||
|
||||
private final UserProfileImagesAdapter adapter;
|
||||
private final ImageView profileImageView;
|
||||
|
||||
public ProfileImageViewHolder(UserProfileImagesAdapter adapter, View itemView) {
|
||||
super(itemView);
|
||||
profileImageView = (ImageView) itemView.findViewById(R.id.profile_image);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public void displayUser(ParcelableUser item) {
|
||||
adapter.getMediaLoader().displayProfileImage(profileImageView, item.profile_image_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SpaceViewHolder extends ViewHolder {
|
||||
|
@ -1296,14 +1420,16 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private boolean mLoadMoreSupported;
|
||||
private boolean mLoadMoreIndicatorVisible;
|
||||
private boolean mDetailMediaExpanded;
|
||||
|
||||
private ParcelableStatus mStatus;
|
||||
private TranslationResult mTranslationResult;
|
||||
private StatusActivity mStatusActivity;
|
||||
private ParcelableCredentials mStatusAccount;
|
||||
private List<ParcelableStatus> mConversation, mReplies;
|
||||
private StatusAdapterListener mStatusAdapterListener;
|
||||
private RecyclerView mRecyclerView;
|
||||
private CharSequence mReplyError, mConversationError;
|
||||
private boolean mRepliesLoading, mConversationsLoading;
|
||||
private TranslationResult mTranslationResult;
|
||||
|
||||
public StatusAdapter(StatusFragment fragment, boolean compact) {
|
||||
super(fragment.getContext());
|
||||
|
@ -1598,7 +1724,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
case VIEW_TYPE_DETAIL_STATUS: {
|
||||
final ParcelableStatus status = getStatus(position);
|
||||
final DetailStatusViewHolder detailHolder = (DetailStatusViewHolder) holder;
|
||||
detailHolder.displayStatus(getStatusAccount(), status, getTranslationResult());
|
||||
detailHolder.displayStatus(getStatusAccount(), status, mStatusActivity,
|
||||
getTranslationResult());
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_LIST_STATUS: {
|
||||
|
@ -1843,6 +1970,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
|
||||
public void setStatusActivity(StatusActivity activity) {
|
||||
mStatusActivity = activity;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public static class StatusErrorItemViewHolder extends ViewHolder {
|
||||
private final TextView textView;
|
||||
|
||||
|
@ -1902,4 +2034,121 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
|
||||
}
|
||||
|
||||
public static class StatusActivitySummaryLoader extends AsyncTaskLoader<StatusActivity> {
|
||||
private final long mAccountId;
|
||||
private final long mStatusId;
|
||||
|
||||
public StatusActivitySummaryLoader(Context context, long accountId, long statusId) {
|
||||
super(context);
|
||||
mAccountId = accountId;
|
||||
mStatusId = statusId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusActivity loadInBackground() {
|
||||
final Context context = getContext();
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, mAccountId, true);
|
||||
final Paging paging = new Paging();
|
||||
final StatusActivity activitySummary = new StatusActivity();
|
||||
final List<ParcelableUser> retweeters = new ArrayList<>();
|
||||
try {
|
||||
for (Status status : twitter.getRetweets(mStatusId, paging)) {
|
||||
retweeters.add(new ParcelableUser(status.getUser(), mAccountId));
|
||||
}
|
||||
activitySummary.setRetweeters(retweeters);
|
||||
final ContentValues statusValues = new ContentValues();
|
||||
final Status status = twitter.showStatus(mStatusId);
|
||||
activitySummary.setFavoriteCount(status.getFavoriteCount());
|
||||
activitySummary.setRetweetCount(status.getRetweetCount());
|
||||
activitySummary.setReplyCount(status.getReplyCount());
|
||||
|
||||
statusValues.put(Statuses.REPLY_COUNT, activitySummary.replyCount);
|
||||
statusValues.put(Statuses.FAVORITE_COUNT, activitySummary.favoriteCount);
|
||||
statusValues.put(Statuses.RETWEET_COUNT, activitySummary.retweetCount);
|
||||
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final Expression statusWhere = Expression.or(
|
||||
Expression.equals(Statuses.STATUS_ID, mStatusId),
|
||||
Expression.equals(Statuses.RETWEET_ID, mStatusId)
|
||||
);
|
||||
cr.update(Statuses.CONTENT_URI, statusValues, statusWhere.getSQL(), null);
|
||||
final Expression activityWhere = Expression.or(
|
||||
Expression.equals(Activities.STATUS_ID, mStatusId),
|
||||
Expression.equals(Activities.STATUS_RETWEET_ID, mStatusId)
|
||||
);
|
||||
|
||||
final Cursor activityCursor = cr.query(Activities.AboutMe.CONTENT_URI,
|
||||
Activities.COLUMNS, activityWhere.getSQL(), null, null);
|
||||
assert activityCursor != null;
|
||||
try {
|
||||
activityCursor.moveToFirst();
|
||||
ParcelableActivityCursorIndices ci = new ParcelableActivityCursorIndices(activityCursor);
|
||||
while (!activityCursor.isAfterLast()) {
|
||||
final ParcelableActivity activity = ci.newObject(activityCursor);
|
||||
ParcelableStatus activityStatus = ParcelableActivity.getActivityStatus(activity);
|
||||
if (activityStatus != null) {
|
||||
activityStatus.favorite_count = activitySummary.favoriteCount;
|
||||
activityStatus.reply_count = activitySummary.replyCount;
|
||||
activityStatus.retweet_count = activitySummary.retweetCount;
|
||||
}
|
||||
cr.update(Activities.AboutMe.CONTENT_URI, ParcelableActivityValuesCreator.create(activity),
|
||||
Expression.equals(Activities._ID, activity._id).getSQL(), null);
|
||||
activityCursor.moveToNext();
|
||||
}
|
||||
} finally {
|
||||
activityCursor.close();
|
||||
}
|
||||
return activitySummary;
|
||||
} catch (TwitterException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
|
||||
public static class StatusActivity {
|
||||
|
||||
List<ParcelableUser> retweeters;
|
||||
|
||||
long favoriteCount;
|
||||
long replyCount = -1;
|
||||
long retweetCount;
|
||||
|
||||
public List<ParcelableUser> getRetweeters() {
|
||||
return retweeters;
|
||||
}
|
||||
|
||||
public void setRetweeters(List<ParcelableUser> retweeters) {
|
||||
this.retweeters = retweeters;
|
||||
}
|
||||
|
||||
public long getFavoriteCount() {
|
||||
return favoriteCount;
|
||||
}
|
||||
|
||||
public void setFavoriteCount(long favoriteCount) {
|
||||
this.favoriteCount = favoriteCount;
|
||||
}
|
||||
|
||||
public long getReplyCount() {
|
||||
return replyCount;
|
||||
}
|
||||
|
||||
public void setReplyCount(long repliersCount) {
|
||||
this.replyCount = repliersCount;
|
||||
}
|
||||
|
||||
public long getRetweetCount() {
|
||||
return retweetCount;
|
||||
}
|
||||
|
||||
public void setRetweetCount(long retweetCount) {
|
||||
this.retweetCount = retweetCount;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -2759,7 +2759,7 @@ public final class Utils implements Constants {
|
|||
} else if (twitter.isDestroyingStatus(status.account_id, status.id)) {
|
||||
isMyRetweet = false;
|
||||
} else {
|
||||
isMyRetweet = isMyRetweet(status);
|
||||
isMyRetweet = status.retweeted || isMyRetweet(status);
|
||||
}
|
||||
final MenuItem delete = menu.findItem(R.id.delete);
|
||||
if (delete != null) {
|
||||
|
|
|
@ -145,7 +145,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
final boolean nameFirst = adapter.isNameFirst();
|
||||
|
||||
final long reply_count = status.reply_count;
|
||||
final long retweet_count;
|
||||
final long retweetCount;
|
||||
final long favorite_count;
|
||||
|
||||
if (status.retweet_id > 0) {
|
||||
|
@ -269,15 +269,15 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
|
||||
if (twitter.isDestroyingStatus(status.account_id, status.my_retweet_id)) {
|
||||
retweetCountView.setActivated(false);
|
||||
retweet_count = Math.max(0, status.retweet_count - 1);
|
||||
retweetCount = Math.max(0, status.retweet_count - 1);
|
||||
} else {
|
||||
final boolean creatingRetweet = twitter.isCreatingRetweet(status.account_id, status.id);
|
||||
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(status.account_id,
|
||||
status.retweeted_by_user_id, status.my_retweet_id));
|
||||
retweet_count = status.retweet_count + (creatingRetweet ? 1 : 0);
|
||||
retweetCountView.setActivated(creatingRetweet || status.retweeted ||
|
||||
Utils.isMyRetweet(status.account_id, status.retweeted_by_user_id, status.my_retweet_id));
|
||||
retweetCount = status.retweet_count + (creatingRetweet ? 1 : 0);
|
||||
}
|
||||
if (retweet_count > 0) {
|
||||
retweetCountView.setText(Utils.getLocalizedNumber(locale, retweet_count));
|
||||
if (retweetCount > 0) {
|
||||
retweetCountView.setText(Utils.getLocalizedNumber(locale, retweetCount));
|
||||
} else {
|
||||
retweetCountView.setText(null);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<org.mariotaku.twidere.view.SquareFrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/element_spacing_msmall">
|
||||
|
||||
<org.mariotaku.twidere.view.ProfileImageView
|
||||
android:id="@+id/profile_image"
|
||||
style="?profileImageStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</org.mariotaku.twidere.view.SquareFrameLayout>
|
|
@ -376,49 +376,21 @@
|
|||
android:layout_below="@+id/quote_original_link"
|
||||
android:layout_marginLeft="@dimen/element_spacing_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:splitMotionEvents="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/replies_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:baselineAligned="true"
|
||||
android:clickable="true"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:id="@+id/replies_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/element_spacing_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="255"/>
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/replies"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/retweets_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackground"
|
||||
android:baselineAligned="true"
|
||||
android:clickable="true"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
|
@ -430,9 +402,11 @@
|
|||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
tools:text="255"/>
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:id="@+id/retweets_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
|
@ -445,11 +419,13 @@
|
|||
android:id="@+id/favorites_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackground"
|
||||
android:baselineAligned="true"
|
||||
android:clickable="true"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
|
@ -461,6 +437,7 @@
|
|||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
tools:text="255"/>
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
|
@ -473,6 +450,12 @@
|
|||
android:textColor="?android:textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/interact_users"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/element_size_normal"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.ActionMenuView
|
||||
|
|
Loading…
Reference in New Issue