public void AddShowViewListener(IShowViewListener listener) { if (listener != null && !showViewListeners.Contains(listener)) { showViewListeners.Add(listener); } }
/// <summary> /// 打开一个界面,同时关闭其他的界面 /// </summary> /// <param name="viewName">需要打开的界面</param> /// <param name="hideList">需要关闭的界面列表</param> /// <param name="listener">回调函数</param> public void ShowView(string viewName, List<string> hideViewList , IShowViewListener listener, bool createAndShow = false ) { //如果缓存中存在对应UI,则显示UI并调用对应的函数 BaseUI baseUI = null; for (int i = 0; i < hideViewList.Count; i++) { if (mDicView.TryGetValue(viewName, out baseUI) && baseUI != null) { baseUI.Hide(); } } if (mDicView.TryGetValue(viewName, out baseUI)) { if (baseUI != null) { baseUI.Show(); if (listener != null) { listener.Succeed(baseUI); } } else { mDicView.Remove(viewName); } return; } for (int i = 0; i <mLoadIns.Count ; i++) { if (mLoadIns[i].viewName.Equals(viewName)) { mLoadIns[i].AddShowViewListener(listener); return; } } LoadViewCallBack callBack = new LoadViewCallBack(viewName,LoadViewCallBack.LoadViewType.Show); if (createAndShow) { callBack.loadType = LoadViewCallBack.LoadViewType.Create; } callBack.AddShowViewListener(listener); CreateView(callBack); }