mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
fixed unable to open media for quoted tweet
This commit is contained in:
parent
44eae297bf
commit
5a3c15161f
@ -120,7 +120,27 @@ public class TwitterDateConverter extends StringBasedTypeConverter<Date> {
|
||||
|
||||
@Override
|
||||
public String convertToString(Date date) {
|
||||
return mDateFormat.format(date);
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(WEEK_NAMES[calendar.get(Calendar.DAY_OF_WEEK) - 1]);
|
||||
sb.append(' ');
|
||||
sb.append(MONTH_NAMES[calendar.get(Calendar.MONTH)]);
|
||||
sb.append(' ');
|
||||
sb.append(calendar.get(Calendar.DAY_OF_MONTH));
|
||||
sb.append(' ');
|
||||
sb.append(calendar.get(Calendar.HOUR_OF_DAY));
|
||||
sb.append(':');
|
||||
sb.append(calendar.get(Calendar.MINUTE));
|
||||
sb.append(':');
|
||||
sb.append(calendar.get(Calendar.SECOND));
|
||||
sb.append(' ');
|
||||
final long offset = TimeUnit.MILLISECONDS.toMinutes(calendar.get(Calendar.ZONE_OFFSET));
|
||||
sb.append(offset > 0 ? '+' : '-');
|
||||
sb.append(String.format(Locale.ROOT, "%02d%02d", Math.abs(offset) / 60, Math.abs(offset) % 60));
|
||||
sb.append(' ');
|
||||
sb.append(calendar.get(Calendar.YEAR));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
@ -50,7 +50,7 @@ public class SensitiveContentWarningDialogFragment extends BaseSupportDialogFrag
|
||||
final Bundle option = args.getBundle(EXTRA_ACTIVITY_OPTIONS);
|
||||
final ParcelableMedia[] media = Utils.newParcelableArray(args.getParcelableArray(EXTRA_MEDIA),
|
||||
ParcelableMedia.CREATOR);
|
||||
openMediaDirectly(context, accountId, status, current, media, option);
|
||||
openMediaDirectly(context, accountId, status, null, current, media, option);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
final ParcelableStatus status = mStatusAdapter.getStatus();
|
||||
if (status == null) return;
|
||||
final Bundle options = Utils.createMediaViewerActivityOption(view);
|
||||
Utils.openMediaDirectly(getActivity(), accountId, status, media, status.media, options);
|
||||
Utils.openMediaDirectly(getActivity(), accountId, status, media, options);
|
||||
// BEGIN HotMobi
|
||||
MediaEvent event = MediaEvent.create(getActivity(), status, media, TimelineType.OTHER,
|
||||
mStatusAdapter.isMediaPreviewEnabled());
|
||||
@ -752,12 +752,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
retweetsCountView.setText(Utils.getLocalizedNumber(locale, status.retweet_count));
|
||||
favoritesCountView.setText(Utils.getLocalizedNumber(locale, status.favorite_count));
|
||||
|
||||
final ParcelableMedia[] media;
|
||||
if (status.is_quote && ArrayUtils.isEmpty(status.media)) {
|
||||
media = status.quoted_media;
|
||||
} else {
|
||||
media = status.media;
|
||||
}
|
||||
final ParcelableMedia[] media = Utils.getPrimaryMedia(status);
|
||||
|
||||
if (media == null) {
|
||||
mediaPreviewContainer.setVisibility(View.GONE);
|
||||
|
@ -2668,7 +2668,7 @@ public final class Utils implements Constants {
|
||||
}
|
||||
|
||||
public static void openMedia(final Context context, final ParcelableStatus status, final ParcelableMedia current, Bundle options) {
|
||||
openMedia(context, status.account_id, status.is_possibly_sensitive, status, null, current, status.media, options);
|
||||
openMedia(context, status.account_id, status.is_possibly_sensitive, status, null, current, getPrimaryMedia(status), options);
|
||||
}
|
||||
|
||||
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
|
||||
@ -2713,11 +2713,18 @@ public final class Utils implements Constants {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void openMediaDirectly(final Context context, final long accountId,
|
||||
final ParcelableStatus status, final ParcelableMedia current,
|
||||
final ParcelableMedia[] media, Bundle options) {
|
||||
openMediaDirectly(context, accountId, status, null, current, media, options);
|
||||
final Bundle options) {
|
||||
openMediaDirectly(context, accountId, status, null, current, getPrimaryMedia(status), options);
|
||||
}
|
||||
|
||||
public static ParcelableMedia[] getPrimaryMedia(ParcelableStatus status) {
|
||||
if (status.is_quote && ArrayUtils.isEmpty(status.media)) {
|
||||
return status.quoted_media;
|
||||
} else {
|
||||
return status.media;
|
||||
}
|
||||
}
|
||||
|
||||
public static void openMediaDirectly(final Context context, final long accountId,
|
||||
|
@ -233,7 +233,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
||||
itemContent.drawEnd();
|
||||
}
|
||||
|
||||
final ParcelableMedia[] media = status.is_quote && ArrayUtils.isEmpty(status.media) ? status.quoted_media : status.media;
|
||||
final ParcelableMedia[] media = Utils.getPrimaryMedia(status);
|
||||
|
||||
if (adapter.isMediaPreviewEnabled()) {
|
||||
mediaPreview.setStyle(adapter.getMediaPreviewStyle());
|
||||
|
@ -26,6 +26,7 @@
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:focusable="false"
|
||||
app:cardBackgroundColor="?cardItemBackgroundColor"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:cardElevation="2dp">
|
||||
@ -35,6 +36,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="false"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="false"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user