Bläddra i källkod

WIP image loader animation

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 år sedan
förälder
incheckning
b74be97a16

+ 1 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -71,7 +71,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 
 /**
- *  Holds a swiping galley where image files contained in an ownCloud directory are shown
+ *  Holds a swiping galley where image files contained in an Nextcloud directory are shown
  */
 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
 public class PreviewImageActivity extends FileActivity implements

+ 28 - 15
src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -46,7 +46,9 @@ import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.FrameLayout;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 
 import com.caverock.androidsvg.SVG;
 import com.caverock.androidsvg.SVGParseException;
@@ -277,11 +279,15 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
                     }
                 }
                 binding.emptyListView.setVisibility(View.GONE);
+                binding.emptyListProgress.setVisibility(View.GONE);
                 binding.image.setBackgroundColor(getResources().getColor(R.color.background_color_inverse));
                 binding.image.setVisibility(View.VISIBLE);
 
             } else {
-                loadBitmapTask = new LoadBitmapTask(binding.image);
+                loadBitmapTask = new LoadBitmapTask(binding.image, binding.emptyListView, binding.emptyListProgress);
+                binding.image.setVisibility(View.GONE);
+                binding.emptyListView.setVisibility(View.GONE);
+                binding.emptyListProgress.setVisibility(View.VISIBLE);
                 loadBitmapTask.execute(getFile());
             }
         } else {
@@ -465,7 +471,9 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
          * Using a weak reference will avoid memory leaks if the target ImageView is retired from
          * memory before the load finishes.
          */
-        private final WeakReference<PhotoView> mImageViewRef;
+        private final WeakReference<PhotoView> imageViewRef;
+        private final WeakReference<LinearLayout> infoViewRef;
+        private final WeakReference<FrameLayout> progressViewRef;
 
         /**
          * Error message to show when a load fails.
@@ -478,8 +486,10 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
          *
          * @param imageView Target {@link ImageView} where the bitmap will be loaded into.
          */
-        LoadBitmapTask(PhotoView imageView) {
-            mImageViewRef = new WeakReference<>(imageView);
+        LoadBitmapTask(PhotoView imageView, LinearLayout infoView, FrameLayout progressView) {
+            imageViewRef = new WeakReference<>(imageView);
+            infoViewRef = new WeakReference<>(infoView);
+            progressViewRef = new WeakReference<>(progressView);
         }
 
         @Override
@@ -597,7 +607,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
         }
 
         private void showLoadedImage(LoadImage result) {
-            final PhotoView imageView = mImageViewRef.get();
+            final PhotoView imageView = imageViewRef.get();
             Bitmap bitmap = result.bitmap;
             Drawable drawable = result.drawable;
 
@@ -614,7 +624,6 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
                         imageView.setImageBitmap(bitmap);
                     }
 
-                    imageView.setVisibility(View.VISIBLE);
                     PreviewImageFragment.this.bitmap = bitmap;  // needs to be kept for recycling when not useful
                 } else {
                     if (drawable != null
@@ -623,8 +632,15 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
                         imageView.setImageDrawable(generateCheckerboardLayeredDrawable(result, null));
                     }
                 }
+                final LinearLayout infoView = infoViewRef.get();
+                if (infoView != null) {
+                    infoView.setVisibility(View.GONE);
+                }
 
-                binding.emptyListView.setVisibility(View.GONE);
+                final FrameLayout progressView = progressViewRef.get();
+                if (progressView != null) {
+                    progressView.setVisibility(View.GONE);
+                }
                 imageView.setBackgroundColor(getResources().getColor(R.color.background_color_inverse));
                 imageView.setVisibility(View.VISIBLE);
             }
@@ -676,16 +692,13 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
     }
 
     private void showErrorMessage(@StringRes int errorMessageId) {
-        binding.image.setBackgroundColor(Color.TRANSPARENT);
         setSorryMessageForMultiList(errorMessageId);
     }
 
     private void setMultiListLoadingMessage() {
-            binding.emptyListViewHeadline.setText("");
-            binding.emptyListViewText.setText("");
-
-            binding.emptyListIcon.setVisibility(View.GONE);
-            binding.emptyListProgress.setVisibility(View.VISIBLE);
+        binding.image.setVisibility(View.GONE);
+        binding.emptyListView.setVisibility(View.GONE);
+        binding.emptyListProgress.setVisibility(View.VISIBLE);
     }
 
     private void setSorryMessageForMultiList(@StringRes int message) {
@@ -697,8 +710,8 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
         binding.emptyListViewHeadline.setTextColor(getResources().getColor(R.color.standard_grey));
         binding.emptyListViewText.setTextColor(getResources().getColor(R.color.standard_grey));
 
-        binding.emptyListViewText.setVisibility(View.VISIBLE);
-        binding.emptyListIcon.setVisibility(View.VISIBLE);
+        binding.image.setVisibility(View.GONE);
+        binding.emptyListView.setVisibility(View.VISIBLE);
         binding.emptyListProgress.setVisibility(View.GONE);
     }
 

+ 26 - 30
src/main/res/layout/preview_image_fragment.xml

@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
   ownCloud Android client application
 
   Copyright (C) 2015  ownCloud Inc.
@@ -17,8 +16,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 -->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/top"
     android:layout_width="match_parent"
@@ -29,7 +27,6 @@
         android:id="@+id/image"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_centerInParent="true"
         android:layout_margin="@dimen/zero"
         android:contentDescription="@string/preview_image_description"
         android:src="@drawable/image_fail" />
@@ -49,30 +46,7 @@
             android:layout_width="@dimen/empty_list_icon_layout_width"
             android:layout_height="@dimen/empty_list_icon_layout_height"
             android:contentDescription="@string/file_list_folder"
-            android:src="@drawable/ic_list_empty_folder"
-            android:visibility="gone" />
-
-        <FrameLayout
-            android:id="@+id/empty_list_progress"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:visibility="gone">
-
-            <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_horizontal"
-                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:contentDescription="@null"
-                android:src="@drawable/ic_image_outline"
-                app:tint="@color/fg_inverse" />
-
-        </FrameLayout>
+            android:src="@drawable/file_image" />
 
         <TextView
             android:id="@+id/empty_list_view_headline"
@@ -108,4 +82,26 @@
             android:visibility="gone"
             app:cornerRadius="@dimen/button_corner_radius" />
     </LinearLayout>
-</RelativeLayout>
+
+    <FrameLayout
+        android:id="@+id/empty_list_progress"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <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:layout_gravity="center"
+            android:contentDescription="@null"
+            android:src="@drawable/ic_image_outline"
+            app:tint="@color/bg_default" />
+
+    </FrameLayout>
+</FrameLayout>