use of io.storj.libstorj.File in project hello-storj by kaloyan-raev.
the class FileInfoFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bucket bucket = (Bucket) getArguments().getSerializable(FilesFragment.BUCKET);
final File file = (File) getArguments().getSerializable(FILE);
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.title_fileinfo).setMessage(String.format("ID: %s\nBucket: %s\nName: %s\nCreated: %s\nDecrypted: %b\nSize: %s\nMIME Type: %s\nErasure: %s\nIndex: %s\nHMAC: %s", file.getId(), file.getBucketId(), file.getName(), file.getCreated(), file.isDecrypted(), Formatter.formatFileSize(getContext(), file.getSize()), file.getMimeType(), file.getErasure(), file.getIndex(), file.getHMAC())).setPositiveButton(R.string.button_download, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
((DownloadListener) getActivity()).onDownload(bucket, file);
}
});
// Create the AlertDialog object and return it
return builder.create();
}
use of io.storj.libstorj.File in project hello-storj by kaloyan-raev.
the class FileDownloader method onComplete.
@Override
public void onComplete(String fileId, String localPath) {
java.io.File file = new java.io.File(localPath);
// hide the "download in progress" notification
mNotifyManager.cancel(fileId.hashCode());
// show the "download completed" notification
DownloadManager dm = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
dm.addCompletedDownload(file.getName(), mActivity.getResources().getString(R.string.app_name), true, getMimeType(file), localPath, file.length(), true);
// remove from last notified map
lastNotifiedMap.remove(fileId);
}
Aggregations