List of usage examples for android.view View getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.selcukcihan.android.namewizard.wizard.ui.BirthDateFragment.java
public static void hideYear(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yearSpinnerId = Resources.getSystem().getIdentifier("year", "id", "android"); if (yearSpinnerId != 0) { View yearSpinner = view.findViewById(yearSpinnerId); if (yearSpinner != null) { yearSpinner.setVisibility(View.GONE); }/* ww w. j a v a 2s. com*/ } } else { //Older SDK versions Field f[] = view.getClass().getDeclaredFields(); for (Field field : f) { if (field.getName().equals("mYearPicker") || field.getName().equals("mYearSpinner")) { field.setAccessible(true); Object yearPicker = null; try { yearPicker = field.get(view); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yearPicker).setVisibility(View.GONE); } } } }
From source file:co.carlosjimenez.android.currencyalerts.app.MenuTint.java
private static ViewGroup findToolbar(ViewGroup viewGroup) { ViewGroup toolbar = null;//from w w w . j a va2s . c om for (int i = 0, len = viewGroup.getChildCount(); i < len; i++) { View view = viewGroup.getChildAt(i); if (view.getClass() == android.support.v7.widget.Toolbar.class || view.getClass().getName().equals("android.widget.Toolbar")) { toolbar = (ViewGroup) view; } else if (view instanceof ViewGroup) { toolbar = findToolbar((ViewGroup) view); } if (toolbar != null) { break; } } return toolbar; }
From source file:co.carlosjimenez.android.currencyalerts.app.MenuTint.java
private static ImageView findOverflowMenuButton(Activity activity, ViewGroup viewGroup) { if (viewGroup == null) { return null; }// ww w . ja va2 s .c o m ImageView overflow = null; for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) { View v = viewGroup.getChildAt(i); if (v instanceof ImageView && (v.getClass().getSimpleName().equals("OverflowMenuButton") || v instanceof ActionMenuView.ActionMenuChildView)) { overflow = (ImageView) v; } else if (v instanceof ViewGroup) { overflow = findOverflowMenuButton(activity, (ViewGroup) v); } if (overflow != null) { break; } } return overflow; }
From source file:cn.zy.ef.refresh.utils.ScrollingUtil.java
public static void scrollAViewBy(View view, int height) { if (view instanceof RecyclerView) ((RecyclerView) view).smoothScrollBy(0, height); else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height); else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 150); else {//w w w .j a v a 2s. c o m try { Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class); method.invoke(view, 0, height); } catch (Exception e) { view.scrollBy(0, height); } } }
From source file:com.ranger.xyg.library.tkrefreshlayout.utils.ScrollingUtil.java
public static void scrollAViewBy(View view, int height) { if (view instanceof RecyclerView) ((RecyclerView) view).scrollBy(0, height); else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height); else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 0); else {// w w w.j av a 2 s . com try { Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class); method.invoke(view, 0, height); } catch (Exception e) { view.scrollBy(0, height); } } }
From source file:com.facebook.appevents.codeless.internal.ViewHierarchy.java
public static JSONObject setBasicInfoOfView(View view, JSONObject json) { try {/*from w w w . j a va 2s . com*/ String text = getTextOfView(view); String hint = getHintOfView(view); Object tag = view.getTag(); CharSequence description = view.getContentDescription(); json.put(CLASS_NAME_KEY, view.getClass().getCanonicalName()); json.put(CLASS_TYPE_BITMASK_KEY, getClassTypeBitmask(view)); json.put(ID_KEY, view.getId()); if (!SensitiveUserDataUtils.isSensitiveUserData(view)) { json.put(TEXT_KEY, text); } else { json.put(TEXT_KEY, ""); } json.put(HINT_KEY, hint); if (tag != null) { json.put(TAG_KEY, tag.toString()); } if (description != null) { json.put(DESC_KEY, description.toString()); } JSONObject dimension = getDimensionOfView(view); json.put(DIMENSION_KEY, dimension); } catch (JSONException e) { Utility.logd(TAG, e); } return json; }
From source file:com.lanma.customviewproject.utils.ScrollingUtil.java
/**viewY?? *//* w w w . java 2 s.c om*/ public static void scrollAViewBy(View view, int height) { if (view instanceof RecyclerView) ((RecyclerView) view).smoothScrollBy(0, height); else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height); else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 150); else { try { Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class); method.invoke(view, 0, height); } catch (Exception e) { view.scrollBy(0, height); } } }
From source file:me.anon.lib.Views.java
/** * Gets all views of a parent that match an class (recursive) * @param parent The parent view/*from w w w. j a v a 2 s.c om*/ * @param instance The class to check * @return An array of views */ public static <T extends View> List<T> findAllChildrenByClass(ViewGroup parent, Class<T> instance) { List<View> views = new ArrayList<View>(); int childCount = parent.getChildCount(); for (int childIndex = 0; childIndex < childCount; childIndex++) { View child = parent.getChildAt(childIndex); if (child != null && child.getClass() == instance) { views.add(child); } if (child instanceof ViewGroup) { views.addAll(findAllChildrenByClass((ViewGroup) child, instance)); } } return (List<T>) views; }
From source file:me.anon.lib.Views.java
/** * Gets all views of a parent that match an class (recursive) * @param parent The parent view/*w w w . j av a 2 s .co m*/ * @param instance The class to check by instance * @return An array of views */ public static <T extends View> List<T> findAllChildrenByInstance(ViewGroup parent, Class<T> instance) { List<View> views = new ArrayList<View>(); int childCount = parent.getChildCount(); for (int childIndex = 0; childIndex < childCount; childIndex++) { View child = parent.getChildAt(childIndex); if (child != null && instance.isAssignableFrom(child.getClass())) { views.add(child); } if (child instanceof ViewGroup) { views.addAll(findAllChildrenByInstance((ViewGroup) child, instance)); } } return (List<T>) views; }
From source file:com.appeaser.sublimepickerlibrary.utilities.AccessibilityUtils.java
public static void makeAnnouncement(View view, CharSequence announcement) { if (view == null) return;//from w w w .j ava2 s . co m if (SUtils.isApi_16_OrHigher()) { view.announceForAccessibility(announcement); } else { // For API 15 and earlier, we need to construct an accessibility event Context ctx = view.getContext(); AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE); if (!am.isEnabled()) return; AccessibilityEvent event = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); AccessibilityRecordCompat arc = AccessibilityEventCompat.asRecord(event); arc.setSource(view); event.setClassName(view.getClass().getName()); event.setPackageName(view.getContext().getPackageName()); event.setEnabled(view.isEnabled()); event.getText().add(announcement); am.sendAccessibilityEvent(event); } }