unofficial keys also supports animated gif
This commit is contained in:
parent
9659330c1e
commit
d7b934a3e0
|
@ -36,7 +36,7 @@ import twitter4j.URLEntity;
|
|||
@SuppressWarnings("unused")
|
||||
public class ParcelableMedia implements Parcelable, JSONParcelable, SimpleValueSerializable {
|
||||
|
||||
@IntDef({TYPE_UNKNOWN, TYPE_IMAGE, TYPE_VIDEO, TYPE_CARD_ANIMATED_GIF})
|
||||
@IntDef({TYPE_UNKNOWN, TYPE_IMAGE, TYPE_VIDEO, TYPE_ANIMATED_GIF, TYPE_CARD_ANIMATED_GIF})
|
||||
public @interface MediaType {
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,9 @@ public class ParcelableMedia implements Parcelable, JSONParcelable, SimpleValueS
|
|||
@MediaType
|
||||
public static final int TYPE_VIDEO = 2;
|
||||
@MediaType
|
||||
public static final int TYPE_CARD_ANIMATED_GIF = 3;
|
||||
public static final int TYPE_ANIMATED_GIF = 3;
|
||||
@MediaType
|
||||
public static final int TYPE_CARD_ANIMATED_GIF = 4;
|
||||
|
||||
public static final Parcelable.Creator<ParcelableMedia> CREATOR = new Parcelable.Creator<ParcelableMedia>() {
|
||||
@Override
|
||||
|
@ -154,6 +156,8 @@ public class ParcelableMedia implements Parcelable, JSONParcelable, SimpleValueS
|
|||
return TYPE_IMAGE;
|
||||
case VIDEO:
|
||||
return TYPE_VIDEO;
|
||||
case ANIMATED_GIF:
|
||||
return TYPE_ANIMATED_GIF;
|
||||
}
|
||||
return TYPE_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package twitter4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -61,13 +60,15 @@ public interface MediaEntity extends URLEntity, Serializable {
|
|||
Type getType();
|
||||
|
||||
enum Type {
|
||||
PHOTO, VIDEO, UNKNOWN;
|
||||
PHOTO, VIDEO, ANIMATED_GIF, UNKNOWN;
|
||||
|
||||
public static Type parse(String typeString) {
|
||||
if ("photo".equalsIgnoreCase(typeString)) {
|
||||
return PHOTO;
|
||||
} else if ("video".equalsIgnoreCase(typeString)) {
|
||||
return VIDEO;
|
||||
} else if ("animated_gif".equalsIgnoreCase(typeString)) {
|
||||
return ANIMATED_GIF;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ public class TypeMappingUtil {
|
|||
return "image";
|
||||
case ParcelableMedia.TYPE_VIDEO:
|
||||
return "video";
|
||||
case ParcelableMedia.TYPE_ANIMATED_GIF:
|
||||
return "animated_gif";
|
||||
case ParcelableMedia.TYPE_CARD_ANIMATED_GIF:
|
||||
return "card_animated_gif";
|
||||
default:
|
||||
|
|
|
@ -482,6 +482,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
args.putLong(EXTRA_ACCOUNT_ID, mAccountId);
|
||||
args.putParcelable(EXTRA_MEDIA, media);
|
||||
switch (media.type) {
|
||||
case ParcelableMedia.TYPE_ANIMATED_GIF:
|
||||
case ParcelableMedia.TYPE_CARD_ANIMATED_GIF: {
|
||||
args.putBoolean(EXTRA_LOOP, true);
|
||||
return Fragment.instantiate(mActivity, VideoPageFragment.class.getName(), args);
|
||||
|
@ -649,7 +650,8 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
private Pair<String, String> getBestVideoUrlAndType(ParcelableMedia media) {
|
||||
if (media == null) return null;
|
||||
switch (media.type) {
|
||||
case ParcelableMedia.TYPE_VIDEO: {
|
||||
case ParcelableMedia.TYPE_VIDEO:
|
||||
case ParcelableMedia.TYPE_ANIMATED_GIF: {
|
||||
if (media.video_info == null) return null;
|
||||
for (String supportedType : SUPPORTED_VIDEO_TYPES) {
|
||||
for (Variant variant : media.video_info.variants) {
|
||||
|
|
|
@ -626,7 +626,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
|
||||
public void displayStatus(ParcelableStatus status) {
|
||||
if (status == null) return;
|
||||
if (status.equals(this.status)) return;
|
||||
this.status = status;
|
||||
final StatusFragment fragment = adapter.getFragment();
|
||||
final Context context = adapter.getContext();
|
||||
|
|
|
@ -150,7 +150,8 @@ public class MediaLoadingHandler implements ImageLoadingListener, ImageLoadingPr
|
|||
final Object tag = parent.getTag();
|
||||
if (tag instanceof ParcelableMedia) {
|
||||
final int type = ((ParcelableMedia) tag).type;
|
||||
return type == ParcelableMedia.TYPE_VIDEO || type == ParcelableMedia.TYPE_CARD_ANIMATED_GIF;
|
||||
return type == ParcelableMedia.TYPE_VIDEO || type == ParcelableMedia.TYPE_ANIMATED_GIF
|
||||
|| type == ParcelableMedia.TYPE_CARD_ANIMATED_GIF;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -644,7 +644,9 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
|
||||
private boolean hasVideo(ParcelableMedia[] media) {
|
||||
for (ParcelableMedia mediaItem : media) {
|
||||
if (mediaItem.type == ParcelableMedia.TYPE_VIDEO) return true;
|
||||
if (mediaItem.type == ParcelableMedia.TYPE_VIDEO
|
||||
|| mediaItem.type == ParcelableMedia.TYPE_ANIMATED_GIF)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue