/// <summary> /// This hook is called whenever an item in the options menu is selected. The default implementation /// simply returns false to have the normal processing happen (calling the item's Runnable or sending /// a message to its Handler as appropriate). You can use this method for any items for which you would /// like to do processing without those other facilities.<br/> /// Derived classes should call through to the base class for it to perform the default menu handling. /// </summary> /// <param name="item">The menu item that was selected.</param> /// <returns><c>false</c> to allow normal menu processing to proceed, <c>true</c> to consume it here.</returns> public override bool OnOptionsItemSelected(IMenuItem item) { if (item.ItemId != Android.Resource.Id.Home) { return(base.OnOptionsItemSelected(item)); } var previousView = Stack.Views.ElementAtOrDefault(Stack.Views.Count() - 2); var viewAtt = previousView == null ? null : Device.Reflector.GetCustomAttribute <StackBehaviorAttribute>(previousView.GetType(), true); var backLink = (Stack.CurrentView as IHistoryEntry)?.BackLink; if ((ActionBar.DisplayOptions & ActionBarDisplayOptions.HomeAsUp) == ActionBarDisplayOptions.HomeAsUp) { DroidFactory.HideKeyboard(false); Stack.HandleBackLink(backLink, Pane.Popover); } else if (Stack.CanGoBack() || backLink == null && (previousView == null || viewAtt != null && (viewAtt.Options & StackBehaviorOptions.HistoryShy) == StackBehaviorOptions.HistoryShy)) { DroidFactory.HideKeyboard(false); Close(false); } return(true); }
private void OnScrollStateChanged(object o, AbsListView.ScrollStateChangedEventArgs e) { DescendantFocusability = DescendantFocusability.BeforeDescendants; DroidFactory.HideKeyboard(); var fragment = Parent as BaseFragment; if (fragment != null) { fragment.RequestFocusHomeUp = false; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var layout = new LinearLayout(Activity) { Orientation = Orientation.Vertical, }; var search = DroidFactory.GetNativeObject <SearchBox>(SearchBox, nameof(SearchBox)); AttachSearchView(search, layout); List = MXContainer.Resolve <ListView>(Activity) ?? new ListView(Activity); List.OnItemSelectedListener = this; List.OnItemClickListener = this; List.OnItemLongClickListener = this; List.DescendantFocusability = DescendantFocusability.BeforeDescendants; List.ScrollingCacheEnabled = false; List.Adapter = new CellAdapter(this); List.ScrollStateChanged += (o, e) => { if (e.ScrollState == ScrollState.Idle) { var cell = List.GetChildAt(0); _index = List.FirstVisiblePosition; _top = cell?.Top ?? 0; } List.DescendantFocusability = DescendantFocusability.BeforeDescendants; if (_touchScroll) { DroidFactory.HideKeyboard(true); } if (e.ScrollState == ScrollState.Idle) { _touchScroll = true; } RequestFocusHomeUp = false; }; List.SetRecyclerListener(this); SeparatorColor = _separatorColor; layout.AddView(List, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent)); if (search == null || search.FocusRequested) { layout.RequestFocus(); } else { List.RequestFocus(); } return(layout); }
/// <summary> /// This hook is called whenever an item in the options menu is selected. The default implementation /// simply returns false to have the normal processing happen (calling the item's Runnable or sending /// a message to its Handler as appropriate). You can use this method for any items for which you would /// like to do processing without those other facilities.<br/> /// Derived classes should call through to the base class for it to perform the default menu handling. /// </summary> /// <param name="item">The menu item that was selected.</param> /// <returns><c>false</c> to allow normal menu processing to proceed, <c>true</c> to consume it here.</returns> public override bool OnOptionsItemSelected(IMenuItem item) { if (item == null || item.ItemId != Android.Resource.Id.Home) { return(base.OnOptionsItemSelected(item)); } var masterStack = PaneManager.Instance.FromNavContext(Pane.Master, PaneManager.Instance.CurrentTab); var masterView = masterStack?.CurrentView as IHistoryEntry; var back = masterView?.BackLink; if (back != null && back.Action == ActionType.None) { return(false); } Link currentTabLink; if ((ActionBar?.DisplayOptions & ActionBarDisplayOptions.HomeAsUp) == ActionBarDisplayOptions.HomeAsUp) { DroidFactory.HideKeyboard(false); masterStack?.HandleBackLink(back, Pane.Master); } else if ((currentTabLink = DroidFactory.Tabs?.TabItems?.ElementAtOrDefault(PaneManager.Instance.CurrentTab)?.NavigationLink) == null) { if (masterView != null) { masterView.OutputPane = Pane.Tabs; } DroidFactory.Navigate(new Link(iApp.Instance.NavigateOnLoad)); } else { DroidFactory.Navigate(currentTabLink, DroidFactory.Tabs); } return(true); }
private void Initialize() { SetIconifiedByDefault(false); QueryTextChange += OnQueryTextChange; QueryTextSubmit += (o, e) => DroidFactory.HideKeyboard(true); }
/// <summary> /// Synchronize the rendered stack with the <see cref="Views"/> collection /// </summary> public void Align(NavigationType navType) { var view = _views.LastOrDefault(); if (view == null) { return; } _views.RemoveAll(v => Device.Reflector.IsAssignableFrom(typeof(LoginLayer), v.ModelType) && !Equals(v, view)); var monoView = view as IView; if (monoView?.Pair is Fragment) { view = DroidFactory.GetNativeObject <Fragment>(monoView, "view") as IMXView; } var fragment = view as Fragment; if (fragment == null) { _views.Remove(view); } else { #region Popover initialization FragmentManager popoverManager = null; if (Context.ActivePane == Pane.Popover) { #region Popover teardown if (view is VanityFragment) { DroidFactory.HideKeyboard(false); PopoverActivity.Close(true); PopoverFragment.Close(); return; } #endregion if (PopoverFragment.Instance != null) { popoverManager = PopoverFragment.ChildFragmentManager; } else if (PopoverActivity.Instance == null) { IHistoryEntry frag; if (Build.VERSION.SdkInt > BuildVersionCodes.JellyBean && iApp.Factory.LargeFormFactor && ((frag = view as IHistoryEntry ?? (view as IPairable)?.Pair as IHistoryEntry) == null || frag.PopoverPresentationStyle != PopoverPresentationStyle.FullScreen)) { var name = Java.Lang.Class.FromType(typeof(PopoverFragment)).Name; var dialog = (DialogFragment)Fragment.Instantiate(DroidFactory.MainActivity, name); dialog.Show(DroidFactory.MainActivity.FragmentManager, null); } else { DroidFactory.MainActivity.StartActivity(MXContainer.Resolve <Type>("Popover")); } return; } } #endregion iApp.CurrentNavContext.ActivePane = Context.ActivePane; iApp.CurrentNavContext.ActiveLayer = view.GetModel() as iLayer; (popoverManager ?? DroidFactory.MainActivity.FragmentManager) .BeginTransaction() .Replace(FragmentId, fragment) .CommitAllowingStateLoss(); } #region Update screen titles if (Context.ActivePane == Pane.Popover) { PopoverFragment.UpdateTitle(); var titleUpdater = PopoverActivity.Instance?.GetType().GetMethod("UpdateTitle", BindingFlags.Static | BindingFlags.NonPublic); titleUpdater?.Invoke(null, null); } else if (DroidFactory.Tabs == null || !DroidFactory.Tabs.TabItems.Any()) { DroidFactory.RefreshTitles(); } else { DroidFactory.Tabs.Title = monoView?.Title ?? iApp.Instance.Title; } #endregion }