使用 Mono droid 和 slodge mvvmcross 从堆栈中删除活动 [英] Remove activity from stack using Mono droid and slodge mvvmcross
问题描述
我试图找到一种从堆栈中删除活动的方法 - 我们的应用程序中有一个流程:活动/视图模型 a -> 活动/视图模型 b -> 活动/视图模型 c.在 c 中,用户可以选择日期或返回.如果他回去,他应该回到b.但是,如果他选择了一个日期,他将被转发到活动/视图模型 b 的新实例,而活动/视图模型 b 的旧"实例已过时,应删除.
I am trying to find a way to remove an activity from the stack- We have a flow in our app: activity/viewmodel a -> activity/viewmodel b ->activity/viewmodel c. In c the user have the posibility of choosing a date or go back. If he goes back he should be returned to b. However if he chooses a date he is fowarded to a new instance of activity/viewmodel b and the "old" instance of activity/viewmodel b is obsolete and should be removed.
来自 Stuart Lodge(在类似线程上,仅用于单声道触摸)的建议是使用 RequestRemoveBackStep(),但我不确定如何使用它,而且我找不到示例.
A suggestion from Stuart Lodge (on a similar thread, just for mono touch) was to use RequestRemoveBackStep() but I am not sure how to use it and I cant find an example.
谁能指出我正确的方向?
Can anyone point me in the right direction?
问候
推荐答案
RequestRemoveBackStep()
方法是 IMvxViewDispatcher
接口的成员,在一些平台上实现:
The RequestRemoveBackStep()
method is a member of the IMvxViewDispatcher
interface and is implemented on some platforms:
public interface IMvxViewDispatcher : IMvxMainThreadDispatcher
{
bool RequestNavigate(MvxShowViewModelRequest request);
bool RequestClose(IMvxViewModel whichViewModel);
bool RequestRemoveBackStep();
}
但是,始终执行此操作并不完全简单......例如,在 Droid 上,它目前实现为:
However, its not entirely simple to always do this... so on Droid, for example, it is currently implemented as:
public bool RequestRemoveBackStep()
{
// not supported on Android? Not sure how to do this currently...
return false;
}
记录了有关此功能的问题 - 例如https://github.com/slodge/MvvmCross/issues/80 - 但似乎很可能此功能可能会从未来的 Mvx 实现中简单地删除 - 特别是因为对于每个平台上的每个视图都不太容易做到.
There are issues logged about this functionality - e.g. https://github.com/slodge/MvvmCross/issues/80 - but it seems likely that this functionality might simply be dropped from future Mvx implementations - especially as it's not very easy to do for every view on every platform.
如果您现在需要这种类型的功能,那么您需要找到自己的方式来实现此功能...取决于您的具体用例是什么(抱歉 - 您当前用例的详细信息不是从问题中我很清楚).
If you need this type of functionality now, then you'll need to find your own way of implementing this functionality... depending on what your specific use case is (sorry - the details of your current use case aren't clear to me from the question).
有几种可用的技术路线,包括:
There are several technical routes available including:
- 使用
NoHistory
标志 - 使用
RequestClose(oldviewModel)
调用 - 将逻辑添加到您的
Presenter
- 使用
Messenger
请求关闭自己的视图.
- using
NoHistory
flags - using
RequestClose(oldviewModel)
calls - adding logic to your
Presenter
- using a
Messenger
to request views close themselves.
这篇关于使用 Mono droid 和 slodge mvvmcross 从堆栈中删除活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!