Skip to content

Commit ed8d2a4

Browse files
authored
Merge pull request #630 from opensrp/jsonfrominteracter-memory-leak
fix memory leaks in NativeRadioButtonFactory
2 parents 7951443 + 5194cf6 commit ed8d2a4

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

android-json-form-wizard/src/main/java/com/vijay/jsonwizard/fragments/JsonFormFragment.java

+6
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,12 @@ public boolean onMenuItemClick(MenuItem item) {
824824
return presenter.onMenuItemClick(item);
825825
}
826826

827+
@Override
828+
public void onStop() {
829+
super.onStop();
830+
presenter.cleanUp();
831+
}
832+
827833
protected class BottomNavigationListener implements View.OnClickListener {
828834
@Override
829835
public void onClick(View view) {

android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java

+6
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,10 @@ public final Set<String> getDefaultTranslatableStepFields() {
278278
return defaultTranslatableStepFields;
279279
}
280280

281+
public void cleanUp() {
282+
if(map.get(JsonFormConstants.NATIVE_RADIO_BUTTON) != null){
283+
NativeRadioButtonFactory nativeRadioButtonFactory = (NativeRadioButtonFactory) map.get(JsonFormConstants.NATIVE_RADIO_BUTTON);
284+
nativeRadioButtonFactory.cleanUp();
285+
}
286+
}
281287
}

android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java

+1
Original file line numberDiff line numberDiff line change
@@ -1270,5 +1270,6 @@ private void addRules(JSONObject jsonObject, Set<String> ruleFiles) {
12701270

12711271
public void cleanUp() {
12721272
cleanupAndExit = true;
1273+
mJsonFormInteractor.cleanUp();
12731274
}
12741275
}

android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/NativeRadioButtonFactory.java

+9
Original file line numberDiff line numberDiff line change
@@ -890,4 +890,13 @@ public Set<String> getCustomTranslatableWidgetFields() {
890890
customTranslatableWidgetFields.add(JsonFormConstants.LABEL_INFO_TITLE);
891891
return customTranslatableWidgetFields;
892892
}
893+
894+
public void cleanUp(){
895+
this.context = null;
896+
this.formFragment = null;
897+
this.radioButton = null;
898+
this.extraInfoTextView = null;
899+
this.specifyTextView = null;
900+
this.reasonsTextView = null;
901+
}
893902
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION_NAME=2.1.16-SNAPSHOT
1+
VERSION_NAME=2.1.17-SNAPSHOT
22
VERSION_CODE=1
33
GROUP=org.smartregister
44
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard

0 commit comments

Comments
 (0)