Search in sources :

Example 1 with MergeCookie

use of com.android.ide.common.rendering.api.MergeCookie in project platform_frameworks_base by android.

the class BridgeInflater method getViewKeyFromParser.

/*package*/
static Object getViewKeyFromParser(AttributeSet attrs, BridgeContext bc, ResourceReference resourceReference, boolean isInMerge) {
    if (!(attrs instanceof BridgeXmlBlockParser)) {
        return null;
    }
    BridgeXmlBlockParser parser = ((BridgeXmlBlockParser) attrs);
    // get the view key
    Object viewKey = parser.getViewCookie();
    if (viewKey == null) {
        int currentDepth = parser.getDepth();
        // test whether we are in an included file or in a adapter binding view.
        BridgeXmlBlockParser previousParser = bc.getPreviousParser();
        if (previousParser != null) {
            // looks like we are inside an embedded layout.
            // only apply the cookie of the calling node (<include>) if we are at the
            // top level of the embedded layout. If there is a merge tag, then
            // skip it and look for the 2nd level
            int testDepth = isInMerge ? 2 : 1;
            if (currentDepth == testDepth) {
                viewKey = previousParser.getViewCookie();
                // if we are in a merge, wrap the cookie in a MergeCookie.
                if (viewKey != null && isInMerge) {
                    viewKey = new MergeCookie(viewKey);
                }
            }
        } else if (resourceReference != null && currentDepth == 1) {
            // else if there's a resource reference, this means we are in an adapter
            // binding case. Set the resource ref as the view cookie only for the top
            // level view.
            viewKey = resourceReference;
        }
    }
    return viewKey;
}
Also used : MergeCookie(com.android.ide.common.rendering.api.MergeCookie) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser)

Example 2 with MergeCookie

use of com.android.ide.common.rendering.api.MergeCookie in project android_frameworks_base by ResurrectionRemix.

the class BridgeInflater method getViewKeyFromParser.

/*package*/
static Object getViewKeyFromParser(AttributeSet attrs, BridgeContext bc, ResourceReference resourceReference, boolean isInMerge) {
    if (!(attrs instanceof BridgeXmlBlockParser)) {
        return null;
    }
    BridgeXmlBlockParser parser = ((BridgeXmlBlockParser) attrs);
    // get the view key
    Object viewKey = parser.getViewCookie();
    if (viewKey == null) {
        int currentDepth = parser.getDepth();
        // test whether we are in an included file or in a adapter binding view.
        BridgeXmlBlockParser previousParser = bc.getPreviousParser();
        if (previousParser != null) {
            // looks like we are inside an embedded layout.
            // only apply the cookie of the calling node (<include>) if we are at the
            // top level of the embedded layout. If there is a merge tag, then
            // skip it and look for the 2nd level
            int testDepth = isInMerge ? 2 : 1;
            if (currentDepth == testDepth) {
                viewKey = previousParser.getViewCookie();
                // if we are in a merge, wrap the cookie in a MergeCookie.
                if (viewKey != null && isInMerge) {
                    viewKey = new MergeCookie(viewKey);
                }
            }
        } else if (resourceReference != null && currentDepth == 1) {
            // else if there's a resource reference, this means we are in an adapter
            // binding case. Set the resource ref as the view cookie only for the top
            // level view.
            viewKey = resourceReference;
        }
    }
    return viewKey;
}
Also used : MergeCookie(com.android.ide.common.rendering.api.MergeCookie) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser)

Example 3 with MergeCookie

use of com.android.ide.common.rendering.api.MergeCookie in project android_frameworks_base by DirtyUnicorns.

the class BridgeInflater method getViewKeyFromParser.

/*package*/
static Object getViewKeyFromParser(AttributeSet attrs, BridgeContext bc, ResourceReference resourceReference, boolean isInMerge) {
    if (!(attrs instanceof BridgeXmlBlockParser)) {
        return null;
    }
    BridgeXmlBlockParser parser = ((BridgeXmlBlockParser) attrs);
    // get the view key
    Object viewKey = parser.getViewCookie();
    if (viewKey == null) {
        int currentDepth = parser.getDepth();
        // test whether we are in an included file or in a adapter binding view.
        BridgeXmlBlockParser previousParser = bc.getPreviousParser();
        if (previousParser != null) {
            // looks like we are inside an embedded layout.
            // only apply the cookie of the calling node (<include>) if we are at the
            // top level of the embedded layout. If there is a merge tag, then
            // skip it and look for the 2nd level
            int testDepth = isInMerge ? 2 : 1;
            if (currentDepth == testDepth) {
                viewKey = previousParser.getViewCookie();
                // if we are in a merge, wrap the cookie in a MergeCookie.
                if (viewKey != null && isInMerge) {
                    viewKey = new MergeCookie(viewKey);
                }
            }
        } else if (resourceReference != null && currentDepth == 1) {
            // else if there's a resource reference, this means we are in an adapter
            // binding case. Set the resource ref as the view cookie only for the top
            // level view.
            viewKey = resourceReference;
        }
    }
    return viewKey;
}
Also used : MergeCookie(com.android.ide.common.rendering.api.MergeCookie) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser)

