Skip to content

Commit

Permalink
Sort apps alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita committed Jan 14, 2018
1 parent 494af81 commit 036f52d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/src/main/java/ua/naiksoftware/j2meloader/AppItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import javax.microedition.shell.ConfigActivity;

public class AppItem implements Serializable {
public class AppItem implements Serializable, SortItem {

private String imagePath;
private String title;
Expand Down Expand Up @@ -68,4 +68,8 @@ public String getVersion() {
return version;
}

public String getSortField() {
return title;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;

import javax.microedition.shell.ConfigActivity;
Expand All @@ -64,6 +66,7 @@ public class MainActivity extends AppCompatActivity implements NavigationDrawerF
private AppsListFragment appsListFragment;
private ArrayList<AppItem> apps = new ArrayList<AppItem>();
private static final int MY_PERMISSIONS_REQUEST_WRITE_STORAGE = 0;
private static final Comparator<SortItem> comparator = new AlphabeticComparator<SortItem>();

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -223,6 +226,7 @@ public void updateApps() {
}
}
}
Collections.sort(apps, comparator);
AppsListAdapter adapter = new AppsListAdapter(this, apps);
appsListFragment.setListAdapter(adapter);
}
Expand Down

0 comments on commit 036f52d

Please sign in to comment.