title: Instantiating an Interface Listener in Kotlin
body: <p>I cannot, for the life of me, instantiate an interface outside of a fragment in Kotlin or Kotlin for Android. It was standard procedure in Java to say something like:</p>
  
  <pre><code>MyInterface mInterfaceListener = new MyInterface(this);
  mInterfaceListener.invokeSomeGenericMethod();
  </code></pre>
  
  <p>Note that mInterfaceListener is referring to an Interface, not an onCLickListener or anything like that</p>
  
  <p><strong>How are interfaces instantiated in Kotlin? How do I make a "listener" and trigger an interface's functions?</strong> </p>
  
  <p>Below are some attempts in a very simple app I am doing for learning purposes. Notice the variable <em>mPresenterListener</em> which is an Interface</p>
  
  <pre><code>    class QuoteActivity : QuoteContract.ViewOps, AppCompatActivity() {
  
      private lateinit var vText: TextView
      private lateinit var vFab: FloatingActionButton
      private lateinit var mPresenterListener: QuoteContract.PresenterOperations
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          mPresenterListener = this.mPresenterListener
          vText=findViewById(R.id.main_quote)
          vFab=findViewById(R.id.main_fab)
          vFab.setOnClickListener{
              mPresenterListener.onQuoteRequested()
          }
      }
  
      override fun displayQuote(quote: String) {
          vText.text = quote
      }
  
  }
  </code></pre>
  
  <p>And my presenter:</p>
  
  <pre><code>    class QuotePresenter(private val viewListener: QuoteContract.ViewOps): QuoteContract.PresenterOperations {
  
      private lateinit var modelListener: QuoteContract.ModelOperations
  
      init {
          modelListener = this.modelListener
      }
  
  
      override fun onQuoteRequested() {
          modelListener.generateQuote()
      }
  
      override fun onQuoteGenerated(quote: String) {
          viewListener.displayQuote(quote)
      }
  
  
  }
  </code></pre>
  
  <p>The interface:</p>
  
  <pre><code>interface QuoteContract {
  
  
  
  //Methods available to Presenter (Presenter -&gt; View)
  interface ViewOps{
      fun displayQuote(quote: String)
  }
  
  
  //Ops offered from presenter to view (Presenter-&gt;View)
  
  interface PresenterOperations {
      //Presenter-&gt;View
      fun onQuoteRequested()
      //Presenter-&gt;Model
      fun onQuoteGenerated(quote: String)
  }
  
  //Ops offered from Model to Presenter (Model -&gt; Presenter)
  interface ModelOperations {
      fun generateQuote()
  }
  </code></pre>
  
  <p>}</p>