-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7435 from emmauss/android
Android: Basic support configuration changes
- Loading branch information
Showing
14 changed files
with
80 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,55 @@ | ||
using Android.App; | ||
using Android.OS; | ||
using Android.Views; | ||
using Android.Content.PM; | ||
using AndroidX.AppCompat.App; | ||
using Android.Content.Res; | ||
using AndroidX.Lifecycle; | ||
|
||
namespace Avalonia.Android | ||
{ | ||
public abstract class AvaloniaActivity : Activity | ||
public abstract class AvaloniaActivity : AppCompatActivity | ||
{ | ||
internal AvaloniaView View; | ||
object _content; | ||
|
||
internal AvaloniaViewModel _viewModel; | ||
protected override void OnCreate(Bundle savedInstanceState) | ||
{ | ||
View = new AvaloniaView(this); | ||
if (_content != null) | ||
View.Content = _content; | ||
SetContentView(View); | ||
|
||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; | ||
|
||
if (_viewModel.Content != null) | ||
{ | ||
View.Content = _viewModel.Content; | ||
} | ||
|
||
base.OnCreate(savedInstanceState); | ||
} | ||
|
||
public object Content | ||
{ | ||
get | ||
{ | ||
return _content; | ||
return _viewModel.Content; | ||
} | ||
set | ||
{ | ||
_content = value; | ||
_viewModel.Content = value; | ||
if (View != null) | ||
View.Content = value; | ||
} | ||
} | ||
|
||
public override void OnConfigurationChanged(Configuration newConfig) | ||
{ | ||
base.OnConfigurationChanged(newConfig); | ||
} | ||
|
||
protected override void OnDestroy() | ||
{ | ||
View.Content = null; | ||
|
||
base.OnDestroy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Avalonia.Android | ||
{ | ||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel | ||
{ | ||
public object Content { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters