public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { MyView myholder = holder as MyView; myholder.Task.Text = Mitems[position].task_name; myholder.Create_by.Text = Mitems[position].task_created_by; myholder.Deadline_date.Text = Mitems[position].deadlineDate.ToString(); // myholder.time_left.Text = Mitems[position].mark_to; var local = new LocalOnClickListener(); myholder.Linear.SetOnClickListener(local); local.HandleOnClick = () => { string id = Mitems[position].task_id; ComplainceFrag nextFrag = new ComplainceFrag(); Android.Support.V4.App.FragmentTransaction ft = fragment.BeginTransaction(); //ft.Replace(Resource.Id.container, nextFrag, "ComplainceFragment"); ft.Hide(fragment.FindFragmentByTag("MainFrag")); ft.Add(Resource.Id.container, nextFrag, "ComplainceFragment"); ft.AddToBackStack("TaskInboxFrag"); ft.SetTransition(FragmentTransaction.TransitFragmentOpen); ft.Commit(); // fragment.BeginTransaction().Replace(Resource.Id.container, nextFrag).Commit(); Bundle bundle = new Bundle(); bundle.PutString("task_id", id); nextFrag.Arguments = bundle; }; myholder.time_left.Text = date_difference(DateTime.Now, Mitems[position].deadlineDate); }
public void PricingTypeDialogFragmentOnActivityResult(bool _clearCart) { mDialogShown = false; //flag to enable dialog show CheckoutFragment fragment = (CheckoutFragment)SupportFragmentManager.FindFragmentByTag("CheckoutFragment"); fragment.RefreshPricingType(_clearCart); }
private void CloseDialog(string dialogName) { FragmentManager fragmentManager = SupportFragmentManager; DialogFragment fragment = (DialogFragment)fragmentManager.FindFragmentByTag(dialogName); if (fragment != null) { fragment.Dismiss(); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); FragmentManager fragmentManager = SupportFragmentManager; Fragment fragment = fragmentManager.FindFragmentByTag("donationsFragment"); if (fragment != null) { fragment.OnActivityResult(requestCode, (int)resultCode, data); } }
private LinearLayout GetRootView(int position) { LinearLayout ly; try { ly = (LinearLayout)_fm.FindFragmentByTag(GetFragmentTag(position)).View.FindViewById(Resource.Id.root); } catch (Exception) { return(null); } return(ly); }
public static HolderFragment <T> FindHolderFragment(FragmentManager manager) { if (manager.IsDestroyed) { throw new IllegalStateException("Can\'t access ViewModels from onDestroy"); } var fragmentByTag = manager.FindFragmentByTag("android.arch.lifecycle.state.StateProviderHolderFragment"); if (fragmentByTag != null && !(fragmentByTag is HolderFragment <T>)) { throw new IllegalStateException("Unexpected fragment instance was returned by HOLDER_TAG"); } return((HolderFragment <T>)fragmentByTag); }
public static void SwitchFragmentById <TargetFragment>( this FragmentManager fm, int id, string targetFragmentTag, Func <Fragment, bool> compare, FragmentTransaction transaction = null, Bundle args = null ) where TargetFragment : Fragment, new() { var currentTransaction = transaction ?? fm.BeginTransaction(); var orgFragment = FindShowingFragmentById(fm, id); if (!compare(orgFragment)) { currentTransaction.Hide(orgFragment); var target = fm.FindFragmentByTag(targetFragmentTag); if (target == null) { target = new TargetFragment(); if (args != null) { target.Arguments = args; } currentTransaction.Add(id, target, targetFragmentTag); } else { if (args != null) { target.Arguments = args; } currentTransaction.Show(target); } } if (transaction == null) { currentTransaction.Commit(); } }
public static void AddFragment(Context context, Android.Support.V4.App.Fragment newFragment, string TAG) { Android.Support.V4.App.Fragment myFragment = null; Android.Support.V4.App.FragmentManager fragmentManager = ((FragmentActivity)context).SupportFragmentManager; Android.Support.V4.App.FragmentTransaction ft = fragmentManager.BeginTransaction(); myFragment = fragmentManager.FindFragmentByTag(TAG); if (myFragment == null) { ft.Add(Resource.Id.home_frame_layout, newFragment, TAG); ft.AddToBackStack(null); ft.Commit(); } else { ft.Detach(myFragment).Attach(myFragment); ft.Commit(); } }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Intent intent; SupportFragment newFragment = new Hub(); var trans = SupportFragmentManager.BeginTransaction(); trans.Add(Resource.Id.flContent, newFragment, "Hub"); trans.Commit(); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); View navheader = navigationView.GetHeaderView(0); CircleImageView iv = (CircleImageView)navheader.FindViewById(Resource.Id.imageCustomerIcon); iv.Click += delegate { intent = new Intent(this, typeof(Profile)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); }; await LoadAccount(); navigationView.NavigationItemSelected += (sender, e) => { SupportFragment frag; e.MenuItem.SetChecked(true); switch (e.MenuItem.ItemId) { case (Resource.Id.nav_hub): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Hub"); newFragment = new Hub(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Hub"); if (frag == null) { trans.AddToBackStack("Hub"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_tournament): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Turnieje"); newFragment = new Tournament(null, null, null, null, null); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Turnieje"); if (frag == null) { trans.AddToBackStack("Turnieje"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_quickgame): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Szybka gra"); newFragment = new Quickgame(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Szybka gra"); if (frag == null) { trans.AddToBackStack("Szybka gra"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_findplayers): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Znajdz gracza"); newFragment = new Findplayers(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Znajdz gracza"); if (frag == null) { trans.AddToBackStack("Znajdz gracza"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_friends): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Znajomi"); newFragment = new FriendList(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Znajomi"); if (frag == null) { trans.AddToBackStack("Znajomi"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_profile): intent = new Intent(this, typeof(Profile)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); break; case (Resource.Id.nav_addQuickgame): intent = new Intent(this, typeof(AddQuickgame)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); break; default: break; } mDrawerLayout.CloseDrawers(); }; pref = ((AppCompatActivity)this).GetSharedPreferences(Notyfication, FileCreationMode.Private); string noty = pref.GetString("Notification", ""); if (noty == "yes") { pref = ((AppCompatActivity)this).GetSharedPreferences(runActivity, FileCreationMode.Private); bool run = pref.GetBoolean("MainActivity", false); if (run) { Intent notint = new Intent(this, typeof(MainActivity)); notint.SetFlags(ActivityFlags.ClearTop); notint.SetFlags(ActivityFlags.NewTask); const int pendingIntentId = 0; PendingIntent pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, notint, PendingIntentFlags.OneShot); var notification = new Notification.Builder(this); notification.SetContentIntent(pendingIntent); notification.SetContentText("Zaproszenie do gry"); notification.SetContentTitle("GameHub"); notification.SetSmallIcon(Resource.Drawable.Icon4); notification.SetAutoCancel(true); notification.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); NotificationManager NotManager = (NotificationManager)GetSystemService(Context.NotificationService); NotManager.Notify(0, notification.Build()); } else { } } }
public void UpdateContent(Uri uri) { Fragment fragment; string tag; FragmentManager fm = SupportFragmentManager; FragmentTransaction tr = fm.BeginTransaction(); if (CurrentContentFragmentTag != null) { Fragment currentFragment = fm.FindFragmentByTag(CurrentContentFragmentTag); if (currentFragment != null) { tr.Hide(currentFragment); } } if (AboutFragment.ABOUT_URI.Equals(uri)) { tag = AboutFragment.TAG; Fragment foundFragment = fm.FindFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new AboutFragment(); } } else if (SandboxFragment.SETTINGS_URI.Equals(uri)) { tag = SandboxFragment.TAG; SandboxFragment foundFragment = (SandboxFragment)fm.FindFragmentByTag(tag); if (foundFragment != null) { foundFragment.OnSettingsChangedListener = mSettingsChangedListener; fragment = foundFragment; } else { SandboxFragment settingsFragment = new SandboxFragment(); settingsFragment.OnSettingsChangedListener = mSettingsChangedListener; fragment = settingsFragment; } } else if (uri != null) { tag = WebViewFragment.TAG; WebViewFragment webViewFragment; Fragment foundFragment = fm.FindFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; webViewFragment = (WebViewFragment)fragment; } else { webViewFragment = new WebViewFragment(); fragment = webViewFragment; } webViewFragment.Url = uri.ToString(); } else { return; } if (fragment.IsAdded) { tr.Show(fragment); } else { tr.Add(Resource.Id.content, fragment, tag); } tr.Commit(); CurrentUri = uri; CurrentContentFragmentTag = tag; }