Search in sources :

Example 1 with AttachmentViewData

use of com.keylesspalace.tusky.viewdata.AttachmentViewData in project Tusky by Vavassor.

the class SFragment method viewMedia.

protected void viewMedia(int urlIndex, List<AttachmentViewData> attachments, @Nullable View view) {
    final AttachmentViewData active = attachments.get(urlIndex);
    Attachment.Type type = active.getAttachment().getType();
    switch(type) {
        case GIFV:
        case VIDEO:
        case IMAGE:
        case AUDIO:
            {
                final Intent intent = ViewMediaActivity.newIntent(getContext(), attachments, urlIndex);
                if (view != null) {
                    String url = active.getAttachment().getUrl();
                    ViewCompat.setTransitionName(view, url);
                    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), view, url);
                    startActivity(intent, options.toBundle());
                } else {
                    startActivity(intent);
                }
                break;
            }
        default:
        case UNKNOWN:
            {
                LinkHelper.openLink(active.getAttachment().getUrl(), getContext());
                break;
            }
    }
}
Also used : AttachmentViewData(com.keylesspalace.tusky.viewdata.AttachmentViewData) Attachment(com.keylesspalace.tusky.entity.Attachment) Intent(android.content.Intent) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat)

Aggregations

Intent (android.content.Intent)1 ActivityOptionsCompat (androidx.core.app.ActivityOptionsCompat)1 Attachment (com.keylesspalace.tusky.entity.Attachment)1 AttachmentViewData (com.keylesspalace.tusky.viewdata.AttachmentViewData)1