Skip to content

Commit

Permalink
Remove usage of viewbinding delegate in SearchFragment (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drumber committed Nov 13, 2024
1 parent 73b5a07 commit c7cc6db
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package io.github.drumber.kitsune.ui.search
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.RecyclerView
import by.kirich1409.viewbindingdelegate.viewBinding
import com.algolia.instantsearch.android.searchbox.SearchBoxViewAppCompat
import com.algolia.instantsearch.core.connection.AbstractConnection
import com.algolia.instantsearch.core.connection.ConnectionHandler
Expand All @@ -37,6 +38,7 @@ import io.github.drumber.kitsune.ui.search.SearchViewModel.SearchClientStatus.In
import io.github.drumber.kitsune.ui.search.SearchViewModel.SearchClientStatus.NotAvailable
import io.github.drumber.kitsune.ui.search.SearchViewModel.SearchClientStatus.NotInitialized
import io.github.drumber.kitsune.util.extensions.navigateSafe
import io.github.drumber.kitsune.util.logD
import io.github.drumber.kitsune.util.ui.initPaddingWindowInsetsListener
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
Expand All @@ -50,7 +52,8 @@ class SearchFragment : BaseCollectionFragment(R.layout.fragment_search),

override val hasTransparentStatusBar = false

private val binding: FragmentSearchBinding by viewBinding()
private var _binding: FragmentSearchBinding? = null
private val binding get() = _binding!!

private val viewModel: SearchViewModel by activityViewModel()

Expand All @@ -62,6 +65,16 @@ class SearchFragment : BaseCollectionFragment(R.layout.fragment_search),

private val connectionHandler = ConnectionHandler()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
logD("SearchFragment - onCreateView $this")
_binding = FragmentSearchBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
postponeEnterTransition()
Expand Down Expand Up @@ -197,6 +210,7 @@ class SearchFragment : BaseCollectionFragment(R.layout.fragment_search),
}

override fun onDestroyView() {
logD("SearchFragment - onDestroyView $this")
connectionHandler.clear()
super.onDestroyView()
}
Expand Down

0 comments on commit c7cc6db

Please sign in to comment.