Search in sources :

Example 1 with File

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bucket(io.storj.libstorj.Bucket) DialogInterface(android.content.DialogInterface) File(io.storj.libstorj.File) NonNull(android.support.annotation.NonNull)

Example 2 with File

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);
}
Also used : File(io.storj.libstorj.File) DownloadManager(android.app.DownloadManager)

Aggregations

File (io.storj.libstorj.File)2 DownloadManager (android.app.DownloadManager)1 DialogInterface (android.content.DialogInterface)1 NonNull (android.support.annotation.NonNull)1 AlertDialog (android.support.v7.app.AlertDialog)1 Bucket (io.storj.libstorj.Bucket)1