Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional single host MvxStartActivity #4846

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions MvvmCross/Platforms/Android/Views/MvxStartActivity.cs
Expand Up @@ -4,25 +4,22 @@

using Android.Runtime;
using Android.Views;
using MvvmCross.Platforms.Android.Binding.BindingContext;
using MvvmCross.ViewModels;

namespace MvvmCross.Platforms.Android.Views;

[Register("mvvmcross.platforms.android.views.MvxStartActivity")]
public abstract class MvxStartActivity
: MvxActivity
: MvxActivity<MvxStartViewModel>
{
protected const int NoContent = 0;

private readonly int _resourceId;

private Bundle _bundle;

public new MvxNullViewModel ViewModel
{
get { return base.ViewModel as MvxNullViewModel; }
set { base.ViewModel = value; }
}
public virtual bool SingleHostActivity => false;

protected MvxStartActivity(int resourceId = NoContent)
{
Expand All @@ -37,7 +34,8 @@ protected MvxStartActivity(IntPtr javaReference, JniHandleOwnership transfer)

protected virtual void RequestWindowFeatures()
{
RequestWindowFeature(WindowFeatures.NoTitle);
if (!SingleHostActivity)
RequestWindowFeature(WindowFeatures.NoTitle);
}

protected override void OnCreate(Bundle savedInstanceState)
Expand All @@ -50,9 +48,7 @@ protected override void OnCreate(Bundle savedInstanceState)

if (_resourceId != NoContent)
{
// Set our view from the "splash" layout resource
// Be careful to use non-binding inflation
var content = LayoutInflater.Inflate(_resourceId, null);
var content = this.BindingInflate(_resourceId, null);
SetContentView(content);
}
}
Expand All @@ -73,7 +69,7 @@ protected virtual async Task RunAppStartAsync(Bundle bundle)
{
await startup.StartAsync(GetAppStartHint(bundle));
}
else
else if (!SingleHostActivity)
{
Finish();
}
Expand All @@ -89,3 +85,5 @@ protected virtual void RegisterSetup()
{
}
}

public class MvxStartViewModel : MvxNullViewModel {}