Browse Source

add shimmer to media preview

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 years ago
parent
commit
50ae3c631f

+ 128 - 150
src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -3,8 +3,10 @@
  *
  *   @author David A. Velasco
  *   @author Chris Narkiewicz
+ *   @author Andy Scherzinger
  *   Copyright (C) 2016 ownCloud Inc.
  *   Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
+ *   Copyright (C) 2020 Andy Scherzinger
  *
  *   This program is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License version 2,
@@ -17,7 +19,6 @@
  *
  *   You should have received a copy of the GNU General Public License
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
  */
 package com.owncloud.android.ui.preview;
 
@@ -45,11 +46,7 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
-import android.widget.ImageView;
 import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.VideoView;
 
 import com.nextcloud.client.account.User;
 import com.nextcloud.client.account.UserAccountManager;
@@ -59,13 +56,13 @@ import com.nextcloud.client.media.ErrorFormat;
 import com.nextcloud.client.media.PlayerServiceConnection;
 import com.nextcloud.client.network.ClientFactory;
 import com.owncloud.android.R;
+import com.owncloud.android.databinding.FragmentPreviewMediaBinding;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.FileMenuFilter;
 import com.owncloud.android.files.StreamMediaFileOperation;
 import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.media.MediaControlView;
 import com.owncloud.android.ui.activity.DrawerActivity;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
@@ -77,7 +74,6 @@ import java.lang.ref.WeakReference;
 
 import javax.inject.Inject;
 
-import androidx.annotation.DrawableRes;
 import androidx.annotation.NonNull;
 import androidx.annotation.StringRes;
 import androidx.drawerlayout.widget.DrawerLayout;
@@ -107,34 +103,26 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     private static final String AUTOPLAY = "AUTOPLAY";
 
     private User user;
-    private ImageView mImagePreview;
-    private VideoView mVideoPreview;
-    private int mSavedPlaybackPosition;
-
-    private RelativeLayout mPreviewContainer;
-
-    private LinearLayout mMultiListContainer;
-    private TextView mMultiListMessage;
-    private TextView mMultiListHeadline;
-    private ImageView mMultiListIcon;
+    private int savedPlaybackPosition;
 
-    private MediaControlView mMediaController;
-    private boolean mAutoplay;
-    private boolean mPrepared;
-    private PlayerServiceConnection mMediaPlayerServiceConnection;
+    private boolean autoplay;
+    private boolean prepared;
+    private PlayerServiceConnection mediaPlayerServiceConnection;
 
-    private Uri mVideoUri;
+    private Uri videoUri;
     @Inject ClientFactory clientFactory;
     @Inject UserAccountManager accountManager;
     @Inject DeviceInfo deviceInfo;
+    FragmentPreviewMediaBinding binding;
+    LinearLayout emptyListView;
 
     /**
      * Creates a fragment to preview a file.
-     *
-     * When 'fileToDetail' or 'ocAccount' are null
+     * <p>
+     * When 'fileToDetail' or 'user' are null
      *
      * @param fileToDetail An {@link OCFile} to preview in the fragment
-     * @param user    Currently active user
+     * @param user         Currently active user
      */
     public static PreviewMediaFragment newInstance(OCFile fileToDetail, User user, int startPlaybackPosition,
                                                    boolean autoplay) {
@@ -162,8 +150,8 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
      */
     public PreviewMediaFragment() {
         super();
-        mSavedPlaybackPosition = 0;
-        mAutoplay = true;
+        savedPlaybackPosition = 0;
+        autoplay = true;
     }
 
     @Override
@@ -175,9 +163,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
 
         setFile(bundle.getParcelable(FILE));
         user = bundle.getParcelable(USER);
-        mSavedPlaybackPosition = bundle.getInt(PLAYBACK_POSITION);
-        mAutoplay = bundle.getBoolean(AUTOPLAY);
-        mMediaPlayerServiceConnection = new PlayerServiceConnection(getContext());
+        savedPlaybackPosition = bundle.getInt(PLAYBACK_POSITION);
+        autoplay = bundle.getBoolean(AUTOPLAY);
+        mediaPlayerServiceConnection = new PlayerServiceConnection(getContext());
     }
 
     @Override
