Call method from Kotlin class
<p>I have an util Kotlin class where I set toolbar title, hide or show toolbar depends on the fragment:</p>

<pre><code>class MyToolbarUtils() {

    fun hideToolbar(activity: Activity) {
        (activity as MainActivity).supportActionBar!!.hide()
    }

    fun showToolbar(activity: Activity, tag: String) {
        setToolbarTitle(tag, activity)
        (activity as MainActivity).supportActionBar!!.show()
    }

    fun setToolbarTitle(tag: String, activity: Activity) {
        var title = ""
        when (tag) {
            "Main_fragment" -&gt; title = activity.resources.getString(R.string.Main_screen)
            "Add_note" -&gt; title = activity.resources.getString(R.string.Add_note)
        }
        activity.title = title
    }
}
</code></pre>

<p>how to call showToolbar(...) from Fragment?
I just tried <code>MyToolbarUtils.showToolbar(..)</code> but it can not be possible</p>

<p>only one way I discover is: </p>

<pre><code>val setToolbarTitle = MyToolbarUtils()
setToolbarTitle.showToolbar(activity, tag)
</code></pre>

<p>but there must be better way to do that..</p>