title: Error "Can't create ViewModelProvider for detached fragment" when i called method from Presenter
body: <p>I have a fragment with <code>updateToolbar()</code> function. When i try to get my ViewModel, calles <strong>UserViewModel</strong> on this method i get error:</p>
  
  <p><code>Can't create ViewModelProvider for detached fragment</code></p>
  
  <p>When i try to get <strong>UserViewModel</strong> inside <code>onViewCreated()</code>, all works fine. Why it happens? I call <code>updateToolbar()</code> after <code>onCreateView()</code> and I'm not create any fragment transactions before function called.</p>
  
  <p>I'm started to learn Clean Architecture, and intuitively i think the reason of error can be on it, so i add this code too. I think problem about presenter, but i can't understand where exactly. </p>
  
  <hr>
  
  <p><strong>PacksFragment:</strong></p>
  
  <pre><code> class PacksFragment : BaseCompatFragment() {
  
      @Inject
      lateinit var presenter: PacksFragmentPresenter
  
      private var userViewModel: UserViewModel? = null
      override fun onCreate(savedInstanceState: Bundle?) {
          userViewModel = ViewModelProviders.of(this).get(UserViewModel::class.java)
          super.onCreate(savedInstanceState)
      }
  
      override fun onCreateView(
          ...
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {    
          LibApp.get().injector.inject(this)
          ...    
          presenter.openNewPack(packId)
      }
  
      fun updateToolbar() {
          Timber.e((userViewModel == null).toString())
          Timber.e(userViewModel?.getData()?.value?.coins.toString())
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>PacksFragmentPresenter:</strong></p>
  
  <pre><code>class PacksFragmentPresenter @Inject constructor(
      private val packsFragment: PacksFragment,
      private val getCoinsFromUserCase: GetCoinsFromUserCase
  ) {
  
      fun openNewPack(packId: Int) {
          if (getCoinsFromUserCase.getCoinsFromUser()){
              packsFragment.updateToolbar()
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>GetCoinsFromUserCase:</strong></p>
  
  <pre><code>class GetCoinsFromUserCase {
  
      fun getCoinsFromUser(): Boolean {
          val userViewModel = UserViewModel()
          userViewModel.takeCoins(10)
          return true
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>userViewModel:</strong></p>
  
  <pre><code>class UserViewModel : ViewModel(), UserApi {
      private val data = MutableLiveData&lt;User&gt;()
  
      fun setData(user: User) {
          //Logged fine
          Timber.e("User setted")
          data.value = user
      }
  
      fun getData(): LiveData&lt;User&gt; {
          if (data.value == null) {
              val user = User()
              user.coins = 200
              data.value = user
          }
          //Logged fine, "false"
          Timber.e("User getted")
          Timber.e("Is user == null? %s", (data.value == null).toString())
          return data
      }
  
      override fun takeCoins(value: Int) {
            //Specially commented it 
  //        getCoins(value)
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>UPD:</strong></p>
  
  <p>I make some changes to prevent crush - make userViewModel nullable(update <strong>PacksFragment</strong> code on the top). </p>
  
  <p>But userViewModel is always null when i call <code>updateToolbar()</code>. Main thing fragment not removed/deleted/invisible/..., it's active fragment with button which called <code>updateToolbar()</code> function.</p>