Skip to content

Commit 08b0486

Browse files
committed
feat: do not show loading spinner
Signed-off-by: alperozturk <[email protected]>
1 parent b4aff05 commit 08b0486

File tree

9 files changed

+4
-95
lines changed

9 files changed

+4
-95
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,6 @@ class FileDisplayActivity :
12591259
}
12601260

12611261
val ocFileListFragment = leftFragment
1262-
1263-
ocFileListFragment.setLoading(mSyncInProgress)
12641262
syncAndUpdateFolder(ignoreETag = true, ignoreFocus = true)
12651263

12661264
var startFile: OCFile? = null
@@ -1530,7 +1528,6 @@ class FileDisplayActivity :
15301528
return
15311529
}
15321530

1533-
ocFileListFragment.setLoading(mSyncInProgress)
15341531
if (mSyncInProgress || ocFileListFragment.isLoading) {
15351532
return
15361533
}
@@ -1684,9 +1681,6 @@ class FileDisplayActivity :
16841681
// TODO what about other kind of previews?
16851682
}
16861683
}
1687-
1688-
val ocFileListFragment: OCFileListFragment? = this@FileDisplayActivity.listOfFilesFragment
1689-
ocFileListFragment?.setLoading(false)
16901684
}
16911685

16921686
// TODO refactor this receiver, and maybe DownloadFinishReceiver; this method is duplicated :S
@@ -2362,12 +2356,8 @@ class FileDisplayActivity :
23622356
)
23632357

23642358
fetchRecommendedFilesIfNeeded(ignoreETag, folder)
2365-
2366-
val fragment = this.listOfFilesFragment
2367-
if (fragment != null && fragment !is GalleryFragment) {
2368-
fragment.setLoading(true)
2369-
}
23702359
mSyncInProgress = false
2360+
ocFileListFragment?.setLoading(false)
23712361
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER)
23722362
}
23732363
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,13 @@ open class FolderPickerActivity :
273273
).also {
274274
it.execute(account, this, null, null)
275275
}
276-
277-
listOfFilesFragment?.isLoading = true
278276
setBackgroundText()
279277
}
280278

281279
override fun onResume() {
282280
super.onResume()
283281
Log_OC.e(TAG, "onResume() start")
284282

285-
listOfFilesFragment?.isLoading = mSyncInProgress
286283
refreshListOfFilesFragment(false)
287284
file = listOfFilesFragment?.currentFile
288285
updateUiElements()
@@ -585,7 +582,6 @@ open class FolderPickerActivity :
585582

586583
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT))
587584
Log_OC.d(TAG, "Setting progress visibility to $mSyncInProgress")
588-
listOfFilesFragment?.isLoading = mSyncInProgress
589585
setBackgroundText()
590586
} catch (e: RuntimeException) {
591587
Log_OC.e(TAG, "Error on broadcast receiver", e)

app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ open class ExtendedListFragment :
284284
val localFileListAdapter = adapter
285285
if (adapter is LocalFileListAdapter) {
286286
localFileListAdapter.filter(query)
287-
activity.fileListFragment.setLoading(false)
288287
}
289288
}
290289

app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
7272

7373
protected void setPhotoSearchQueryRunning(boolean value) {
7474
this.photoSearchQueryRunning = value;
75-
this.setLoading(value); // link the photoSearchQueryRunning variable with UI progress loading
7675
}
7776

