Search in sources :

Example 1 with Backblaze

use of com.cloudrail.si.services.Backblaze 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 2 with Backblaze

use of com.cloudrail.si.services.Backblaze in project cloudrail-si-android-sdk by CloudRail.

the class FileViewer method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_file_viewer, container, false);
    this.listView = (ListView) v.findViewById(R.id.fileListView);
    this.spinner = (ProgressBar) v.findViewById(R.id.spinner);
    switch(mServiceString) {
        case "amazon":
            {
                // service = new AmazonS3(context, "[Your S3 Access Key ID]", "[Your S3 Secret Access Key]", "[Your AWS region]");
                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_file_bar, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_delete_file:
                            {
                                removeItem();
                                return true;
                            }
                        case R.id.action_download_file:
                            {
                                downloadItem();
                                return true;
                            }
                        default:
                            return false;
                    }
                }
            });
            popupMenu.show();
            return true;
        }
    });
    ((TextView) v.findViewById(R.id.text2)).setText("Bucket \"" + mBucketName + "\"");
    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) Backblaze(com.cloudrail.si.services.Backblaze) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) GoogleCloudPlatform(com.cloudrail.si.services.GoogleCloudPlatform) PopupMenu(android.widget.PopupMenu)

Aggregations

MenuInflater (android.view.MenuInflater)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 PopupMenu (android.widget.PopupMenu)2 TextView (android.widget.TextView)2 AmazonS3 (com.cloudrail.si.services.AmazonS3)2 Backblaze (com.cloudrail.si.services.Backblaze)2 GoogleCloudPlatform (com.cloudrail.si.services.GoogleCloudPlatform)2 MicrosoftAzure (com.cloudrail.si.services.MicrosoftAzure)2 Rackspace (com.cloudrail.si.services.Rackspace)2 ArrayAdapter (android.widget.ArrayAdapter)1 Bucket (com.cloudrail.si.types.Bucket)1