treelevel
This commit is contained in:
parent
303994dc58
commit
48e80d66e9
3 changed files with 46 additions and 7 deletions
|
@ -28,7 +28,8 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
ArrayList Name;
|
ArrayList Name;
|
||||||
ArrayList Img;
|
ArrayList Img;
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
String username, password, endpoint;
|
String username, password, endpoint, prefix;
|
||||||
|
int treelevel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -36,6 +37,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
endpoint = getIntent().getStringExtra("endpoint");
|
endpoint = getIntent().getStringExtra("endpoint");
|
||||||
username = getIntent().getStringExtra("username");
|
username = getIntent().getStringExtra("username");
|
||||||
password = getIntent().getStringExtra("password");
|
password = getIntent().getStringExtra("password");
|
||||||
|
prefix = "";
|
||||||
setContentView(R.layout.activity_bucket_select);
|
setContentView(R.layout.activity_bucket_select);
|
||||||
Region region = Region.getRegion(US_EAST_1);
|
Region region = Region.getRegion(US_EAST_1);
|
||||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
|
@ -118,10 +120,13 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
private void explorer(String bucket) {
|
private void explorer(String bucket) {
|
||||||
|
|
||||||
Intent intent = new Intent(this, ObjectSelect.class);
|
Intent intent = new Intent(this, ObjectSelect.class);
|
||||||
|
treelevel = 0;
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
intent.putExtra("password", password);
|
intent.putExtra("password", password);
|
||||||
intent.putExtra("bucket", bucket);
|
intent.putExtra("bucket", bucket);
|
||||||
|
intent.putExtra("prefix", prefix);
|
||||||
|
intent.putExtra("treelevel", treelevel);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,11 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
|
|
||||||
ArrayList Name;
|
ArrayList Name;
|
||||||
ArrayList Img;
|
ArrayList Img;
|
||||||
|
ArrayList object;
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
String username, password, endpoint, bucket;
|
String username, password, endpoint, bucket, prefix;
|
||||||
|
int treelevel;
|
||||||
|
String[] filename;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -42,6 +45,8 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
username = getIntent().getStringExtra("username");
|
username = getIntent().getStringExtra("username");
|
||||||
password = getIntent().getStringExtra("password");
|
password = getIntent().getStringExtra("password");
|
||||||
bucket = getIntent().getStringExtra("bucket");
|
bucket = getIntent().getStringExtra("bucket");
|
||||||
|
prefix = getIntent().getStringExtra("prefix");
|
||||||
|
treelevel = getIntent().getIntExtra("treelevel", 0);
|
||||||
setContentView(R.layout.activity_object_select);
|
setContentView(R.layout.activity_object_select);
|
||||||
Region region = Region.getRegion(US_EAST_1);
|
Region region = Region.getRegion(US_EAST_1);
|
||||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
|
@ -74,15 +79,22 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
int i=0;
|
int i=0;
|
||||||
List<S3ObjectSummary> objects = result.getObjectSummaries();
|
List<S3ObjectSummary> objects = result.getObjectSummaries();
|
||||||
for (S3ObjectSummary os : objects) {
|
for (S3ObjectSummary os : objects) {
|
||||||
Name.add(os.getKey());
|
filename = os.getKey().split("/");
|
||||||
|
Name.add(filename[treelevel]);
|
||||||
if (os.getKey().endsWith(".opus") || os.getKey().endsWith(".ogg")
|
if (os.getKey().endsWith(".opus") || os.getKey().endsWith(".ogg")
|
||||||
|| os.getKey().endsWith(".oga") || os.getKey().endsWith(".mp3")
|
|| os.getKey().endsWith(".oga") || os.getKey().endsWith(".mp3")
|
||||||
|| os.getKey().endsWith(".m4a")) {
|
|| os.getKey().endsWith(".m4a") || os.getKey().endsWith(".flac")
|
||||||
|
|| os.getKey().endsWith(".mka")) {
|
||||||
Img.add(R.drawable.audiofile);
|
Img.add(R.drawable.audiofile);
|
||||||
}
|
}
|
||||||
else {
|
else if(os.getKey().endsWith(".mp4") || os.getKey().endsWith(".mkv")
|
||||||
|
|| os.getKey().endsWith(".webm") || os.getKey().endsWith(".m4v")) {
|
||||||
Img.add(R.drawable.videofile);
|
Img.add(R.drawable.videofile);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Img.add(R.drawable.unknownfile);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*for (Bucket bucket : buckets) {
|
/*for (Bucket bucket : buckets) {
|
||||||
|
@ -105,6 +117,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
System.out.println("tree "+treelevel);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -124,7 +137,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view, int position) {
|
public void onClick(View view, int position) {
|
||||||
System.out.println("Click on "+Name.get(position).toString());
|
//System.out.println("Click on "+Name.get(position).toString());
|
||||||
//explorer(Name.get(position).toString());
|
//explorer(Name.get(position).toString());
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, Name.get(position).toString());
|
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, Name.get(position).toString());
|
||||||
URL objectURL = s3client.generatePresignedUrl(request);
|
URL objectURL = s3client.generatePresignedUrl(request);
|
||||||
|
@ -133,7 +146,8 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLongClick(View view, int position) {
|
public void onLongClick(View view, int position) {
|
||||||
System.out.println("Long click on "+Name.get(position).toString());
|
//System.out.println("Long click on "+Name.get(position).toString());
|
||||||
|
explorer(bucket);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -145,4 +159,24 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void explorer(String bucket) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(this, ObjectSelect.class);
|
||||||
|
treelevel ++;
|
||||||
|
intent.putExtra("endpoint", endpoint);
|
||||||
|
intent.putExtra("username", username);
|
||||||
|
intent.putExtra("password", password);
|
||||||
|
intent.putExtra("bucket", bucket);
|
||||||
|
intent.putExtra("prefix", prefix);
|
||||||
|
intent.putExtra("treelevel", treelevel);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBackPressed() {
|
||||||
|
treelevel --;
|
||||||
|
System.out.println("tree "+treelevel);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
BIN
app/src/main/res/drawable/unknownfile.png
Normal file
BIN
app/src/main/res/drawable/unknownfile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
Loading…
Reference in a new issue