Example 4 with MergeCookie

use of com.android.ide.common.rendering.api.MergeCookie in project android_frameworks_base by ParanoidAndroid.

the class BridgeInflater method setupViewInContext.

private void setupViewInContext(View view, AttributeSet attrs) {
    if (getContext() instanceof BridgeContext) {
        BridgeContext bc = (BridgeContext) getContext();
        if (attrs instanceof BridgeXmlBlockParser) {
            BridgeXmlBlockParser parser = (BridgeXmlBlockParser) attrs;
            // get the view key
            Object viewKey = parser.getViewCookie();
            if (viewKey == null) {
                int currentDepth = parser.getDepth();
                // test whether we are in an included file or in a adapter binding view.
                BridgeXmlBlockParser previousParser = bc.getPreviousParser();
                if (previousParser != null) {
                    // looks like we inside an embedded layout.
                    // only apply the cookie of the calling node (<include>) if we are at the
                    // top level of the embedded layout. If there is a merge tag, then
                    // skip it and look for the 2nd level
                    int testDepth = mIsInMerge ? 2 : 1;
                    if (currentDepth == testDepth) {
                        viewKey = previousParser.getViewCookie();
                        // if we are in a merge, wrap the cookie in a MergeCookie.
                        if (viewKey != null && mIsInMerge) {
                            viewKey = new MergeCookie(viewKey);
                        }
                    }
                } else if (mResourceReference != null && currentDepth == 1) {
                    // else if there's a resource reference, this means we are in an adapter
                    // binding case. Set the resource ref as the view cookie only for the top
                    // level view.
                    viewKey = mResourceReference;
                }
            }
            if (viewKey != null) {
                bc.addViewKey(view, viewKey);
            }
        }
    }
}
Also used : BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) MergeCookie(com.android.ide.common.rendering.api.MergeCookie) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser)

Example 5 with MergeCookie

use of com.android.ide.common.rendering.api.MergeCookie in project android_frameworks_base by AOSPA.

the class BridgeInflater method getViewKeyFromParser.

/*package*/
static Object getViewKeyFromParser(AttributeSet attrs, BridgeContext bc, ResourceReference resourceReference, boolean isInMerge) {
    if (!(attrs instanceof BridgeXmlBlockParser)) {
        return null;
    }
    BridgeXmlBlockParser parser = ((BridgeXmlBlockParser) attrs);
    // get the view key
    Object viewKey = parser.getViewCookie();
    if (viewKey == null) {
        int currentDepth = parser.getDepth();
        // test whether we are in an included file or in a adapter binding view.
        BridgeXmlBlockParser previousParser = bc.getPreviousParser();
        if (previousParser != null) {
            // looks like we are inside an embedded layout.
            // only apply the cookie of the calling node (<include>) if we are at the
            // top level of the embedded layout. If there is a merge tag, then
            // skip it and look for the 2nd level
            int testDepth = isInMerge ? 2 : 1;
            if (currentDepth == testDepth) {
                viewKey = previousParser.getViewCookie();
                // if we are in a merge, wrap the cookie in a MergeCookie.
                if (viewKey != null && isInMerge) {
                    viewKey = new MergeCookie(viewKey);
                }
            }
        } else if (resourceReference != null && currentDepth == 1) {
            // else if there's a resource reference, this means we are in an adapter
            // binding case. Set the resource ref as the view cookie only for the top
            // level view.
            viewKey = resourceReference;
        }
    }
    return viewKey;
}
Also used : MergeCookie(com.android.ide.common.rendering.api.MergeCookie) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser)

Aggregations

MergeCookie (com.android.ide.common.rendering.api.MergeCookie)6 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)6 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)1