Skip to content

Commit

Permalink
removes lazy delegate extsionsion via argument
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Aug 8, 2019
1 parent f4d5175 commit 58b328d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/com/skydoves/balloondemo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.skydoves.balloon.OnBalloonClickListener
import com.skydoves.balloon.balloon
import com.skydoves.balloon.showAlignTop
import com.skydoves.balloondemo.recycler.ItemUtils
import com.skydoves.balloondemo.recycler.SampleAdapter
Expand All @@ -33,8 +32,8 @@ import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity(), SampleViewHolder.Delegate, OnBalloonClickListener {

private val adapter by lazy { SampleAdapter(this) }
private val profileBalloon by balloon(BalloonUtils.getProfileBalloon(this, this))
private val navigationBalloon by balloon(BalloonUtils.getNavigationBalloon(this, this, this))
private val profileBalloon by lazy { BalloonUtils.getProfileBalloon(this, this) }
private val navigationBalloon by lazy { BalloonUtils.getNavigationBalloon(this, this, this) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
12 changes: 0 additions & 12 deletions balloon/src/main/java/com/skydoves/balloon/BalloonExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,10 @@ inline fun ComponentActivity.balloon(
return lazy { balloonProducer() }
}

/** returns a [Lazy] delegate to access the [ComponentActivity]'s Balloon. */
@MainThread
fun ComponentActivity.balloon(balloon: Balloon): Lazy<Balloon> {
return lazy { balloon }
}

/** returns a [Lazy] delegate to access the [Fragment]'s Balloon. */
@MainThread
inline fun Fragment.balloon(
crossinline balloonProducer: (() -> Balloon)
): Lazy<Balloon> {
return lazy { balloonProducer() }
}

/** returns a [Lazy] delegate to access the [Fragment]'s Balloon. */
@MainThread
fun Fragment.balloon(balloon: Balloon): Lazy<Balloon> {
return lazy { balloon }
}

0 comments on commit 58b328d

Please sign in to comment.