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();
}
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();
}
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;
}
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;
}
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);
}
Aggregations