Skip to content

Commit c65587e

Browse files
alperozturk96backportbot[bot]
authored andcommitted
fix: loading state
Signed-off-by: alperozturk <[email protected]>
1 parent ed3c5b0 commit c65587e

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class FileDisplayActivity :
197197
private var mSyncInProgress: Boolean = false
198198
set(value) {
199199
field = value
200-
setBackgroundText()
200+
setEmptyListState()
201201
}
202202

203203
private var mWaitingToSend: OCFile? = null
@@ -797,7 +797,6 @@ class FileDisplayActivity :
797797
setLeftFragment(fragment, true)
798798
}
799799

800-
@get:Deprecated("")
801800
val listOfFilesFragment: OCFileListFragment?
802801
get() {
803802
val listOfFiles =
@@ -1531,7 +1530,6 @@ class FileDisplayActivity :
15311530
syncResult: Any?
15321531
) {
15331532
if (FileSyncAdapter.EVENT_FULL_SYNC_START == event) {
1534-
mSyncInProgress = true
15351533
return
15361534
}
15371535

@@ -1548,14 +1546,7 @@ class FileDisplayActivity :
15481546
}
15491547

15501548
handleSyncResult(event, syncResult)
1551-
15521549
DataHolderUtil.getInstance().delete(id)
1553-
1554-
mSyncInProgress =
1555-
FileSyncAdapter.EVENT_FULL_SYNC_END != event &&
1556-
RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED != event
1557-
Log_OC.d(TAG, "Setting progress visibility to $mSyncInProgress")
1558-
15591550
handleScrollBehaviour(fileListFragment)
15601551
}
15611552

@@ -1657,21 +1648,16 @@ class FileDisplayActivity :
16571648
(syncResult.isException && syncResult.exception is AuthenticatorException)
16581649
}
16591650

1660-
/**
1661-
* Show a text message on screen view for notifying user if content is loading or folder is empty
1662-
*/
1663-
private fun setBackgroundText() {
1664-
val ocFileListFragment = listOfFilesFragment ?: return
1665-
connectivityService.isNetworkAndServerAvailable { result: Boolean? ->
1651+
private fun setEmptyListState() {
1652+
listOfFilesFragment?.let {
16661653
when {
1667-
mSyncInProgress && result == true -> {
1668-
ocFileListFragment.setEmptyListMessage(EmptyListState.LOADING)
1654+
mSyncInProgress -> {
1655+
it.setEmptyListMessage(EmptyListState.LOADING)
16691656
}
16701657
MainApp.isOnlyOnDevice() -> {
1671-
ocFileListFragment.setEmptyListMessage(EmptyListState.ONLY_ON_DEVICE)
1658+
it.setEmptyListMessage(EmptyListState.ONLY_ON_DEVICE)
16721659
}
1673-
result == true -> ocFileListFragment.setEmptyListMessage(SearchType.NO_SEARCH)
1674-
else -> ocFileListFragment.setEmptyListMessage(EmptyListState.OFFLINE_MODE)
1660+
else -> it.setEmptyListMessage(SearchType.NO_SEARCH)
16751661
}
16761662
}
16771663
}
@@ -2404,19 +2390,20 @@ class FileDisplayActivity :
24042390
// or if the method is called from a dialog that is being dismissed
24052391

24062392
if (TextUtils.isEmpty(searchQuery) && user.isPresent) {
2393+
mSyncInProgress = true
2394+
24072395
handler.postDelayed({
24082396
val user = getUser()
24092397
if (!ignoreFocus && !hasWindowFocus() || !user.isPresent) {
24102398
// do not refresh if the user rotates the device while another window has focus
24112399
// or if the current user is no longer valid
2400+
mSyncInProgress = false
24122401
return@postDelayed
24132402
}
24142403

24152404
val currentSyncTime = System.currentTimeMillis()
2416-
mSyncInProgress = true
24172405

2418-
// perform folder synchronization
2419-
val refreshFolderOperation: RemoteOperation<*> = RefreshFolderOperation(
2406+
val operation = RefreshFolderOperation(
24202407
folder,
24212408
currentSyncTime,
24222409
false,
@@ -2425,7 +2412,7 @@ class FileDisplayActivity :
24252412
user.get(),
24262413
applicationContext
24272414
)
2428-
refreshFolderOperation.execute(
2415+
operation.execute(
24292416
account,
24302417
MainApp.getAppContext(),
24312418
this@FileDisplayActivity,
@@ -2434,8 +2421,6 @@ class FileDisplayActivity :
24342421
)
24352422

24362423
fetchRecommendedFilesIfNeeded(ignoreETag, folder)
2437-
mSyncInProgress = false
2438-
ocFileListFragment?.setLoading(false)
24392424
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER)
24402425
}
24412426
}

0 commit comments

Comments
 (0)