Skip to content

Commit 78af43e

Browse files
ashishkumar468neslihanturan
authored andcommitted
Categories with pipe suffix (commons-app#1873)
* Bug fix issue commons-app#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
1 parent 2b72871 commit 78af43e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,19 @@ private void enableDeleteButton(boolean visibility) {
431431
private void rebuildCatList() {
432432
categoryContainer.removeAllViews();
433433
// @fixme add the category items
434-
for (String cat : categoryNames) {
435-
View catLabel = buildCatLabel(cat, categoryContainer);
434+
435+
//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
436+
//that was meant for alphabetical sorting of the categories and can be safely removed.
437+
for (int i = 0; i < categoryNames.size(); i++) {
438+
String categoryName = categoryNames.get(i);
439+
//Removed everything after '|'
440+
int indexOfPipe = categoryName.indexOf('|');
441+
if (indexOfPipe != -1) {
442+
categoryName = categoryName.substring(0, indexOfPipe);
443+
//Set the updated category to the list as well
444+
categoryNames.set(i, categoryName);
445+
}
446+
View catLabel = buildCatLabel(categoryName, categoryContainer);
436447
categoryContainer.addView(catLabel);
437448
}
438449
}

0 commit comments

Comments
 (0)