Ver código fonte

add shimmer effect to trashbin screen

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 anos atrás
pai
commit
afb4d925a1

+ 24 - 19
src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java

@@ -67,6 +67,7 @@ public class TrashbinActivity extends DrawerActivity implements
     TrashbinContract.View,
     Injectable {
 
+    public static final int EMPTY_LIST_COUNT = 1;
     @Inject AppPreferences preferences;
     @Inject CurrentAccountProvider accountProvider;
     @Inject ClientFactory clientFactory;
@@ -138,31 +139,31 @@ public class TrashbinActivity extends DrawerActivity implements
     }
 
     protected void loadFolder() {
-        binding.swipeContainingList.setRefreshing(true);
+        if (trashbinListAdapter.getItemCount() > EMPTY_LIST_COUNT) {
+            binding.swipeContainingList.setRefreshing(true);
+        } else {
+            binding.loadingContent.setVisibility(View.VISIBLE);
+            binding.list.setVisibility(View.GONE);
+        }
         trashbinPresenter.loadFolder();
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         boolean retval = true;
-        switch (item.getItemId()) {
-            case android.R.id.home:
-                if (isDrawerOpen()) {
-                    closeDrawer();
-                } else if (trashbinPresenter.isRoot()) {
-                    onBackPressed();
-                } else {
-                    openDrawer();
-                }
-                break;
-
-            case R.id.action_empty_trashbin:
-                trashbinPresenter.emptyTrashbin();
-                break;
-
-            default:
-                retval = super.onOptionsItemSelected(item);
-                break;
+        int itemId = item.getItemId();
+        if (itemId == android.R.id.home) {
+            if (isDrawerOpen()) {
+                closeDrawer();
+            } else if (trashbinPresenter.isRoot()) {
+                onBackPressed();
+            } else {
+                openDrawer();
+            }
+        } else if (itemId == R.id.action_empty_trashbin) {
+            trashbinPresenter.emptyTrashbin();
+        } else {
+            retval = super.onOptionsItemSelected(item);
         }
 
         return retval;
@@ -236,6 +237,8 @@ public class TrashbinActivity extends DrawerActivity implements
         if (active) {
             trashbinListAdapter.setTrashbinFiles(trashbinFiles, true);
             binding.swipeContainingList.setRefreshing(false);
+            binding.loadingContent.setVisibility(View.GONE);
+            binding.list.setVisibility(View.VISIBLE);
         }
     }
 
@@ -264,6 +267,8 @@ public class TrashbinActivity extends DrawerActivity implements
     @Override
     public void showError(int message) {
         if (active) {
+            binding.loadingContent.setVisibility(View.GONE);
+            binding.list.setVisibility(View.VISIBLE);
             binding.swipeContainingList.setRefreshing(false);
 
             binding.emptyList.emptyListViewHeadline.setText(R.string.common_error);

+ 13 - 0
src/main/res/layout/trashbin_activity.xml

@@ -57,6 +57,19 @@
                     android:layout_height="match_parent" />
             </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
+            <LinearLayout
+                android:id="@+id/loading_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:visibility="gone">
+
+                <include layout="@layout/trashbin_item_shimmer" />
+                <include layout="@layout/trashbin_item_shimmer" />
+                <include layout="@layout/trashbin_item_shimmer" />
+
+            </LinearLayout>
+
             <include
                 android:id="@+id/empty_list"
                 layout="@layout/empty_list" />

+ 125 - 0
src/main/res/layout/trashbin_item_shimmer.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?><!--
+  ownCloud Android client application
+
+  Copyright (C) 2012  Bartek Przybylski
+  Copyright (C) 2015 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/ListItemLayout"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:minHeight="@dimen/standard_list_item_size"
+    android:background="?android:attr/selectableItemBackground"
+    android:descendantFocusability="blocksDescendants"
+    android:orientation="horizontal">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:orientation="horizontal"
+        android:paddingTop="@dimen/standard_padding"
+        android:paddingBottom="@dimen/standard_padding">
+
+        <com.elyeproj.loaderviewlibrary.LoaderImageView
+            android:id="@+id/thumbnail"
+            android:layout_width="@dimen/file_icon_size"
+            android:layout_height="@dimen/file_icon_size"
+            android:layout_marginLeft="@dimen/standard_margin"
+            android:layout_marginRight="@dimen/standard_margin"
+            android:contentDescription="@null"
+            app:corners="16" />
+
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="top"
+            android:orientation="vertical">
+
+            <com.elyeproj.loaderviewlibrary.LoaderTextView
+                android:id="@+id/Filename"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/standard_quarter_margin"
+                android:textStyle="bold" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <com.elyeproj.loaderviewlibrary.LoaderTextView
+                    android:id="@+id/fileSize"
+                    android:layout_height="12sp"
+                    android:layout_width="80dp" />
+
+                <com.elyeproj.loaderviewlibrary.LoaderTextView
+                    android:id="@+id/deletionTimestamp"
+                    android:layout_width="80dp"
+                    android:layout_height="12sp"
+                    android:layout_marginStart="@dimen/standard_half_margin"
+                    android:layout_marginEnd="@dimen/standard_half_margin" />
+
+            </LinearLayout>
+
+            <com.elyeproj.loaderviewlibrary.LoaderTextView
+                android:id="@+id/originalLocation"
+                android:layout_width="100dp"
+                android:layout_height="12sp"
+                android:layout_marginTop="4dp" />
+
+        </LinearLayout>
+
+        <RelativeLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingEnd="@dimen/zero"
+            android:paddingStart="@dimen/standard_half_padding">
+
+            <com.elyeproj.loaderviewlibrary.LoaderImageView
+                android:id="@+id/restore"
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_marginStart="@dimen/standard_half_padding"
+                android:layout_marginEnd="@dimen/list_item_share_right_margin"
+                android:contentDescription="@null"
+                app:corners="100" />
+
+            <com.elyeproj.loaderviewlibrary.LoaderTextView
+                android:id="@+id/customCheckbox"
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_toEndOf="@id/restore"
+                android:contentDescription="@null"
+                android:layout_marginEnd="@dimen/alternate_padding"
+                android:layout_marginStart="@dimen/standard_half_padding" />
+
+            <com.elyeproj.loaderviewlibrary.LoaderTextView
+                android:id="@+id/overflowMenu"
+                android:layout_width="8dp"
+                android:layout_height="24dp"
+                android:layout_toEndOf="@id/customCheckbox"
+                android:contentDescription="@null"
+                android:layout_marginEnd="@dimen/standard_margin"
+                android:layout_marginStart="@dimen/standard_margin" />
+
+        </RelativeLayout>
+
+    </LinearLayout>
+
+</LinearLayout>