Skip to content

Commit

Permalink
Merge pull request #630 from opensrp/jsonfrominteracter-memory-leak
Browse files Browse the repository at this point in the history
fix memory leaks in NativeRadioButtonFactory
  • Loading branch information
ndegwamartin authored Jun 17, 2022
2 parents 7951443 + 5194cf6 commit ed8d2a4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ public boolean onMenuItemClick(MenuItem item) {
return presenter.onMenuItemClick(item);
}

@Override
public void onStop() {
super.onStop();
presenter.cleanUp();
}

protected class BottomNavigationListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,10 @@ public final Set<String> getDefaultTranslatableStepFields() {
return defaultTranslatableStepFields;
}

public void cleanUp() {
if(map.get(JsonFormConstants.NATIVE_RADIO_BUTTON) != null){
NativeRadioButtonFactory nativeRadioButtonFactory = (NativeRadioButtonFactory) map.get(JsonFormConstants.NATIVE_RADIO_BUTTON);
nativeRadioButtonFactory.cleanUp();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1270,5 +1270,6 @@ private void addRules(JSONObject jsonObject, Set<String> ruleFiles) {

public void cleanUp() {
cleanupAndExit = true;
mJsonFormInteractor.cleanUp();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -890,4 +890,13 @@ public Set<String> getCustomTranslatableWidgetFields() {
customTranslatableWidgetFields.add(JsonFormConstants.LABEL_INFO_TITLE);
return customTranslatableWidgetFields;
}

public void cleanUp(){
this.context = null;
this.formFragment = null;
this.radioButton = null;
this.extraInfoTextView = null;
this.specifyTextView = null;
this.reasonsTextView = null;
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.1.16-SNAPSHOT
VERSION_NAME=2.1.17-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
Expand Down

0 comments on commit ed8d2a4

Please sign in to comment.