Skip to content

Commit 4627f08

Browse files
authored
Merge pull request #312 from misaochan/fix-categories
Fix issue with categories not being added
2 parents 5c1fd5b + 85d6e98 commit 4627f08

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public static interface OnCategoriesSaveHandler {
7676

7777
protected HashMap<String, ArrayList<String>> categoriesCache;
7878

79+
private ArrayList<String> selectedCategories = new ArrayList<String>();
80+
7981
// LHS guarantees ordered insertions, allowing for prioritized method A results
8082
private final Set<String> results = new LinkedHashSet<String>();
8183
PrefixUpdater prefixUpdaterSub;
@@ -584,7 +586,7 @@ public void onSaveInstanceState(Bundle outState) {
584586
public boolean onOptionsItemSelected(MenuItem menuItem) {
585587
switch(menuItem.getItemId()) {
586588
case R.id.menu_save_categories:
587-
ArrayList<String> selectedCategories = new ArrayList<String>();
589+
588590
int numberSelected = 0;
589591

590592
for(CategoryItem item: categoriesAdapter.getItems()) {
@@ -594,9 +596,6 @@ public boolean onOptionsItemSelected(MenuItem menuItem) {
594596
}
595597
}
596598

597-
//Need to reassign to a final variable to use in inner class
598-
final ArrayList<String> finalCategories = selectedCategories;
599-
600599
//If no categories selected, display warning to user
601600
if (numberSelected == 0) {
602601
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@@ -612,7 +611,7 @@ public void onClick(DialogInterface dialog, int id) {
612611
builder.setNegativeButton("Yes, submit", new DialogInterface.OnClickListener() {
613612
public void onClick(DialogInterface dialog, int id) {
614613
//Proceed to submission
615-
onCategoriesSaveHandler.onCategoriesSave(finalCategories);
614+
onCategoriesSaveHandler.onCategoriesSave(selectedCategories);
616615
return;
617616
}
618617
});
@@ -621,7 +620,7 @@ public void onClick(DialogInterface dialog, int id) {
621620
dialog.show();
622621
} else {
623622
//Proceed to submission
624-
onCategoriesSaveHandler.onCategoriesSave(finalCategories);
623+
onCategoriesSaveHandler.onCategoriesSave(selectedCategories);
625624
return true;
626625
}
627626
}

0 commit comments

Comments
 (0)