mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Faster currentDir refresh
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
ed7a1bfc15
commit
f0179d86f8
4 changed files with 14 additions and 8 deletions
|
@ -7,9 +7,14 @@
|
|||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
fun AppCompatActivity.isDialogFragmentReady(fragment: Fragment): Boolean = isActive() && !fragment.isStateSaved()
|
||||
fun AppCompatActivity.isDialogFragmentReady(fragment: Fragment): Boolean = isActive() && !fragment.isStateSaved
|
||||
|
||||
fun AppCompatActivity.isActive(): Boolean = !isFinishing && !isDestroyed
|
||||
|
||||
fun AppCompatActivity.fragments(): List<Fragment> = supportFragmentManager.fragments
|
||||
|
||||
fun AppCompatActivity.lastFragment(): Fragment = fragments().last()
|
||||
|
|
|
@ -1603,15 +1603,16 @@ public class FileDisplayActivity extends FileActivity
|
|||
} else if (state instanceof WorkerState.UploadFinished) {
|
||||
refreshList();
|
||||
} else if (state instanceof WorkerState.OfflineOperationsCompleted) {
|
||||
refreshFolderWithDelay();
|
||||
refreshCurrentDirectory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshFolderWithDelay() {
|
||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||
if (fileListFragment != null) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(fileListFragment::onRefresh, 1500);
|
||||
public void refreshCurrentDirectory() {
|
||||
Fragment lastFragment = ActivityExtensionsKt.lastFragment(this);
|
||||
if (lastFragment instanceof OCFileListFragment fragment) {
|
||||
OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByDecryptedRemotePath(getCurrentDir().getRemotePath());
|
||||
fragment.listDirectory(currentDir,false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial
|
|||
|
||||
if (offlineFiles.isNotEmpty()) {
|
||||
val activity = requireActivity() as? FileDisplayActivity
|
||||
activity?.refreshFolderWithDelay()
|
||||
activity?.refreshCurrentDirectory()
|
||||
}
|
||||
|
||||
finishActionMode()
|
||||
|
|
|
@ -149,7 +149,7 @@ class RenameFileDialogFragment : DialogFragment(), DialogInterface.OnClickListen
|
|||
fileDataStorageManager.renameCreateFolderOfflineOperation(mTargetFile, newFileName)
|
||||
if (requireActivity() is FileDisplayActivity) {
|
||||
val activity = requireActivity() as FileDisplayActivity
|
||||
activity.refreshFolderWithDelay()
|
||||
activity.refreshCurrentDirectory()
|
||||
}
|
||||
} else {
|
||||
(requireActivity() as ComponentsGetter).fileOperationsHelper.renameFile(mTargetFile, newFileName)
|
||||
|
|
Loading…
Reference in a new issue