mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +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); | ||||
|             } | ||||
|         } | ||||
|         showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG); | ||||
|         showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment); | ||||
|     } | ||||
| 
 | ||||
|     private void showMediaDetailPagerFragment() { | ||||
|         // hide nearby card view on media detail is visible | ||||
|         setupViewForMediaDetails(); | ||||
|         showFragment(mediaDetailPagerFragment, MEDIA_DETAIL_PAGER_FRAGMENT_TAG); | ||||
|         showFragment(mediaDetailPagerFragment, MEDIA_DETAIL_PAGER_FRAGMENT_TAG, contributionsListFragment); | ||||
|     } | ||||
| 
 | ||||
|     private void setupViewForMediaDetails() { | ||||
|  | @ -334,7 +334,7 @@ public class ContributionsFragment | |||
|             showContributionsListFragment(); | ||||
|         } | ||||
| 
 | ||||
|         showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG); | ||||
|         showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -342,15 +342,44 @@ public class ContributionsFragment | |||
|      * | ||||
|      * @param fragment | ||||
|      * @param tag | ||||
|      * @param otherFragment | ||||
|      */ | ||||
|     private void showFragment(Fragment fragment, String tag) { | ||||
|     private void showFragment(Fragment fragment, String tag, Fragment otherFragment) { | ||||
|         FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); | ||||
|         transaction.replace(R.id.root_frame, fragment, tag); | ||||
|         transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||||
|         transaction.commit(); | ||||
|         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.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||||
|             transaction.commit(); | ||||
|             getChildFragmentManager().executePendingTransactions(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void removeFragment(Fragment fragment) { | ||||
|         getChildFragmentManager() | ||||
|             .beginTransaction() | ||||
|             .remove(fragment) | ||||
|             .commit(); | ||||
|         getChildFragmentManager().executePendingTransactions(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public Intent getUploadServiceIntent(){ | ||||
|         Intent intent = new Intent(getActivity(), UploadService.class); | ||||
|         intent.setAction(UploadService.ACTION_START_SERVICE); | ||||
|  | @ -625,7 +654,8 @@ public class ContributionsFragment | |||
|             } else { | ||||
|                 nearbyNotificationCardView.setVisibility(View.GONE); | ||||
|             } | ||||
|             getChildFragmentManager().popBackStack(); | ||||
|             removeFragment(mediaDetailPagerFragment); | ||||
|             showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment); | ||||
|             ((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); | ||||
|             ((MainActivity)getActivity()).showTabs(); | ||||
|             fetchCampaigns(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Pratham Pahariya
						Pratham Pahariya