/// <summary> /// Pop to a specific fragment name /// </summary> /// <param name="name">Name.</param> public void NavigateBackToFragment(string name) { // get out fragment we want to navigate to var fragment = SupportFragmentManager.FindFragmentByTag(name); // pop everything up to our fragment RunOnUiThread(() => { _drawerLayout.CloseDrawers(); HideSoftInput(); try { SupportFragmentManager.PopBackStackImmediate(name, (int)PopBackStackFlags.None); } catch (Java.Lang.RuntimeException exception) { var dict = new Dictionary <string, string> { { "Fragment Name", name } }; Crashes.TrackError(exception, dict); } }); }
/** * @return may return null if the fragment has not been instantiated yet for that position - this depends on if the fragment has been viewed * yet OR is a sibling covered by {@link android.support.v4.view.ViewPager#setOffscreenPageLimit(int)}. Can use this to call methods on * the current positions fragment. */ public V4App.Fragment GetFragment(int position) { string tag = MakeFragmentName(Pager.Id, position); var fragment = SupportFragmentManager.FindFragmentByTag(tag); return(fragment); }
/// <summary> /// Called when a key was pressed down and not handled by any of the views inside of the activity. /// </summary> /// <param name="keyCode">The value in event.getKeyCode().</param> /// <param name="e">Description of the key event.</param> /// <returns> /// <b>false</b> - indicates that this event is not handled and should be propagated; otherwise - <b>true</b>. /// </returns> public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e) { switch (e.KeyCode) { // if Back key is pressed case Keycode.Back: // get barcode scanner fragment Android.Support.V4.App.Fragment barcodeScannerFragment = SupportFragmentManager.FindFragmentByTag(BARCODE_SCANNER_FRAGMENT_TAG); // if barcode scanner fragment is found and barcode scanner fragment is visible if (barcodeScannerFragment != null && barcodeScannerFragment.IsVisible) { // if this activity was called by another application if (IntentSource == Intents.IntentSource.NAITIVE_APP_INTENT) { // set result - canceled SetResult(Result.Canceled); // finish activity Finish(); return(true); } if (_barcodeScannerFragment.BackKeyPressed()) { return(true); } } else { // set default window settings SetDefaultWindowSettings(); } break; } return(base.OnKeyDown(keyCode, e)); }
/// <summary> /// No comments here :) /// </summary> /// <param name="showKeyboard"></param> public void HideOverlay(bool showKeyboard) { RunOnUiThread(() => { try { Fragment fragmentOverlay = SupportFragmentManager.FindFragmentByTag(FragmentOverlayTag); if (fragmentOverlay == null) { return; } if (!_isHidden) { SupportFragmentManager.BeginTransaction() .Remove(fragmentOverlay) .CommitAllowingStateLoss(); } if (showKeyboard) { ShowKeyboard(null); } ShowContentFragment(); BringFrameToFront(Resource.Id.frameButtons); } catch (IllegalStateException e) { Logger.Warning(e); } }); }
public void IniciarFragmentoMapa(int frame) { try { //Se obtiene el fragmento del mapa fragmentoMapa = SupportFragmentManager.FindFragmentByTag("map") as SupportMapFragment; //Si es null se va a crear if (fragmentoMapa == null) { //Se agregan las opciones del mapa GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeSatellite) .InvokeZoomControlsEnabled(true) .InvokeCompassEnabled(true); //Se crea la instancia del mapa, se agregan las opciones y se carga en el frame Android.Support.V4.App.FragmentTransaction transaccion = SupportFragmentManager.BeginTransaction(); fragmentoMapa = SupportMapFragment.NewInstance(mapOptions); transaccion.Add(frame, fragmentoMapa, "map"); transaccion.Commit(); } } catch (Exception ex) { //Se guarda el detalle del error Logs.saveLogError("MainActivity.IniciarFragmentoMapa " + ex.Message + " " + ex.StackTrace); } }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.aspect_ratio: if (mCameraView != null && SupportFragmentManager.FindFragmentByTag(FRAGMENT_DIALOG) == null) { AspectRatio[] ratios = mCameraView.SupportedAspectRatios.ToArray(); AspectRatio currentRatio = mCameraView.AspectRatio; AspectRatioFragment.NewInstance(ratios, currentRatio).Show(SupportFragmentManager, FRAGMENT_DIALOG); } return(true); case Resource.Id.switch_flash: if (mCameraView != null) { mCurrentFlash = (mCurrentFlash + 1) % FLASH_OPTIONS.Length; item.SetTitle(FLASH_TITLES[mCurrentFlash]); item.SetIcon(FLASH_ICONS[mCurrentFlash]); mCameraView.Flash = FLASH_OPTIONS[mCurrentFlash]; } return(true); case Resource.Id.switch_camera: if (mCameraView != null) { int facing = mCameraView.Facing; mCameraView.Facing = facing == CameraView.FacingFront ? CameraView.FacingBack : CameraView.FacingFront; } return(true); } return(base.OnOptionsItemSelected(item)); }
/// <summary> /// Switches from <paramref name="lastAttachedFragment"/> to the <see cref="BarcodeScannerFragment"/> instance. /// </summary> /// <param name="lastAttachedFragment">Last attached fragment.</param> internal void SwitchToHistory(Android.Support.V4.App.Fragment lastAttachedFragment) { // clear window flags Window.ClearFlags(WindowManagerFlags.KeepScreenOn); // show action bar SupportActionBar.Show(); // set action bar title SupportActionBar.SetTitle(Resource.String.history_title); // create a new transaction Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction(); // if last attached fragment is not empty if (lastAttachedFragment != null) { transaction.Detach(lastAttachedFragment); } // if history fragment does not exist if (SupportFragmentManager.FindFragmentByTag(HISTORY_FRAGMENT_TAG) == null) { // add fragment to the container transaction.Add(Resource.Id.contentFrame, _historyFragment, HISTORY_FRAGMENT_TAG); } // if history fragment exists else { // attach fragment to the container transaction.Attach(_historyFragment); } // add transaction to back stack transaction.AddToBackStack(null); // commit the transaction transaction.Commit(); }
public void searchButtonClicked(object sender, EventArgs e) { Android.Support.V4.App.Fragment fragment = SupportFragmentManager.FindFragmentByTag("UserBoardGamesFragment"); if (fragment != null && fragment.IsVisible) { } }
private void InitFragment() { mConversationFragment = (ConversationFragment)SupportFragmentManager.FindFragmentByTag(LivepersonFragment); Log.Debug(Tag, "initFragment. mConversationFragment = " + mConversationFragment); try { if (mConversationFragment == null) { /* * * String authCode = SampleAppStorage.getInstance(FragmentContainerActivity.this).getAuthCode(); * String publicKey = SampleAppStorage.getInstance(FragmentContainerActivity.this).getPublicKey(); * * Log.d(TAG, "initFragment. authCode = "+ authCode); * Log.d(TAG, "initFragment. publicKey = "+ publicKey); * LPAuthenticationParams authParams = new LPAuthenticationParams(); * authParams.setAuthKey(authCode); * authParams.addCertificatePinningKey(publicKey); */ LPAuthenticationParams authParams = new LPAuthenticationParams(); CampaignInfo campaignInfo = null;//SampleAppUtils.getCampaignInfo(this); ConversationViewParams conversationViewParams = new ConversationViewParams().SetCampaignInfo(campaignInfo).SetReadOnlyMode(isReadOnly()); mConversationFragment = (ConversationFragment)LivePerson.GetConversationFragment(authParams, conversationViewParams); if (isValidState()) { // Pending intent for image foreground service Intent notificationIntent = new Intent(CallBackInFragmentcontext, typeof(Activity_Message)); //notificationIntent.SetFlags(Intent.Flags); PendingIntent pendingIntent = PendingIntent.GetActivity(CallBackInFragmentcontext, 0, notificationIntent, 0); LivePerson.SetImageServicePendingIntent(pendingIntent); // Notification builder for image upload foreground service Notification.Builder uploadBuilder = new Notification.Builder(CallBackInFragmentcontext); Notification.Builder downloadBuilder = new Notification.Builder(CallBackInFragmentcontext); uploadBuilder.SetContentTitle("Uploading image") //.SetSmallIcon(Android.R.drawable.arrow_up_float) .SetContentIntent(pendingIntent) .SetProgress(0, 0, true); downloadBuilder.SetContentTitle("Downloading image") //.setSmallIcon(Android.R.drawable.arrow_down_float) .SetContentIntent(pendingIntent) .SetProgress(0, 0, true); LivePerson.SetImageServiceUploadNotificationBuilder(uploadBuilder); LivePerson.SetImageServiceDownloadNotificationBuilder(downloadBuilder); var ft = SupportFragmentManager.BeginTransaction(); ft.Add(Resource.Id.frameLayout1, mConversationFragment, LivepersonFragment).CommitAllowingStateLoss(); } } else { AttachFragment(); } } catch (Java.Lang.Exception e) { throw e; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.actv_ViewLegislator); SetupToolbar(Resource.Id.viewLegislatorActv_toolbar); SetupNavigationMenu(Resource.Id.viewLegislatorActv_navigationDrawer); _viewLegislatorFragment = SupportFragmentManager.FindFragmentByTag(TagsType.ViewLegislatorsFragment) as ViewLegislatorFragment; if (_viewLegislatorFragment == null) { var serializedLegislator = AndroidHelper.GetStringFromIntent(Intent, BundleType.Legislator); _viewLegislatorFragment = new ViewLegislatorFragment(); //TODO RM (Low Priority): //http://stackoverflow.com/questions/9245408/best-practice-for-instantiating-a-new-android-fragment if (_viewLegislatorFragment.Arguments == null) { _viewLegislatorFragment.Arguments = new Bundle(); } _viewLegislatorFragment.Arguments.PutString(BundleType.Legislator, serializedLegislator); AndroidHelper.AddSupportFragment(SupportFragmentManager, _viewLegislatorFragment, Resource.Id.viewLegislatorActv_fragmentContainer, TagsType.ViewLegislatorsFragment); } var adView = FindViewById <Android.Gms.Ads.AdView>(Resource.Id.viewLegislatorActv_adView); var adRequest = new Android.Gms.Ads.AdRequest.Builder().Build(); adView.LoadAd(adRequest); }
void SwitchTo (Android.Support.V4.App.Fragment fragment) { if (fragment.IsVisible) return; var section = fragment as IMoyeuSection; if (section == null) return; var name = section.Name; var data = new Dictionary<string, string> (); data.Add ("Section", section.Name); Xamarin.Insights.Track ("Navigated", data); var t = SupportFragmentManager.BeginTransaction (); var currentFragment = CurrentFragment; if (currentFragment == null) { t.Add (Resource.Id.content_frame, fragment, name); } else { t.SetCustomAnimations (Resource.Animator.frag_slide_in, Resource.Animator.frag_slide_out); var existingFragment = SupportFragmentManager.FindFragmentByTag (name); if (existingFragment != null) existingFragment.View.BringToFront (); currentFragment.View.BringToFront (); t.Hide (CurrentFragment); if (existingFragment != null) { t.Show (existingFragment); } else { t.Add (Resource.Id.content_frame, fragment, name); } section.RefreshData (); } t.Commit (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.actv_Main); SetupToolbar(Resource.Id.mainActv_toolbar); SetupNavigationMenu(Resource.Id.mainActv_navigationDrawer); var id = "ca-app-pub-2083619170491780~6859816114"; Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, id); _mainFragment = SupportFragmentManager.FindFragmentByTag(TagsType.MainParentFragment) as MainFragment; if (_mainFragment == null) { _mainFragment = new MainFragment(); AndroidHelper.AddSupportFragment(SupportFragmentManager, _mainFragment, Resource.Id.mainActv_fragmentContainer, TagsType.MainParentFragment); } var adView = FindViewById <Android.Gms.Ads.AdView>(Resource.Id.adView2); var adRequest = new Android.Gms.Ads.AdRequest.Builder().Build(); adView.LoadAd(adRequest); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.layout_aggregated_reporting_activity); AddToolbar(Resource.String.reporting_screen_title, true); this._swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_layout); this._swipeRefreshLayout.SetColorSchemeResources(Resource.Color.blue, Resource.Color.white, Resource.Color.gray1, Resource.Color.green); // load fragment var fragmentTransaction = SupportFragmentManager.BeginTransaction(); var frag = SupportFragmentManager.FindFragmentByTag(ReportingLevelFragmentTag); if (frag == null) { this._reportingStatsFragment = new ReportingLevelStatsFragment(); var bundle = new Bundle(); this._reportingStatsFragment.Arguments = bundle; fragmentTransaction.Replace(Resource.Id.reporting_placeholder, this._reportingStatsFragment, ReportingLevelFragmentTag); } else { this._reportingStatsFragment = frag; } fragmentTransaction.Commit(); _swipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh; }
public bool OnNavigationItemSelected(IMenuItem item) { int id = item.ItemId; if (id == Resource.Id.nav_home) { Android.Support.V4.App.Fragment fragment_home = SupportFragmentManager.FindFragmentByTag("HOME_FRAGMENT"); if (fragment_home == null || !fragment_home.IsVisible) { SupportFragmentManager.BeginTransaction().Replace(Resource.Id.flContent, new MainFragment(), "HOME_FRAGMENT").Commit(); } } else if (id == Resource.Id.nav_workout) { Android.Support.V4.App.Fragment fragment_workout = SupportFragmentManager.FindFragmentByTag("WORKOUT_FRAGMENT"); if (fragment_workout == null || !fragment_workout.IsVisible) { SupportFragmentManager.BeginTransaction().Replace(Resource.Id.flContent, new EditWorkoutFragment(), "WORKOUT_FRAGMENT").Commit(); } } else if (id == Resource.Id.nav_calendar) { } else if (id == Resource.Id.nav_profile) { } DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); drawer.CloseDrawer(GravityCompat.Start); return(true); }
/// <summary> /// Старт обработки списка Bitmap /// </summary> /// <param name="textBitmaps">список для текстового распознавания</param> /// <param name="latexBitmaps">список для LaTeX распознавания</param> void ProcessBitmaps(Bitmap[] textBitmaps, Bitmap[] latexBitmaps) { if (textBitmaps.Length == 0 && latexBitmaps.Length == 0) { StopLoading(); Toast.MakeText(this, "Вы ещё не выбрали фрагментов для анализа!", ToastLength.Short).Show(); } else { Android.Support.V4.App.Fragment currentFragment = SupportFragmentManager.FindFragmentByTag("crop_view_tag"); EnableDisableViewGroup((currentFragment.View as ViewGroup), false); ShowLoading(); if (textBitmaps.Length != 0) { processNums++; firebaseImageService.ProcessImages(textBitmaps); } if (latexBitmaps.Length != 0) { processNums++; latexService.ProcessImages(latexBitmaps); } } }
/// <summary> /// Switches from <paramref name="lastAttachedFragment"/> to the <see cref="BarcodeScannerFragment"/> instance. /// </summary> /// <param name="lastAttachedFragment">Last attached fragment.</param> internal void SwitchToBarcodeScanner(Android.Support.V4.App.Fragment lastAttachedFragment) { // set default window settings SetDefaultWindowSettings(); // create a new transaction Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction(); // if last attached fragment is not empty if (lastAttachedFragment != null) { transaction.Detach(lastAttachedFragment); } // if barcode scanner fragment does not exist if (SupportFragmentManager.FindFragmentByTag(BARCODE_SCANNER_FRAGMENT_TAG) == null) { // add fragment to the container transaction.Add(Resource.Id.contentFrame, _barcodeScannerFragment, BARCODE_SCANNER_FRAGMENT_TAG); } // if barcode scanner fragment exists else { // attach fragment to the container transaction.Attach(_barcodeScannerFragment); } // commit the transaction transaction.Commit(); }
protected Fragment GetFragmentFromBackstack(string tag) { if (string.IsNullOrWhiteSpace(tag)) { return(null); } return(SupportFragmentManager.FindFragmentByTag(tag)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ConfigTables); suppToolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar); drawerLayout = FindViewById <DrawerLayout>(Resource.Id.Drawer); viewDrawer = FindViewById <ListView>(Resource.Id.ListView); mUserName = FindViewById <TextView>(Resource.Id.drawerUsername); mUserNameAndSurname = FindViewById <TextView>(Resource.Id.drawerUserNameSurname); if (SupportFragmentManager.FindFragmentByTag("Fragment1") != null) { mFragmentConfigTables = SupportFragmentManager.FindFragmentByTag("Fragment1") as FragmentConfigTablesAndColumns; } else { mFragmentConfigTables = new FragmentConfigTablesAndColumns(); mFragmentParameters = new FragmentParameters(); var trans = SupportFragmentManager.BeginTransaction(); trans.Add(Resource.Id.fragmentContainer, mFragmentConfigTables, "Fragment1"); trans.Commit(); mCurrentFragment = mFragmentConfigTables; } ISharedPreferences preferences = Application.Context.GetSharedPreferences("RememberMe", FileCreationMode.Private); string UserName = preferences.GetString("UserName", ""); string Name = preferences.GetString("Name", ""); string Surname = preferences.GetString("Surname", ""); mUserName.Text = UserName; mUserNameAndSurname.Text = Name + " " + Surname; listDrawer = new List <string>(); listDrawer.Add("Configuration columns"); listDrawer.Add("Configuration table"); listDrawer.Add("Stats columns"); listDrawer.Add("Stats tables"); listDrawer.Add("User table"); adapterDrawer = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, listDrawer); viewDrawer.Adapter = adapterDrawer; viewDrawer.ItemClick += ViewDrawer_ItemClick; SetSupportActionBar(suppToolbar); drawerToogle = new MyActionBarDrawerToggle(this /*host*/, drawerLayout, Resource.String.open_drawer, Resource.String.close_drawer); drawerLayout.SetDrawerListener(drawerToogle); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); drawerToogle.SyncState(); }
public void OnTagListUpdated() { var fragment = SupportFragmentManager.FindFragmentByTag(AnnotationListFragment.FragmentTag) as AnnotationListFragment; if (fragment != null) { fragment.Refresh(); } }
void HideRecordingDialog() { var recDialogExist = SupportFragmentManager.FindFragmentByTag("rec"); if (recDialogExist != null) { (recDialogExist as RecordingIndicator).Dismiss(); } }
public void UpdatePublicationDetailInfo(int bookId) { var detailInfo = SupportFragmentManager.FindFragmentByTag(PublicationDetailInfoFragment.PublicationDetailInfoFragmentKey); if (detailInfo != null) { ((PublicationDetailInfoFragment)detailInfo).UpdateWholeInfo(bookId); } }
public void SprayQualityClicked(Android.Views.View v) { var f = SupportFragmentManager.FindFragmentByTag(CalcFragTag); if (f != null) { ((CalcFragment)f).SprayQualityClicked(v); } }
public void BoomHeightClicked(Android.Views.View v) { var f = SupportFragmentManager.FindFragmentByTag(CalcFragTag); if (f != null) { ((CalcFragment)f).BoomHeightClicked(v); } }
private void OnClassScheduleSelected() { _activeFragment = ClassSchedule; SupportFragmentManager.BeginTransaction() .Attach(SupportFragmentManager.FindFragmentByTag("class")) .Detach(SupportFragmentManager.FindFragmentByTag("classroom")) .Commit(); SupportActionBar.Subtitle = Resources.GetStringArray(Resource.Array.subtitles)[_activeFragment]; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetTheme(Resource.Style.Theme_Normal); SetContentView(Resource.Layout.Ingest); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); Window.ClearFlags(WindowManagerFlags.TranslucentStatus); if (savedInstanceState == null) { var fragmentTransaction = SupportFragmentManager.BeginTransaction(); allclipsfragment = new AllClipsFragment(AllClipsFragment.ClipViewMode.INGEST); fragmentTransaction.Replace(Resource.Id.selector, allclipsfragment, "frag1"); fragmentTransaction.Commit(); (allclipsfragment as IImagePausable).Pause(); allclipsfragment.OnPreview += Allclipsfragment_OnPreview; allclipsfragment.OnBack += Allclipsfragment_OnBack; allclipsfragment.OnNext += Allclipsfragment_OnNext; } else { allclipsfragment = SupportFragmentManager.FindFragmentByTag("frag1") as AllClipsFragment; } IngestWizard.ShowWizard(this, false); spinner = FindViewById <Spinner>(Resource.Id.filter_spinner); filters = new IconSpinnerAdapter(this); foreach (var t in Bootlegger.MediaItemFilter) { filters.Add(new FilterTuple <Bootlegger.MediaItemFilterType, string>(t.Key, t.Value)); } spinner.Adapter = filters; spinner2 = FindViewById <Spinner>(Resource.Id.direction_spinner); directions = new IconOrderSpinnerAdapter(this); directions.Add(new FilterTuple <Bootlegger.MediaItemFilterDirection, string>(Bootlegger.MediaItemFilterDirection.ASCENDING, "")); directions.Add(new FilterTuple <Bootlegger.MediaItemFilterDirection, string>(Bootlegger.MediaItemFilterDirection.DESCENDING, "")); spinner2.Adapter = directions; spinner.ItemSelected += Spinner_ItemSelected; spinner2.ItemSelected += Spinner2_ItemSelected; }
public void OnPageSelected(int position) { var tag = "android:switcher:" + pager.Id + ":" + position; var frag = SupportFragmentManager.FindFragmentByTag(tag) as BaseFragment; if (frag != null) { frag.Init(); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); var fragment = SupportFragmentManager.FindFragmentByTag(typeof(SearchedSessionsFragment).Name); if (fragment != null) { fragment.OnActivityResult(requestCode, (int)resultCode, data); } }
/// <summary> /// End the nicotine editing fragment and update the UI. /// </summary> public void StopEditNicotine() { SupportFragmentManager.PopBackStackImmediate(); var list = SupportFragmentManager.FindFragmentByTag("listFragment") as NicotineListFragment; if (list != null) { list.Reset(); } }
private void Navigate(Type type) { var fragment = SupportFragmentManager.FindFragmentByTag(type.Name); if (fragment == null) { fragment = (Android.Support.V4.App.Fragment)Activator.CreateInstance(type); } SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content, fragment, type.Name).Commit(); }
private void ToggleAdIfNeeded() { var homeFragment = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.pager + ":0") as HomeFragment; if (homeFragment != null && !AdsEnabled()) { homeFragment.HideAd(); } }