Show and play videos
This commit is contained in:
parent
ff163d83da
commit
dc63d054dc
|
@ -20,7 +20,6 @@ public class Attachment extends BaseModel{
|
|||
public Type type;
|
||||
@RequiredField
|
||||
public String url;
|
||||
@RequiredField
|
||||
public String previewUrl;
|
||||
public String remoteUrl;
|
||||
public String description;
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.joinmastodon.android.model.Status;
|
|||
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
|
||||
|
||||
public class GifVStatusDisplayItem extends ImageStatusDisplayItem{
|
||||
public GifVStatusDisplayItem(String parentID, Status status, Attachment photo, BaseStatusListFragment parentFragment, int index, int totalPhotos){
|
||||
super(parentID, parentFragment, photo, status, index, totalPhotos);
|
||||
request=new UrlImageLoaderRequest(photo.previewUrl, 1000, 1000);
|
||||
public GifVStatusDisplayItem(String parentID, Status status, Attachment attachment, BaseStatusListFragment parentFragment, int index, int totalPhotos){
|
||||
super(parentID, parentFragment, attachment, status, index, totalPhotos);
|
||||
request=new UrlImageLoaderRequest(attachment.previewUrl, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,6 +48,7 @@ public abstract class StatusDisplayItem{
|
|||
case TEXT -> new TextStatusDisplayItem.Holder(activity, parent);
|
||||
case PHOTO -> new PhotoStatusDisplayItem.Holder(activity, parent);
|
||||
case GIFV -> new GifVStatusDisplayItem.Holder(activity, parent);
|
||||
case VIDEO -> new VideoStatusDisplayItem.Holder(activity, parent);
|
||||
case FOOTER -> new FooterStatusDisplayItem.Holder(activity, parent);
|
||||
default -> throw new UnsupportedOperationException();
|
||||
};
|
||||
|
@ -69,7 +70,7 @@ public abstract class StatusDisplayItem{
|
|||
int photoIndex=0;
|
||||
int totalPhotos=0;
|
||||
for(Attachment attachment:statusForContent.mediaAttachments){
|
||||
if(attachment.type==Attachment.Type.IMAGE || attachment.type==Attachment.Type.GIFV){
|
||||
if(attachment.type==Attachment.Type.IMAGE || attachment.type==Attachment.Type.GIFV || attachment.type==Attachment.Type.VIDEO){
|
||||
totalPhotos++;
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +81,9 @@ public abstract class StatusDisplayItem{
|
|||
}else if(attachment.type==Attachment.Type.GIFV){
|
||||
items.add(new GifVStatusDisplayItem(parentID, status, attachment, fragment, photoIndex, totalPhotos));
|
||||
photoIndex++;
|
||||
}else if(attachment.type==Attachment.Type.VIDEO){
|
||||
items.add(new VideoStatusDisplayItem(parentID, status, attachment, fragment, photoIndex, totalPhotos));
|
||||
photoIndex++;
|
||||
}
|
||||
}
|
||||
items.add(new FooterStatusDisplayItem(parentID, fragment, statusForContent, accountID));
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.joinmastodon.android.ui.displayitems;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Outline;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
import org.joinmastodon.android.model.Attachment;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
|
||||
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
|
||||
|
||||
public class VideoStatusDisplayItem extends ImageStatusDisplayItem{
|
||||
public VideoStatusDisplayItem(String parentID, Status status, Attachment attachment, BaseStatusListFragment parentFragment, int index, int totalPhotos){
|
||||
super(parentID, parentFragment, attachment, status, index, totalPhotos);
|
||||
request=new UrlImageLoaderRequest(attachment.previewUrl, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType(){
|
||||
return Type.VIDEO;
|
||||
}
|
||||
|
||||
public static class Holder extends ImageStatusDisplayItem.Holder<VideoStatusDisplayItem>{
|
||||
|
||||
public Holder(Activity activity, ViewGroup parent){
|
||||
super(activity, R.layout.display_item_video, parent);
|
||||
View play=findViewById(R.id.play_button);
|
||||
play.setOutlineProvider(new ViewOutlineProvider(){
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline){
|
||||
outline.setOval(0, 0, view.getWidth(), view.getHeight());
|
||||
outline.setAlpha(.99f); // fixes shadow rendering
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import org.joinmastodon.android.model.Attachment;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -52,7 +53,7 @@ public class PhotoViewer implements ZoomPanView.Listener{
|
|||
|
||||
public PhotoViewer(Activity activity, List<Attachment> attachments, int index, Listener listener){
|
||||
this.activity=activity;
|
||||
this.attachments=attachments;
|
||||
this.attachments=attachments.stream().filter(a->a.type==Attachment.Type.IMAGE || a.type==Attachment.Type.GIFV || a.type==Attachment.Type.VIDEO).collect(Collectors.toList());
|
||||
currentIndex=index;
|
||||
this.listener=listener;
|
||||
|
||||
|
@ -242,7 +243,7 @@ public class PhotoViewer implements ZoomPanView.Listener{
|
|||
Attachment att=attachments.get(position);
|
||||
return switch(att.type){
|
||||
case IMAGE -> 0;
|
||||
case GIFV -> 1;
|
||||
case GIFV, VIDEO -> 1;
|
||||
default -> throw new IllegalStateException("Unexpected value: "+att.type);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/play_button"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_gravity="center"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/play_button"/>
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue