Commit 5345c348 authored by Jérémy VIGNELLES's avatar Jérémy VIGNELLES Committed by Martin Finkel

Fixed some android build errors

(cherry picked from commit d623e24c)

# Conflicts:
#	src/LibVLCSharp.Forms/Platforms/Android/SystemUI.cs
#	src/LibVLCSharp.Forms/Platforms/Android/VideoViewRenderer.cs
parent d0e62898
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
......
...@@ -23,34 +23,34 @@ namespace LibVLCSharp.Forms.Platforms.Android ...@@ -23,34 +23,34 @@ namespace LibVLCSharp.Forms.Platforms.Android
set => CurrentActivity.SetTarget(value); set => CurrentActivity.SetTarget(value);
} }
public void OnActivityCreated(Activity activity, Bundle savedInstanceState) public void OnActivityCreated(Activity? activity, Bundle? savedInstanceState)
{ {
Activity = activity; Activity = activity;
} }
public void OnActivityDestroyed(Activity activity) public void OnActivityDestroyed(Activity? activity)
{ {
} }
public void OnActivityPaused(Activity activity) public void OnActivityPaused(Activity? activity)
{ {
Activity = activity; Activity = activity;
} }
public void OnActivityResumed(Activity activity) public void OnActivityResumed(Activity? activity)
{ {
Activity = activity; Activity = activity;
} }
public void OnActivitySaveInstanceState(Activity activity, Bundle outState) public void OnActivitySaveInstanceState(Activity? activity, Bundle? outState)
{ {
} }
public void OnActivityStarted(Activity activity) public void OnActivityStarted(Activity? activity)
{ {
} }
public void OnActivityStopped(Activity activity) public void OnActivityStopped(Activity? activity)
{ {
} }
} }
...@@ -73,7 +73,13 @@ namespace LibVLCSharp.Forms.Platforms.Android ...@@ -73,7 +73,13 @@ namespace LibVLCSharp.Forms.Platforms.Android
{ {
lifecycleListener = new ActivityLifecycleContextListener(); lifecycleListener = new ActivityLifecycleContextListener();
LifecycleListener = lifecycleListener; LifecycleListener = lifecycleListener;
activity.Application.RegisterActivityLifecycleCallbacks(lifecycleListener); var app = activity.Application;
if (app is null)
{
throw new InvalidOperationException("The given activity is not linked to an Application instance (activity.Application is null)");
}
app.RegisterActivityLifecycleCallbacks(lifecycleListener);
} }
lifecycleListener.Activity = activity; lifecycleListener.Activity = activity;
} }
......
using Android.App; using Android.Views;
using Android.Views;
using Java.Lang;
using LibVLCSharp.Forms.Platforms.Android; using LibVLCSharp.Forms.Platforms.Android;
using LibVLCSharp.Forms.Shared; using LibVLCSharp.Forms.Shared;
using Xamarin.Forms; using Xamarin.Forms;
...@@ -12,21 +10,23 @@ namespace LibVLCSharp.Forms.Platforms.Android ...@@ -12,21 +10,23 @@ namespace LibVLCSharp.Forms.Platforms.Android
{ {
public void ShowSystemUI() public void ShowSystemUI()
{ {
if (Platform.Activity == null) var decorView = Platform.Activity?.Window?.DecorView;
if (decorView == null)
return; return;
Platform.Activity.Window.DecorView.SystemUiVisibility = decorView.SystemUiVisibility =
(StatusBarVisibility)(SystemUiFlags.LayoutStable | (StatusBarVisibility)(SystemUiFlags.LayoutStable |
SystemUiFlags.LayoutFullscreen); SystemUiFlags.LayoutFullscreen);
} }
public void HideSystemUI() public void HideSystemUI()
{ {
if (Platform.Activity == null) var decorView = Platform.Activity?.Window?.DecorView;
if (decorView == null)
return; return;
Platform.Activity.Window.DecorView.SystemUiVisibility = decorView.SystemUiVisibility =
Platform.Activity.Window.DecorView.SystemUiVisibility | decorView.SystemUiVisibility |
(StatusBarVisibility)(SystemUiFlags.ImmersiveSticky | (StatusBarVisibility)(SystemUiFlags.ImmersiveSticky |
SystemUiFlags.Fullscreen | SystemUiFlags.Fullscreen |
SystemUiFlags.HideNavigation | SystemUiFlags.HideNavigation |
......
...@@ -35,7 +35,7 @@ namespace LibVLCSharp.Forms.Platforms.Android ...@@ -35,7 +35,7 @@ namespace LibVLCSharp.Forms.Platforms.Android
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context)); SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context!));
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging; e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control!.MediaPlayer != e.NewElement.MediaPlayer) if (Control!.MediaPlayer != e.NewElement.MediaPlayer)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment