title: Questions about the responsbilities of each component in Android Architecture Components
body: <p>I've been using MVP for a long time now and I'm starting to transfer to a hybrid state between MVP and MVVM</p>
  
  <p>In detail my apps will go like this:</p>
  
  <ul>
  <li>Each Activity has a 0 to x Fragments that represent its views</li>
  <li>Each Fragment will request the Activity's ViewModel so that they can retrieve data using LiveData</li>
  <li>The Activity will have a seperate ViewModel which will act as the presenter. On creation that ViewModel will be injected with the Activity's ViewModel with the LiveData so that it can update the UI as needed</li>
  <li>The presenter will get the messages sent to the data ViewModel and send the results back to it</li>
  </ul>
  
  <p>My questions:</p>
  
  <ol>
  <li>Could holding a reference to the data ViewModel in the presenter ViewModel cause a memory leak or adverse effects such as memory leaks?</li>
  <li>Where should business logic be? in the presenter or in the model part?</li>
  </ol>
  
  <p>For example, let's say I have a list of items and the user long presses one to edit them, what part of this architecture should be responsible for checking if the user has permission to do this and either let them edit the item or show an error message?</p>
  
  <ol start="3">
  <li>Is there a way for the Fragments to only get part of the Activity's ViewModel?</li>
  </ol>
  
  <p>For example , assuming the activity has 3 Fragments under it, and one ViewModel to cater to them</p>
  
  <p>Can I use something like:</p>
  
  <pre><code>class MainViewModel : ViewModel() , IFragmentA, IFragmentB, IFragmentC
  </code></pre>
  
  <p>and then when I try to get the ViewModel in the fragments I can write something like:</p>
  
  <pre><code>lateinit var viewModel: IFragmentA
  
  override fun onAttach(context: Context?) {
      super.onAttach(context)
      vm = ViewModelProviders.of(context as AppCompatActivity).get(IFragmentA::class.java)
  }
  </code></pre>
  
  <p>note:I know the above code does not work , what I am asking is if there is a way for something similar to this could work</p>
  
  <ol start="4">
  <li>Is the correct way to send back messages to the activity SingleEvents? </li>
  </ol>
  
  <p>For example, if the user tries to delete an entry , and I wish for them to enter a password, would the flow be:</p>
  
  <ul>
  <li>The Fragment sends the message to delete to its ViewModel</li>
  <li>The ViewModel passes it on to the Presenter</li>
  <li>The Presenter decides that it needs password verification before moving on</li>
  <li>The presenter sets the value of a SingleEvent in ViewModel</li>
  <li>The ViewModel notifies the event's subscribers (in this case the MainActivity) that they should show a dialog asking for a password</li>
  </ul>
  
  <p>Thank you for any help you can provide</p>