Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package com.nextcloud.utils.extensions

import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import android.text.Selection
import android.text.Spannable
Expand All @@ -24,6 +26,12 @@ import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

fun mainThread(delay: Long = 1000, action: () -> Unit) {
Handler(Looper.getMainLooper()).postDelayed({
action()
}, delay)
}

fun clickWithDebounce(view: View, debounceTime: Long = 600L, action: () -> Unit) {
view.setOnClickListener(object : View.OnClickListener {
private var lastClickTime: Long = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public class ReceiveExternalFilesActivity extends FileActivity

private SyncBroadcastReceiver mSyncBroadcastReceiver;
private ReceiveExternalFilesAdapter receiveExternalFilesAdapter;
private boolean mSyncInProgress;

private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1;

Expand Down Expand Up @@ -856,7 +855,6 @@ private void startSyncFolderOperation(OCFile folder) {

executorService.execute(() -> {
long currentSyncTime = System.currentTimeMillis();
mSyncInProgress = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused unnecessary duplicated logic that we have in FileDisplayActivity

final var optionalUser = getUser();
if (optionalUser.isEmpty()) {
DisplayUtils.showSnackMessage(this, R.string.user_information_retrieval_error);
Expand Down Expand Up @@ -1155,58 +1153,32 @@ public void onReceive(Context context, Intent intent) {
boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name)
&& getStorageManager() != null;

if (sameAccount) {

if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
mSyncInProgress = true;
if (sameAccount && !FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
OCFile currentFile = (mFile == null) ? null : getStorageManager().getFileByPath(mFile.getRemotePath());
OCFile currentDir = (getCurrentFolder() == null) ? null : getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());

if (currentDir == null) {
// current folder was removed from the server
DisplayUtils.showSnackMessage(getActivity(), R.string.sync_current_folder_was_removed, getCurrentFolder().getFileName());
browseToRoot();
} else {
OCFile currentFile = (mFile == null) ? null :
getStorageManager().getFileByPath(mFile.getRemotePath());
OCFile currentDir = (getCurrentFolder() == null) ? null :
getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());

if (currentDir == null) {
// current folder was removed from the server
DisplayUtils.showSnackMessage(
getActivity(),
R.string.sync_current_folder_was_removed,
getCurrentFolder().getFileName()
);
browseToRoot();

} else {
if (currentFile == null && !mFile.isFolder()) {
// currently selected file was removed in the server, and now we know it
currentFile = currentDir;
}

if (currentDir.getRemotePath().equals(syncFolderRemotePath)) {
populateDirectoryList(currentFile);
}
if (currentFile == null && !mFile.isFolder()) {
// currently selected file was removed in the server, and now we know it
currentFile = currentDir;
}

mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);

if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event)
/// TODO refactor and make common
&& syncResult != null && !syncResult.isSuccess()) {

if (syncResult.getCode() == ResultCode.UNAUTHORIZED ||
(syncResult.isException() && syncResult.getException()
instanceof AuthenticatorException)) {

requestCredentialsUpdate();

} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {

showUntrustedCertDialog(syncResult);
}
if (currentDir.getRemotePath().equals(syncFolderRemotePath)) {
populateDirectoryList(currentFile);
}
}
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);

if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) && syncResult != null && !syncResult.isSuccess()) {
if (syncResult.getCode() == ResultCode.UNAUTHORIZED || (syncResult.isException() && syncResult.getException() instanceof AuthenticatorException)) {
requestCredentialsUpdate();
} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {
showUntrustedCertDialog(syncResult);
}
}
}
} catch (RuntimeException e) {
// avoid app crashes after changing the serial id of RemoteOperationResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.nextcloud.client.di.Injectable
import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.client.preferences.AppPreferencesImpl
import com.nextcloud.utils.extensions.getTypedActivity
import com.nextcloud.utils.extensions.mainThread
import com.owncloud.android.MainApp
import com.owncloud.android.R
import com.owncloud.android.databinding.ListFragmentBinding
Expand Down Expand Up @@ -720,6 +721,10 @@ open class ExtendedListFragment :
true
)
}
}.also {
mainThread {
mRefreshListLayout?.isRefreshing = false
Copy link
Collaborator Author

@alperozturk96 alperozturk96 Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRefreshing only set via pull-to-refresh since from #15529, no need to keep it as true.

}
}
}

Expand Down
Loading