From 4cecb99878774f1d55042703a9caf4c6ce3bff26 Mon Sep 17 00:00:00 2001 From: skydoves Date: Sun, 23 Aug 2020 15:24:34 +0900 Subject: [PATCH] Fix generic type of the flourishView by inflated --- app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt | 4 +++- flourish/src/main/java/com/skydoves/flourish/Flourish.kt | 4 ++-- .../src/main/java/com/skydoves/flourish/FlourishExtensions.kt | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt b/app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt index a816833..aa23c5a 100644 --- a/app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt +++ b/app/src/main/java/com/skydoves/flourishdemo/MainActivity.kt @@ -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 @@ -42,7 +44,7 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - val flourish = createFlourish(parentLayout) { + val flourish: Flourish = createFlourish(parentLayout) { setFlourishLayout(R.layout.layout_flourish_main) setFlourishAnimation(FlourishAnimation.BOUNCE) setFlourishOrientation(FlourishOrientation.TOP_LEFT) diff --git a/flourish/src/main/java/com/skydoves/flourish/Flourish.kt b/flourish/src/main/java/com/skydoves/flourish/Flourish.kt index d875411..0ce4444 100644 --- a/flourish/src/main/java/com/skydoves/flourish/Flourish.kt +++ b/flourish/src/main/java/com/skydoves/flourish/Flourish.kt @@ -36,7 +36,7 @@ class Flourish(private val builder: Builder) { var isFlourishing = false private set - lateinit var flourishView: ViewGroup + lateinit var flourishView: T init { createByBuilder() @@ -130,7 +130,7 @@ class Flourish(private val builder: Builder) { /** Builder class for creating [Flourish]. */ @FlourishDsl - class Builder(val parentLayout: T) { + class Builder(val parentLayout: ViewGroup) { @JvmField var flourishLayout: T? = null diff --git a/flourish/src/main/java/com/skydoves/flourish/FlourishExtensions.kt b/flourish/src/main/java/com/skydoves/flourish/FlourishExtensions.kt index 70a906f..85d6332 100644 --- a/flourish/src/main/java/com/skydoves/flourish/FlourishExtensions.kt +++ b/flourish/src/main/java/com/skydoves/flourish/FlourishExtensions.kt @@ -22,5 +22,5 @@ import android.view.ViewGroup /** creates an instance of [Flourish] by [Flourish.Builder] using kotlin dsl. */ @FlourishDsl -inline fun createFlourish(parent: T, block: Flourish.Builder.() -> Unit): Flourish = - Flourish.Builder(parent).apply(block).build() +inline fun createFlourish(parent: ViewGroup, block: Flourish.Builder.() -> Unit): Flourish = + Flourish.Builder(parent).apply(block).build()