mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fixed the issue with back button in contribution tab. (#4177)
Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
parent
bad65e3e12
commit
36406bad85
1 changed files with 38 additions and 8 deletions
|
|
@ -291,13 +291,13 @@ public class ContributionsFragment
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
nearbyNotificationCardView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG);
|
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMediaDetailPagerFragment() {
|
private void showMediaDetailPagerFragment() {
|
||||||
// hide nearby card view on media detail is visible
|
// hide nearby card view on media detail is visible
|
||||||
setupViewForMediaDetails();
|
setupViewForMediaDetails();
|
||||||
showFragment(mediaDetailPagerFragment, MEDIA_DETAIL_PAGER_FRAGMENT_TAG);
|
showFragment(mediaDetailPagerFragment, MEDIA_DETAIL_PAGER_FRAGMENT_TAG, contributionsListFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupViewForMediaDetails() {
|
private void setupViewForMediaDetails() {
|
||||||
|
|
@ -334,7 +334,7 @@ public class ContributionsFragment
|
||||||
showContributionsListFragment();
|
showContributionsListFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG);
|
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -342,14 +342,43 @@ public class ContributionsFragment
|
||||||
*
|
*
|
||||||
* @param fragment
|
* @param fragment
|
||||||
* @param tag
|
* @param tag
|
||||||
|
* @param otherFragment
|
||||||
*/
|
*/
|
||||||
private void showFragment(Fragment fragment, String tag) {
|
private void showFragment(Fragment fragment, String tag, Fragment otherFragment) {
|
||||||
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
||||||
|
if (fragment.isAdded() && otherFragment != null) {
|
||||||
|
transaction.hide(otherFragment);
|
||||||
|
transaction.show(fragment);
|
||||||
|
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG);
|
||||||
|
transaction.commit();
|
||||||
|
getChildFragmentManager().executePendingTransactions();
|
||||||
|
} else if (fragment.isAdded() && otherFragment == null) {
|
||||||
|
transaction.show(fragment);
|
||||||
|
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG);
|
||||||
|
transaction.commit();
|
||||||
|
getChildFragmentManager().executePendingTransactions();
|
||||||
|
}else if (!fragment.isAdded() && otherFragment != null ) {
|
||||||
|
transaction.hide(otherFragment);
|
||||||
|
transaction.add(R.id.root_frame, fragment, tag);
|
||||||
|
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG);
|
||||||
|
transaction.commit();
|
||||||
|
getChildFragmentManager().executePendingTransactions();
|
||||||
|
} else if (!fragment.isAdded()) {
|
||||||
transaction.replace(R.id.root_frame, fragment, tag);
|
transaction.replace(R.id.root_frame, fragment, tag);
|
||||||
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG);
|
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
getChildFragmentManager().executePendingTransactions();
|
getChildFragmentManager().executePendingTransactions();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFragment(Fragment fragment) {
|
||||||
|
getChildFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.remove(fragment)
|
||||||
|
.commit();
|
||||||
|
getChildFragmentManager().executePendingTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Intent getUploadServiceIntent(){
|
public Intent getUploadServiceIntent(){
|
||||||
Intent intent = new Intent(getActivity(), UploadService.class);
|
Intent intent = new Intent(getActivity(), UploadService.class);
|
||||||
|
|
@ -625,7 +654,8 @@ public class ContributionsFragment
|
||||||
} else {
|
} else {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
nearbyNotificationCardView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
getChildFragmentManager().popBackStack();
|
removeFragment(mediaDetailPagerFragment);
|
||||||
|
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
||||||
((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
((MainActivity)getActivity()).showTabs();
|
((MainActivity)getActivity()).showTabs();
|
||||||
fetchCampaigns();
|
fetchCampaigns();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue