Search in sources :

Example 1 with Bucket

use of io.storj.libstorj.Bucket 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 Bucket

use of io.storj.libstorj.Bucket in project hello-storj by kaloyan-raev.

the class FilesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Show the Up button in new Intent(this, DetailActivity.class)the action bar.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    // 
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity_main
        // using a fragment transaction.
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            Bucket bucket = (Bucket) extras.getSerializable(FilesFragment.BUCKET);
            setTitle(bucket.getName());
            FilesFragment fragment = new FilesFragment();
            Bundle bundle = new Bundle();
            bundle.putSerializable(FilesFragment.BUCKET, bucket);
            fragment.setArguments(bundle);
            getSupportFragmentManager().beginTransaction().add(R.id.detail_container, fragment).commit();
        }
    }
}
Also used : Bucket(io.storj.libstorj.Bucket) Bundle(android.os.Bundle) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Bucket (io.storj.libstorj.Bucket)2 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 ActionBar (android.support.v7.app.ActionBar)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toolbar (android.support.v7.widget.Toolbar)1 File (io.storj.libstorj.File)1