Skip to content

Commit

Permalink
Fix theme issue
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonlee committed Jan 6, 2024
1 parent 6e3d55d commit b3112b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ internal class LayoutlibCallbackImpl(

override fun getApplicationId(): String = appId

override fun getResourcePackage(): String = appId

override fun loadView(
name: String,
constructorSignature: Array<out Class<*>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ data class SessionParamsBuilder(
require(themeName != null)

val folderConfiguration = deviceModel.resourceConfiguration
val platformResources = listOf(ResourceNamespace.ANDROID).associateWith {
frameworkResources.getConfiguredResources(folderConfiguration).row(it)
}
val applicationResources = projectResources.getConfiguredResources(folderConfiguration).rowMap()
val resourceResolver = ResourceResolver.create(
mapOf(
ResourceNamespace.ANDROID to frameworkResources.getConfiguredResources(folderConfiguration)
.row(ResourceNamespace.ANDROID),
*projectResources.getConfiguredResources(folderConfiguration).rowMap()
.map { (key, value) -> key to value }.toTypedArray()
),
ResourceReference(ResourceNamespace.ANDROID, ResourceType.STYLE, themeName),
platformResources + applicationResources,
ResourceReference(ResourceNamespace.RES_AUTO, ResourceType.STYLE, themeName),
)
val sessionParams = SessionParams(
layoutPullParser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.johnsonlee.playground.sandbox.parsers

open class AttributeSnapshot(
open val namespace: String,
open val prefix: String,
open val prefix: String?,
open val name: String,
open val value: String
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class ResourceParser(input: InputStream) : KXmlParser() {
}

private fun findPrefixByQualifiedName(qualifiedName: String): String {
return qualifiedName.substringBefore(':').takeIf(String::isNotEmpty) ?: ""
return qualifiedName.substringBefore(':', "")
}

private fun findLocalNameByQualifiedName(qualifiedName: String): String {
return qualifiedName.substringAfterLast(':')
return qualifiedName.substringAfter(':')
}

private fun createAttributesForTag(): MutableList<AttributeSnapshot> {
Expand Down

0 comments on commit b3112b1

Please sign in to comment.