MTK HISTROY 小结 4

在上两偏里,主要讲了进入一个app是需要用到的一个函数 EntryNewScreen,今天就说一下主动退出一个应用需要使用的函数 GoBackHistory,这个函数的作用就是退出当前app,回到上一个app。 在 GoBackHistory 这个函数里,没有什么内容,主要是 一个执行一个函数 ExecutePopHistory(),还有就是设置了 mmi_is_orderly_exit_screen = MMI_FALSE;  对于这个变量,也是一种特殊用法,只有当使用GoBackToHistory切换到指定 app 时才有效(这里说的app,也可以是一个模块入口或者界面的入口)。

static void ExecutePopHistory(void)
{
    //IsBackHistory 这变量表示 正在处理gobackhistroy,在  MTK HISTROY 小结 3 里就批评了这个 全局变量
    //这么搞一个全局变量,很让人头疼,不是static的. 在 AddHistory 里面起到保护 historyData的作用,怕这个数据被重入.就是当gobackhistory时,会又entryNewScreen,又会AddHistory. 有点绕。
    IsBackHistory = MMI_TRUE;
    //
    CheckMainLCDHistoryBack = MMI_TRUE;
    //又是一个全局变量,比 IsBackHistory 好一点,至少搞成static的了,
    bBackHistoryFlag = MMI_TRUE;

    // 判断是否有入口函数和是否不是最后一个历史记录(除了idle 的 currHistoryIndex 0)
    // 这个写法是否有bug?
    // 如果 currHistoryIndex 刚好为 -1 而 historyData[currHistoryIndex] == NULL,那就crash了
    // 至少应该这么写 if (currHistoryIndex > 0 && historyData[currHistoryIndex].entryFuncPtr )

    if (historyData[currHistoryIndex].entryFuncPtr && currHistoryIndex > 0)
    {
        U16 id;
        // 执行 当前active app 的注册的 del 函数
        ExecTopScrnCallbackHandler();

     
        id = historyData[currHistoryIndex].scrnID;
        {
            //执行入历史记录的口函数
            if (historyData[currHistoryIndex].entryFuncPtr)
            {
                (*(historyData[currHistoryIndex].entryFuncPtr)) ();
            }
            
            if (id == historyData[currHistoryIndex].scrnID)
            {
                // 删除历史记录
                decrement();
            }
        }
    }
    else
    {
        
        ExecTopScrnCallbackHandler();
        
        //进入到idle
        currHistoryIndex = -1;
        if ((historyData[0].entryFuncPtr))
        {
             (*(historyData[0].entryFuncPtr)) ();
        }
        //表示已经释放过,防止重复释放
        if (bDinitHistoryFlag)
        {
            bDinitHistoryFlag = MMI_FALSE;
        }
        else
        {
            mmi_free_history_buffer(0);
            memset(&historyData[0], 0, sizeof(historyNode));
        }

        IsBackHistory = MMI_FALSE;

    }

    CheckMainLCDHistoryBack = MMI_FALSE;
    bBackHistoryFlag = MMI_FALSE;
 }

先到这,待续

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值