diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-02-17 22:21:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-02-17 22:21:11 +0000 |
commit | 0a300b897711bfa39e0d30e2fa61664f01fb58d8 (patch) | |
tree | d567646c67a770b5c65e1b251efe2a7610b42c6f /tools/layoutlib/bridge/src/com | |
parent | a0fb87a3b831e8eb4e4f7e03fc170cf8f93a2161 (diff) | |
parent | 068499111c173fdd9869e7dbe5b9de857aca1c2d (diff) | |
download | frameworks_base-0a300b897711bfa39e0d30e2fa61664f01fb58d8.zip frameworks_base-0a300b897711bfa39e0d30e2fa61664f01fb58d8.tar.gz frameworks_base-0a300b897711bfa39e0d30e2fa61664f01fb58d8.tar.bz2 |
am ad879adb: Merge "Add Asset management support for fonts." into lmp-dev
automerge: 0684991
* commit '068499111c173fdd9869e7dbe5b9de857aca1c2d':
Add Asset management support for fonts.
Diffstat (limited to 'tools/layoutlib/bridge/src/com')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java | 11 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java | 19 |
2 files changed, 18 insertions, 12 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 3441878..2f62b93 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -18,6 +18,7 @@ package com.android.layoutlib.bridge.android; import android.os.IBinder; import com.android.annotations.Nullable; +import com.android.ide.common.rendering.api.AssetRepository; import com.android.ide.common.rendering.api.ILayoutPullParser; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; @@ -48,6 +49,7 @@ import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; +import android.content.res.BridgeAssetManager; import android.content.res.BridgeResources; import android.content.res.BridgeTypedArray; import android.content.res.Configuration; @@ -102,6 +104,7 @@ public final class BridgeContext extends Context { * used to populate the mViewKeyMap. */ private final HashMap<Object, Object> mViewKeyHelpMap = new HashMap<Object, Object>(); + private final BridgeAssetManager mAssets; private Resources mSystemResources; private final Object mProjectKey; private final DisplayMetrics mMetrics; @@ -141,6 +144,7 @@ public final class BridgeContext extends Context { */ public BridgeContext(Object projectKey, DisplayMetrics metrics, RenderResources renderResources, + AssetRepository assets, IProjectCallback projectCallback, Configuration config, int targetSdkVersion, @@ -151,6 +155,8 @@ public final class BridgeContext extends Context { mRenderResources = renderResources; mConfig = config; + mAssets = new BridgeAssetManager(); + mAssets.setAssetRepository(assets); mApplicationInfo = new ApplicationInfo(); mApplicationInfo.targetSdkVersion = targetSdkVersion; @@ -1088,9 +1094,8 @@ public final class BridgeContext extends Context { } @Override - public AssetManager getAssets() { - // pass - return null; + public BridgeAssetManager getAssets() { + return mAssets; } @Override diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java index 60f5331..127cb72 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java @@ -35,7 +35,6 @@ import com.android.resources.ScreenSize; import android.content.res.Configuration; import android.os.HandlerThread_Delegate; -import android.os.Looper; import android.util.DisplayMetrics; import android.view.ViewConfiguration_Accessor; import android.view.inputmethod.InputMethodManager; @@ -71,7 +70,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso /** * Creates a renderAction. * <p> - * This <b>must</b> be followed by a call to {@link RenderAction#init()}, which act as a + * This <b>must</b> be followed by a call to {@link RenderAction#init(long)}, which act as a * call to {@link RenderAction#acquire(long)} * * @param params the RenderParams. This must be a copy that the action can keep @@ -121,8 +120,8 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso // build the context mContext = new BridgeContext(mParams.getProjectKey(), metrics, resources, - mParams.getProjectCallback(), getConfiguration(), mParams.getTargetSdkVersion(), - mParams.isRtlSupported()); + mParams.getAssets(), mParams.getProjectCallback(), getConfiguration(), + mParams.getTargetSdkVersion(), mParams.isRtlSupported()); setUp(); @@ -139,7 +138,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso * The preparation can fail if another rendering took too long and the timeout was elapsed. * * More than one call to this from the same thread will have no effect and will return - * {@link Result#SUCCESS}. + * {@link Result.Status#SUCCESS}. * * After scene actions have taken place, only one call to {@link #release()} must be * done. @@ -173,7 +172,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso * Acquire the lock so that the scene can be acted upon. * <p> * This returns null if the lock was just acquired, otherwise it returns - * {@link Result#SUCCESS} if the lock already belonged to that thread, or another + * {@link Result.Status#SUCCESS} if the lock already belonged to that thread, or another * instance (see {@link Result#getStatus()}) if an error occurred. * * @param timeout the time to wait if another rendering is happening. @@ -184,11 +183,11 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso */ private Result acquireLock(long timeout) { ReentrantLock lock = Bridge.getLock(); - if (lock.isHeldByCurrentThread() == false) { + if (!lock.isHeldByCurrentThread()) { try { boolean acquired = lock.tryLock(timeout, TimeUnit.MILLISECONDS); - if (acquired == false) { + if (!acquired) { return ERROR_TIMEOUT.createResult(); } } catch (InterruptedException e) { @@ -308,7 +307,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso */ protected void checkLock() { ReentrantLock lock = Bridge.getLock(); - if (lock.isHeldByCurrentThread() == false) { + if (!lock.isHeldByCurrentThread()) { throw new IllegalStateException("scene must be acquired first. see #acquire(long)"); } if (sCurrentContext != mContext) { @@ -347,6 +346,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue(); config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue(); if (config.screenHeightDp < config.screenWidthDp) { + //noinspection SuspiciousNameCombination config.smallestScreenWidthDp = config.screenHeightDp; } else { config.smallestScreenWidthDp = config.screenWidthDp; @@ -367,6 +367,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso config.orientation = Configuration.ORIENTATION_LANDSCAPE; break; case SQUARE: + //noinspection deprecation config.orientation = Configuration.ORIENTATION_SQUARE; break; } |