mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 10:49:04 +03:00
Fix opening downloaded files when offline (#5265)
Signed-off-by: t-m-w <7275539+t-m-w@users.noreply.github.com>
This commit is contained in:
parent
85a43e838e
commit
3fc5be9b07
1 changed files with 13 additions and 3 deletions
|
@ -36,11 +36,13 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.DocumentsProvider;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
|
@ -206,12 +208,20 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
|||
DownloadFileOperation downloadFileOperation = new DownloadFileOperation(account, ocFile, context);
|
||||
RemoteOperationResult result = downloadFileOperation.execute(document.getClient());
|
||||
if (!result.isSuccess()) {
|
||||
if (ocFile.isDown()) {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(() -> Toast.makeText(MainApp.getAppContext(),
|
||||
R.string.file_not_synced,
|
||||
Toast.LENGTH_SHORT).show());
|
||||
} else {
|
||||
Log_OC.e(TAG, result.toString());
|
||||
throw new FileNotFoundException("Error downloading file: " + ocFile.getFileName());
|
||||
}
|
||||
} else {
|
||||
saveDownloadedFile(document.getStorageManager(), downloadFileOperation, ocFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(ocFile.getStoragePath());
|
||||
|
||||
|
|
Loading…
Reference in a new issue