Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from kuylar/fix/lateinit_player_2_electric_boo…
Browse files Browse the repository at this point in the history
…galoo

fix: lateinit crashing. again
  • Loading branch information
kuylar authored Mar 3, 2024
2 parents c2c31c3 + 5726e28 commit e7d9d28
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down

0 comments on commit e7d9d28

Please sign in to comment.