Skip to content
This repository was archived by the owner on May 3, 2021. It is now read-only.

Commit 7d9c355

Browse files
committed
Sorting by name ignoring case
1 parent 6a537f8 commit 7d9c355

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
2323
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
2424
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25-
//implementation project(':applistmanagerlibrary')
25+
implementation project(':applistmanagerlibrary')
2626
testImplementation 'junit:junit:4.12'
2727
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2828
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
2929
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
30-
implementation 'com.github.LayoutXML:AppListManager:1.0.0'
30+
//implementation 'com.github.LayoutXML:AppListManager:1.0.0'
3131
}

app/src/main/java/com/layoutxml/applistmanager/ListActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ protected void onResume() {
109109

110110
@Override
111111
public void activityListener(List<AppData> appDataList, Intent intent, Integer activityFlags, Integer applicationFlags, Boolean applicationFlagsMatch, Integer uniqueIdentifier) {
112-
AppList.sort(appDataList,AppList.BY_APPNAME,AppList.IN_ASCENDING,uniqueIdentifier);
112+
AppList.sort(appDataList,AppList.BY_APPNAME_IGNORE_CASE,AppList.IN_ASCENDING,uniqueIdentifier);
113113
}
114114

115115
@Override
116116
public void appListener(List<AppData> appDataList, Integer applicationFlags, Boolean applicationFlagsMatch, Integer uniqueIdentifier) {
117-
AppList.sort(appDataList,AppList.BY_APPNAME,AppList.IN_ASCENDING,uniqueIdentifier);
117+
AppList.sort(appDataList,AppList.BY_APPNAME_IGNORE_CASE,AppList.IN_ASCENDING,uniqueIdentifier);
118118
}
119119

120120
@Override
@@ -134,15 +134,15 @@ else if (uniqueIdentifier==2 || uniqueIdentifier==3) {
134134
public void newActivityListener(List<AppData> appDataList, Intent intent, Integer activityFlags, Integer applicationFlags, Boolean applicationFlagsMatch, Boolean fromReceiver, Integer uniqueIdentifier) {
135135
if (!apps) {
136136
appDataList.addAll(this.appDataList);
137-
AppList.sort(appDataList,AppList.BY_APPNAME,AppList.IN_ASCENDING,3);
137+
AppList.sort(appDataList,AppList.BY_APPNAME_IGNORE_CASE,AppList.IN_ASCENDING,3);
138138
}
139139
}
140140

141141
@Override
142142
public void newAppListener(List<AppData> appDataList, Integer applicationFlags, Boolean applicationFlagsMatch, Boolean fromReceiver, Integer uniqueIdentifier) {
143143
if (apps) {
144144
appDataList.addAll(this.appDataList);
145-
AppList.sort(appDataList,AppList.BY_APPNAME,AppList.IN_ASCENDING,2);
145+
AppList.sort(appDataList,AppList.BY_APPNAME_IGNORE_CASE,AppList.IN_ASCENDING,2);
146146
}
147147
}
148148

app/src/main/res/layout/item_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:layout_marginLeft="16dp"
3131
android:layout_marginRight="16dp"
3232
android:layout_marginStart="16dp"
33-
android:layout_marginTop="16dp"
33+
android:layout_marginTop="20dp"
3434
android:text="App Name"
3535
android:textColor="#000000"
3636
android:textSize="16sp"

applistmanagerlibrary/src/main/java/com/layoutxml/applistmanagerlibrary/AppList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class AppList extends BroadcastReceiver{
5858
//Values
5959
public static final Integer BY_APPNAME = 0;
6060
public static final Integer BY_PACKAGENAME = 1;
61+
public static final Integer BY_APPNAME_IGNORE_CASE = 2;
6162
public static final Integer IN_ASCENDING = 0;
6263
public static final Integer IN_DESCENDING = 1;
6364

applistmanagerlibrary/src/main/java/com/layoutxml/applistmanagerlibrary/tasks/SortTask.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ public int compare(AppData t0, AppData t1) {
6060
return t1.getPackageName().compareTo(t0.getPackageName());
6161
}
6262
});
63+
} else if (sortBy.equals(2) && inOrder.equals(0)) {
64+
Collections.sort(appDataList, new Comparator<AppData>() {
65+
@Override
66+
public int compare(AppData t0, AppData t1) {
67+
return t0.getName().toLowerCase().compareTo(t1.getName().toLowerCase());
68+
}
69+
});
70+
} else if (sortBy.equals(2) && inOrder.equals(1)) {
71+
Collections.sort(appDataList, new Comparator<AppData>() {
72+
@Override
73+
public int compare(AppData t0, AppData t1) {
74+
return t1.getName().toLowerCase().compareTo(t0.getName().toLowerCase());
75+
}
76+
});
6377
}
6478
return appDataList;
6579
}

0 commit comments

Comments
 (0)