@@ -185,44 +173,30 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         super.onCreateView(inflater, container, savedInstanceState);
         Log_OC.v(TAG, "onCreateView");
 
+        binding = FragmentPreviewMediaBinding.inflate(inflater, container, false);
+        View view = binding.getRoot();
 
-        View view = inflater.inflate(R.layout.file_preview, container, false);
-
-        mPreviewContainer = view.findViewById(R.id.file_preview_container);
-        mImagePreview = view.findViewById(R.id.image_preview);
-        mVideoPreview = view.findViewById(R.id.video_preview);
-        mVideoPreview.setOnTouchListener(this);
+        emptyListView = binding.emptyView.emptyListView;
 
-        mMediaController = view.findViewById(R.id.media_controller);
+        binding.videoPreview.setOnTouchListener(this);
 
-        setupMultiView(view);
-        setMultiListLoadingMessage();
+        setLoadingView();
         return view;
     }
 
-    private void setupMultiView(View view) {
-        mMultiListContainer = view.findViewById(R.id.empty_list_view);
-        mMultiListMessage = view.findViewById(R.id.empty_list_view_text);
-        mMultiListHeadline = view.findViewById(R.id.empty_list_view_headline);
-        mMultiListIcon = view.findViewById(R.id.empty_list_icon);
+    private void setLoadingView() {
+        binding.progress.setVisibility(View.VISIBLE);
+        binding.emptyView.emptyListView.setVisibility(View.GONE);
     }
 
-    private void setMultiListLoadingMessage() {
-        if (mMultiListContainer != null) {
-            mMultiListHeadline.setText(R.string.file_list_loading);
-            mMultiListMessage.setText("");
-            mMultiListIcon.setVisibility(View.GONE);
-        }
-    }
-
-    private void setMessageForMultiList(String headline, @StringRes int message, @DrawableRes int icon) {
-        if (mMultiListContainer != null && mMultiListMessage != null) {
-            mMultiListHeadline.setText(headline);
-            mMultiListMessage.setText(message);
-            mMultiListIcon.setImageResource(icon);
-            mMultiListMessage.setVisibility(View.VISIBLE);
-            mMultiListIcon.setVisibility(View.VISIBLE);
-        }
+    private void setVideoErrorMessage(String headline, @StringRes int message) {
+        binding.emptyView.emptyListViewHeadline.setText(headline);
+        binding.emptyView.emptyListViewText.setText(message);
+        binding.emptyView.emptyListIcon.setImageResource(R.drawable.file_movie);
+        binding.emptyView.emptyListViewText.setVisibility(View.VISIBLE);
+        binding.emptyView.emptyListIcon.setVisibility(View.VISIBLE);
+        binding.progress.setVisibility(View.GONE);
+        binding.emptyView.emptyListView.setVisibility(View.VISIBLE);
     }
 
     @Override
@@ -242,18 +216,18 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
             file = savedInstanceState.getParcelable(EXTRA_FILE);
             setFile(file);
             user = savedInstanceState.getParcelable(EXTRA_USER);
-            mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_PLAY_POSITION);
-            mAutoplay = savedInstanceState.getBoolean(EXTRA_PLAYING);
+            savedPlaybackPosition = savedInstanceState.getInt(EXTRA_PLAY_POSITION);
+            autoplay = savedInstanceState.getBoolean(EXTRA_PLAYING);
         }
 
         if (file != null) {
             if (MimeTypeUtil.isVideo(file)) {
-                mVideoPreview.setVisibility(View.VISIBLE);
-                mImagePreview.setVisibility(View.GONE);
+                binding.videoPreview.setVisibility(View.VISIBLE);
+                binding.imagePreview.setVisibility(View.GONE);
                 prepareVideo();
             } else {
-                mVideoPreview.setVisibility(View.GONE);
-                mImagePreview.setVisibility(View.VISIBLE);
+                binding.videoPreview.setVisibility(View.GONE);
+                binding.imagePreview.setVisibility(View.VISIBLE);
                 extractAndSetCoverArt(file);
             }
         }
