Skip to content

Commit

Permalink
Add file sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
kairusds committed Oct 17, 2024
1 parent 9d0cdaa commit 88d4b0b
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -75,9 +77,9 @@ protected void onCreate(Bundle savedInstanceState){
videoLayout.setOnClickListener(v -> {
if(libVLCAvailable()){
if(mediaPlayer.isPlaying()){
pause();
pause();
}else{
play();
play();
}
}else{
executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
Expand Down Expand Up @@ -196,6 +198,22 @@ private void showFilePickerDialog(File dir){
try{
executor.execute(() -> {
File[] files = dir.listFiles();
Arrays.sort(files, new Comparator<File>(){
@Override
public int compare(File f1, File f2){
String name1 = f1.getName();
String name2 = f2.getName();

boolean isSymbol1 = !Character.isLetterOrDigit(name1.charAt(0));
boolean isSymbol2 = !Character.isLetterOrDigit(name2.charAt(0));

if(isSymbol1 && !isSymbol2) return -1;
if(!isSymbol1 && isSymbol2) return 1;

return name1.compareToIgnoreCase(name2);
}
});

ArrayList<String> fileList = new ArrayList<>();
HashMap<String, String> paths = new HashMap<>();
fileList.add("..");
Expand Down

0 comments on commit 88d4b0b

Please sign in to comment.