7877
public boolean isPhotoSearchQueryRunning() {
@@ -229,7 +228,6 @@ public CommonOCFileListAdapterInterface getCommonAdapter() {
229228
public void onResume() {
230229
super.onResume();
231230

232-
setLoading(this.isPhotoSearchQueryRunning());
233231
if (getActivity() instanceof FileDisplayActivity fileDisplayActivity) {
234232
fileDisplayActivity.updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
235233
fileDisplayActivity.setMainFabVisible(false);

app/src/main/java/com/owncloud/android/ui/fragment/GroupfolderListFragment.kt

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@ import android.content.Intent
1212
import android.content.Intent.ACTION_VIEW
1313
import android.os.Bundle
1414
import android.os.Handler
15-
import androidx.lifecycle.lifecycleScope
1615
import androidx.recyclerview.widget.LinearLayoutManager
1716
import com.nextcloud.android.lib.resources.groupfolders.Groupfolder
1817
import com.nextcloud.client.di.Injectable
1918
import com.nextcloud.client.logger.Logger
2019
import com.owncloud.android.MainApp
2120
import com.owncloud.android.R
22-
import com.owncloud.android.datamodel.OCFile
23-
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
24-
import com.owncloud.android.lib.resources.files.model.RemoteFile
2521
import com.owncloud.android.ui.EmptyRecyclerView
2622
import com.owncloud.android.ui.activity.FileDisplayActivity
2723
import com.owncloud.android.ui.adapter.GroupfolderListAdapter
2824
import com.owncloud.android.ui.asynctasks.GroupfoldersSearchTask
2925
import com.owncloud.android.ui.interfaces.GroupfolderListInterface
30-
import com.owncloud.android.utils.DisplayUtils
31-
import com.owncloud.android.utils.FileStorageUtils
32-
import kotlinx.coroutines.Dispatchers
33-
import kotlinx.coroutines.launch
34-
import kotlinx.coroutines.withContext
3526
import javax.inject.Inject
3627

3728
/**
@@ -105,45 +96,6 @@ class GroupfolderListFragment :
10596
adapter.notifyDataSetChanged()
10697
}
10798

108-
private suspend fun fetchFileData(partialFile: OCFile): OCFile? = withContext(Dispatchers.IO) {
109-
val user = accountManager.user
110-
val fetchResult = ReadFileRemoteOperation(partialFile.remotePath).execute(user, context)
111-
if (!fetchResult.isSuccess) {
112-
logger.e(SHARED_TAG, "Error fetching file")
113-
if (fetchResult.isException && fetchResult.exception != null) {
114-
logger.e(SHARED_TAG, "exception: ", fetchResult.exception!!)
115-
}
116-
null
117-
} else {
118-
val remoteFile = fetchResult.data[0] as RemoteFile
119-
val file = FileStorageUtils.fillOCFile(remoteFile)
120-
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.accountName)
121-
val savedFile = mContainerActivity.storageManager.saveFileWithParent(file, context)
122-
savedFile.apply {
123-
isSharedViaLink = partialFile.isSharedViaLink
124-
isSharedWithSharee = partialFile.isSharedWithSharee
125-
sharees = partialFile.sharees
126-
}
127-
}
128-
}
129-
130-
private fun fetchFileAndRun(partialFile: OCFile, block: (file: OCFile) -> Unit) {
131-
lifecycleScope.launch {
132-
isLoading = true
133-
val file = fetchFileData(partialFile)
134-
isLoading = false
135-
if (file != null) {
136-
block(file)
137-
} else {
138-
DisplayUtils.showSnackMessage(requireActivity(), R.string.error_retrieving_file)
139-
}
140-
}
141-
}
142-
143-
companion object {
144-
private val SHARED_TAG = GroupfolderListFragment::class.java.simpleName
145-
}
146-
14799
override fun onFolderClick(path: String) {
148100
MainApp.showOnlyFilesOnDevice(false)
149101
Intent(

app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import android.content.Context;
1414
import android.os.Bundle;
1515
import android.os.Environment;
16-
import android.os.Handler;
1716
import android.view.LayoutInflater;
1817
import android.view.Menu;
1918
import android.view.MenuInflater;
@@ -381,22 +380,6 @@ public void switchToListView() {
381380
super.switchToListView();
382381
}
383382

384-
@Override
385-
public void setLoading(boolean enabled) {
386-
super.setLoading(enabled);
387-
if (enabled) {
388-
setEmptyListMessage(EmptyListState.LOADING);
389-
} else {
390-
// ugly hack because setEmptyListLoadingMessage also uses a handler and there's a race condition otherwise
391-
new Handler().post(() -> {
392-
mAdapter.notifyDataSetChanged();
393-
if (mAdapter.getFilesCount() == 0) {
394-
setEmptyListMessage(SearchType.LOCAL_SEARCH);
395-
}
396-
});
397-
}
398-
}
399-
400383
@VisibleForTesting
401384
public void setFiles(List<File> newFiles) {
402385
mAdapter.setFiles(newFiles);

app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,6 @@ public void onMessageEvent(FileLockEvent event) {
20522052
final User user = accountManager.getUser();
20532053

20542054
try {
2055-
new Handler(Looper.getMainLooper()).post(() -> setLoading(true));
20562055
NextcloudClient client = clientFactory.createNextcloudClient(user);
20572056
ToggleFileLockRemoteOperation operation = new ToggleFileLockRemoteOperation(event.getShouldLock(), event.getFilePath());
20582057
RemoteOperationResult<Void> result = operation.execute(client);
@@ -2074,8 +2073,6 @@ public void onMessageEvent(FileLockEvent event) {
20742073
R.string.error_file_lock,
20752074
Snackbar.LENGTH_LONG).show();
20762075
}
2077-
} finally {
2078-
new Handler(Looper.getMainLooper()).post(() -> setLoading(false));
20792076
}
20802077
}
20812078

app/src/main/java/com/owncloud/android/ui/fragment/OCFileListSearchAsyncTask.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
package com.owncloud.android.ui.fragment
99

10+
import android.annotation.SuppressLint
1011
import android.os.AsyncTask
1112
import android.os.Handler
1213
import android.os.Looper
@@ -35,7 +36,6 @@ class OCFileListSearchAsyncTask(
3536
override fun onPreExecute() {
3637
fragmentReference.get()?.let { fragment ->
3738
Handler(Looper.getMainLooper()).post {
38-
fragment.isLoading = true
3939
fragment.setEmptyListMessage(EmptyListState.LOADING)
4040
}
4141
}
@@ -51,7 +51,7 @@ class OCFileListSearchAsyncTask(
5151
lateinit var remoteOperationResult: RemoteOperationResult<List<Any>>
5252
try {
5353
remoteOperationResult = remoteOperation.execute(currentUser, fragment.context)
54-
} catch (e: UnsupportedOperationException) {
54+
} catch (_: UnsupportedOperationException) {
5555
remoteOperationResult = remoteOperation.executeNextcloudClient(currentUser, fragment.requireContext())
5656
}
5757

@@ -72,9 +72,9 @@ class OCFileListSearchAsyncTask(
7272
return remoteOperationResult.isSuccess
7373
}
7474

75+
@SuppressLint("NotifyDataSetChanged")
7576
override fun onPostExecute(bool: Boolean) {
7677
fragmentReference.get()?.let { fragment ->
77-
fragment.isLoading = false
7878
if (!isCancelled) {
7979
fragment.adapter.notifyDataSetChanged()
8080
}

app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ class SharedListFragment :
104104

105105
private fun fetchFileAndRun(partialFile: OCFile, block: (file: OCFile) -> Unit) {
106106
lifecycleScope.launch {
107-
isLoading = true
108107
val file = fetchFileData(partialFile)
109-
isLoading = false
110108
withContext(Dispatchers.Main) {
111109
if (file != null) {
112110
block(file)
@@ -119,7 +117,6 @@ class SharedListFragment :
119117

120118
private fun fetchAllAndRun(partialFiles: MutableSet<OCFile>?, callback: (MutableSet<OCFile>?) -> Unit) {
121119
lifecycleScope.launch {
122-
isLoading = true
123120
if (partialFiles != null) {
124121
val files = partialFiles.toMutableSet().mapNotNull { partialFile ->
125122
fetchFileData(partialFile).also { fetched ->
@@ -128,10 +125,7 @@ class SharedListFragment :
128125
}
129126
}
130127
}
131-
isLoading = false
132128
callback(files.toHashSet())
133-
} else {
134-
isLoading = false
135129
}
136130
}
137131
}

0 commit comments

Comments
 (0)