title: Fragment is not associated with a fragment manager
body: <p>This question has been asked multiple times, but the proposed solutions do not function in my specific case.</p>
  <p>When the onProjectImageViewClick function is executed I receive the following error:</p>
  <pre><code>java.lang.IllegalStateException: Fragment HomeFragment{191080d} (9545b64c-bf0a-4464-8a71-b8c474526181)} not associated with a fragment manager.
  </code></pre>
  <p>One of the proposed solutions was to use the code below to navigate, but since my fragment is detached I can't navigate to the other fragment.</p>
  <pre><code>view?.post {
  findNavController().navigate(R.id.fragment_project_info)
  </code></pre>
  <p>}</p>
  <p>Also, when I troubleshoot using <code>println(Homefragment().isAdded)</code>, it returns false, therefore I can't use the solution written above.</p>
  <p>Before implementing the firebase database (only using placeholders for my recyclerview), I could navigate to my fragment_project_info.</p>
  <p>My Fragment:</p>
  <pre><code>class HomeFragment : Fragment(), HomeProjectListAdapter.OnItemClickListener {
  
  private lateinit var auth: FirebaseAuth
  private lateinit var databaseReference: DatabaseReference
  lateinit var listener: ValueEventListener
  
  var recentPostRef = FirebaseDatabase.getInstance().getReference(&quot;projects&quot;).limitToLast(50)
  
  val TAG = &quot;loadPostData Result&quot;
  
  override fun onCreateView(
      inflater: LayoutInflater, container: ViewGroup?,
      savedInstanceState: Bundle?
  ): View? {
      return inflater.inflate(R.layout.fragment_home, container, false)
  }
  
  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
      super.onViewCreated(view, savedInstanceState)
      auth = Firebase.auth
  
  }
  override fun onActivityCreated(savedInstanceState: Bundle?) {
      super.onActivityCreated(savedInstanceState)
      postQueryValueListener()
  }
  
  override fun onStart() {
      super.onStart()
      val currentUser = auth.currentUser
      updateUI(currentUser)
  }
  
  override fun onProjectImageViewClick(position: Int, projectData: ProjectData) {
      findNavController().navigate(R.id.fragment_project_info)
  
  }
  
  private fun updateUI(currentUser: FirebaseUser?){
      if(currentUser == null){
          upload_button.visibility = View.GONE
          projects_button.visibility = View.GONE
  
      }
  }
  
  private fun postQueryValueListener() {
      listener = recentPostRef.addValueEventListener(object : ValueEventListener {
          override fun onDataChange(dataSnapshot: DataSnapshot) {
              for (postSnapshot in dataSnapshot.children) {
                  var list = ArrayList&lt;ProjectData&gt;()
                  for (dataSnapshot1 in dataSnapshot.children) {
                      val p: ProjectData? = dataSnapshot1.getValue(ProjectData::class.java)
                      if (p != null) {
                          list.add(p)
                      }
                  }
                  var adapter = HomeProjectListAdapter(list, HomeFragment())
                  recycler_view.adapter = adapter
                  recycler_view.layoutManager = LinearLayoutManager(context)
                  recycler_view.hasFixedSize()
              }
          }
  
          override fun onCancelled(databaseError: DatabaseError) {
              Log.w(TAG, &quot;loadPost:onCancelled&quot;, databaseError.toException())
          }
      })
  }
  
  override fun onStop() {
      super.onStop()
      recentPostRef.removeEventListener(listener)
  }
  </code></pre>
  <p>}</p>
  <p>Here is my adapter:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class HomeProjectListAdapter(
      private val projectList: List&lt;ProjectData&gt;,
      private val listener: HomeFragment
  ) : RecyclerView.Adapter&lt;HomeProjectListAdapter.ProjectListViewHolder&gt;() {
      val TAG = "loadUserData Result"
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProjectListViewHolder {
          val itemView = LayoutInflater.from(parent.context).inflate(R.layout.layout_project_card,
          parent, false)
  
          return ProjectListViewHolder(itemView)
  
      }
  
      override fun onBindViewHolder(holder: ProjectListViewHolder, position: Int) {
          val currentItem = projectList[position]
  
          Glide.with(holder.projectImageView.context)
              .load(currentItem.mainImageURL)
              .into(holder.projectImageView)
      }
  
      override fun getItemCount() = projectList.size
  
      inner class ProjectListViewHolder(itemView: View): RecyclerView.ViewHolder(itemView),
      View.OnClickListener{
          var projectImageView: ImageView = itemView.project_card_image
  
          init {
              projectImageView.setOnClickListener(this)
          }
          override fun onClick(v: View?) {
              val position = adapterPosition
              val projectData: ProjectData = projectList[position]
              if (position != RecyclerView.NO_POSITION){
                  if (v != null) {
                      if(v.id == R.id.project_card_image) {
                          listener.onProjectImageViewClick(position, projectData)
                      }
                  }
              }
          }
      }
  
      interface OnItemClickListener {
          fun onProjectImageViewClick(position: Int, projectData: ProjectData)
      }
  }</code></pre>
  </div>
  </div>
  </p>