Fix Crash Edit Categories Fragment (#5510)

* fix crash

* Tests Added

* Tests and Null Checks Added
This commit is contained in:
Shashank Kumar 2024-02-26 15:12:51 +05:30 committed by GitHub
parent 535792390e
commit f5a5159f8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 10 deletions

View file

@ -102,17 +102,17 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
wikiText = bundle.getString("WikiText");
nearbyPlaceCategory = bundle.getString(SELECTED_NEARBY_PLACE_CATEGORY);
}
if(callback!=null) {
init();
presenter.getCategories().observe(getViewLifecycleOwner(), this::setCategories);
}
init();
presenter.getCategories().observe(getViewLifecycleOwner(), this::setCategories);
}
private void init() {
if (media == null) {
tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
callback.getTotalNumberOfSteps(), getString(R.string.categories_activity_title)));
if (callback != null) {
tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
callback.getTotalNumberOfSteps(), getString(R.string.categories_activity_title)));
}
} else {
tvTitle.setText(R.string.edit_categories);
tvSubTitle.setVisibility(View.GONE);
@ -221,7 +221,9 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
@Override
public void goToNextScreen() {
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
if (callback != null){
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
}
}
@Override
@ -314,7 +316,9 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
mediaDetailFragment.onResume();
goBackToPreviousScreen();
} else {
callback.onPreviousButtonClicked(callback.getIndexInViewFlipper(this));
if (callback != null) {
callback.onPreviousButtonClicked(callback.getIndexInViewFlipper(this));
}
}
}