Skip to content

Commit

Permalink
updated sort author name
Browse files Browse the repository at this point in the history
  • Loading branch information
MansiBhayade committed Jul 13, 2023
1 parent 7397056 commit cda70bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 0 additions & 6 deletions app/src/main/java/dev/ukanth/iconmgr/IconAttr.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

public class IconAttr {

public String authorName;

public long getSize() {
return size;
}
Expand All @@ -18,10 +16,6 @@ public void setSize(long size) {
this.size = size;
}

// public String getauthorName(){ return authorName; }
//
// public void setauthorName(String authorName ){this.authorName = authorName ;}

public int getMissed() {
return missed;
}
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/dev/ukanth/iconmgr/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ private void showIconSearch() {
}

private void reload() {
Collections.sort(iconPacksList, new PackageComparator(this));
PackageComparator packageComparator = new PackageComparator(MainActivity.this); // Pass the activity context here
Collections.sort(iconPacksList, packageComparator);
adapter = new IconAdapter(iconPacksList, installed);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
Expand Down Expand Up @@ -516,7 +517,9 @@ public boolean onQueryTextSubmit(String query) {
public boolean onQueryTextChange(String query) {
List<IPObj> filteredModelList = filter(query);

Collections.sort(new ArrayList(filteredModelList), new PackageComparator(this));
PackageComparator packageComparator = new PackageComparator(MainActivity.this); // Pass the activity context here
Collections.sort(new ArrayList<>(filteredModelList), packageComparator);


adapter = new IconAdapter(filteredModelList, installed);
recyclerView.setAdapter(adapter);
Expand Down Expand Up @@ -654,7 +657,7 @@ protected void onPostExecute(Void result) {
setTitle(getString(R.string.app_name) + " - #" + iconPacksList.size());
recyclerView.setVisibility(View.VISIBLE);
emptyView.setVisibility(View.GONE);
Collections.sort(iconPacksList, new PackageComparator(getApplicationContext()));
Collections.sort(iconPacksList, new PackageComparator(MainActivity.this));
if (Prefs.useFavorite()) {
Collections.sort(iconPacksList, new Comparator<IPObj>() {
@Override
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/dev/ukanth/iconmgr/util/PackageComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

public class PackageComparator implements Comparator<IPObj> {

private Context ctx;
private Context context;

public PackageComparator(Context context) {
this.ctx = context;
this.context = context;
}

@Override
public int compare(IPObj o1, IPObj o2) {
public int compare( IPObj o1, IPObj o2) {
switch (Prefs.sortBy()) {
case "s0":
return String.CASE_INSENSITIVE_ORDER.compare(o1.getIconName(), o2.getIconName());
Expand All @@ -38,8 +38,8 @@ public int compare(IPObj o1, IPObj o2) {
case "s4":
return (o2.getMissed() > o1.getMissed()) ? -1 : (o2.getMissed() < o1.getMissed()) ? 1 : 0;
case "s5":
String authorName1 = Util.getAuthorName(ctx, o1.getIconPkg());
String authorName2 = Util.getAuthorName(ctx, o2.getIconPkg());
String authorName1 = Util.getAuthorName(context, o1.getIconPkg());
String authorName2 = Util.getAuthorName(context, o2.getIconPkg());
return String.CASE_INSENSITIVE_ORDER.compare(authorName1, authorName2);
}
return 1;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="lastupdated">By last update</string>
<string name="iconcount">By icon count</string>
<string name="iconsize">By package size</string>
<string name="authorname">By Author Name</string>
<string name="iconpercent">By match percent</string>
<string name="total_icons">Show icon count</string>
<string name="show_notification">Notify on new icon pack install</string>
Expand Down Expand Up @@ -88,7 +89,7 @@
<string name="license_check_retry">Unable to check license, please try again in a few moments</string>
<string name="showsize">Show application size</string>
<string name="show_percent">Show Percentage</string>
<string name="authorname">By Author Name</string>
<string name="show_authorname">Show Author Name</string>
<string name="forcereload">Rebuild list</string>
<string name="onlysupportedroot">Supported through root mode only</string>
<string name="action_random">Random</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<SwitchPreference
android:defaultValue="false"
android:key="show_authorName"
android:title="@string/authorname" />
android:title="@string/show_authorname" />

<SwitchPreference
android:defaultValue="false"
Expand Down

0 comments on commit cda70bf

Please sign in to comment.