use of android.annotation.TargetApi in project android_frameworks_base by DirtyUnicorns.
the class RenderTarget method forSurfaceTexture.
@TargetApi(11)
public RenderTarget forSurfaceTexture(SurfaceTexture surfaceTexture) {
EGLConfig eglConfig = chooseEglConfig(mEgl, mDisplay);
EGLSurface eglSurf = null;
synchronized (mSurfaceSources) {
eglSurf = mSurfaceSources.get(surfaceTexture);
if (eglSurf == null) {
eglSurf = mEgl.eglCreateWindowSurface(mDisplay, eglConfig, surfaceTexture, null);
mSurfaceSources.put(surfaceTexture, eglSurf);
}
}
checkEglError(mEgl, "eglCreateWindowSurface");
checkSurface(mEgl, eglSurf);
RenderTarget result = new RenderTarget(mDisplay, mContext, eglSurf, 0, false, true);
result.setSurfaceSource(surfaceTexture);
result.addReferenceTo(eglSurf);
return result;
}
use of android.annotation.TargetApi in project AgentWeb by Justson.
the class AgentWebView method trySetWebDebuggEnabled.
/**
* Android 4.4 KitKat 使用Chrome DevTools 远程调试WebView
* WebView.setWebContentsDebuggingEnabled(true);
* http://blog.csdn.net/t12x3456/article/details/14225235
*/
@TargetApi(19)
protected void trySetWebDebuggEnabled() {
if (LogUtils.isDebug() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
Class<?> clazz = WebView.class;
Method method = clazz.getMethod("setWebContentsDebuggingEnabled", boolean.class);
method.invoke(null, true);
} catch (Throwable e) {
if (LogUtils.isDebug()) {
e.printStackTrace();
}
}
}
}
use of android.annotation.TargetApi in project weex-example by KalicyZhou.
the class WXScroller method initComponentHostView.
@Override
protected ViewGroup initComponentHostView(@NonNull Context context) {
String scroll;
if (getDomObject() == null || getDomObject().getAttrs().isEmpty()) {
scroll = "vertical";
} else {
scroll = getDomObject().getAttrs().getScrollDirection();
}
ViewGroup host;
if (("horizontal").equals(scroll)) {
mOrientation = Constants.Orientation.HORIZONTAL;
WXHorizontalScrollView scrollView = new WXHorizontalScrollView(context);
mRealView = new FrameLayout(context);
scrollView.setScrollViewListener(new WXHorizontalScrollView.ScrollViewListener() {
@Override
public void onScrollChanged(WXHorizontalScrollView scrollView, int x, int y, int oldx, int oldy) {
procAppear(x, y, oldx, oldy);
}
});
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
scrollView.addView(mRealView, layoutParams);
scrollView.setHorizontalScrollBarEnabled(false);
host = scrollView;
} else {
mOrientation = Constants.Orientation.VERTICAL;
BounceScrollerView scrollerView = new BounceScrollerView(context, mOrientation, this);
mRealView = new FrameLayout(context);
WXScrollView innerView = scrollerView.getInnerView();
innerView.addScrollViewListener(this);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
innerView.addView(mRealView, layoutParams);
innerView.setVerticalScrollBarEnabled(true);
innerView.addScrollViewListener(new WXScrollViewListener() {
@Override
public void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy) {
}
@Override
public void onScrollToBottom(WXScrollView scrollView, int x, int y) {
}
@Override
public void onScrollStopped(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrollStateChanged(scrollView, x, y, OnWXScrollListener.IDLE);
}
}
}
}
@Override
public void onScroll(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrolled(scrollView, x, y);
}
}
}
}
});
host = scrollerView;
}
host.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
procAppear(0, 0, 0, 0);
View view;
if ((view = getHostView()) == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
return host;
}
use of android.annotation.TargetApi in project weex-example by KalicyZhou.
the class BasicListComponent method initComponentHostView.
@Override
protected T initComponentHostView(@NonNull Context context) {
T bounceRecyclerView = generateListView(context, getOrientation());
String transforms = (String) getDomObject().getAttrs().get(TRANSFORM);
if (transforms != null) {
bounceRecyclerView.getInnerView().addItemDecoration(parseTransforms(transforms));
}
RecyclerViewBaseAdapter recyclerViewBaseAdapter = new RecyclerViewBaseAdapter<>(this);
recyclerViewBaseAdapter.setHasStableIds(true);
bounceRecyclerView.setRecyclerViewBaseAdapter(recyclerViewBaseAdapter);
bounceRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
bounceRecyclerView.getInnerView().clearOnScrollListeners();
bounceRecyclerView.getInnerView().addOnScrollListener(mViewOnScrollListener);
bounceRecyclerView.getInnerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
for (ListBaseViewHolder holder : recycleViewList) {
if (holder != null && holder.getComponent() != null && !holder.getComponent().isUsing()) {
recycleImage(holder.getView());
}
}
recycleViewList.clear();
}
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
View topView = recyclerView.getChildAt(0);
if (topView != null) {
int y = topView.getTop();
listener.onScrollStateChanged(recyclerView, 0, y, newState);
}
}
}
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrolled(recyclerView, dx, dy);
}
}
}
}
});
bounceRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
T view;
if ((view = getHostView()) == null)
return;
mViewOnScrollListener.onScrolled(view.getInnerView(), 0, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
return bounceRecyclerView;
}
use of android.annotation.TargetApi in project K6nele by Kaljurand.
the class AbstractRecognizerIntentActivity method getPictureInPictureArgs.
@TargetApi(26)
private PictureInPictureArgs getPictureInPictureArgs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
Intent thisIntent = getIntent();
ArrayList<RemoteAction> actions = new ArrayList<>();
// Action to start recognition
actions.add(new RemoteAction(Icon.createWithResource(this, R.drawable.ic_voice_search_api_material), "Recognize", "Tap & Speak", PendingIntent.getActivity(this, 10, thisIntent, 0)));
// Action to go to the settings
actions.add(new RemoteAction(Icon.createWithResource(this, R.drawable.ic_settings_24dp), "Settings", "Settings", PendingIntent.getActivity(this, 11, new Intent(getApplicationContext(), Preferences.class), 0)));
PictureInPictureArgs mPictureInPictureArgs = new PictureInPictureArgs();
mPictureInPictureArgs.setActions(actions);
return mPictureInPictureArgs;
}
return null;
}
Aggregations