diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java index 8feed101e..43debf323 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java @@ -431,8 +431,19 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment { private void rebuildCatList() { categoryContainer.removeAllViews(); // @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); } }