Dialog源码之语法学习括号直接判断即无if的判断

Dialog.java类里面,这个函数响应搜索的请求
/**
     * This hook is called when the user signals the desire to start a search.
     */
    public boolean onSearchRequested() {
        final SearchManager searchManager = (SearchManager) mContext
                .getSystemService(Context.SEARCH_SERVICE);

        // can't start search without an associated activity (e.g a system dialog)
        if (!searchManager.hasIdent()) {
            return false;
        }

        // associate search with owner activity if possible (otherwise it will default to
        // global search).

        final ComponentName appName = getAssociatedActivity();
        final boolean globalSearch = (appName == null);
        searchManager.startSearch(null, false, appName, null, globalSearch);
        dismiss();
        return true;
    }

 

红色的那句话对我来说比较新奇,是新的语法,我要学习;

 

意思就是说:如果appName是null  的话就返回true,否则就是false

 

这函数的注释挺有意思,不和Activity关联的Dialog不能打开搜索,呵呵,看来验证了我的一个猜测,就是对话框的制造的种类。

 

 

 

你可能感兴趣的:(制造)