List of usage examples for android.view View getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.mome.main.business.widget.pulltorefresh.PullToRefreshBase.java
@Override public void addView(View child, int index, ViewGroup.LayoutParams params) { if (DEBUG) {/*from w w w. j av a2 s.com*/ Log.d(LOG_TAG, "addView: " + child.getClass().getSimpleName()); } final T refreshableView = getRefreshableView(); if (refreshableView instanceof ViewGroup) { ((ViewGroup) refreshableView).addView(child, index, params); } else { throw new UnsupportedOperationException("Refreshable View is not a ViewGroup so can't addView"); } }
From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java
/** * @param direction Negative to check scrolling left, positive to check scrolling right. * @return Whether it is possible for the child view of this layout to * scroll left or right. Override this if the child view is a custom view. *//* w w w .ja v a 2 s . co m*/ private boolean canViewScrollHorizontally(View view, MotionEvent event, int direction) { boolean ret; event.offsetLocation(view.getScrollX() - view.getLeft(), view.getScrollY() - view.getTop()); if (mScrollLeftOrRightHandler != null) { boolean canViewScrollLeftOrRight = mScrollLeftOrRightHandler.canScrollLeftOrRight(view, direction); if (canViewScrollLeftOrRight) return true; } if (android.os.Build.VERSION.SDK_INT < 14) { if (view instanceof ViewPager) { ret = ((ViewPager) view).canScrollHorizontally(direction); } else { ret = view.getScrollX() * direction > 0; } } else { ret = ViewCompat.canScrollHorizontally(view, direction); } ret = ret || canChildrenScrollHorizontally(view, event, direction); if (DEBUG) Log.d(TAG, "canViewScrollHorizontally " + view.getClass().getName() + " " + ret); return ret; }
From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. *///from w w w. ja va 2 s .c o m private boolean canViewScrollUp(View view, MotionEvent event) { boolean ret; event.offsetLocation(view.getScrollX() - view.getLeft(), view.getScrollY() - view.getTop()); if (mScrollUpHandler != null) { boolean canViewScrollUp = mScrollUpHandler.canScrollUp(view); if (canViewScrollUp) return true; } if (android.os.Build.VERSION.SDK_INT < 14) { if (view instanceof AbsListView) { final AbsListView absListView = (AbsListView) view; ret = absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { ret = view.getScrollY() > 0 || canChildrenScrollUp(view, event); } } else { ret = ViewCompat.canScrollVertically(view, -1) || canChildrenScrollUp(view, event); } if (DEBUG) Log.d(TAG, "canViewScrollUp " + view.getClass().getName() + " " + ret); return ret; }
From source file:com.juick.android.MainActivity.java
private void layoutNavigationPane() { final MyRelativeLayout mll = (MyRelativeLayout) findViewById(R.id.layout_container); final View navigationPanel = mll.findViewById(R.id.navigation_panel); boolean oldBlockLayoutRequests = mll.blockLayoutRequests; mll.blockLayoutRequests = true;/* w w w . jav a 2s . co m*/ int pix = navigationPanel.getWidth(); final View frag = mll.findViewById(R.id.messagesfragment); if (isNavigationMenuShown()) { frag.layout(pix, 0, pix + mll.getWidth(), mll.getHeight()); } else { frag.layout(0, 0, mll.getWidth(), mll.getHeight()); } frag.clearAnimation(); mll.blockLayoutRequests = oldBlockLayoutRequests; visitViewHierarchy(getWindow().getDecorView(), new ViewHierarchyVisitor() { @Override public void visitView(View v) { if (v.getClass().getName().contains("OverflowMenuButton") && v instanceof ImageButton) { ImageButton ib = (ImageButton) v; ib.setImageResource(R.drawable.ic_menu_moreoverflow); } //super.visitView(v); //To change body of overridden methods use File | Settings | File Templates. } }); }
From source file:foam.starwisp.StarwispBuilder.java
public String WalkDraggable(StarwispActivity ctx, String name, String ctxname, int id) { View v = ctx.findViewById(id); Class c = v.getClass(); String ret = ""; if (c == LinearLayout.class) { LinearLayout l = (LinearLayout) v; String result = m_Scheme.eval("(run-draggable-callback \"" + ctxname + "\" " + id + " '())") + " "; try {// www .jav a 2s.co m JSONArray arr = new JSONArray(result); int is_atom = arr.getInt(0); if (is_atom == 0) ret += "("; // a number? if (is_atom == 2) ret += arr.getString(1) + " "; else ret += JSONToScheme(arr.getString(1)) + " "; //Log.i("starwisp","post conv "+ret); for (int i = 0; i < l.getChildCount(); i++) { View cv = l.getChildAt(i); Class cc = cv.getClass(); if (cc == LinearLayout.class) { ret += WalkDraggable(ctx, name, ctxname, cv.getId()); } } if (is_atom == 0) ret += ")"; } catch (JSONException e) { Log.e("starwisp", "Error parsing draggable code " + e.toString()); Log.e("starwisp", "Code is: " + ret); return ""; } } return ret; }
From source file:org.tabc.living3.widgets.TourViewPager.java
private static boolean isDecorView(@NonNull View view) { Class<?> clazz = view.getClass(); return clazz.getAnnotation(DecorView.class) != null; }
From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { View v = getCurrentFocus(); if (v != null && (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_MOVE) && v instanceof EditText && !v.getClass().getName().startsWith("android.webkit.")) { int scrcoords[] = new int[2]; v.getLocationOnScreen(scrcoords); float x = ev.getRawX() + v.getLeft() - scrcoords[0]; float y = ev.getRawY() + v.getTop() - scrcoords[1]; if (x < v.getLeft() || x > v.getRight() || y < v.getTop() || y > v.getBottom()) hideKeyboard(this); }/*from w w w .j a v a2 s.c o m*/ return super.dispatchTouchEvent(ev); }
From source file:com.example.sky.test.view.ViewPager.java
private static boolean isDecorView(@NonNull View view) { Class<?> clazz = view.getClass(); return clazz.getAnnotation(ViewPager.DecorView.class) != null; }
From source file:example.luojing.androidsourceanalysis.ViewPager.java
/** * ???DecorView/*from ww w . j a v a2 s .c om*/ */ private static boolean isDecorView(@NonNull View view) { Class<?> clazz = view.getClass(); return clazz.getAnnotation(DecorView.class) != null; }
From source file:meizhi.meizhi.malin.utils.DestroyCleanUtil.java
@SuppressLint("ObsoleteSdkInt") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void unBindView(View view) { if (view == null) return;/*w ww . j a v a 2 s . c o m*/ Drawable drawable; int i; //1. try { view.setOnClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //2. try { view.setOnCreateContextMenuListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //3. try { view.setOnFocusChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //4. try { view.setOnKeyListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //5. try { view.setOnLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //6. try { view.setOnTouchListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //7. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { view.setOnApplyWindowInsetsListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //8. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnContextClickListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //9. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnScrollChangeListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //10. try { view.setOnDragListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //11. try { view.setOnGenericMotionListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //12. try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {//13 view.setOnHoverListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //13. try { view.setOnSystemUiVisibilityChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } /** * @see SwipeRefreshLayout#onDetachedFromWindow() */ if (view.getBackground() != null && !view.getClass().getName().equals(CIRCLE_CLASS)) { try { view.getBackground().setCallback(null); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {//16 view.setBackgroundDrawable(null); } else { view.setBackground(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageView if (view instanceof ImageView) { try { ImageView imageView = (ImageView) view; drawable = imageView.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageView.setImageDrawable(null); imageView.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //TextView if (view instanceof TextView) { try { TextView textView = (TextView) view; textView.setCompoundDrawables(null, null, null, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { textView.setCompoundDrawablesRelative(null, null, null, null); } textView.setCursorVisible(false); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageButton if (view instanceof ImageButton) { try { ImageButton imageButton = (ImageButton) view; drawable = imageButton.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageButton.setImageDrawable(null); imageButton.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ListView if (view instanceof ListView) { ListView listView = (ListView) view; try { listView.setAdapter(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnScrollListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemSelectedListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //RecyclerView if (view instanceof RecyclerView) { try { RecyclerView recyclerView = (RecyclerView) view; recyclerView.setAdapter(null); recyclerView.setChildDrawingOrderCallback(null); recyclerView.setOnScrollListener(null); recyclerView.addOnScrollListener(null); recyclerView.removeOnScrollListener(null); recyclerView.setRecyclerListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //WebView if (view instanceof WebView) { WebView webView = (WebView) view; try { webView.stopLoading(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.removeAllViews(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebChromeClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebViewClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.destroy(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { if (null != view.getParent() && view.getParent() instanceof ViewGroup) { ((ViewGroup) view.getParent()).removeView(view); } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } //SurfaceView if (view instanceof SurfaceView) { try { SurfaceView surfaceView = (SurfaceView) view; SurfaceHolder holder = surfaceView.getHolder(); if (holder != null) { Surface surface = holder.getSurface(); if (surface != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { surface.release(); } } } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } view.destroyDrawingCache(); view.clearAnimation(); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int childCount = (viewGroup).getChildCount(); for (i = 0; i < childCount; i++) { unBindView((viewGroup).getChildAt(i)); } } }