Search in sources :

Example 1 with Bucket

use of com.cloudrail.si.types.Bucket in project cloudrail-si-android-sdk by CloudRail.

the class BucketViewer method removeItem.

private void removeItem() {
    this.startSpinner();
    ArrayAdapter<Bucket> adapter = (ArrayAdapter<Bucket>) listView.getAdapter();
    final Bucket bucket = adapter.getItem(selectedItemPosition);
    new Thread(new Runnable() {

        @Override
        public void run() {
            service.deleteBucket(bucket);
            refreshList();
        }
    }).start();
}
Also used : Bucket(com.cloudrail.si.types.Bucket) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with Bucket

use of com.cloudrail.si.types.Bucket in project cloudrail-si-android-sdk by CloudRail.

the class BucketViewer method createBucket.

private void createBucket() {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("create new bucket");
    final EditText input = new EditText(context);
    input.setHint("enter name");
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            new_bucket_name = input.getText().toString();
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        Bucket newBucket = service.createBucket(new_bucket_name);
                        if (newBucket != null) {
                            refreshList();
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Toast.makeText(context, "Bucket " + new_bucket_name + " created", Toast.LENGTH_SHORT).show();
                                }
                            });
                        }
                    } catch (Exception e) {
                        ((Activity) context).runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(context, "Bucket " + new_bucket_name + " could not be created\nMaybe there was a naming conflict.", Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                }
            }).start();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) Bucket(com.cloudrail.si.types.Bucket)

Example 3 with Bucket

use of com.cloudrail.si.types.Bucket in project cloudrail-si-android-sdk by CloudRail.

the class BucketViewer method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_bucket_viewer, container, false);
    this.listView = (ListView) v.findViewById(R.id.bucketListView);
    this.spinner = (ProgressBar) v.findViewById(R.id.spinner);
    switch(mServiceString) {
        case "amazon":
            {
                service = new AmazonS3(context, MainActivity.AMAZON_ACCESS_KEY, MainActivity.AMAZON_SECRET_ACCESS_KEY, MainActivity.AMAZON_REGION);
                break;
            }
        case "backblaze":
            {
                service = new Backblaze(context, MainActivity.BACKBLAZE_ACCOUNT_ID, MainActivity.BACKBLACE_APP_KEY);
                break;
            }
        case "google":
            {
                service = new GoogleCloudPlatform(context, MainActivity.GOOGLE_CLIENT_EMAIL, MainActivity.GOOGLE_PRIVATE_KEY, MainActivity.GOOGLE_PROJECT_ID);
                break;
            }
        case "microsoft":
            {
                service = new MicrosoftAzure(context, MainActivity.AZURE_ACCOUNT_NAME, MainActivity.AZURE_ACCESS_KEY);
                break;
            }
        case "rackspace":
            {
                service = new Rackspace(context, MainActivity.RACKSPACE_USER_NAME, MainActivity.RACKSPACE_API_KEY, MainActivity.RACKSPACE_REGION);
                break;
            }
    }
    refreshList();
    this.listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            selectedItem = view;
            selectedItemPosition = position;
            PopupMenu popupMenu = new PopupMenu(context, view);
            MenuInflater menuInflater = ((Activity) context).getMenuInflater();
            menuInflater.inflate(R.menu.selected_bucket_bar, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_delete_bucket:
                            {
                                removeItem();
                                return true;
                            }
                        default:
                            return false;
                    }
                }
            });
            popupMenu.show();
            return true;
        }
    });
    this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectedItem = view;
            selectedItemPosition = position;
            ArrayAdapter<Bucket> adapter = (ArrayAdapter<Bucket>) listView.getAdapter();
            Bucket bucket = adapter.getItem(position);
            mListener.onBucketSelected(mServiceString, bucket.getName(), bucket.getIdentifier());
        }
    });
    ((TextView) v.findViewById(R.id.text2)).setText(mServiceString);
    return v;
}
Also used : AmazonS3(com.cloudrail.si.services.AmazonS3) MenuInflater(android.view.MenuInflater) Rackspace(com.cloudrail.si.services.Rackspace) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) MicrosoftAzure(com.cloudrail.si.services.MicrosoftAzure) Bucket(com.cloudrail.si.types.Bucket) Backblaze(com.cloudrail.si.services.Backblaze) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) GoogleCloudPlatform(com.cloudrail.si.services.GoogleCloudPlatform) ArrayAdapter(android.widget.ArrayAdapter) PopupMenu(android.widget.PopupMenu)

Example 4 with Bucket

use of com.cloudrail.si.types.Bucket in project cloudrail-si-android-sdk by CloudRail.

the class BucketAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = inflater.inflate(R.layout.list_item, null);
    }
    final Bucket bucket = this.data.get(position);
    if (bucket != null) {
        TextView tv = (TextView) v.findViewById(R.id.list_item);
        tv.setText(bucket.getName());
    }
    return v;
}
Also used : Bucket(com.cloudrail.si.types.Bucket) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with Bucket

use of com.cloudrail.si.types.Bucket in project cloudrail-si-android-sdk by CloudRail.

the class FileViewer method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mServiceString = getArguments().getString(ARG_SERVICE);
        mBucketName = getArguments().getString(ARG_BUCKET_NAME);
        mBucketId = getArguments().getString(ARG_BUCKET_ID);
        mBucket = new Bucket();
        mBucket.setName(mBucketName);
        mBucket.setIdentifier(mBucketId);
    }
    setHasOptionsMenu(true);
}
Also used : Bucket(com.cloudrail.si.types.Bucket)

Aggregations

Bucket (com.cloudrail.si.types.Bucket)5 View (android.view.View)2 ArrayAdapter (android.widget.ArrayAdapter)2 TextView (android.widget.TextView)2 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 LayoutInflater (android.view.LayoutInflater)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 ListView (android.widget.ListView)1 PopupMenu (android.widget.PopupMenu)1 AmazonS3 (com.cloudrail.si.services.AmazonS3)1 Backblaze (com.cloudrail.si.services.Backblaze)1 GoogleCloudPlatform (com.cloudrail.si.services.GoogleCloudPlatform)1 MicrosoftAzure (com.cloudrail.si.services.MicrosoftAzure)1 Rackspace (com.cloudrail.si.services.Rackspace)1