android.content.res.Resources.getAnimation()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中android.content.res.Resources.getAnimation方法的一些代码示例,展示了Resources.getAnimation的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resources.getAnimation方法的具体详情如下:
包路径:android.content.res.Resources
类名称:Resources
方法名:getAnimation

Resources.getAnimation介绍

暂无

代码示例

代码示例来源:origin: JakeWharton/butterknife

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;
}

代码示例来源:origin: cgeo/cgeo

/**
 * 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();
  }
}

代码示例来源:origin: com.nineoldandroids/library

/**
 * 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();
  }
}

代码示例来源:origin: iqiyi/Neptune

@Override
public XmlResourceParser getAnimation(int id) throws NotFoundException {
  try {
    return super.getAnimation(id);
  } catch (NotFoundException e) {
    return mHostResources.getAnimation(id);
  }
}

代码示例来源:origin: baidu/GPT

@Override
public XmlResourceParser getAnimation(int id) throws NotFoundException {
  try {
    return super.getAnimation(id);
  } catch (NotFoundException e) {
    return mHostResources.getAnimation(id);
  }
}

代码示例来源:origin: onehilltech/android-metadata

/**
 * 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;
}

代码示例来源:origin: hcs-xph/RetrofitUtils

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();
  }
}

代码示例来源:origin: LuckSiege/CustomView

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();
  }
}

代码示例来源:origin: LuckSiege/PictureSelectorLight

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();
  }
}

代码示例来源:origin: Android500/AwesomeDrawer

/**
 * 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();
  }
}

代码示例来源:origin: alexjlockwood/kyrie

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();
  }
 }
}

代码示例来源:origin: alexjlockwood/kyrie

return LINEAR_OUT_SLOW_IN;
 parser = context.getResources().getAnimation(id);
 return createInterpolatorFromXml(context, parser);
} catch (XmlPullParserException | IOException e) {

代码示例来源:origin: jbruchanov/AnUitor

case animator:
case interpolator:
  response.Data = DOM2XmlPullBuilder.transform(mRes.getAnimation(id));
  response.DataType = XML;
  break;

相关文章

微信公众号

最新文章

更多