Fresco加载gif图

/**
*加载本地gif图需要转换为URI,加载网络gif图直接放图片URI就ok
**/
  val controller = Fresco.newDraweeControllerBuilder()
                            .setUri(getUriFromDrawableRes(context, R.drawable.sample))
                            .setAutoPlayAnimations(true) // 设置加载图片完成后是否直接进行播放
                            .build()
 simpleDraweeView.setController(controller);

/**
*本地Drawable id 转换URI(gif图放到drawable文件夹下就好了)
**/
private fun getUriFromDrawableRes(context: Context?, id: Int): Uri {
            val resources = context?.resources
            val path: String = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources?.getResourcePackageName(id) + "/" + resources?.getResourceTypeName(id) + "/" + resources?.getResourceEntryName(id)
            return try {
                Uri.parse(path)
            } catch (e: Exception) {
                null
            }
        }