Search in sources :

Example 1 with LayoutLog

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

the class RenderAction method setUp.

/**
     * Sets up the session for rendering.
     * <p/>
     * The counterpart is {@link #tearDown()}.
     */
private void setUp() {
    // make sure the Resources object references the context (and other objects) for this
    // scene
    mContext.initResources();
    sCurrentContext = mContext;
    // create an InputMethodManager
    InputMethodManager.getInstance();
    LayoutLog currentLog = mParams.getLog();
    Bridge.setLog(currentLog);
    mContext.getRenderResources().setFrameworkResourceIdProvider(this);
    mContext.getRenderResources().setLogger(currentLog);
}
Also used : LayoutLog(com.android.ide.common.rendering.api.LayoutLog)

Example 2 with LayoutLog

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

the class RenderAction method setUp.

/**
     * Sets up the session for rendering.
     * <p/>
     * The counterpart is {@link #tearDown()}.
     */
private void setUp() {
    // setup the ParserFactory
    ParserFactory.setParserFactory(mParams.getLayoutlibCallback().getParserFactory());
    // make sure the Resources object references the context (and other objects) for this
    // scene
    mContext.initResources();
    sCurrentContext = mContext;
    // create an InputMethodManager
    InputMethodManager.getInstance();
    LayoutLog currentLog = mParams.getLog();
    Bridge.setLog(currentLog);
    mContext.getRenderResources().setFrameworkResourceIdProvider(this);
    mContext.getRenderResources().setLogger(currentLog);
}
Also used : LayoutLog(com.android.ide.common.rendering.api.LayoutLog)

Example 3 with LayoutLog

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

the class RenderAction method setUp.

/**
     * Sets up the session for rendering.
     * <p/>
     * The counterpart is {@link #tearDown()}.
     */
private void setUp() {
    // setup the ParserFactory
    ParserFactory.setParserFactory(mParams.getLayoutlibCallback().getParserFactory());
    // make sure the Resources object references the context (and other objects) for this
    // scene
    mContext.initResources();
    sCurrentContext = mContext;
    // create an InputMethodManager
    InputMethodManager.getInstance();
    LayoutLog currentLog = mParams.getLog();
    Bridge.setLog(currentLog);
    mContext.getRenderResources().setFrameworkResourceIdProvider(this);
    mContext.getRenderResources().setLogger(currentLog);
}
Also used : LayoutLog(com.android.ide.common.rendering.api.LayoutLog)

Example 4 with LayoutLog

use of com.android.ide.common.rendering.api.LayoutLog in project android by JetBrains.

the class LayoutLibraryLoader method load.