@@ -273,12 +247,12 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
                 byte[] data = mmr.getEmbeddedPicture();
                 if (data != null) {
                     Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
-                    mImagePreview.setImageBitmap(bitmap); //associated cover art in bitmap
+                    binding.imagePreview.setImageBitmap(bitmap); //associated cover art in bitmap
                 } else {
-                    mImagePreview.setImageResource(R.drawable.logo);
+                    binding.imagePreview.setImageResource(R.drawable.logo);
                 }
             } catch (Throwable t) {
-                mImagePreview.setImageResource(R.drawable.logo);
+                binding.imagePreview.setImageResource(R.drawable.logo);
             }
         }
     }
@@ -292,15 +266,15 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         outState.putParcelable(EXTRA_USER, user);
 
         if (MimeTypeUtil.isVideo(getFile())) {
-            if (mVideoPreview != null) {
-                mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
-                mAutoplay = mVideoPreview.isPlaying();
-                outState.putInt(EXTRA_PLAY_POSITION, mSavedPlaybackPosition);
-                outState.putBoolean(EXTRA_PLAYING, mAutoplay);
+            if (binding.videoPreview != null) {
+                savedPlaybackPosition = binding.videoPreview.getCurrentPosition();
+                autoplay = binding.videoPreview.isPlaying();
+                outState.putInt(EXTRA_PLAY_POSITION, savedPlaybackPosition);
+                outState.putBoolean(EXTRA_PLAYING, autoplay);
             }
-        } else if(mMediaPlayerServiceConnection.isConnected()) {
-            outState.putInt(EXTRA_PLAY_POSITION, mMediaPlayerServiceConnection.getCurrentPosition());
-            outState.putBoolean(EXTRA_PLAYING, mMediaPlayerServiceConnection.isPlaying());
+        } else if(mediaPlayerServiceConnection.isConnected()) {
+            outState.putInt(EXTRA_PLAY_POSITION, mediaPlayerServiceConnection.getCurrentPosition());
+            outState.putBoolean(EXTRA_PLAYING, mediaPlayerServiceConnection.isPlaying());
         }
     }
 
