List of usage examples for android.view View getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static void setBackgroundColor(View view, int backgroundColor) { Drawable background = view.getBackground(); if (background instanceof ShapeDrawable) { ShapeDrawable shapeDrawable = (ShapeDrawable) background; shapeDrawable.getPaint().setColor(backgroundColor); } else if (background instanceof GradientDrawable) { GradientDrawable gradientDrawable = (GradientDrawable) background; gradientDrawable.setColor(backgroundColor); } else if (background instanceof ColorDrawable) { // alpha value may need to be set again after this call ColorDrawable colorDrawable = (ColorDrawable) background; colorDrawable.setColor(backgroundColor); } else {/* w w w. ja v a 2s . com*/ L.e("Unknown background type to set color on: " + view.getClass()); } }
From source file:com.tmall.wireless.tangram.MVHelper.java
private void loadMethod(BaseCell cell, View view) { if (view instanceof ITangramViewLifeCycle) { return;//from w w w.ja v a 2s .c om } if (methodMap.get(cell) != null) { return; } ArrayMap<Method, Object> paramMap = new ArrayMap<>(); Method[] methods; if (methodCacheMap.get(view.getClass()) == null) { methods = view.getClass().getDeclaredMethods(); methodCacheMap.put(view.getClass(), methods); } else { methods = methodCacheMap.get(view.getClass()); } CellRender cellRender; Class[] paramClazz; for (Method method : methods) { cellRender = method.getAnnotation(CellRender.class); paramClazz = method.getParameterTypes(); if (!method.isAnnotationPresent(CellRender.class) || paramClazz == null || paramClazz.length != 1) continue; if (method.getName().equals("postBindView")) { postBindMap.put(cell, method); continue; } if (method.getName().equals("postUnBindView")) { postUnBindMap.put(cell, method); continue; } if (method.getName().equals("cellInited")) { cellInitedMap.put(cell, method); continue; } if (!TextUtils.isEmpty(cellRender.key()) && cell.hasParam(cellRender.key())) { if ("null".equals(cell.optParam(cellRender.key()))) { paramMap.put(method, null); } else if (paramClazz[0].equals(Integer.class) || paramClazz[0].equals(int.class)) { paramMap.put(method, cell.optIntParam(cellRender.key())); } else if (paramClazz[0].equals(String.class)) { paramMap.put(method, cell.optStringParam(cellRender.key())); } else if (paramClazz[0].equals(Boolean.class) || paramClazz[0].equals(boolean.class)) { paramMap.put(method, cell.optBoolParam(cellRender.key())); } else if (paramClazz[0].equals(Double.class) || paramClazz[0].equals(double.class)) { paramMap.put(method, cell.optDoubleParam(cellRender.key())); } else if (paramClazz[0].equals(JSONArray.class)) { paramMap.put(method, cell.optJsonArrayParam(cellRender.key())); } else if (paramClazz[0].equals(Long.class) || paramClazz[0].equals(long.class)) { paramMap.put(method, cell.optLongParam(cellRender.key())); } else if (paramClazz[0].equals(JSONObject.class)) { paramMap.put(method, cell.optJsonObjectParam(cellRender.key())); } else { paramMap.put(method, cell.optParam(cellRender.key())); } } else if (cell.hasParam(method.getName())) { if ("null".equals(cell.optParam(method.getName()))) { paramMap.put(method, null); } else if (paramClazz[0].equals(Integer.class) || paramClazz[0].equals(int.class)) { paramMap.put(method, cell.optIntParam(method.getName())); } else if (paramClazz[0].equals(String.class)) { paramMap.put(method, cell.optStringParam(method.getName())); } else if (paramClazz[0].equals(Boolean.class) || paramClazz[0].equals(boolean.class)) { paramMap.put(method, cell.optBoolParam(method.getName())); } else if (paramClazz[0].equals(Double.class) || paramClazz[0].equals(double.class)) { paramMap.put(method, cell.optDoubleParam(method.getName())); } else if (paramClazz[0].equals(JSONArray.class)) { paramMap.put(method, cell.optJsonArrayParam(method.getName())); } else if (paramClazz[0].equals(Long.class) || paramClazz[0].equals(long.class)) { paramMap.put(method, cell.optLongParam(method.getName())); } else if (paramClazz[0].equals(JSONObject.class)) { paramMap.put(method, cell.optJsonObjectParam(method.getName())); } else { paramMap.put(method, cell.optParam(method.getName())); } } else { if (paramClazz[0].equals(Integer.class) || paramClazz[0].equals(int.class)) { paramMap.put(method, 0); } else if (paramClazz[0].equals(String.class)) { paramMap.put(method, ""); } else if (paramClazz[0].equals(Boolean.class) || paramClazz[0].equals(boolean.class)) { paramMap.put(method, false); } else if (paramClazz[0].equals(Double.class) || paramClazz[0].equals(double.class)) { paramMap.put(method, 0); } else if (paramClazz[0].equals(JSONArray.class)) { paramMap.put(method, null); } else if (paramClazz[0].equals(Long.class) || paramClazz[0].equals(long.class)) { paramMap.put(method, 0); } else if (paramClazz[0].equals(JSONObject.class)) { paramMap.put(method, null); } else { paramMap.put(method, ""); } } } if (!paramMap.isEmpty()) methodMap.put(cell, paramMap); }
From source file:com.example.percentlayout.view.PercentLayoutHelper.java
private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) { Log.d(TAG, "supportMinOrMaxDimesion"); try {/*from ww w . j av a 2s . co m*/ Class clazz = view.getClass(); invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent); invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent); invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent); invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:KSView.PercentLayoutHelper.java
private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) { LogUtil.d(TAG, "supportMinOrMaxDimesion"); try {//from w w w .ja v a 2 s .co m Class clazz = view.getClass(); invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent); invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent); invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent); invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:android.percent.support.PercentLayoutHelper.java
private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) { try {/* ww w . j ava 2s . c om*/ Class clazz = view.getClass(); invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent); invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent); invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent); invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:io.github.meness.easyintro.EasyIntroCarouselFragment.java
private void setViewPagerToPageIndicator() { try {// w ww.jav a2 s . com View view = mIndicatorsContainer.findViewById(R.id.pageIndicator); // invoke indicator `setViewPager(ViewPager)` method view.getClass().getMethod("setViewPager", ViewPager.class).invoke(view, mPager); } catch (NoSuchMethodException e) { Log.e(EasyIntro.TAG, getString(R.string.exception_no_such_method_set_view_pager)); e.printStackTrace(); } catch (InvocationTargetException e) { Log.e(EasyIntro.TAG, getString(R.string.exception_invocation_target_set_view_pager)); e.printStackTrace(); } catch (IllegalAccessException e) { Log.e(EasyIntro.TAG, getString(R.string.exception_illegal_access_set_view_pager)); e.printStackTrace(); } }
From source file:com.spark.percent.PercentLayoutHelper.java
private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) { try {/* w ww .j ava 2s.com*/ Class<?> clazz = view.getClass(); invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent); invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent); invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent); invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.magestore.app.pos.SalesActivity.java
public boolean isCustomKeyboardVisible() { View focusCurrent = mCheckoutListController.getMagestoreContext().getActivity().getWindow() .getCurrentFocus();/*from w w w . j a v a 2 s . com*/ if (focusCurrent != null && focusCurrent.getClass() == EditTextFloat.class) { EditTextFloat edittext = (EditTextFloat) focusCurrent; edittext.setSelection(edittext.getText().length()); } return ll_custom_keyboard.getVisibility() == View.VISIBLE; }
From source file:com.google.android.apps.common.testing.accessibility.framework.SpeakableTextPresentViewCheck.java
@Override public List<AccessibilityViewCheckResult> runCheckOnView(View view) { List<AccessibilityViewCheckResult> results = new ArrayList<AccessibilityViewCheckResult>(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { results.add(new AccessibilityViewCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN, "This check only runs on Android 4.1 and above.", view)); return results; }/*from ww w . j a v a 2s . c o m*/ if (!ViewAccessibilityUtils.isImportantForAccessibility(view)) { results.add(new AccessibilityViewCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN, "View is not important for accessibility.", view)); return results; } for (Class<? extends ViewGroup> clazz : blacklistedViewTypes) { if (clazz.isAssignableFrom(view.getClass())) { String msg = String.format("Views of type %s are not checked for speakable text.", clazz.getName()); results.add(new AccessibilityViewCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN, msg, view)); return results; } } if (shouldFocusView(view)) { // We must evaluate this view for speakable text if (TextUtils.isEmpty(AccessibilityCheckUtils.getSpeakableTextForView(view))) { results.add(new AccessibilityViewCheckResult(this.getClass(), AccessibilityCheckResultType.ERROR, "View is missing speakable text needed for a screen reader", view)); } } else { results.add(new AccessibilityViewCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN, "View is not focused by a screen reader", view)); } return results; }
From source file:cz.tsystems.portablecheckin.MainActivity.java
private void populateTextsAndRbtn(ViewGroup theView) { String fieldName = ""; DMCheckin checkinData = app.getCheckin(); for (int i = 0; i < theView.getChildCount(); i++) { View v = theView.getChildAt(i); Class<? extends View> c = v.getClass(); fieldName = (String) v.getTag(); if (fieldName == null) continue; Field field = null;//from www.ja va 2s . c o m try { field = DMCheckin.class.getField(fieldName.toLowerCase(Locale.ENGLISH)); } catch (NoSuchFieldException e) { Log.v(TAG, "NOT FOUND :" + fieldName.toLowerCase(Locale.ENGLISH)); continue; } Log.v(TAG, fieldName.toLowerCase(Locale.ENGLISH)); try { if (c == EditText.class || c == vinEditText.class || c == BaseEditText.class) { EditText editText = (EditText) v; editText.setText(""); if (field.get(checkinData) == null) continue; DecimalFormat nf = new DecimalFormat("#"); if (field.getType() == String.class)// jnCheckin.hasNonNull(fieldName)) editText.setText((String) field.get(checkinData)); else if (field.getType() == int.class) editText.setText(String.valueOf(field.getInt(checkinData))); else if (field.getType() == short.class) editText.setText(String.valueOf(field.getShort(checkinData))); else if (field.getType() == double.class) editText.setText(nf.format(field.getDouble(checkinData))); else if (field.getType() == Double.class) editText.setText(NumberFormat.getInstance().format((Double) field.get(checkinData))); else if (field.getType() == Date.class) editText.setText(sdto.format((Date) field.get(checkinData))); } else if (c == Switch.class) { ((Switch) v).setChecked(field.getBoolean(checkinData)); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }