Fixes #4329 "Back button in edit categories triggers back of media details." (#4346)

* Back button on fragment

* Handled back events

* minor changes

* removed extra lines
This commit is contained in:
Aditya-Srivastav 2021-04-19 19:49:27 +05:30 committed by GitHub
parent fd247f6321
commit f8a8f92070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 115 additions and 8 deletions

View file

@ -100,8 +100,11 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
public void onBackPressed() {
((BookmarkListRootFragment) (adapter.getItem(tabLayout.getSelectedTabPosition())))
.backPressed();
if(((BookmarkListRootFragment)(adapter.getItem(tabLayout.getSelectedTabPosition()))).backPressed()) {
// The event is handled internally by the adapter , no further action required.
return;
}
// Event is not handled by the adapter ( performed back action ) change action bar.
((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
}

View file

@ -180,10 +180,14 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
}
}
public void backPressed() {
public boolean backPressed() {
//check mediaDetailPage fragment is not null then we check mediaDetail.is Visible or not to avoid NullPointerException
if(mediaDetails!=null) {
if (mediaDetails.isVisible()) {
if(mediaDetails.backButtonClicked()) {
// mediaDetails handled the back clicked , no further action required.
return true;
}
// todo add get list fragment
((BookmarkFragment) getParentFragment()).setupTabLayout();
ArrayList<Integer> removed=mediaDetails.getRemovedItems();
@ -206,6 +210,8 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
} else {
moveToContributionsFragment();
}
// notify mediaDetails did not handled the backPressed further actions required.
return false;
}
void moveToContributionsFragment(){