use of com.android.layoutlib.bridge.android.BridgeContext in project android_frameworks_base by ResurrectionRemix.
the class HandlerThread_Delegate method run.
// -------- Delegate methods
@LayoutlibDelegate
static /*package*/
void run(HandlerThread theThread) {
// record the thread so that it can be quit() on clean up.
BridgeContext context = RenderAction.getCurrentContext();
List<HandlerThread> list = sThreads.get(context);
if (list == null) {
list = new ArrayList<HandlerThread>();
sThreads.put(context, list);
}
list.add(theThread);
// ---- START DEFAULT IMPLEMENTATION.
theThread.mTid = Process.myTid();
Looper.prepare();
synchronized (theThread) {
theThread.mLooper = Looper.myLooper();
theThread.notifyAll();
}
Process.setThreadPriority(theThread.mPriority);
theThread.onLooperPrepared();
Looper.loop();
theThread.mTid = -1;
}
use of com.android.layoutlib.bridge.android.BridgeContext in project android_frameworks_base by ResurrectionRemix.
the class BridgePreferenceInflater method onCreateItem.
@Override
protected Preference onCreateItem(String name, AttributeSet attrs) throws ClassNotFoundException {
Object viewKey = null;
BridgeContext bc = null;
Context context = getContext();
if (context instanceof BridgeContext) {
bc = (BridgeContext) context;
}
if (attrs instanceof BridgeXmlBlockParser) {
viewKey = ((BridgeXmlBlockParser) attrs).getViewCookie();
}
Preference preference = super.onCreateItem(name, attrs);
if (viewKey != null && bc != null) {
bc.addCookie(preference, viewKey);
}
return preference;
}
use of com.android.layoutlib.bridge.android.BridgeContext in project android_frameworks_base by ResurrectionRemix.
the class RenderSessionImpl method init.
/**
* Initializes and acquires the scene, creating various Android objects such as context,
* inflater, and parser.
*
* @param timeout the time to wait if another rendering is happening.
*
* @return whether the scene was prepared
*
* @see #acquire(long)
* @see #release()
*/
@Override
public Result init(long timeout) {
Result result = super.init(timeout);
if (!result.isSuccess()) {
return result;
}
SessionParams params = getParams();
BridgeContext context = getContext();
// use default of true in case it's not found to use alpha by default
mIsAlphaChannelImage = ResourceHelper.getBooleanThemeValue(params.getResources(), "windowIsFloating", true, true);
mLayoutBuilder = new Layout.Builder(params, context);
// FIXME: find those out, and possibly add them to the render params
boolean hasNavigationBar = true;
//noinspection ConstantConditions
IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(), context.getMetrics(), Surface.ROTATION_0, hasNavigationBar);
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
// build the inflater and parser.
mInflater = new BridgeInflater(context, params.getLayoutlibCallback());
context.setBridgeInflater(mInflater);
mBlockParser = new BridgeXmlBlockParser(params.getLayoutDescription(), context, false);
return SUCCESS.createResult();
}
use of com.android.layoutlib.bridge.android.BridgeContext in project android_frameworks_base by ResurrectionRemix.
the class RenderSessionImpl method animate.
/**
* Animate an object
* <p>
* {@link #acquire(long)} must have been called before this.
*
* @throws IllegalStateException if the current context is different than the one owned by
* the scene, or if {@link #acquire(long)} was not called.
*
* @see RenderSession#animate(Object, String, boolean, IAnimationListener)
*/
public Result animate(Object targetObject, String animationName, boolean isFrameworkAnimation, IAnimationListener listener) {
checkLock();
BridgeContext context = getContext();
// find the animation file.
ResourceValue animationResource;
int animationId = 0;
if (isFrameworkAnimation) {
animationResource = context.getRenderResources().getFrameworkResource(ResourceType.ANIMATOR, animationName);
if (animationResource != null) {
animationId = Bridge.getResourceId(ResourceType.ANIMATOR, animationName);
}
} else {
animationResource = context.getRenderResources().getProjectResource(ResourceType.ANIMATOR, animationName);
if (animationResource != null) {
animationId = context.getLayoutlibCallback().getResourceId(ResourceType.ANIMATOR, animationName);
}
}
if (animationResource != null) {
try {
Animator anim = AnimatorInflater.loadAnimator(context, animationId);
if (anim != null) {
anim.setTarget(targetObject);
new PlayAnimationThread(anim, this, animationName, listener).start();
return SUCCESS.createResult();
}
} catch (Exception e) {
// get the real cause of the exception.
Throwable t = e;
while (t.getCause() != null) {
t = t.getCause();
}
return ERROR_UNKNOWN.createResult(t.getMessage(), t);
}
}
return ERROR_ANIM_NOT_FOUND.createResult();
}
use of com.android.layoutlib.bridge.android.BridgeContext in project android_frameworks_base by ResurrectionRemix.
the class RenderSessionImpl method getViewKey.
/* (non-Javadoc)
* The cookie for menu items are stored in menu item and not in the map from View stored in
* BridgeContext.
*/
@Nullable
private Object getViewKey(View view) {
BridgeContext context = getContext();
if (!(view instanceof MenuView.ItemView)) {
return context.getViewKey(view);
}
MenuItemImpl menuItem;
if (view instanceof ActionMenuItemView) {
menuItem = ((ActionMenuItemView) view).getItemData();
} else if (view instanceof ListMenuItemView) {
menuItem = ((ListMenuItemView) view).getItemData();
} else if (view instanceof IconMenuItemView) {
menuItem = ((IconMenuItemView) view).getItemData();
} else {
menuItem = null;
}
if (menuItem instanceof BridgeMenuItemImpl) {
return ((BridgeMenuItemImpl) menuItem).getViewCookie();
}
return null;
}
Aggregations