Эх сурвалжийг харах

Show message when the file list is being loading and when it is empty

jabarros 10 жил өмнө
parent
commit
89e7ad9e67

+ 1 - 1
res/layout/list_fragment.xml

@@ -39,7 +39,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:gravity="center_vertical|center_horizontal"
-        android:text="@string/file_list_empty"
+        android:text="@string/empty"
         android:visibility="gone"
 	/>
 

+ 2 - 0
res/values/strings.xml

@@ -54,6 +54,7 @@
     <string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
     <string name="uploader_info_uploading">Uploading</string>
     <string name="file_list_empty">Nothing in here. Upload something!</string>
+    <string name="file_list_loading">Loading...</string>
     <string name="local_file_list_empty">There are no files in this folder.</string>
     <string name="filedetails_select_file">Tap on a file to display additional information.</string>
     <string name="filedetails_size">Size:</string>
@@ -270,5 +271,6 @@
 	<string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
 	<string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
 	<string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
+	<string name="empty"></string>
 	
 </resources>

+ 23 - 0
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -196,6 +196,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         getSupportActionBar().setHomeButtonEnabled(true);       // mandatory since Android ICS, according to the official documentation
         setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);    // always AFTER setContentView(...) ; to work around bug in its implementation
         
+        showMessageView();
+
         Log_OC.d(TAG, "onCreate() end");
     }
     
@@ -960,6 +962,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
                     removeStickyBroadcast(intent);
                     Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
                     setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
+
+                    showMessageView();
                         
                 }
                 
@@ -976,6 +980,23 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         }
     }
     
+    /**
+     * Show a text message on screen view for notifying user if content is
+     * loading or folder is empty
+     */
+    private void showMessageView() {
+        OCFileListFragment ocFileListFragment = getListOfFilesFragment();
+        if (ocFileListFragment != null) {
+            int message = R.string.file_list_loading;
+            if (!mSyncInProgress) {
+                // In case file list is empty
+                message = R.string.file_list_empty;
+            }
+            ocFileListFragment.setMessageforEmptyView(message);
+        } else {
+            Log.e(TAG, "OCFileListFragment is null");
+        }
+    }
 
     /**
      * Once the file upload has finished -> update view
@@ -1529,6 +1550,8 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         synchFolderOp.execute(getAccount(), this, null, null);
         
         setSupportProgressBarIndeterminateVisibility(true);
+
+        showMessageView();
     }
 
     /**

+ 3 - 1
src/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -168,7 +168,9 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
      * Set message for empty list view
      */
     public void setMessageforEmptyView(int message) {
-        mEmptyListMessage.setText(message);
+        if (mEmptyListMessage != null) {
+            mEmptyListMessage.setText(message);
+        }
     }
  
     

+ 0 - 2
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -107,8 +107,6 @@ public class OCFileListFragment extends ExtendedListFragment {
         super.onActivityCreated(savedInstanceState);
         Log_OC.e(TAG, "onActivityCreated() start");
         
-        setMessageforEmptyView(R.string.file_list_empty);
-
         mAdapter = new FileListListAdapter(getSherlockActivity(), mContainerActivity); 
                 
         if (savedInstanceState != null) {