Search in sources :

Example 1 with RenderSessionImpl

use of com.android.layoutlib.bridge.impl.RenderSessionImpl in project android_frameworks_base by ResurrectionRemix.

the class Bridge method createSession.

/**
     * Starts a layout session by inflating and rendering it. The method returns a
     * {@link RenderSession} on which further actions can be taken.
     * <p/>
     * If {@link SessionParams} includes the {@link RenderParamsFlags#FLAG_DO_NOT_RENDER_ON_CREATE},
     * this method will only inflate the layout but will NOT render it.
     * @param params the {@link SessionParams} object with all the information necessary to create
     *           the scene.
     * @return a new {@link RenderSession} object that contains the result of the layout.
     * @since 5
     */
@Override
public RenderSession createSession(SessionParams params) {
    try {
        Result lastResult = SUCCESS.createResult();
        RenderSessionImpl scene = new RenderSessionImpl(params);
        try {
            prepareThread();
            lastResult = scene.init(params.getTimeout());
            if (lastResult.isSuccess()) {
                lastResult = scene.inflate();
                boolean doNotRenderOnCreate = Boolean.TRUE.equals(params.getFlag(RenderParamsFlags.FLAG_DO_NOT_RENDER_ON_CREATE));
                if (lastResult.isSuccess() && !doNotRenderOnCreate) {
                    lastResult = scene.render(true);
                }
            }
        } finally {
            scene.release();
            cleanupThread();
        }
        return new BridgeRenderSession(scene, lastResult);
    } catch (Throwable t) {
        // get the real cause of the exception.
        Throwable t2 = t;
        while (t2.getCause() != null) {
            t2 = t.getCause();
        }
        return new BridgeRenderSession(null, ERROR_UNKNOWN.createResult(t2.getMessage(), t));
    }
}
Also used : RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) Result(com.android.ide.common.rendering.api.Result)

Example 2 with RenderSessionImpl

use of com.android.layoutlib.bridge.impl.RenderSessionImpl in project android_frameworks_base by DirtyUnicorns.

the class Bridge method createSession.

/**
     * Starts a layout session by inflating and rendering it. The method returns a
     * {@link RenderSession} on which further actions can be taken.
     * <p/>
     * If {@link SessionParams} includes the {@link RenderParamsFlags#FLAG_DO_NOT_RENDER_ON_CREATE},
     * this method will only inflate the layout but will NOT render it.
     * @param params the {@link SessionParams} object with all the information necessary to create
     *           the scene.
     * @return a new {@link RenderSession} object that contains the result of the layout.
     * @since 5
     */
@Override
public RenderSession createSession(SessionParams params) {
    try {
        Result lastResult = SUCCESS.createResult();
        RenderSessionImpl scene = new RenderSessionImpl(params);
        try {
            prepareThread();
            lastResult = scene.init(params.getTimeout());
            if (lastResult.isSuccess()) {
                lastResult = scene.inflate();
                boolean doNotRenderOnCreate = Boolean.TRUE.equals(params.getFlag(RenderParamsFlags.FLAG_DO_NOT_RENDER_ON_CREATE));
                if (lastResult.isSuccess() && !doNotRenderOnCreate) {
                    lastResult = scene.render(true);
                }
            }
        } finally {
            scene.release();
            cleanupThread();
        }
        return new BridgeRenderSession(scene, lastResult);
    } catch (Throwable t) {
        // get the real cause of the exception.
        Throwable t2 = t;
        while (t2.getCause() != null) {
            t2 = t.getCause();
        }
        return new BridgeRenderSession(null, ERROR_UNKNOWN.createResult(t2.getMessage(), t));
    }
}
Also used : RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) Result(com.android.ide.common.rendering.api.Result)

Example 3 with RenderSessionImpl

use of com.android.layoutlib.bridge.impl.RenderSessionImpl in project platform_frameworks_base by android.

the class Bridge method createSession.

/**
     * Starts a layout session by inflating and rendering it. The method returns a
     * {@link RenderSession} on which further actions can be taken.
     * <p/>
     * If {@link SessionParams} includes the {@link RenderParamsFlags#FLAG_DO_NOT_RENDER_ON_CREATE},
     * this method will only inflate the layout but will NOT render it.
     * @param params the {@link SessionParams} object with all the information necessary to create
     *           the scene.
     * @return a new {@link RenderSession} object that contains the result of the layout.
     * @since 5
     */
