使用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屋!