private void OnTabLayoutOnTabSelected(object sender, TabLayout.TabSelectedEventArgs e) { if (e.Tab.Position == 2) { _prevTab.Select(); if (!RequestPermissions(CommonPermissionsRequestCode, Manifest.Permission.Camera, Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage)) { var intent = new Intent(this, typeof(CameraActivity)); StartActivity(intent); } } else { SelectTab(e.Tab.Position); _prevTab = e.Tab; AppSettings.SelectedTab = e.Tab.Position; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.ChatGroupContact_Fragments, container, false); viewPager = view.FindViewById <ViewPager>(Resource.Id.pager); tabLayoutForContacts = view.FindViewById <TabLayout>(Resource.Id.sliding_tabs); //Since we are a fragment in a fragment you need to pass down the child fragment manager! FragmentPagerAdapter adapter = new CustomPagerAdapterForContacts(ChildFragmentManager); viewPager.Adapter = adapter; viewPager.PageSelected += ViewPager_PageSelected; tabLayoutForContacts.SetupWithViewPager(viewPager); tabLayoutForContacts.TabSelected += TabLayoutForContacts_TabSelected; TabLayout.Tab tab = tabLayoutForContacts.GetTabAt(TabIndex); tab.Select(); return(view); }
private void OnTabLayoutOnTabSelected(object sender, TabLayout.TabSelectedEventArgs e) { if (e.Tab.Position == 2) { if (PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.Camera) == (int)Permission.Granted && PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.WriteExternalStorage) == (int)Permission.Granted) { _prevTab.Select(); var intent = new Intent(this, typeof(CameraActivity)); StartActivity(intent); } else { //Replace for Permission request this.ShowAlert(LocalizationKeys.CheckPermission); } } else { SelectTab(e.Tab.Position); _prevTab = e.Tab; BasePresenter.User.SelectedTab = e.Tab.Position; } }