public void loadFile( final Context context, final Credentials credentials, final ListItem item) { result = new File(context.getFilesDir(), new File(item.getFullPath()).getName()); new Thread( new Runnable() { @Override public void run() { TransportClient client = null; try { client = TransportClient.getInstance(context, credentials); client.downloadFile( item.getFullPath(), result, DownloadFileRetainedFragment.this); downloadComplete(); } catch (IOException ex) { Log.d(TAG, "loadFile", ex); sendException(ex); } catch (WebdavException ex) { Log.d(TAG, "loadFile", ex); sendException(ex); } finally { if (client != null) { client.shutdown(); } } } }) .start(); }
private void makeWorldReadableAndOpenFile(File file) { file.setReadable(true, false); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), item.getContentType()); startActivity( Intent.createChooser(intent, getText(R.string.example_loading_file_chooser_title))); }
@Override public int compare(ListItem f1, ListItem f2) { if (f1.isCollection() && !f2.isCollection()) { return -1; } else if (f2.isCollection() && !f1.isCollection()) { return 1; } else { return collator.compare(f1.getDisplayName(), f2.getDisplayName()); } }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialog = new ProgressDialog(getActivity()); dialog.setTitle(R.string.example_loading_file_title); dialog.setMessage(item.getDisplayName()); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setIndeterminate(true); dialog.setButton( ProgressDialog.BUTTON_NEUTRAL, getString(R.string.example_loading_file_cancel_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); onCancel(); } }); dialog.setOnCancelListener(this); dialog.show(); return dialog; }