no duplicates

This commit is contained in:
Page Asgardius 2022-09-03 11:33:38 -07:00
parent 48e80d66e9
commit 0674537f39

View file

@ -26,13 +26,14 @@ import com.amazonaws.services.s3.model.S3ObjectSummary;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
public class ObjectSelect extends AppCompatActivity { public class ObjectSelect extends AppCompatActivity {
ArrayList Name; ArrayList Name;
ArrayList Img; ArrayList Img;
ArrayList object; //ArrayList object;
RecyclerView recyclerView; RecyclerView recyclerView;
String username, password, endpoint, bucket, prefix; String username, password, endpoint, bucket, prefix;
int treelevel; int treelevel;
@ -72,16 +73,25 @@ public class ObjectSelect extends AppCompatActivity {
ListObjectsV2Result result = s3client.listObjectsV2(bucket, "/"); ListObjectsV2Result result = s3client.listObjectsV2(bucket, "/");
//System.out.println(objects); //System.out.println(objects);
//This convert bucket list to an array list //This convert bucket list to an array list
Name = new ArrayList<String>();
Img = new ArrayList<String>(); Img = new ArrayList<String>();
LinkedHashSet<String> object = new LinkedHashSet<String>();
// Print bucket names // Print bucket names
//System.out.println("Buckets:"); //System.out.println("Buckets:");
int i=0; //int i=0;
List<S3ObjectSummary> objects = result.getObjectSummaries(); List<S3ObjectSummary> objects = result.getObjectSummaries();
for (S3ObjectSummary os : objects) { for (S3ObjectSummary os : objects) {
filename = os.getKey().split("/"); filename = os.getKey().split("/");
Name.add(filename[treelevel]); object.add(filename[treelevel]);
if (os.getKey().endsWith(".opus") || os.getKey().endsWith(".ogg")
//i++;
}
Name = new ArrayList<String>(object);
//Img.add(R.drawable.unknownfile);
int i = 0;
while(i<Name.size()) {
Img.add(R.drawable.unknownfile);
/*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(".flac") || os.getKey().endsWith(".m4a") || os.getKey().endsWith(".flac")
|| os.getKey().endsWith(".mka")) { || os.getKey().endsWith(".mka")) {
@ -93,9 +103,10 @@ public class ObjectSelect extends AppCompatActivity {
} }
else { else {
Img.add(R.drawable.unknownfile); Img.add(R.drawable.unknownfile);
} }*/
i++; i++;
} }
object.clear();
/*for (Bucket bucket : buckets) { /*for (Bucket bucket : buckets) {
//i++; //i++;