@@ -311,15 +285,16 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         OCFile file = getFile();
         if (file != null) {
             // bind to any existing player
-            mMediaPlayerServiceConnection.bind();
+            mediaPlayerServiceConnection.bind();
 
             if (MimeTypeUtil.isAudio(file)) {
-                mMediaController.setMediaPlayer(mMediaPlayerServiceConnection);
-                mMediaPlayerServiceConnection.start(user, file, mAutoplay, mSavedPlaybackPosition);
-                mMultiListContainer.setVisibility(View.GONE);
-                mPreviewContainer.setVisibility(View.VISIBLE);
+                binding.mediaController.setMediaPlayer(mediaPlayerServiceConnection);
+                mediaPlayerServiceConnection.start(user, file, mAutoplay, mSavedPlaybackPosition);
+                binding.emptyView.emptyListView.setVisibility(View.GONE);
+                binding.progress.setVisibility(View.GONE);
+                binding.filePreviewContainer.setVisibility(View.VISIBLE);
             } else if (MimeTypeUtil.isVideo(file)) {
-                if (mMediaPlayerServiceConnection.isConnected()) {
+                if (mediaPlayerServiceConnection.isConnected()) {
                     // always stop player
                     stopAudio();
                 }
@@ -329,7 +304,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     }
 
     private void stopAudio() {
-        mMediaPlayerServiceConnection.stop();
+        mediaPlayerServiceConnection.stop();
     }
 
     @Override
@@ -412,31 +387,25 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case R.id.action_send_share_file: {
-                sendShareFile();
-                return true;
-            }
-            case R.id.action_open_file_with: {
-                openFile();
-                return true;
-            }
-            case R.id.action_remove_file: {
-                RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
-                dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
-                return true;
-            }
-            case R.id.action_see_details: {
-                seeDetails();
-                return true;
-            }
-            case R.id.action_sync_file: {
-                containerActivity.getFileOperationsHelper().syncFile(getFile());
-                return true;
-            }
-            default:
-                return super.onOptionsItemSelected(item);
+        int itemId = item.getItemId();
+        if (itemId == R.id.action_send_share_file) {
+            sendShareFile();
+            return true;
+        } else if (itemId == R.id.action_open_file_with) {
+            openFile();
+            return true;
+        } else if (itemId == R.id.action_remove_file) {
+            RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
+            dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
+            return true;
+        } else if (itemId == R.id.action_see_details) {
+            seeDetails();
+            return true;
+        } else if (itemId == R.id.action_sync_file) {
+            containerActivity.getFileOperationsHelper().syncFile(getFile());
+            return true;
         }
+        return super.onOptionsItemSelected(item);
     }
 
     /**
@@ -461,19 +430,19 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     private void prepareVideo() {
         // create helper to get more control on the playback
         VideoHelper videoHelper = new VideoHelper();
-        mVideoPreview.setOnPreparedListener(videoHelper);
-        mVideoPreview.setOnCompletionListener(videoHelper);
-        mVideoPreview.setOnErrorListener(videoHelper);
+        binding.videoPreview.setOnPreparedListener(videoHelper);
+        binding.videoPreview.setOnCompletionListener(videoHelper);
+        binding.videoPreview.setOnErrorListener(videoHelper);
     }
 
     private void playVideo() {
         // create and prepare control panel for the user
-        mMediaController.setMediaPlayer(mVideoPreview);
+        binding.mediaController.setMediaPlayer(binding.videoPreview);
 
         // load the video file in the video player
         // when done, VideoHelper#onPrepared() will be called
         if (getFile().isDown()) {
-            mVideoPreview.setVideoURI(getFile().getStorageUri());
+            binding.videoPreview.setVideoURI(getFile().getStorageUri());
         } else {
             try {
                 OwnCloudClient client = clientFactory.create(user);
@@ -512,13 +481,13 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
             final Context context = previewMediaFragment != null ? previewMediaFragment.getContext() : null;
             if (previewMediaFragment != null && context != null) {
                 if (uri != null) {
-                    previewMediaFragment.mVideoUri = uri;
-                    previewMediaFragment.mVideoPreview.setVideoURI(uri);
+                    previewMediaFragment.videoUri = uri;
+                    previewMediaFragment.binding.videoPreview.setVideoURI(uri);
                 } else {
-                    previewMediaFragment.mMultiListContainer.setVisibility(View.VISIBLE);
-                    previewMediaFragment.setMessageForMultiList(
+                    previewMediaFragment.emptyListView.setVisibility(View.VISIBLE);
+                    previewMediaFragment.setVideoErrorMessage(
                         previewMediaFragment.getString(R.string.stream_not_possible_headline),
-                        R.string.stream_not_possible_message, R.drawable.file_movie);
+                        R.string.stream_not_possible_message);
                 }
             } else {
                 Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
@@ -538,15 +507,16 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         @Override
         public void onPrepared(MediaPlayer vp) {
             Log_OC.v(TAG, "onPrepared");
-            mMultiListContainer.setVisibility(View.GONE);
-            mPreviewContainer.setVisibility(View.VISIBLE);
-            mVideoPreview.seekTo(mSavedPlaybackPosition);
-            if (mAutoplay) {
-                mVideoPreview.start();
+            binding.emptyView.emptyListView.setVisibility(View.GONE);
+            binding.progress.setVisibility(View.GONE);
+            binding.filePreviewContainer.setVisibility(View.VISIBLE);
+            binding.videoPreview.seekTo(savedPlaybackPosition);
+            if (autoplay) {
+                binding.videoPreview.start();
             }
-            mMediaController.setEnabled(true);
-            mMediaController.updatePausePlay();
-            mPrepared = true;
+            binding.mediaController.setEnabled(true);
+            binding.mediaController.updatePausePlay();
+            prepared = true;
         }
 
 
@@ -561,9 +531,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         public void onCompletion(MediaPlayer mp) {
             Log_OC.v(TAG, "completed");
             if (mp != null) {
-                mVideoPreview.seekTo(0);
+                binding.videoPreview.seekTo(0);
             } // else : called from onError()
-            mMediaController.updatePausePlay();
+            binding.mediaController.updatePausePlay();
         }
 
         /**
@@ -576,12 +546,13 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         @Override
         public boolean onError(MediaPlayer mp, int what, int extra) {
             Log_OC.e(TAG, "Error in video playback, what = " + what + ", extra = " + extra);
-            mPreviewContainer.setVisibility(View.GONE);
+            binding.filePreviewContainer.setVisibility(View.GONE);
+            binding.progress.setVisibility(View.GONE);
             final Context context = getActivity();
-            if (mVideoPreview.getWindowToken() != null && context != null) {
+            if (binding.videoPreview.getWindowToken() != null && context != null) {
                 String message = ErrorFormat.toString(context, what, extra);
-                mMultiListContainer.setVisibility(View.VISIBLE);
-                setMessageForMultiList(message, R.string.preview_sorry, R.drawable.file_movie);
+                binding.emptyView.emptyListView.setVisibility(View.VISIBLE);
+                setVideoErrorMessage(message, R.string.preview_sorry);
             }
             return true;
         }
@@ -606,17 +577,24 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         super.onDestroy();
     }
 
+    @Override
+    public void onDestroyView() {
+        Log_OC.v(TAG, "onDestroyView");
+        super.onDestroyView();
+        binding = null;
+    }
+
     @Override
     public void onStop() {
         Log_OC.v(TAG, "onStop");
-        mMediaPlayerServiceConnection.unbind();
+        mediaPlayerServiceConnection.unbind();
         toggleDrawerLockMode(containerActivity, DrawerLayout.LOCK_MODE_UNLOCKED);
         super.onStop();
     }
 
     @Override
     public boolean onTouch(View v, MotionEvent event) {
-        if (event.getAction() == MotionEvent.ACTION_DOWN && v.equals(mVideoPreview)) {
+        if (event.getAction() == MotionEvent.ACTION_DOWN && v.equals(binding.videoPreview)) {
             // added a margin on the left to avoid interfering with gesture to open navigation drawer
             if (event.getX() / Resources.getSystem().getDisplayMetrics().density > MIN_DENSITY_RATIO) {
                 startFullScreenVideo();
@@ -627,14 +605,14 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     }
 
     private void startFullScreenVideo() {
-        Intent i = new Intent(getActivity(), PreviewVideoActivity.class);
-        i.putExtra(FileActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
-        i.putExtra(FileActivity.EXTRA_FILE, getFile());
-        i.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, mVideoPreview.isPlaying());
-        i.putExtra(PreviewVideoActivity.EXTRA_STREAM_URL, mVideoUri);
-        mVideoPreview.pause();
-        i.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPreview.getCurrentPosition());
-        startActivityForResult(i, FileActivity.REQUEST_CODE__LAST_SHARED + 1);
+        Intent intent = new Intent(getActivity(), PreviewVideoActivity.class);
+        intent.putExtra(FileActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
+        intent.putExtra(FileActivity.EXTRA_FILE, getFile());
+        intent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, binding.videoPreview.isPlaying());
+        intent.putExtra(PreviewVideoActivity.EXTRA_STREAM_URL, videoUri);
+        binding.videoPreview.pause();
+        intent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, binding.videoPreview.getCurrentPosition());
+        startActivityForResult(intent, FileActivity.REQUEST_CODE__LAST_SHARED + 1);
     }
 
     @Override
@@ -648,8 +626,8 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         Log_OC.v(TAG, "onActivityResult " + this);
         super.onActivityResult(requestCode, resultCode, data);
         if (resultCode == Activity.RESULT_OK) {
-            mSavedPlaybackPosition = data.getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
-            mAutoplay = data.getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, false);
+            savedPlaybackPosition = data.getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
+            autoplay = data.getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, false);
         }
     }
 
@@ -676,9 +654,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     public void stopPreview(boolean stopAudio) {
         OCFile file = getFile();
         if (MimeTypeUtil.isAudio(file) && stopAudio) {
-            mMediaPlayerServiceConnection.pause();
+            mediaPlayerServiceConnection.pause();
         } else if (MimeTypeUtil.isVideo(file)) {
-            mVideoPreview.stopPlayback();
+            binding.videoPreview.stopPlayback();
         }
     }
 
@@ -693,11 +671,11 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
     }
 
     public int getPosition() {
-        if (mPrepared) {
-            mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
+        if (prepared) {
+            savedPlaybackPosition = binding.videoPreview.getCurrentPosition();
         }
-        Log_OC.v(TAG, "getting position: " + mSavedPlaybackPosition);
-        return mSavedPlaybackPosition;
+        Log_OC.v(TAG, "getting position: " + savedPlaybackPosition);
+        return savedPlaybackPosition;
     }
 
     private void toggleDrawerLockMode(ContainerActivity containerActivity, int lockMode) {

+ 37 - 11
src/main/res/layout/file_preview.xml → src/main/res/layout/fragment_preview_media.xml

@@ -2,6 +2,7 @@
 <!--
   ownCloud Android client application
 
+  Copyright (C) 2020 Andy Scherzinger
   Copyright (C) 2015 ownCloud Inc.
 
   This program is free software: you can redistribute it and/or modify
@@ -19,12 +20,13 @@
 -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                xmlns:tools="http://schemas.android.com/tools"
-                android:id="@+id/top"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:gravity="center"
-                tools:context=".ui.fragment.FilePreviewFragment">
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/top"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center"
+    tools:context=".ui.preview.PreviewMediaFragment">
 
     <RelativeLayout
         android:id="@+id/file_preview_container"
@@ -38,8 +40,7 @@
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_above="@+id/media_controller"
-            android:layout_alignParentTop="true"
-            >
+            android:layout_alignParentTop="true">
 
             <ImageView
                 android:id="@+id/image_preview"
@@ -55,8 +56,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_gravity="center"
-                android:visibility="gone"
-                />
+                android:visibility="gone" />
 
         </FrameLayout>
 
@@ -69,9 +69,35 @@
     </RelativeLayout>
 
     <FrameLayout
+        android:id="@+id/progress"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <include layout="@layout/empty_list" />
+
+        <com.elyeproj.loaderviewlibrary.LoaderImageView
+            android:layout_width="@dimen/empty_list_icon_layout_width"
+            android:layout_height="@dimen/empty_list_icon_layout_width"
+            android:layout_gravity="center"
+            android:contentDescription="@null"
+            app:corners="24" />
+
+        <ImageView
+            android:layout_width="@dimen/empty_list_icon_layout_width"
+            android:layout_height="@dimen/empty_list_icon_layout_height"
+            android:padding="@dimen/standard_half_padding"
+            android:layout_gravity="center"
+            android:contentDescription="@null"
+            android:src="@drawable/file_movie"
+            app:tint="@color/bg_default" />
+
+    </FrameLayout>
+
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <include
+            android:id="@+id/empty_view"
+            layout="@layout/empty_list" />
     </FrameLayout>
 
 </RelativeLayout>