@Nullable
public static LayoutLibrary load(@NotNull IAndroidTarget target, @NotNull Map<String, Map<String, Integer>> enumMap) throws RenderingException, IOException {
    final String fontFolderPath = FileUtil.toSystemIndependentName((target.getPath(IAndroidTarget.FONTS)));
    final VirtualFile fontFolder = LocalFileSystem.getInstance().findFileByPath(fontFolderPath);
    if (fontFolder == null || !fontFolder.isDirectory()) {
        throw new RenderingException(LayoutlibBundle.message("android.directory.cannot.be.found.error", FileUtil.toSystemDependentName(fontFolderPath)));
    }
    final String platformFolderPath = target.isPlatform() ? target.getLocation() : target.getParent().getLocation();
    final File platformFolder = new File(platformFolderPath);
    if (!platformFolder.isDirectory()) {
        throw new RenderingException(LayoutlibBundle.message("android.directory.cannot.be.found.error", FileUtil.toSystemDependentName(platformFolderPath)));
    }
    final File buildProp = new File(platformFolder, SdkConstants.FN_BUILD_PROP);
    if (!buildProp.isFile()) {
        throw new RenderingException(LayoutlibBundle.message("android.file.not.exist.error", FileUtil.toSystemDependentName(buildProp.getPath())));
    }
    if (!SystemInfo.isJavaVersionAtLeast("1.8") && target.getVersion().getFeatureLevel() >= 24) {
        // From N, we require to be running in Java 8
        throw new UnsupportedJavaRuntimeException(LayoutlibBundle.message("android.layout.preview.unsupported.jdk", SdkVersionInfo.getCodeName(target.getVersion().getFeatureLevel())));
    }
    LayoutLibrary library;
    final ILogger logger = new LogWrapper(LOG);
    if (USE_SDK_LAYOUTLIB) {
        final String resFolderPath = FileUtil.toSystemIndependentName((target.getPath(IAndroidTarget.RESOURCES)));
        final VirtualFile resFolder = LocalFileSystem.getInstance().findFileByPath(resFolderPath);
        if (resFolder == null || !resFolder.isDirectory()) {
            throw new RenderingException(LayoutlibBundle.message("android.directory.cannot.be.found.error", FileUtil.toSystemDependentName(resFolderPath)));
        }
        final String layoutLibJarPath = FileUtil.toSystemIndependentName((target.getPath(IAndroidTarget.LAYOUT_LIB)));
        final VirtualFile layoutLibJar = LocalFileSystem.getInstance().findFileByPath(layoutLibJarPath);
        if (layoutLibJar == null || layoutLibJar.isDirectory()) {
            throw new RenderingException(LayoutlibBundle.message("android.file.not.exist.error", FileUtil.toSystemDependentName(layoutLibJarPath)));
        }
        library = LayoutLibrary.load(layoutLibJar.getPath(), logger, ApplicationNamesInfo.getInstance().getFullProductName());
    } else {
        // We instantiate the local Bridge implementation and pass it to the LayoutLibrary instance
        library = LayoutLibrary.load(new Bridge(), LayoutLibraryLoader.class.getClassLoader());
    }
    if (library.getStatus() != LoadStatus.LOADED) {
        throw new RenderingException(library.getLoadMessage());
    }
    final Map<String, String> buildPropMap = ProjectProperties.parsePropertyFile(new BufferingFileWrapper(buildProp), logger);
    final LayoutLog layoutLog = new LayoutLogWrapper(LOG);
    if (library.init(buildPropMap, new File(fontFolder.getPath()), enumMap, layoutLog)) {
        return library;
    } else {
        return null;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) BufferingFileWrapper(org.jetbrains.android.util.BufferingFileWrapper) LayoutLibrary(com.android.ide.common.rendering.LayoutLibrary) ILogger(com.android.utils.ILogger) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Bridge(com.android.layoutlib.bridge.Bridge) LayoutLog(com.android.ide.common.rendering.api.LayoutLog) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with LayoutLog

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

the class RenderAction method setUp.

/**
     * Sets up the session for rendering.
     * <p/>
     * The counterpart is {@link #tearDown()}.
     */
private void setUp() {
    // setup the ParserFactory
    ParserFactory.setParserFactory(mParams.getLayoutlibCallback().getParserFactory());
    // make sure the Resources object references the context (and other objects) for this
    // scene
    mContext.initResources();
    sCurrentContext = mContext;
    // create an InputMethodManager
    InputMethodManager.getInstance();
    LayoutLog currentLog = mParams.getLog();
    Bridge.setLog(currentLog);
    mContext.getRenderResources().setFrameworkResourceIdProvider(this);
    mContext.getRenderResources().setLogger(currentLog);
}
Also used : LayoutLog(com.android.ide.common.rendering.api.LayoutLog)

Aggregations

LayoutLog (com.android.ide.common.rendering.api.LayoutLog)7 LayoutLibrary (com.android.ide.common.rendering.LayoutLibrary)1 Bridge (com.android.layoutlib.bridge.Bridge)1 ILogger (com.android.utils.ILogger)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 BufferingFileWrapper (org.jetbrains.android.util.BufferingFileWrapper)1 Nullable (org.jetbrains.annotations.Nullable)1