@@ -120,6 +120,7 @@ import com.owncloud.android.ui.dialog.TermsOfServiceDialog
120
120
import com.owncloud.android.ui.events.SearchEvent
121
121
import com.owncloud.android.ui.events.SyncEventFinished
122
122
import com.owncloud.android.ui.events.TokenPushEvent
123
+ import com.owncloud.android.ui.fragment.EmptyListState
123
124
import com.owncloud.android.ui.fragment.FileDetailFragment
124
125
import com.owncloud.android.ui.fragment.FileFragment
125
126
import com.owncloud.android.ui.fragment.GalleryFragment
@@ -191,7 +192,11 @@ class FileDisplayActivity :
191
192
192
193
private var mWaitingToPreview: OCFile ? = null
193
194
194
- private var mSyncInProgress = false
195
+ private var mSyncInProgress: Boolean = false
196
+ set(value) {
197
+ field = value
198
+ setBackgroundText()
199
+ }
195
200
196
201
private var mWaitingToSend: OCFile ? = null
197
202
@@ -1435,8 +1440,10 @@ class FileDisplayActivity :
1435
1440
) {
1436
1441
mLastSslUntrustedServerResult = syncResult
1437
1442
}
1438
- } catch (e : java.lang.RuntimeException ) {
1443
+ } catch (_ : java.lang.RuntimeException ) {
1439
1444
safelyDeleteResult(intent)
1445
+ } finally {
1446
+ mSyncInProgress = false
1440
1447
}
1441
1448
}
1442
1449
}
@@ -1486,7 +1493,6 @@ class FileDisplayActivity :
1486
1493
Log_OC .d(TAG , " Setting progress visibility to $mSyncInProgress " )
1487
1494
1488
1495
handleScrollBehaviour(fileListFragment)
1489
- setBackgroundText()
1490
1496
}
1491
1497
1492
1498
private fun handleRemovedFileFromServer (currentFile : OCFile ? , currentDir : OCFile ? ): OCFile ? {
@@ -1592,36 +1598,18 @@ class FileDisplayActivity :
1592
1598
* Show a text message on screen view for notifying user if content is loading or folder is empty
1593
1599
*/
1594
1600
private fun setBackgroundText () {
1595
- val ocFileListFragment = this .listOfFilesFragment
1596
- if (ocFileListFragment != null ) {
1597
- if (mSyncInProgress ||
1598
- file.fileLength > 0 &&
1599
- storageManager.getFolderContent(
1600
- file,
1601
- false
1602
- ).isEmpty()
1603
- ) {
1604
- ocFileListFragment.setEmptyListLoadingMessage()
1605
- } else {
1606
- if (MainApp .isOnlyOnDevice()) {
1607
- ocFileListFragment.setMessageForEmptyList(
1608
- R .string.file_list_empty_headline,
1609
- R .string.file_list_empty_on_device,
1610
- R .drawable.ic_list_empty_folder,
1611
- true
1612
- )
1613
- } else {
1614
- connectivityService.isNetworkAndServerAvailable { result: Boolean? ->
1615
- if (result == true ) {
1616
- ocFileListFragment.setEmptyListMessage(SearchType .NO_SEARCH )
1617
- } else {
1618
- ocFileListFragment.setEmptyListMessage(SearchType .OFFLINE_MODE )
1619
- }
1620
- }
1601
+ val ocFileListFragment = listOfFilesFragment ? : return
1602
+ connectivityService.isNetworkAndServerAvailable { result: Boolean? ->
1603
+ when {
1604
+ mSyncInProgress && result == true -> {
1605
+ ocFileListFragment.setEmptyListMessage(EmptyListState .LOADING )
1621
1606
}
1607
+ MainApp .isOnlyOnDevice() -> {
1608
+ ocFileListFragment.setEmptyListMessage(EmptyListState .ONLY_ON_DEVICE )
1609
+ }
1610
+ result == true -> ocFileListFragment.setEmptyListMessage(SearchType .NO_SEARCH )
1611
+ else -> ocFileListFragment.setEmptyListMessage(EmptyListState .OFFLINE_MODE )
1622
1612
}
1623
- } else {
1624
- Log_OC .e(TAG , " OCFileListFragment is null" )
1625
1613
}
1626
1614
}
1627
1615
@@ -2379,7 +2367,7 @@ class FileDisplayActivity :
2379
2367
if (fragment != null && fragment !is GalleryFragment ) {
2380
2368
fragment.setLoading(true )
2381
2369
}
2382
- setBackgroundText()
2370
+ mSyncInProgress = false
2383
2371
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER )
2384
2372
}
2385
2373
}
0 commit comments