Sort folders on display name

pull/156/head
M66B 5 years ago
parent b32a67bf34
commit ff09645b7c

@ -647,14 +647,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
String name1 = f1.getDisplayName(context);
String name2 = f2.getDisplayName(context);
int n = collator.compare(name1, name2);
if (n != 0)
return n;
if (f1.accountName == null || f2.accountName == null)
return 0;
return collator.compare(f1.accountName, f2.accountName);
return collator.compare(name1, name2);
} else {
int i1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
int i2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);

@ -49,15 +49,19 @@ public class AdapterOrder extends RecyclerView.Adapter<AdapterOrder.ViewHolder>
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView tvTitle;
private TextView tvSubTitle;
ViewHolder(View itemView) {
super(itemView);
tvTitle = itemView.findViewById(R.id.tvTitle);
tvSubTitle = itemView.findViewById(R.id.tvSubTitle);
}
private void bindTo(EntityOrder item) {
tvTitle.setText(item.getSortTitle(context));
String[] text = item.getSortTitle(context);
tvTitle.setText(text[0]);
tvSubTitle.setText(text[1]);
}
}
@ -82,8 +86,8 @@ public class AdapterOrder extends RecyclerView.Adapter<AdapterOrder.ViewHolder>
if (o != 0)
return o;
String name1 = s1.getSortTitle(context);
String name2 = s2.getSortTitle(context);
String name1 = s1.getSortKey(context);
String name2 = s2.getSortKey(context);
return collator.compare(name1, name2);
}
});

@ -124,10 +124,15 @@ public class EntityAccount extends EntityOrder implements Serializable {
}
@Override
String getSortTitle(Context context) {
String getSortKey(Context context) {
return name;
}
@Override
String[] getSortTitle(Context context) {
return new String[]{name, null};
}
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("id", id);

@ -235,8 +235,13 @@ public class EntityFolder extends EntityOrder implements Serializable {
}
@Override
String getSortTitle(Context context) {
return Helper.localizeFolderName(context, name);
String getSortKey(Context context) {
return getDisplayName(context);
}
@Override
String[] getSortTitle(Context context) {
return new String[]{getDisplayName(context), null};
}
boolean isOutgoing() {

@ -26,5 +26,7 @@ public abstract class EntityOrder {
abstract Long getSortId();
abstract String getSortTitle(Context context);
abstract String getSortKey(Context context);
abstract String[] getSortTitle(Context context);
}

@ -25,7 +25,7 @@ public class TupleFolderSort extends EntityFolder {
public String accountName;
@Override
String getSortTitle(Context context) {
return accountName + "/" + super.getSortTitle(context);
String[] getSortTitle(Context context) {
return new String[]{getDisplayName(context), accountName};
}
}

@ -14,12 +14,27 @@
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Text1"
android:layout_marginEnd="6dp"
android:ellipsize="middle"
android:singleLine="true"
android:text="Title"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvSubTitle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="Sub"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
Loading…
Cancel
Save