Skip to content

Commit d09c82c

Browse files
committed
revert
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent c7dded7 commit d09c82c

1 file changed

Lines changed: 23 additions & 29 deletions

File tree

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

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import com.nextcloud.utils.extensions.BundleExtensionsKt;
6767
import com.nextcloud.utils.extensions.FileExtensionsKt;
6868
import com.nextcloud.utils.extensions.IntentExtensionsKt;
69+
import com.nextcloud.utils.extensions.ViewExtensionsKt;
6970
import com.nextcloud.utils.fileNameValidator.FileNameValidator;
7071
import com.nextcloud.utils.view.FastScrollUtils;
7172
import com.owncloud.android.MainApp;
@@ -145,9 +146,6 @@
145146
import java.util.Collection;
146147
import java.util.List;
147148
import java.util.Optional;
148-
import java.util.concurrent.Executors;
149-
import java.util.concurrent.ScheduledExecutorService;
150-
import java.util.concurrent.TimeUnit;
151149

152150
import javax.inject.Inject;
153151

@@ -254,8 +252,6 @@ public class FileDisplayActivity extends FileActivity
254252
*/
255253
private long fileIDForImmediatePreview = -1;
256254

257-
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
258-
259255
public void setFileIDForImmediatePreview(long fileIDForImmediatePreview) {
260256
this.fileIDForImmediatePreview = fileIDForImmediatePreview;
261257
}
@@ -443,19 +439,19 @@ private void checkOutdatedServer() {
443439
DisplayUtils.showServerOutdatedSnackbar(this, Snackbar.LENGTH_LONG);
444440
}
445441
}
446-
442+
447443
private void checkNotifications() {
448444
new Thread(() -> {
449445
try {
450446
RemoteOperationResult<List<Notification>> result = new GetNotificationsRemoteOperation()
451447
.execute(clientFactory.createNextcloudClient(accountManager.getUser()));
452-
448+
453449
if (result.isSuccess() && !result.getResultData().isEmpty()) {
454450
runOnUiThread(() -> mNotificationButton.setVisibility(View.VISIBLE));
455451
} else {
456452
runOnUiThread(() -> mNotificationButton.setVisibility(View.GONE));
457453
}
458-
454+
459455
} catch (ClientFactory.CreationException e) {
460456
Log_OC.e(TAG, "Could not fetch notifications!");
461457
}
@@ -2184,36 +2180,35 @@ public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
21842180
* @param ignoreFocus reloads file list even without focus, e.g. on tablet mode, focus can still be in detail view
21852181
*/
21862182
public void startSyncFolderOperation(final OCFile folder, final boolean ignoreETag, boolean ignoreFocus) {
2183+
21872184
// the execution is slightly delayed to allow the activity get the window focus if it's being started
21882185
// or if the method is called from a dialog that is being dismissed
2189-
if (!TextUtils.isEmpty(searchQuery) || getUser().isEmpty()) {
2190-
Log_OC.w(TAG,"Cannot startSyncFolderOperation, search query is empty or user not present");
2191-
return;
2192-
}
2193-
2194-
executor.schedule(() -> {
2195-
Optional<User> user = getUser();
2196-
if (!ignoreFocus && !hasWindowFocus() || user.isEmpty()) {
2197-
Log_OC.w(TAG,"do not refresh if the user rotates the device while another window has focus or if the current user is no longer valid");
2198-
return;
2199-
}
2186+
if (TextUtils.isEmpty(searchQuery) && getUser().isPresent()) {
2187+
getHandler().postDelayed(() -> {
2188+
Optional<User> user = getUser();
2189+
2190+
if (!ignoreFocus && !hasWindowFocus() || !user.isPresent()) {
2191+
// do not refresh if the user rotates the device while another window has focus
2192+
// or if the current user is no longer valid
2193+
return;
2194+
}
22002195

2201-
long currentSyncTime = System.currentTimeMillis();
2202-
mSyncInProgress = true;
2196+
long currentSyncTime = System.currentTimeMillis();
2197+
mSyncInProgress = true;
22032198

2204-
// perform folder synchronization on background thread
2205-
final var refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, ignoreETag, getStorageManager(), user.get(), getApplicationContext());
2206-
refreshFolderOperation.execute(getAccount(), MainApp.getAppContext(), FileDisplayActivity.this, null, null);
2199+
// perform folder synchronization
2200+
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, ignoreETag, getStorageManager(), user.get(), getApplicationContext());
2201+
refreshFolderOperation.execute(getAccount(), MainApp.getAppContext(), FileDisplayActivity.this, null, null);
22072202

2208-
// switch back to main thread
2209-
getHandler().post(() -> {
22102203
OCFileListFragment fragment = getListOfFilesFragment();
2204+
22112205
if (fragment != null && !(fragment instanceof GalleryFragment)) {
22122206
fragment.setLoading(true);
22132207
}
2208+
22142209
setBackgroundText();
2215-
});
2216-
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER, TimeUnit.MILLISECONDS);
2210+
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER);
2211+
}
22172212
}
22182213

22192214
private void requestForDownload(OCFile file, String downloadBehaviour, String packageName, String activityName) {
@@ -2605,7 +2600,6 @@ public void onReceive(Context context, Intent intent) {
26052600

26062601
@Override
26072602
protected void onDestroy() {
2608-
executor.shutdown();
26092603
LocalBroadcastManager.getInstance(this).unregisterReceiver(refreshFolderEventReceiver);
26102604
super.onDestroy();
26112605
}

0 commit comments

Comments
 (0)