Skip to content

Commit fb6b1fa

Browse files
committed
* improve order of font list
1 parent 2af5b3c commit fb6b1fa

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

app/src/main/java/com/mikepenz/iconics/sample/MainActivity.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class MainActivity extends AppCompatActivity {
5555

5656
private IconsFragment mIconsFragment;
5757
private boolean mRandomize;
58-
58+
private List<ITypeface> mFonts;
5959

6060
@Override
6161
protected void onCreate(Bundle savedInstanceState) {
@@ -68,8 +68,8 @@ protected void onCreate(Bundle savedInstanceState) {
6868
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
6969

7070
//order fonts by their name
71-
List<ITypeface> fonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
72-
Collections.sort(fonts, new Comparator<ITypeface>() {
71+
mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
72+
Collections.sort(mFonts, new Comparator<ITypeface>() {
7373
@Override
7474
public int compare(final ITypeface object1, final ITypeface object2) {
7575
return object1.getFontName().compareTo(object2.getFontName());
@@ -78,7 +78,7 @@ public int compare(final ITypeface object1, final ITypeface object2) {
7878

7979
//add all icons of all registered Fonts to the list
8080
ArrayList<IDrawerItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
81-
for (ITypeface font : fonts) {
81+
for (ITypeface font : mFonts) {
8282
PrimaryDrawerItem pdi = new PrimaryDrawerItem()
8383
.withName(font.getFontName())
8484
.withBadge("" + font.getIcons().size())
@@ -101,10 +101,8 @@ public int compare(final ITypeface object1, final ITypeface object2) {
101101
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
102102
@Override
103103
public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
104-
ITypeface font = new ArrayList<>(Iconics.getRegisteredFonts(MainActivity.this)).get(i);
105-
loadIcons(font.getFontName());
106-
107-
getSupportActionBar().setTitle(font.getFontName());
104+
loadIcons(mFonts.get(i).getFontName());
105+
getSupportActionBar().setTitle(mFonts.get(i).getFontName());
108106

109107
return false;
110108
}

0 commit comments

Comments
 (0)