@Override
public RenderSession createSession(SessionParams params) {
    try {
        Result lastResult = SUCCESS.createResult();
        RenderSessionImpl scene = new RenderSessionImpl(params);
        try {
            prepareThread();
            lastResult = scene.init(params.getTimeout());
            if (lastResult.isSuccess()) {
                lastResult = scene.inflate();
                boolean doNotRenderOnCreate = Boolean.TRUE.equals(params.getFlag(RenderParamsFlags.FLAG_DO_NOT_RENDER_ON_CREATE));
                if (lastResult.isSuccess() && !doNotRenderOnCreate) {
                    lastResult = scene.render(true);
                }
            }
        } finally {
            scene.release();
            cleanupThread();
        }
        return new BridgeRenderSession(scene, lastResult);
    } catch (Throwable t) {
        // get the real cause of the exception.
        Throwable t2 = t;
        while (t2.getCause() != null) {
            t2 = t.getCause();
        }
        return new BridgeRenderSession(null, ERROR_UNKNOWN.createResult(t2.getMessage(), t));
    }
}
Also used : RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) Result(com.android.ide.common.rendering.api.Result)

Example 4 with RenderSessionImpl

use of com.android.layoutlib.bridge.impl.RenderSessionImpl in project android_frameworks_base by ParanoidAndroid.

the class Bridge method createSession.

/**
     * Starts a layout session by inflating and rendering it. The method returns a
     * {@link RenderSession} on which further actions can be taken.
     *
     * @param params the {@link SessionParams} object with all the information necessary to create
     *           the scene.
     * @return a new {@link RenderSession} object that contains the result of the layout.
     * @since 5
     */
@Override
public RenderSession createSession(SessionParams params) {
    try {
        Result lastResult = SUCCESS.createResult();
        RenderSessionImpl scene = new RenderSessionImpl(params);
        try {
            prepareThread();
            lastResult = scene.init(params.getTimeout());
            if (lastResult.isSuccess()) {
                lastResult = scene.inflate();
                if (lastResult.isSuccess()) {
                    lastResult = scene.render(true);
                }
            }
        } finally {
            scene.release();
            cleanupThread();
        }
        return new BridgeRenderSession(scene, lastResult);
    } catch (Throwable t) {
        // get the real cause of the exception.
        Throwable t2 = t;
        while (t2.getCause() != null) {
            t2 = t.getCause();
        }
        return new BridgeRenderSession(null, ERROR_UNKNOWN.createResult(t2.getMessage(), t));
    }
}
Also used : RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) Result(com.android.ide.common.rendering.api.Result)

Example 5 with RenderSessionImpl

use of com.android.layoutlib.bridge.impl.RenderSessionImpl in project android_frameworks_base by AOSPA.

the class Bridge method createSession.

/**
     * Starts a layout session by inflating and rendering it. The method returns a
     * {@link RenderSession} on which further actions can be taken.
     * <p/>
     * If {@link SessionParams} includes the {@link RenderParamsFlags#FLAG_DO_NOT_RENDER_ON_CREATE},
     * this method will only inflate the layout but will NOT render it.
     * @param params the {@link SessionParams} object with all the information necessary to create
     *           the scene.
     * @return a new {@link RenderSession} object that contains the result of the layout.
     * @since 5
     */
@Override
public RenderSession createSession(SessionParams params) {
    try {
        Result lastResult = SUCCESS.createResult();
        RenderSessionImpl scene = new RenderSessionImpl(params);
        try {
            prepareThread();
            lastResult = scene.init(params.getTimeout());
            if (lastResult.isSuccess()) {
                lastResult = scene.inflate();
                boolean doNotRenderOnCreate = Boolean.TRUE.equals(params.getFlag(RenderParamsFlags.FLAG_DO_NOT_RENDER_ON_CREATE));
                if (lastResult.isSuccess() && !doNotRenderOnCreate) {
                    lastResult = scene.render(true);
                }
            }
        } finally {
            scene.release();
            cleanupThread();
        }
        return new BridgeRenderSession(scene, lastResult);
    } catch (Throwable t) {
        // get the real cause of the exception.
        Throwable t2 = t;
        while (t2.getCause() != null) {
            t2 = t.getCause();
        }
        return new BridgeRenderSession(null, ERROR_UNKNOWN.createResult(t2.getMessage(), t));
    }
}
Also used : RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) Result(com.android.ide.common.rendering.api.Result)

Aggregations

Result (com.android.ide.common.rendering.api.Result)6 RenderSessionImpl (com.android.layoutlib.bridge.impl.RenderSessionImpl)6