Skip to content

Commit

Permalink
fixed parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vlgrigorev committed Dec 25, 2018
1 parent 213a4e8 commit 47f1938
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import com.intellij.util.ui.UIUtil
object Constants {
val ICON_SIZE = if (UIUtil.isRetina()) 36 else 16
const val XML_TYPE = ".xml"
const val DRAWABLES_FOLDER_TYPE = "drawable"
val SUPPORTED_FOLDERS = arrayOf("drawable", "mipmap")
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ object XmlImageFactory {
fun getDrawable(path: String): Drawable? = parseDocument(path)?.let { DrawableInflater.getDrawable(it.documentElement) }

private fun parseDocument(path: String): Document? {
if (!(path.endsWith(Constants.XML_TYPE) && path.contains(Constants.DRAWABLES_FOLDER_TYPE))) {
val supportedFolder = Constants.SUPPORTED_FOLDERS.fold(false) { acc, next -> acc || path.contains(next) }
if (!(path.endsWith(Constants.XML_TYPE) && supportedFolder)) {
return null
}

Expand Down

0 comments on commit 47f1938

Please sign in to comment.