Categories with pipe suffix (#1873)

* Bug fix issue #1826
Changes made :
-Certain category names used to show suffixed with strings prefixed with pipe '|'. Removed everything after the pipe. As per the discussion on the thread, its safe to remove everything after the pipe, including the pipe

* review suggested changes
*Code formatting
*Extracted out the index of pipe in a variable
*Added issue link in comments
This commit is contained in:
Ashish Kumar 2018-11-10 13:58:55 +05:30 committed by neslihanturan
parent 2b728718ae
commit 78af43e95b

View file

@ -431,8 +431,19 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
private void rebuildCatList() { private void rebuildCatList() {
categoryContainer.removeAllViews(); categoryContainer.removeAllViews();
// @fixme add the category items // @fixme add the category items
for (String cat : categoryNames) {
View catLabel = buildCatLabel(cat, categoryContainer); //As per issue #1826(see https://github.com/commons-app/apps-android-commons/issues/1826), some categories come suffixed with strings prefixed with |. As per the discussion
//that was meant for alphabetical sorting of the categories and can be safely removed.
for (int i = 0; i < categoryNames.size(); i++) {
String categoryName = categoryNames.get(i);
//Removed everything after '|'
int indexOfPipe = categoryName.indexOf('|');
if (indexOfPipe != -1) {
categoryName = categoryName.substring(0, indexOfPipe);
//Set the updated category to the list as well
categoryNames.set(i, categoryName);
}
View catLabel = buildCatLabel(categoryName, categoryContainer);
categoryContainer.addView(catLabel); categoryContainer.addView(catLabel);
} }
} }