summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-10-06 10:17:51 -0700
committerJason Smith <jason.smith@xamarin.com>2016-10-06 10:20:23 -0700
commit459b04eb1fd6261c5b366ff475c3a4886b3e6213 (patch)
tree7c2a9718f7ed6319526afe06e77d3e15d11294f8
parent9bff801e6bb728535d423fbb4de69dd955e3b448 (diff)
downloadxamarin-forms-459b04eb1fd6261c5b366ff475c3a4886b3e6213.tar.gz
xamarin-forms-459b04eb1fd6261c5b366ff475c3a4886b3e6213.tar.bz2
xamarin-forms-459b04eb1fd6261c5b366ff475c3a4886b3e6213.zip
[A] Prevent blank page from appearing when MainPage is switched (#421)
* repro * [A]Add horrible hack to prevent background flashing when swapping MainPage * cleanup repro * Revert "[A]Add horrible hack to prevent background flashing when swapping MainPage" This reverts commit d0fdc3856d0eaa5ec781f790d524ad7624a26560. * [A] E.Z.'s less magical but just as effective solution
-rw-r--r--Xamarin.Forms.Controls/App.cs13
-rw-r--r--Xamarin.Forms.Controls/Bugzilla44596SplashPage.cs25
-rw-r--r--Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj1
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs7
4 files changed, 44 insertions, 2 deletions
diff --git a/Xamarin.Forms.Controls/App.cs b/Xamarin.Forms.Controls/App.cs
index c6480040..3af36ee3 100644
--- a/Xamarin.Forms.Controls/App.cs
+++ b/Xamarin.Forms.Controls/App.cs
@@ -8,6 +8,7 @@ using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
namespace Xamarin.Forms.Controls
{
+
public class App : Application
{
public const string AppName = "XamarinFormsControls";
@@ -31,6 +32,18 @@ namespace Xamarin.Forms.Controls
Master = new ContentPage { Title = "Master", BackgroundColor = Color.Red },
Detail = CoreGallery.GetMainPage()
};
+
+ //// Uncomment to verify that there is no gray screen displayed between the blue splash and red MasterDetailPage.
+ //MainPage = new Bugzilla44596SplashPage(() =>
+ //{
+ // var newTabbedPage = new TabbedPage();
+ // newTabbedPage.Children.Add(new ContentPage { BackgroundColor = Color.Red, Content = new Label { Text = "yay" } });
+ // MainPage = new MasterDetailPage
+ // {
+ // Master = new ContentPage { Title = "Master", BackgroundColor = Color.Red },
+ // Detail = newTabbedPage
+ // };
+ //});
}
protected override void OnAppLinkRequestReceived(Uri uri)
diff --git a/Xamarin.Forms.Controls/Bugzilla44596SplashPage.cs b/Xamarin.Forms.Controls/Bugzilla44596SplashPage.cs
new file mode 100644
index 00000000..ba7cdc46
--- /dev/null
+++ b/Xamarin.Forms.Controls/Bugzilla44596SplashPage.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class Bugzilla44596SplashPage : ContentPage
+ {
+ Action FinishedLoading { get; set; }
+
+
+ public Bugzilla44596SplashPage(Action finishedLoading)
+ {
+ BackgroundColor = Color.Blue;
+ FinishedLoading = finishedLoading;
+ }
+
+
+ protected async override void OnAppearing()
+ {
+ base.OnAppearing();
+ await Task.Delay(2000);
+ FinishedLoading?.Invoke();
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
index 7ad923e0..e7c61508 100644
--- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
+++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
@@ -84,6 +84,7 @@
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="AppLifeCycle.cs" />
+ <Compile Include="Bugzilla44596SplashPage.cs" />
<Compile Include="ControlGalleryPages\CellForceUpdateSizeGalleryPage.cs" />
<Compile Include="ControlGalleryPages\LayoutAddPerformance.xaml.cs">
<DependentUpon>LayoutAddPerformance.xaml</DependentUpon>
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
index 1b85b42f..fad745aa 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
@@ -1,5 +1,6 @@
using Android.App;
using Android.Content;
+using Android.OS;
using Fragment = Android.Support.V4.App.Fragment;
using FragmentManager = Android.Support.V4.App.FragmentManager;
using FragmentTransaction = Android.Support.V4.App.FragmentTransaction;
@@ -82,7 +83,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
// The renderers for NavigationPage and TabbedPage both host fragments, so they need to be wrapped in a
// FragmentContainer in order to get isolated fragment management
Fragment fragment = FragmentContainer.CreateInstance(page);
-
+
var fc = fragment as FragmentContainer;
fc?.SetOnCreateCallback(pc =>
@@ -100,10 +101,12 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
}
transaction.Add(Id, fragment);
- transaction.SetTransition((int)FragmentTransit.FragmentOpen);
+ transaction.SetTransition((int)FragmentTransit.None);
transaction.Commit();
_currentFragment = fragment;
+
+ new Handler(Looper.MainLooper).PostAtFrontOfQueue(() => FragmentManager.ExecutePendingTransactions());
}
}