mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-30 16:35:00 +01:00
click media preview to open media now works
This commit is contained in:
parent
70c8494438
commit
344136e7bd
@ -37,6 +37,7 @@ import org.mariotaku.twidere.adapter.iface.IActivitiesAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ImageLoadingHandler;
|
||||
@ -255,6 +256,13 @@ public abstract class AbsActivitiesAdapter<Data> extends Adapter<ViewHolder> imp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemActionClick(ViewHolder holder, int id, int position) {
|
||||
|
||||
|
@ -16,6 +16,7 @@ import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.support.UserFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ImageLoadingHandler;
|
||||
@ -245,6 +246,14 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
||||
if (mStatusAdapterListener != null) {
|
||||
mStatusAdapterListener.onMediaClick(holder, media, position);
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(StatusAdapterListener listener) {
|
||||
mStatusAdapterListener = listener;
|
||||
}
|
||||
@ -267,6 +276,8 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
|
||||
public static interface StatusAdapterListener {
|
||||
void onGapClick(GapViewHolder holder, int position);
|
||||
|
||||
void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position);
|
||||
|
||||
void onStatusActionClick(StatusViewHolder holder, int id, int position);
|
||||
|
||||
void onStatusClick(StatusViewHolder holder, int position);
|
||||
|
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus.CursorIndices;
|
||||
import org.mariotaku.twidere.view.holder.StatusViewHolder;
|
||||
|
@ -36,8 +36,8 @@ import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage.CursorIndices;
|
||||
import org.mariotaku.twidere.util.DirectMessageOnLinkClickHandler;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ImageLoadingHandler;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
@ -172,7 +172,7 @@ public class MessageConversationAdapter extends Adapter<ViewHolder>
|
||||
case R.id.media_preview: {
|
||||
final ParcelableDirectMessage message = getDirectMessage(position);
|
||||
if (message == null || message.media == null) return;
|
||||
openMedia(mContext, message.account_id, false, message, null, message.media);
|
||||
openMedia(mContext, message, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.view.View;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.StatusViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ColorUtils;
|
||||
@ -446,6 +447,13 @@ public abstract class AbsStatusesFragment<Data> extends BaseSupportFragment impl
|
||||
mSwipeRefreshLayout.setVisibility(shown ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
||||
final ParcelableStatus status = mAdapter.getStatus(position);
|
||||
if (status == null) return;
|
||||
Utils.openMedia(getActivity(), status, media);
|
||||
}
|
||||
|
||||
private void updateRefreshProgressOffset() {
|
||||
if (mSystemWindowsInsets.top == 0 || mSwipeRefreshLayout == null || isRefreshing()) return;
|
||||
final float density = getResources().getDisplayMetrics().density;
|
||||
|
@ -108,18 +108,15 @@ import twitter4j.TwitterException;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
import static org.mariotaku.twidere.util.UserColorNameUtils.clearUserColor;
|
||||
import static org.mariotaku.twidere.util.UserColorNameUtils.getUserColor;
|
||||
import static org.mariotaku.twidere.util.UserColorNameUtils.getUserNickname;
|
||||
import static org.mariotaku.twidere.util.UserColorNameUtils.setUserColor;
|
||||
import static org.mariotaku.twidere.util.Utils.findStatus;
|
||||
import static org.mariotaku.twidere.util.Utils.formatToLongTimeString;
|
||||
import static org.mariotaku.twidere.util.Utils.getLocalizedNumber;
|
||||
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
|
||||
import static org.mariotaku.twidere.util.Utils.isMyRetweet;
|
||||
import static org.mariotaku.twidere.util.Utils.openStatus;
|
||||
import static org.mariotaku.twidere.util.Utils.openUserProfile;
|
||||
import static org.mariotaku.twidere.util.Utils.showErrorMessage;
|
||||
import static org.mariotaku.twidere.util.Utils.showOkMessage;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/12/5.
|
||||
@ -248,6 +245,13 @@ public class StatusFragment extends BaseSupportFragment
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
||||
final ParcelableStatus status = mStatusAdapter.getStatus(position);
|
||||
if (status == null) return;
|
||||
Utils.openMedia(getActivity(), status, media);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusActionClick(StatusViewHolder holder, int id, int position) {
|
||||
final ParcelableStatus status = mStatusAdapter.getStatus(position);
|
||||
@ -579,6 +583,13 @@ public class StatusFragment extends BaseSupportFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
||||
if (mStatusAdapterListener != null) {
|
||||
mStatusAdapterListener.onMediaClick(holder, media, position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserProfileClick(StatusViewHolder holder, int position) {
|
||||
final Context context = getContext();
|
||||
|
@ -35,7 +35,7 @@ public class StatusLinkClickHandler extends OnLinkClickHandler {
|
||||
protected void openMedia(long account_id, boolean sensitive, String link, int start, int end) {
|
||||
final ParcelableStatus status = mStatus;
|
||||
final ParcelableMedia current = findByLink(status.media, link);
|
||||
Utils.openMedia(context, account_id, sensitive, status, current, status.media);
|
||||
Utils.openMedia(context, status, current);
|
||||
}
|
||||
|
||||
private ParcelableMedia findByLink(ParcelableMedia[] media, String link) {
|
||||
|
@ -2885,16 +2885,12 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
|
||||
final ParcelableDirectMessage message, final ParcelableMedia current,
|
||||
final ParcelableMedia[] media) {
|
||||
openMedia(context, accountId, isPossiblySensitive, null, message, current, media);
|
||||
public static void openMedia(final Context context, final ParcelableDirectMessage message, final ParcelableMedia current) {
|
||||
openMedia(context, message.account_id, false, null, message, current, message.media);
|
||||
}
|
||||
|
||||
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
|
||||
final ParcelableStatus status, final ParcelableMedia current,
|
||||
final ParcelableMedia[] media) {
|
||||
openMedia(context, accountId, isPossiblySensitive, status, null, current, media);
|
||||
public static void openMedia(final Context context, final ParcelableStatus status, final ParcelableMedia current) {
|
||||
openMedia(context, status.account_id, status.is_possibly_sensitive, status, null, current, status.media);
|
||||
}
|
||||
|
||||
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
|
||||
|
@ -33,8 +33,8 @@ import android.widget.TextView;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ImageLoadingHandler;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
|
||||
|
||||
/**
|
||||
@ -113,6 +113,7 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
||||
if (i < k) {
|
||||
final ParcelableMedia media = mediaArray[i];
|
||||
loader.displayPreviewImage(imageView, media.page_url, loadingHandler);
|
||||
child.setTag(media);
|
||||
child.setVisibility(VISIBLE);
|
||||
if (i == j - 1) {
|
||||
final TextView moreIndicator = (TextView) child.findViewById(R.id.more_media);
|
||||
|
@ -38,9 +38,10 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.SimpleValueSerializer;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer;
|
||||
|
||||
public class MessageConversationViewHolder extends ViewHolder {
|
||||
public class MessageConversationViewHolder extends ViewHolder implements OnMediaClickListener {
|
||||
|
||||
public final CardMediaContainer mediaContainer;
|
||||
public final TextView text, time;
|
||||
@ -83,7 +84,12 @@ public class MessageConversationViewHolder extends ViewHolder {
|
||||
text.setMovementMethod(null);
|
||||
time.setText(Utils.formatToLongTimeString(context, timestamp));
|
||||
mediaContainer.setVisibility(media != null && media.length > 0 ? View.VISIBLE : View.GONE);
|
||||
mediaContainer.displayMedia(media, loader, accountId, null, null);
|
||||
mediaContainer.displayMedia(media, loader, accountId, this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
|
||||
Utils.openMedia(adapter.getContext(), adapter.getDirectMessage(getAdapterPosition()), media);
|
||||
}
|
||||
|
||||
public void setMessageColor(int color) {
|
||||
|
@ -27,6 +27,7 @@ import org.mariotaku.twidere.util.SimpleValueSerializer;
|
||||
import org.mariotaku.twidere.util.TwitterCardUtils;
|
||||
import org.mariotaku.twidere.util.UserColorNameUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer;
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
import org.mariotaku.twidere.view.ShortTimeView;
|
||||
@ -44,7 +45,8 @@ import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
|
||||
* <p/>
|
||||
* Created by mariotaku on 14/11/19.
|
||||
*/
|
||||
public class StatusViewHolder extends RecyclerView.ViewHolder implements Constants, OnClickListener {
|
||||
public class StatusViewHolder extends RecyclerView.ViewHolder implements Constants, OnClickListener,
|
||||
OnMediaClickListener {
|
||||
|
||||
private final IStatusesAdapter<?> adapter;
|
||||
|
||||
@ -172,7 +174,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
} else {
|
||||
mediaPreviewContainer.setVisibility(View.GONE);
|
||||
}
|
||||
mediaPreviewContainer.displayMedia(media, loader, status.account_id, null, handler);
|
||||
mediaPreviewContainer.displayMedia(media, loader, status.account_id, this, handler);
|
||||
} else {
|
||||
mediaPreviewContainer.setVisibility(View.GONE);
|
||||
}
|
||||
@ -312,7 +314,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
if (adapter.isMediaPreviewEnabled()) {
|
||||
mediaPreviewContainer.setStyle(adapter.getMediaPreviewStyle());
|
||||
mediaPreviewContainer.setVisibility(media != null && media.length > 0 ? View.VISIBLE : View.GONE);
|
||||
mediaPreviewContainer.displayMedia(media, loader, account_id, null,
|
||||
mediaPreviewContainer.displayMedia(media, loader, account_id, this,
|
||||
adapter.getImageLoadingHandler());
|
||||
} else {
|
||||
mediaPreviewContainer.setVisibility(View.GONE);
|
||||
@ -396,6 +398,13 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
|
||||
if (statusClickListener == null) return;
|
||||
final int position = getAdapterPosition();
|
||||
statusClickListener.onMediaClick(this, media, position);
|
||||
}
|
||||
|
||||
public void setOnClickListeners() {
|
||||
setStatusClickListener(adapter);
|
||||
}
|
||||
@ -407,7 +416,6 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
profileImageView.setOnClickListener(this);
|
||||
mediaPreviewContainer.setOnClickListener(this);
|
||||
replyCountView.setOnClickListener(this);
|
||||
retweetCountView.setOnClickListener(this);
|
||||
favoriteCountView.setOnClickListener(this);
|
||||
@ -465,6 +473,8 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
|
||||
void onStatusClick(StatusViewHolder holder, int position);
|
||||
|
||||
void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position);
|
||||
|
||||
void onUserProfileClick(StatusViewHolder holder, int position);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user