Skip to content

Commit

Permalink
Fix generic type of the flourishView by inflated
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Aug 23, 2020
1 parent 3917cf9 commit 4cecb99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
package com.skydoves.flourishdemo

import android.os.Bundle
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.skydoves.flourish.Flourish
import com.skydoves.flourish.FlourishAnimation
import com.skydoves.flourish.FlourishOrientation
import com.skydoves.flourish.createFlourish
Expand All @@ -42,7 +44,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val flourish = createFlourish(parentLayout) {
val flourish: Flourish<LinearLayout> = createFlourish(parentLayout) {
setFlourishLayout(R.layout.layout_flourish_main)
setFlourishAnimation(FlourishAnimation.BOUNCE)
setFlourishOrientation(FlourishOrientation.TOP_LEFT)
Expand Down
4 changes: 2 additions & 2 deletions flourish/src/main/java/com/skydoves/flourish/Flourish.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Flourish<T : ViewGroup>(private val builder: Builder<T>) {
var isFlourishing = false
private set

lateinit var flourishView: ViewGroup
lateinit var flourishView: T

init {
createByBuilder()
Expand Down Expand Up @@ -130,7 +130,7 @@ class Flourish<T : ViewGroup>(private val builder: Builder<T>) {

/** Builder class for creating [Flourish]. */
@FlourishDsl
class Builder<T : ViewGroup>(val parentLayout: T) {
class Builder<T : ViewGroup>(val parentLayout: ViewGroup) {

@JvmField
var flourishLayout: T? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ import android.view.ViewGroup

/** creates an instance of [Flourish] by [Flourish.Builder] using kotlin dsl. */
@FlourishDsl
inline fun <reified T : ViewGroup> createFlourish(parent: T, block: Flourish.Builder<T>.() -> Unit): Flourish<T> =
Flourish.Builder(parent).apply(block).build()
inline fun <reified T : ViewGroup> createFlourish(parent: ViewGroup, block: Flourish.Builder<T>.() -> Unit): Flourish<T> =
Flourish.Builder<T>(parent).apply(block).build()

0 comments on commit 4cecb99

Please sign in to comment.