Skip to content

Commit

Permalink
fix: fixed bug in aliumSutrveyLoaded added xfragment check
Browse files Browse the repository at this point in the history
  • Loading branch information
yusera-at-dwao committed Dec 6, 2024
1 parent 07e26b4 commit 0a09bea
Showing 1 changed file with 43 additions and 31 deletions.
74 changes: 43 additions & 31 deletions alium/src/main/java/com/dwao/alium/survey/AliumSurveyLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,33 @@ private void findAndLoadSurveyForCurrentScr() {
Log.d("activeSurvey", "survey existes");
return;
}
}else
if(activity instanceof FragmentActivity) {
FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
Fragment fragment= fm.findFragmentByTag(key+"-"+surveyParameters.screenName);
} else
if(xfragment!=null){
FragmentManager fm=xfragment.getChildFragmentManager();
Fragment fragment= fm.findFragmentByTag(key+"-"+surveyParameters.screenName);
if(fragment!=null){
Log.d("activeSurvey", "survey existes");
return;
}
}else{

android.app.FragmentManager fm = activity.getFragmentManager();
android.app.Fragment fragment= fm.findFragmentByTag(key+"-"+surveyParameters.screenName);
if(fragment!=null){
Log.d("activeSurvey", "survey existes");
return;
}else if(activity !=null){
if (activity instanceof FragmentActivity) {
FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(key + "-" + surveyParameters.screenName);
if (fragment != null) {
Log.d("activeSurvey", "survey existes");
return;
}
} else {

android.app.FragmentManager fm = activity.getFragmentManager();
android.app.Fragment fragment = fm.findFragmentByTag(key + "-" + surveyParameters.screenName);
if (fragment != null) {
Log.d("activeSurvey", "survey existes");
return;
}
}
}
}
loadSurveyIfShouldBeLoaded(jsonObject, key);
}
} catch (Exception e) {
Expand Down Expand Up @@ -234,31 +244,33 @@ else if(fragment!=null ){
.commitAllowingStateLoss();
}
}
if(activity instanceof FragmentActivity){
FragmentManager fm=((FragmentActivity)activity).getSupportFragmentManager();
if(!fm.isStateSaved()){
fm.beginTransaction()
.add(SurveyDialogFragment.newInstance(executableSurveySpecs,
surveyParameters, false), loadableSurveySpecs.key+"-"+surveyParameters.screenName)
.commit();
}
if(activity!=null){
if (activity instanceof FragmentActivity) {
FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
if (!fm.isStateSaved()) {
fm.beginTransaction()
.add(SurveyDialogFragment.newInstance(executableSurveySpecs,
surveyParameters, false), loadableSurveySpecs.key + "-" + surveyParameters.screenName)
.commit();
}

}else{
android.app.FragmentManager fm=activity.getFragmentManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if(!fm.isStateSaved()){
} else {
android.app.FragmentManager fm = activity.getFragmentManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (!fm.isStateSaved()) {
fm.beginTransaction()
.add(LegacySurveyDialogFragment.newInstance(executableSurveySpecs,
surveyParameters, false), loadableSurveySpecs.key + "-" + surveyParameters.screenName)
.commit();
}
} else {
fm.beginTransaction()
.add(LegacySurveyDialogFragment.newInstance(executableSurveySpecs,
surveyParameters, false), loadableSurveySpecs.key+"-"+surveyParameters.screenName)
.commit();
surveyParameters, false), loadableSurveySpecs.key + "-" + surveyParameters.screenName)
.commitAllowingStateLoss();
}
}else{
fm.beginTransaction()
.add(LegacySurveyDialogFragment.newInstance(executableSurveySpecs,
surveyParameters, false), loadableSurveySpecs.key+"-"+surveyParameters.screenName)
.commitAllowingStateLoss();
}

}
}
}
private void loadSurveyFromActivity(JSONObject json, LoadableSurveySpecs loadableSurveySpecs){
Expand Down

0 comments on commit 0a09bea

Please sign in to comment.