return from designer earlier (#6102)
authorShane Neuville <shane94@hotmail.com>
Tue, 7 May 2019 01:44:00 +0000 (19:44 -0600)
committerGitHub <noreply@github.com>
Tue, 7 May 2019 01:44:00 +0000 (19:44 -0600)
* return from designer earlier

* - initialize fake coordinator layout for designer

* change to a non appcompat compatible layout

Xamarin.Forms.Platform.Android/Renderers/ShellFlyoutTemplatedContentRenderer.cs
Xamarin.Forms.Sandbox/Xamarin.Forms.Sandbox.csproj

index 5ab3e2a..b0a1df9 100644 (file)
@@ -38,48 +38,21 @@ namespace Xamarin.Forms.Platform.Android
         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);
 
index cbae474..dca9fb7 100644 (file)
     <DebugType>pdbonly</DebugType>
     <DebugSymbols>true</DebugSymbols>
   </PropertyGroup>
-
-  <ItemGroup>
-    <None Include="ShellPage.xaml">
-      <Generator>MSBuild:Compile</Generator>
-    </None>
-  </ItemGroup>
   
   <ItemGroup>
     <!-- A reference to the entire .NET Framework is automatically included -->