public static int getStatusBarHeight() { int result = 0; try { int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = Resources.getSystem().getDimensionPixelSize(resourceId); } } catch (Resources.NotFoundException e) { e.printStackTrace(); } return result; }
public int getColor(int resId){ int originColor = context.getResources().getColor(resId); if(mResources == null || isDefaultSkin){ return originColor; } String resName = context.getResources().getResourceEntryName(resId); int trueResId = mResources.getIdentifier(resName, "color", skinPackageName); int trueColor = 0; try{ trueColor = mResources.getColor(trueResId); }catch(NotFoundException e){ e.printStackTrace(); trueColor = originColor; } return trueColor; }
e.printStackTrace(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace();
public ColorStateList getColorStateList(String name) { try { name = appendSuffix(name); return mResources.getColorStateList(mResources.getIdentifier(name, DEFTYPE_COLOR, mPluginPackageName)); } catch (Resources.NotFoundException e) { e.printStackTrace(); return null; } }
/** * 设置角标背景 */ public void setBadgeBackgroundResource(@DrawableRes int resid) { try { setBadgeBackground(ResourcesCompat.getDrawable(mTargetView.getResources(), resid, null)); } catch (Resources.NotFoundException e) { e.printStackTrace(); } }
public void addBitmap(int bitMapId){ try { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), bitMapId); addBitmap(bitmap); }catch (Resources.NotFoundException e){ e.printStackTrace(); } }
public static int getNavigationBarHeight(Activity context) { if (mNavigationBarHeight <= 0) { Resources resources = context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { try { mNavigationBarHeight = resources.getDimensionPixelSize(resourceId); } catch (Resources.NotFoundException e) { e.printStackTrace(); } } } return mNavigationBarHeight; }
public static int getStatusBarHeight(Context context) { int result = 0; try { int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = context.getResources().getDimensionPixelSize(resourceId); } } catch (Resources.NotFoundException e) { e.printStackTrace(); } return result; }
@SuppressLint("NewApi") public Drawable getDrawable(int id, Theme theme) throws NotFoundException { try { return super.getDrawable(id, theme); } catch (NotFoundException e) { e.printStackTrace(); return old.getDrawable(id, theme); } } }
public void getValue(int id, TypedValue outValue, boolean resolveRefs) throws NotFoundException { try { super.getValue(id, outValue, resolveRefs); } catch (NotFoundException e) { e.printStackTrace(); old.getValue(id, outValue, resolveRefs); } }
} catch(Resources.NotFoundException e) { e.printStackTrace();
@Override public void apply(View view, String resName) { Drawable drawable = getResourceManager().getDrawableByName(resName); if (drawable != null) { view.setBackgroundDrawable(drawable); } else { try { int color = getResourceManager().getColor(resName); view.setBackgroundColor(color); } catch (Resources.NotFoundException ex) { ex.printStackTrace(); } } } },
public Drawable getDrawableByName(String name) { try { name = appendSuffix(name); L.e("name = " + name + " , " + mPluginPackageName); return mResources.getDrawable(mResources.getIdentifier(name, DEFTYPE_DRAWABLE, mPluginPackageName)); } catch (Resources.NotFoundException e) { e.printStackTrace(); return null; } }
public ColorStateList getColorStateList(String name) { try { name = appendSuffix(name); L.e("name = " + name); return mResources.getColorStateList(mResources.getIdentifier(name, DEFTYPE_COLOR, mPluginPackageName)); } catch (Resources.NotFoundException e) { e.printStackTrace(); return null; } }
return originColorList; } catch (NotFoundException e) { e.printStackTrace(); L.e("resName = " + resName + " NotFoundException : "+ e.getMessage()); return trueColorList; } catch (NotFoundException e) { e.printStackTrace(); L.w("resName = " + resName + " NotFoundException :" + e.getMessage()); return originColorList; } catch (NotFoundException e) { e.printStackTrace(); L.w("resName = " + resName + " NotFoundException :" + e.getMessage());
e.printStackTrace(); } catch (NotFoundException e) { e.printStackTrace();
/** * Get Background color if the attr is color value * * @param context Context * @param attrs AttributeSet * @return Color */ public static int getBackgroundColor(Context context, AttributeSet attrs) { int color = Color.TRANSPARENT; if (isHaveAttribute(attrs, "background")) { int styleId = attrs.getStyleAttribute(); int[] attributesArray = new int[]{android.R.attr.background}; try { TypedArray typedArray = context.obtainStyledAttributes(styleId, attributesArray); if (typedArray.length() > 0) color = typedArray.getColor(0, color); typedArray.recycle(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } } return color; }
@SuppressLint("NewApi") public Drawable getDrawable(int resId){ Drawable originDrawable = context.getResources().getDrawable(resId); if(mResources == null || isDefaultSkin){ return originDrawable; } String resName = context.getResources().getResourceEntryName(resId); int trueResId = mResources.getIdentifier(resName, "drawable", skinPackageName); Drawable trueDrawable = null; try{ L.e("ttgg", "SDK_INT = " + android.os.Build.VERSION.SDK_INT); if(android.os.Build.VERSION.SDK_INT < 22){ trueDrawable = mResources.getDrawable(trueResId); }else{ trueDrawable = mResources.getDrawable(trueResId, null); } }catch(NotFoundException e){ e.printStackTrace(); trueDrawable = originDrawable; } return trueDrawable; }
@OnClick(R.id.expand) void onExpand() { try { mExpandableView.expand(parentItem); } catch (Resources.NotFoundException e) { e.printStackTrace(); } } }
@OnClick(R.id.collapse) void onCollapse() { try { mExpandableView.collapse(parentItem); } catch (Resources.NotFoundException e) { e.printStackTrace(); } }