protected virtual void LoadView(IShellContext shellContext)
{
var context = shellContext.AndroidContext;
- var coordinator = (ViewGroup)LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null);
- var recycler = coordinator.FindViewById<RecyclerView>(Resource.Id.flyoutcontent_recycler);
- var appBar = coordinator.FindViewById<ViewGroup>(Resource.Id.flyoutcontent_appbar);
-
- _rootView = coordinator;
-
- if((recycler == null || appBar == null) && !context.IsDesignerContext())
- {
- if (recycler == null)
- throw new ArgumentNullException("flyoutcontent_recycler", "Unable to find layout for flyoutcontent_recycler");
-
- // PREVIEWER HACK for some reason previewer pulls this out as a FrameLayout and ignores the internal resources
- if (appBar == null)
- throw new ArgumentNullException("flyoutcontent_appbar", "Unable to find layout for flyoutcontent_recycler");
-
- }
-
- try
- {
- // PREVIEWER HACK for some reason previewer can't find the resources for the recycler or the appBar
- if (recycler == null)
- recycler = (RecyclerView)coordinator.GetChildAt(1);
- if (appBar == null)
- appBar = (AppBarLayout)coordinator.GetChildAt(0);
- }
- catch
+ // Android designer can't load fragments or resources from layouts
+ if (context.IsDesignerContext())
{
- // PReviewer hack.
- // appcompat and non appcompat initialize this whole thing differently so the above are for appcompat the below are for non
+ _rootView = new FrameLayout(context);
+ return;
}
- // PREVIEWER HACK for some reason previewer can't find the resources for the recycler or the appBar
- if (recycler == null)
- recycler = coordinator.FindViewById<RecyclerView>(context.Resources.GetIdentifier("flyoutcontent_recycler", "id", context.PackageName));
-
- // PREVIEWER HACK for some reason previewer pulls this out as a FrameLayout and ignores the internal resources
- if (appBar == null)
- appBar = coordinator.FindViewById<ViewGroup>(context.Resources.GetIdentifier("flyoutcontent_appbar", "id", context.PackageName));
+ var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null);
+ var recycler = coordinator.FindViewById<RecyclerView>(Resource.Id.flyoutcontent_recycler);
+ var appBar = coordinator.FindViewById<AppBarLayout>(Resource.Id.flyoutcontent_appbar);
+ _rootView = coordinator;
- (appBar as AppBarLayout)?.AddOnOffsetChangedListener(this);
+ appBar.AddOnOffsetChangedListener(this);
int actionBarHeight = (int)context.ToPixels(56);