From 5726e28ce952a04b8f43ed148d76bcd72b36c0a1 Mon Sep 17 00:00:00 2001 From: Kayra Uylar Date: Sun, 3 Mar 2024 22:03:25 +0300 Subject: [PATCH] fix: lateinit crashing. fr this time. ong --- .../ui/fragment/AddVideoToPlaylistFragment.kt | 2 +- .../kuylar/lighttube/ui/fragment/LibraryFragment.kt | 8 ++++---- .../kuylar/lighttube/ui/fragment/PlaylistFragment.kt | 10 +++++----- .../lighttube/ui/fragment/RecyclerViewFragment.kt | 8 ++++---- .../dev/kuylar/lighttube/ui/fragment/SearchFragment.kt | 8 ++++---- .../lighttube/ui/fragment/SubscriptionsFragment.kt | 8 ++++---- .../lighttube/ui/fragment/VideoCommentsFragment.kt | 4 ++-- .../kuylar/lighttube/ui/fragment/VideoInfoFragment.kt | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/AddVideoToPlaylistFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/AddVideoToPlaylistFragment.kt index a9f45ae..8466934 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/AddVideoToPlaylistFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/AddVideoToPlaylistFragment.kt @@ -28,12 +28,12 @@ class AddVideoToPlaylistFragment(private val videoId: String) : BottomSheetDialo savedInstanceState: Bundle? ): View { binding = FragmentAddVideoToPlaylistBinding.inflate(inflater, container, false) - api = (activity as MainActivity).getApi() return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + api = (activity as MainActivity).getApi() binding.buttonNewPlaylist.setOnClickListener { Utils.showPlaylistDialog( diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/LibraryFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/LibraryFragment.kt index b0f2064..5444dd5 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/LibraryFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/LibraryFragment.kt @@ -31,15 +31,15 @@ class LibraryFragment : Fragment() { savedInstanceState: Bundle? ): View { binding = FragmentLibraryBinding.inflate(inflater) - (activity as MainActivity).apply { - this@LibraryFragment.api = getApi() - this@LibraryFragment.player = getPlayer() - } return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as MainActivity).apply { + this@LibraryFragment.api = getApi() + this@LibraryFragment.player = getPlayer() + } val adapter = RendererRecyclerAdapter(items) binding.recyclerLibrary.layoutManager = LinearLayoutManager(context) binding.recyclerLibrary.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/PlaylistFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/PlaylistFragment.kt index 172234c..97de98e 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/PlaylistFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/PlaylistFragment.kt @@ -1,10 +1,10 @@ package dev.kuylar.lighttube.ui.fragment import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.snackbar.Snackbar @@ -34,15 +34,15 @@ class PlaylistFragment : Fragment() { arguments?.let { id = it.getString("id")!! } - (activity as MainActivity).apply { - this@PlaylistFragment.api = getApi() - supportActionBar?.title = "" - } return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as MainActivity).apply { + this@PlaylistFragment.api = getApi() + supportActionBar?.title = "" + } val adapter = RendererRecyclerAdapter(items) binding.recyclerPlaylist.layoutManager = LinearLayoutManager(context) binding.recyclerPlaylist.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/RecyclerViewFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/RecyclerViewFragment.kt index 814c6fb..ae93e12 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/RecyclerViewFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/RecyclerViewFragment.kt @@ -37,10 +37,6 @@ class RecyclerViewFragment : Fragment() { savedInstanceState: Bundle? ): View { binding = FragmentRecyclerviewBinding.inflate(inflater) - (activity as MainActivity).apply { - this@RecyclerViewFragment.api = getApi() - this@RecyclerViewFragment.player = getPlayer() - } type = arguments?.getString("type")!! args = arguments?.getString("args")!! params = arguments?.getString("params") @@ -49,6 +45,10 @@ class RecyclerViewFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as MainActivity).apply { + this@RecyclerViewFragment.api = getApi() + this@RecyclerViewFragment.player = getPlayer() + } val adapter = RendererRecyclerAdapter(items) binding.recycler.layoutManager = LinearLayoutManager(context) binding.recycler.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SearchFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SearchFragment.kt index 213d5d0..a21d6e7 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SearchFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SearchFragment.kt @@ -34,16 +34,16 @@ class SearchFragment : Fragment() { savedInstanceState: Bundle? ): View { binding = FragmentSearchBinding.inflate(inflater) - (activity as MainActivity).apply { - this@SearchFragment.api = getApi() - this@SearchFragment.player = getPlayer() - } query = arguments?.getString("query") ?: "asdf" return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as MainActivity).apply { + this@SearchFragment.api = getApi() + this@SearchFragment.player = getPlayer() + } val adapter = RendererRecyclerAdapter(items) binding.recyclerSearch.layoutManager = LinearLayoutManager(context) binding.recyclerSearch.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SubscriptionsFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SubscriptionsFragment.kt index 6d90b8f..5c0a569 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SubscriptionsFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/SubscriptionsFragment.kt @@ -33,15 +33,15 @@ class SubscriptionsFragment : Fragment() { savedInstanceState: Bundle? ): View { binding = FragmentSubscriptionsBinding.inflate(inflater) - (activity as MainActivity).apply { - this@SubscriptionsFragment.api = getApi() - this@SubscriptionsFragment.player = getPlayer() - } return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as MainActivity).apply { + this@SubscriptionsFragment.api = getApi() + this@SubscriptionsFragment.player = getPlayer() + } val adapter = SubscriptionFeedRecyclerAdapter(items, this::playVideo) binding.recyclerFeed.layoutManager = LinearLayoutManager(context) binding.recyclerFeed.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoCommentsFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoCommentsFragment.kt index 05a2452..ddbe77c 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoCommentsFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoCommentsFragment.kt @@ -40,14 +40,14 @@ class VideoCommentsFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - api = (activity as MainActivity).getApi() - player = (activity as MainActivity).getPlayer() binding = FragmentVideoCommentsBinding.inflate(inflater) return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + api = (activity as MainActivity).getApi() + player = (activity as MainActivity).getPlayer() val adapter = RendererRecyclerAdapter(items) binding.recyclerComments.layoutManager = LinearLayoutManager(context) binding.recyclerComments.adapter = adapter diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoInfoFragment.kt b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoInfoFragment.kt index cdd876f..2f94b28 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoInfoFragment.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/fragment/VideoInfoFragment.kt @@ -37,8 +37,6 @@ class VideoInfoFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - api = (requireActivity() as MainActivity).getApi() - player = (requireActivity() as MainActivity).getPlayer() arguments?.let { id = it.getString("id")!! playlistId = it.getString("playlistId") @@ -55,6 +53,8 @@ class VideoInfoFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + api = (requireActivity() as MainActivity).getApi() + player = (requireActivity() as MainActivity).getPlayer() if (id.isNotBlank()) thread { try {