Skip to content

Commit 2af5b3c

Browse files
committed
* improve sample application
1 parent bff8ce5 commit 2af5b3c

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void onCreate() {
1717
Iconics.registerFont(new CustomFont());
1818

1919
//Generic font creation process
20-
GenericFont gf2 = new GenericFont("gmf", "fonts/materialdrawerfont.ttf");
20+
GenericFont gf2 = new GenericFont("GenericFont", "SampleGenericFont", "gmf", "fonts/materialdrawerfont.ttf");
2121
gf2.registerIcon("person", '\ue800');
2222
gf2.registerIcon("up", '\ue801');
2323
gf2.registerIcon("down", '\ue802');

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
4545

4646
import java.util.ArrayList;
47+
import java.util.Collections;
48+
import java.util.Comparator;
4749
import java.util.Iterator;
50+
import java.util.List;
4851
import java.util.Random;
4952

5053

@@ -64,9 +67,18 @@ protected void onCreate(Bundle savedInstanceState) {
6467
setSupportActionBar(toolbar);
6568
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
6669

67-
ArrayList<IDrawerItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
70+
//order fonts by their name
71+
List<ITypeface> fonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
72+
Collections.sort(fonts, new Comparator<ITypeface>() {
73+
@Override
74+
public int compare(final ITypeface object1, final ITypeface object2) {
75+
return object1.getFontName().compareTo(object2.getFontName());
76+
}
77+
});
78+
6879
//add all icons of all registered Fonts to the list
69-
for (ITypeface font : Iconics.getRegisteredFonts(this)) {
80+
ArrayList<IDrawerItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
81+
for (ITypeface font : fonts) {
7082
PrimaryDrawerItem pdi = new PrimaryDrawerItem()
7183
.withName(font.getFontName())
7284
.withBadge("" + font.getIcons().size())

app/src/main/java/com/mikepenz/iconics/sample/typeface/CustomFont.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getFontName() {
5050

5151
@Override
5252
public String getVersion() {
53-
return "";
53+
return "1.0.0";
5454
}
5555

5656
@Override
@@ -72,7 +72,7 @@ public Collection<String> getIcons() {
7272

7373
@Override
7474
public String getAuthor() {
75-
return "";
75+
return "SampleCustomFont";
7676
}
7777

7878
@Override

0 commit comments

Comments
 (0)