Upgrading MvvmCross to 5.2 shows error on CustomAndroidPresenter

∥☆過路亽.° 提交于 2020-01-11 11:57:04

问题


After upgrading MvvmCross from 5.1 to 5.2 , my CustomAndroidPresenter.cs is throwing a build error. What is causing this?

CustomAndroidPresenter.cs:

namespace TestPrjDroid
{
    public class CustomAndroidPresenter : MvxAndroidViewPresenter
    {
        public override void Show(MvxViewModelRequest request)
        {
            if (request != null && request.PresentationValues != null)
            {
                if (request.PresentationValues.ContainsKey("MyCustomFlag"))
                {
                    // Get intent from request and set flags to clear backstack.
                    var intent = base.CreateIntentForRequest(request);
                    intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                    base.Show(intent);
                    return;
                }
            }
            base.Show(request);
        }
    }
}

Error:

There is no argument given that corresponds to the required formal parameter 'androidViewAssemblies' of 'MvxAndroidViewPresenter.MvxAndroidViewPresenter(IEnumerable)'

Argument 1: cannot convert from 'Android.Content.Intent' to 'MvvmCross.Core.ViewModels.MvxViewModelRequest'


回答1:


You need to add a constructor for MvxAndroidViewPresenter(IEnumerable):

public class CustomAndroidPresenter : MvxAndroidViewPresenter
{

    public CustomAndroidPresenter(IEnumerable<Assembly> androidViewAssemblies) : base(androidViewAssemblies)
    {
    }

    public override void Show(MvxViewModelRequest request)
    {
        if (request != null && request.PresentationValues != null)
        {
            if (request.PresentationValues.ContainsKey("MyCustomFlag"))
            {
                // Get intent from request and set flags to clear backstack.
                var intent = base.CreateIntentForRequest(request);
                intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                base.ShowIntent(intent);
                return;
            }
        }
        base.Show(request);
    }
}


来源:https://stackoverflow.com/questions/46280219/upgrading-mvvmcross-to-5-2-shows-error-on-customandroidpresenter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!