Skip to content

Commit

Permalink
Test PR (#28)
Browse files Browse the repository at this point in the history
* improve view group ignore support

* some gradle updates

* hasDrawableBounds check and schedule skeleton builds with post

Co-authored-by: Eudy Contreras <Darkyec777@gmail.com>
Co-authored-by: Mattias Östergren <dr.ostergren@gmail.com>
  • Loading branch information
3 people authored Feb 16, 2022
1 parent c9ebafb commit 274d99a
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {

// Android dependencies
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

// Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
Expand Down
6 changes: 3 additions & 3 deletions boneslibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

dataBinding {
enabled = true
buildFeatures {
dataBinding true
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal fun View.hasValidBounds(): Boolean {
}

internal fun View.hasDrawableBounds(boneProps: BoneProperties): Boolean {
return (measuredWidth > 0 && measuredHeight > boneProps.minThickness)
return minimumWidth > 0 || (measuredWidth > 0 && measuredHeight > boneProps.minThickness)
}

internal fun View.getBackgroundColor(): MutableColor? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ internal class Skeleton(
}

if (foundInvalid) {
viewGroup.doOnLayout {
viewGroup.post {
applyAndBuild(viewGroup, descendants)
onCompute()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.eudycontreras.boneslibrary.framework.skeletons

import android.view.View
import android.view.ViewGroup
import com.eudycontreras.boneslibrary.bindings.SkeletonBindings
import com.eudycontreras.boneslibrary.extensions.descendantViews
import com.eudycontreras.boneslibrary.extensions.generateId
import com.eudycontreras.boneslibrary.framework.bones.BoneBuilder
import com.eudycontreras.boneslibrary.framework.bones.BoneProperties
Expand Down Expand Up @@ -299,7 +301,7 @@ class SkeletonBuilder(
* generation
*/
fun withIgnoredBones(vararg ids: Int): SkeletonBuilder {
builderQueue.add { this.skeletonProperties.addIgnored(*ids) }
builderQueue.add { this.skeletonProperties.ignoredIds.addAll(ids.toList()) }
return this
}

Expand All @@ -316,7 +318,14 @@ class SkeletonBuilder(
* generation
*/
fun withIgnoredBones(vararg views: View): SkeletonBuilder {
builderQueue.add { this.skeletonProperties.addIgnored(*views.map { it.generateId() }.toIntArray()) }
builderQueue.add {
val viewIds = views.flatMap {
if (it is ViewGroup) {
it.descendantViews().map { child -> child.generateId() }
} else listOf(it.generateId())
}
this.skeletonProperties.ignoredIds.addAll(viewIds)
}
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SkeletonProperties : Cloneable<SkeletonProperties>, Reusable {

private var boneProperties: MutableMap<Int, BoneProperties> = mutableMapOf()

private var ignoredIds: HashSet<Int> = HashSet()
internal var ignoredIds: HashSet<Int> = HashSet()

private var disposedIds: HashSet<Int> = HashSet()

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 274d99a

Please sign in to comment.