Skip to content

Commit 30fc950

Browse files
committed
fix: loading indicator
Signed-off-by: alperozturk <[email protected]>
1 parent 378dbbf commit 30fc950

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

app/src/main/java/com/nextcloud/utils/extensions/Extensions.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99
package com.nextcloud.utils.extensions
1010

11+
import android.os.Handler
12+
import android.os.Looper
1113
import android.os.SystemClock
1214
import android.text.Selection
1315
import android.text.Spannable
@@ -24,6 +26,12 @@ import java.text.SimpleDateFormat
2426
import java.util.Date
2527
import java.util.Locale
2628

29+
fun mainThread(delay: Long = 1000, action: () -> Unit) {
30+
Handler(Looper.getMainLooper()).postDelayed({
31+
action()
32+
}, delay)
33+
}
34+
2735
fun clickWithDebounce(view: View, debounceTime: Long = 600L, action: () -> Unit) {
2836
view.setOnClickListener(object : View.OnClickListener {
2937
private var lastClickTime: Long = 0

app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
148148

149149
private SyncBroadcastReceiver mSyncBroadcastReceiver;
150150
private ReceiveExternalFilesAdapter receiveExternalFilesAdapter;
151-
private boolean mSyncInProgress;
152151

153152
private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1;
154153

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

857856
executorService.execute(() -> {
858857
long currentSyncTime = System.currentTimeMillis();
859-
mSyncInProgress = true;
860858
final var optionalUser = getUser();
861859
if (optionalUser.isEmpty()) {
862860
DisplayUtils.showSnackMessage(this, R.string.user_information_retrieval_error);
@@ -1157,10 +1155,7 @@ public void onReceive(Context context, Intent intent) {
11571155

11581156
if (sameAccount) {
11591157

1160-
if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
1161-
mSyncInProgress = true;
1162-
1163-
} else {
1158+
if (!FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
11641159
OCFile currentFile = (mFile == null) ? null :
11651160
getStorageManager().getFileByPath(mFile.getRemotePath());
11661161
OCFile currentDir = (getCurrentFolder() == null) ? null :
@@ -1186,9 +1181,6 @@ public void onReceive(Context context, Intent intent) {
11861181
}
11871182
}
11881183

1189-
mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
1190-
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
1191-
11921184
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event)
11931185
/// TODO refactor and make common
11941186
&& syncResult != null && !syncResult.isSuccess()) {
@@ -1205,8 +1197,6 @@ public void onReceive(Context context, Intent intent) {
12051197
}
12061198
}
12071199
}
1208-
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
1209-
12101200
}
12111201
} catch (RuntimeException e) {
12121202
// avoid app crashes after changing the serial id of RemoteOperationResult

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import com.nextcloud.client.di.Injectable
5656
import com.nextcloud.client.preferences.AppPreferences
5757
import com.nextcloud.client.preferences.AppPreferencesImpl
5858
import com.nextcloud.utils.extensions.getTypedActivity
59+
import com.nextcloud.utils.extensions.mainThread
5960
import com.owncloud.android.MainApp
6061
import com.owncloud.android.R
6162
import com.owncloud.android.databinding.ListFragmentBinding
@@ -720,6 +721,10 @@ open class ExtendedListFragment :
720721
true
721722
)
722723
}
724+
}.also {
725+
mainThread {
726+
mRefreshListLayout?.isRefreshing = false
727+
}
723728
}
724729
}
725730

0 commit comments

Comments
 (0)