Refactored code of comparator
This commit is contained in:
parent
9fd0c20131
commit
3f32c71c8d
1 changed files with 13 additions and 21 deletions
|
@ -781,19 +781,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
||||||
String[] filenames = new String[2];
|
return cl.compare(getNameToDisplay(lhs), getNameToDisplay(rhs));
|
||||||
for (int i =0; i< 2;i++){
|
|
||||||
String mapDescr = getMapDescription(i == 0 ? lhs.getFileName() : rhs.getFileName());
|
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
|
||||||
((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(),
|
|
||||||
i == 0 ? lhs.getFileName() : rhs.getFileName());
|
|
||||||
if (mapDescr.length() > 0){
|
|
||||||
filenames[i] = mapDescr + " - " + mapName;
|
|
||||||
} else {
|
|
||||||
filenames[i] = mapName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cl.compare(filenames[0], filenames[1]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -913,14 +901,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
||||||
}
|
}
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
||||||
String mapDescr = getMapDescription(child.getFileName());
|
viewName.setText(getNameToDisplay(child));
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
|
||||||
|
|
||||||
if (mapDescr.length() > 0){
|
|
||||||
viewName.setText(mapDescr + " - " + mapName);
|
|
||||||
} else {
|
|
||||||
viewName.setText(mapName);
|
|
||||||
}
|
|
||||||
if (child.isNotSupported()) {
|
if (child.isNotSupported()) {
|
||||||
viewName.setTextColor(warningColor);
|
viewName.setTextColor(warningColor);
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||||
|
@ -978,6 +959,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getNameToDisplay(LocalIndexInfo child) {
|
||||||
|
String mapDescr = getMapDescription(child.getFileName());
|
||||||
|
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
||||||
|
|
||||||
|
if (mapDescr.length() > 0){
|
||||||
|
return mapDescr + " - " + mapName;
|
||||||
|
} else {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
|
|
Loading…
Reference in a new issue