这是我的设置,注册我的演示者:
public class Setup : MvxAppCompatSetup
{
public Setup(Context applicationContext)
: base(applicationContext)
{
}
protected override IEnumerable<Assembly> AndroidViewAssemblies => new List<Assembly>(base.AndroidViewAssemblies)
{
typeof(global::Android.Support.V7.Widget.Toolbar).Assembly
};
protected override IMvxApplication CreateApp()
{
Mvx.RegisterSingleton<INetworkManager>(() => new NetworkManagerAndroid(this.ApplicationContext));
return new App();
}
protected override void InitializeLastChance()
{
base.InitializeLastChance();
Mvx.RegisterSingleton<IAnalyticsService>(() => GoogleAnalyticsService.GetInstance());
}
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var presenter = new MyAndroidPresenter(AndroidViewAssemblies);
Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(presenter);
return presenter;
}
}
这是我的实际演示者:
public class MyAndroidPresenter : MvxFragmentsPresenter
{
public MyAndroidPresenter(IEnumerable<Assembly> AndroidViewAssemblies)
: base(AndroidViewAssemblies) // EXCEPTION HERE
{
}
protected override void ShowFragment(MvxViewModelRequest request)
{
if (GoHomeHandled(request))
return;
if (ShowModalHandled(request))
return;
base.ShowFragment(request);
}
protected override void ShowActivity(MvxViewModelRequest request, MvxViewModelRequest fragmentRequest = null)
{
if (GoHomeHandled(request))
return;
if (ShowModalHandled(request))
return;
base.ShowActivity(request, fragmentRequest);
}
private bool ShowModalHandled(MvxViewModelRequest request)
{
if (request.PresentationValues == null)
return false;
var viewsContainer = Mvx.Resolve<IMvxViewsContainer>();
var viewType = viewsContainer.GetViewType(request.ViewModelType);
var intent = new Intent(Application.Context, viewType);
if (request.PresentationValues.ContainsKey(Utilities.Constants.Navigation.ShowModal))
{
intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
Application.Context.StartActivity(intent);
return true;
}
else if (request.PresentationValues.ContainsKey(Utilities.Constants.Navigation.StayModal))
{
Application.Context.StartActivity(intent);
return true;
}
else
{
return false;
}
}
private bool GoHomeHandled(MvxViewModelRequest request)
{
if (request.PresentationValues == null)
return false;
if (request.PresentationValues.ContainsKey(Utilities.Constants.Navigation.ReturnHome))
{
var intent = new Intent(Application.Context, typeof(MainActivity));
intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask | ActivityFlags.TaskOnHome);
Application.Context.StartActivity(intent);
return true;
}
return false;
}
}
我得到的例外是标题中的例外。我尝试过清洁,重建,刷新NuGet包都无济于事。
我有点沮丧而且不知所措。我将不胜感激任何帮助。
答案 0 :(得分:2)
演示者名称应为MvxAppCompatViewPresenter
。如果您仍然是MvxFragmentsPresenter
,则表示一个或多个软件包已过时。查看Playground示例以查看完整实现:https://github.com/MvvmCross/MvvmCross/tree/develop/TestProjects/Playground