private static @Nullable Unbinder parseBindAnim(Object target, Field field, View source) { BindAnim bindAnim = field.getAnnotation(BindAnim.class); if (bindAnim == null) { return null; } validateMember(field); int id = bindAnim.value(); Resources resources = source.getContext().getResources(); Object value; Class<?> fieldType = field.getType(); if (fieldType == Animation.class) { value = resources.getAnimation(id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
/** * Loads an {@link Animator} object from a resource * * @param context Application context used to access resources * @param id The resource id of the animation to load * @return The animator object reference by the specified id * @throws android.content.res.Resources.NotFoundException when the animation cannot be loaded */ public static Animator loadAnimator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimatorFromXml(context, parser); } catch (XmlPullParserException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
/** * Loads an {@link Animator} object from a resource * * @param context Application context used to access resources * @param id The resource id of the animation to load * @return The animator object reference by the specified id * @throws android.content.res.Resources.NotFoundException when the animation cannot be loaded */ public static Animator loadAnimator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimatorFromXml(context, parser); } catch (XmlPullParserException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
@Override public XmlResourceParser getAnimation(int id) throws NotFoundException { try { return super.getAnimation(id); } catch (NotFoundException e) { return mHostResources.getAnimation(id); } }
@Override public XmlResourceParser getAnimation(int id) throws NotFoundException { try { return super.getAnimation(id); } catch (NotFoundException e) { return mHostResources.getAnimation(id); } }
/** * Get the value from a resource. The value type is determined by * the field object type. * * @param rcid * @return */ private Object getValueFromResource (int rcid, Class <?> typeInfo) { Resources r = this.context_.getResources (); if (typeInfo.isAssignableFrom (String.class)) return r.getString (rcid); else if (typeInfo.isAssignableFrom (int.class) || typeInfo.isAssignableFrom (Integer.class)) return rcid; else if (typeInfo.isAssignableFrom (boolean.class) || typeInfo.isAssignableFrom (Boolean.class)) return r.getBoolean (rcid); else if (typeInfo.isAssignableFrom (float.class) || typeInfo.isAssignableFrom (Float.class)) return r.getDimension (rcid); else if (typeInfo.isAssignableFrom (int[].class)) return r.getIntArray (rcid); else if (typeInfo.isAssignableFrom (XmlResourceParser.class)) return r.getAnimation (rcid); else return null; }
public static Animation loadAnimation(Context context, int id) throws Resources.NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
public static Animation loadAnimation(Context context, int id) throws Resources.NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
public static Animation loadAnimation(Context context, int id) throws Resources.NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
/** * Loads an {@link Animator} object from a resource * * @param context Application context used to access resources * @param id The resource id of the animation to load * @return The animator object reference by the specified id * @throws NotFoundException when the animation cannot be loaded */ public static Animator loadAnimator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimatorFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
private static Map<String, List<Animation<?, ?>>> loadAnimationMap( Context context, @AnimatorRes @AnimRes int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createAnimatorFromXml( context, parser, Xml.asAttributeSet(parser), null, ORDERING_TOGETHER) .toMap(0); } catch (XmlPullParserException | IOException ex) { final NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); //noinspection UnnecessaryInitCause rnf.initCause(ex); throw rnf; } finally { if (parser != null) { parser.close(); } } }
return LINEAR_OUT_SLOW_IN; parser = context.getResources().getAnimation(id); return createInterpolatorFromXml(context, parser); } catch (XmlPullParserException | IOException e) {
case animator: case interpolator: response.Data = DOM2XmlPullBuilder.transform(mRes.getAnimation(id)); response.DataType = XML; break;