Skip to content

Commit

Permalink
Library: Fix shadows are not updated after NeumorphTextView#setText()…
Browse files Browse the repository at this point in the history
… is called (#49)
  • Loading branch information
fornewid committed Nov 3, 2020
1 parent a72ea52 commit 4965c2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ class NeumorphTextView @JvmOverloads constructor(
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
lastTextCache = buildTextCache(w, h).also { origin ->
if (lastShadowLight == null) {
lastShadowLight = origin.generateBitmapShadowCache(w, h, shadowColorLight)
}
if (lastShadowDark == null) {
lastShadowDark = origin.generateBitmapShadowCache(w, h, shadowColorDark)
}
lastShadowLight = origin.generateBitmapShadowCache(w, h, shadowColorLight)
lastShadowDark = origin.generateBitmapShadowCache(w, h, shadowColorDark)
}
}

Expand Down
4 changes: 4 additions & 0 deletions sample/src/main/java/soup/neumorphism/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class MainActivity : AppCompatActivity() {
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.textview.setOnClickListener {
binding.textview.text = listOf("Neumorphism", "in", "Android").random()
}

binding.button.setOnClickListener {
startActivity(Intent(this, ColorSampleActivity::class.java))
}
Expand Down

0 comments on commit 4965c2a

Please sign in to comment.