bucketlist function
This commit is contained in:
parent
f9a38c607d
commit
47509ffdf8
2 changed files with 51 additions and 27 deletions
|
@ -33,7 +33,7 @@ public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{
|
||||||
public void onBindViewHolder(@NonNull Adapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull Adapter.ViewHolder holder, int position) {
|
||||||
int res = (int) Img.get(position);
|
int res = (int) Img.get(position);
|
||||||
holder.images.setImageResource(res);
|
holder.images.setImageResource(res);
|
||||||
holder.text.setText((Integer) Name.get(position));
|
holder.text.setText((CharSequence) Name.get(position));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
|
@ -3,6 +3,8 @@ package asgardius.page.s3manager;
|
||||||
import static com.amazonaws.regions.Regions.US_EAST_1;
|
import static com.amazonaws.regions.Regions.US_EAST_1;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -21,6 +23,9 @@ import java.util.List;
|
||||||
public class BucketSelect extends AppCompatActivity {
|
public class BucketSelect extends AppCompatActivity {
|
||||||
|
|
||||||
AmazonS3 s3client;
|
AmazonS3 s3client;
|
||||||
|
ArrayList Name;
|
||||||
|
ArrayList Img;
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -33,35 +38,54 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
s3client = new AmazonS3Client(myCredentials, region);
|
s3client = new AmazonS3Client(myCredentials, region);
|
||||||
s3client.setEndpoint(getResources().getString(R.string.endpoint_url));
|
s3client.setEndpoint(getResources().getString(R.string.endpoint_url));
|
||||||
s3client.setS3ClientOptions(s3ClientOptions);
|
s3client.setS3ClientOptions(s3ClientOptions);
|
||||||
listbucket list = new listbucket();
|
|
||||||
list.execute("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
private class listbucket extends AsyncTask<String, Void, String> {
|
recyclerView = findViewById(R.id.recyclerview);
|
||||||
|
|
||||||
@Override
|
// layout for vertical orientation
|
||||||
protected String doInBackground(String[] params) {
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||||
// do above Server call here
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
//This get bucket list
|
Thread listbucket = new Thread(new Runnable() {
|
||||||
List<Bucket> buckets = s3client.listBuckets();
|
|
||||||
//This convert bucket list to an array list
|
@Override
|
||||||
List<String> bucketList = new ArrayList<String>();
|
public void run() {
|
||||||
// Print bucket names
|
try {
|
||||||
//System.out.println("Buckets:");
|
//Your code goes here
|
||||||
int i=0;
|
List<Bucket> buckets = s3client.listBuckets();
|
||||||
for (Bucket bucket : buckets) {
|
//This convert bucket list to an array list
|
||||||
//i++;
|
Name = new ArrayList<String>();
|
||||||
//System.out.println(bucket.getName());
|
Img = new ArrayList<String>();
|
||||||
bucketList.add(bucket.getName());
|
// Print bucket names
|
||||||
|
//System.out.println("Buckets:");
|
||||||
|
int i=0;
|
||||||
|
for (Bucket bucket : buckets) {
|
||||||
|
//i++;
|
||||||
|
//System.out.println(bucket.getName());
|
||||||
|
Name.add(bucket.getName());
|
||||||
|
//Img.add(R.drawable.ic_launcher_foreground);
|
||||||
|
Img.add(R.drawable.ic_launcher_foreground);
|
||||||
|
}
|
||||||
|
System.out.println(Name);
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Sending reference and data to Adapter
|
||||||
|
Adapter adapter = new Adapter(BucketSelect.this, Img, Name);
|
||||||
|
|
||||||
|
// Setting Adapter to RecyclerView
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
System.out.println(bucketList);
|
});
|
||||||
//System.out.println(s3client.listBuckets().toArray());
|
|
||||||
return "some message";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
listbucket.start();
|
||||||
protected void onPostExecute(String message) {
|
//listbucket list = new listbucket();
|
||||||
//process message
|
//list.execute("test");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue