chore: remove unneeded type annotations

This commit is contained in:
Bnyro 2023-08-03 14:39:35 +02:00
parent 1143e9f2bd
commit 3a106c449b
15 changed files with 31 additions and 39 deletions

View File

@ -9,9 +9,7 @@ import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
class ClosingService : Service() { class ClosingService : Service() {
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?) = null
return null
}
// Handle application closing // Handle application closing
override fun onTaskRemoved(rootIntent: Intent?) { override fun onTaskRemoved(rootIntent: Intent?) {

View File

@ -183,7 +183,7 @@ class DownloadService : LifecycleService() {
val sourceByte = con.inputStream.source() val sourceByte = con.inputStream.source()
var lastTime = System.currentTimeMillis() / 1000 var lastTime = System.currentTimeMillis() / 1000
var lastRead: Long = 0 var lastRead = 0L
try { try {
// Check if downloading is still active and read next bytes. // Check if downloading is still active and read next bytes.

View File

@ -77,9 +77,8 @@ class OnlinePlayerService : LifecycleService() {
/** /**
* SponsorBlock Segment data * SponsorBlock Segment data
*/ */
private var segments: List<Segment> = listOf() private var segments = listOf<Segment>()
private var sponsorBlockConfig: MutableMap<String, SbSkipOptions> = private var sponsorBlockConfig = PlayerHelper.getSponsorBlockCategories()
PlayerHelper.getSponsorBlockCategories()
/** /**
* [Notification] for the player * [Notification] for the player

View File

@ -60,7 +60,7 @@ class MainActivity : BaseActivity() {
private var savedSearchQuery: String? = null private var savedSearchQuery: String? = null
val autoRotationEnabled: Boolean by lazy { val autoRotationEnabled by lazy {
PreferenceHelper.getBoolean( PreferenceHelper.getBoolean(
PreferenceKeys.AUTO_ROTATION, PreferenceKeys.AUTO_ROTATION,
resources.getBoolean(R.bool.config_default_auto_rotation_pref) resources.getBoolean(R.bool.config_default_auto_rotation_pref)

View File

@ -19,8 +19,7 @@ class LogoutDialog(
val user = PreferenceHelper.getUsername() val user = PreferenceHelper.getUsername()
binding.user.text = binding.user.text = binding.user.text.toString() + " ($user)"
binding.user.text.toString() + " (" + user + ")"
binding.logout.setOnClickListener { binding.logout.setOnClickListener {
Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()

View File

@ -16,6 +16,7 @@ class StatsDialog(
) : DialogFragment() { ) : DialogFragment() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val binding = DialogStatsBinding.inflate(layoutInflater) val binding = DialogStatsBinding.inflate(layoutInflater)
binding.videoId.setText(videoId) binding.videoId.setText(videoId)

View File

@ -53,11 +53,11 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
private val viewModel: PlayerViewModel by activityViewModels() private val viewModel: PlayerViewModel by activityViewModels()
// for the transition // for the transition
private var sId: Int = 0 private var transitionStartId = 0
private var eId: Int = 0 private var transitionEndId = 0
private var handler = Handler(Looper.getMainLooper()) private var handler = Handler(Looper.getMainLooper())
private var isPaused: Boolean = false private var isPaused = false
private var playerService: OnlinePlayerService? = null private var playerService: OnlinePlayerService? = null
@ -215,15 +215,15 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
progress: Float progress: Float
) { ) {
mainMotionLayout.progress = abs(progress) mainMotionLayout.progress = abs(progress)
eId = endId transitionEndId = endId
sId = startId transitionStartId = startId
} }
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
if (currentId == eId) { if (currentId == transitionEndId) {
viewModel.isMiniPlayerVisible.value = true viewModel.isMiniPlayerVisible.value = true
mainMotionLayout.progress = 1F mainMotionLayout.progress = 1F
} else if (currentId == sId) { } else if (currentId == transitionStartId) {
viewModel.isMiniPlayerVisible.value = false viewModel.isMiniPlayerVisible.value = false
mainMotionLayout.progress = 0F mainMotionLayout.progress = 0F
} }

View File

@ -146,8 +146,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
private lateinit var videoId: String private lateinit var videoId: String
private var playlistId: String? = null private var playlistId: String? = null
private var channelId: String? = null private var channelId: String? = null
private var keepQueue: Boolean = false private var keepQueue = false
private var timeStamp: Long = 0 private var timeStamp = 0L
/** /**
* Video information fetched at runtime * Video information fetched at runtime
@ -157,8 +157,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
/** /**
* for the transition * for the transition
*/ */
private var sId: Int = 0 private var transitionStartId = 0
private var eId: Int = 0 private var transitionEndId = 0
private var isTransitioning = true private var isTransitioning = true
/** /**
@ -166,7 +166,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
*/ */
private lateinit var exoPlayer: ExoPlayer private lateinit var exoPlayer: ExoPlayer
private lateinit var trackSelector: DefaultTrackSelector private lateinit var trackSelector: DefaultTrackSelector
private var captionLanguage: String? = PlayerHelper.defaultSubtitleCode private var captionLanguage = PlayerHelper.defaultSubtitleCode
private val cronetDataSourceFactory = CronetDataSource.Factory( private val cronetDataSourceFactory = CronetDataSource.Factory(
CronetHelper.cronetEngine, CronetHelper.cronetEngine,
@ -323,14 +323,14 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
binding.player.hideController() binding.player.hideController()
binding.player.useController = false binding.player.useController = false
commentsViewModel.setCommentSheetExpand(false) commentsViewModel.setCommentSheetExpand(false)
eId = endId transitionEndId = endId
sId = startId transitionStartId = startId
} }
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
if (_binding == null) return if (_binding == null) return
if (currentId == eId) { if (currentId == transitionEndId) {
viewModel.isMiniPlayerVisible.value = true viewModel.isMiniPlayerVisible.value = true
// disable captions temporarily // disable captions temporarily
updateCaptionsLanguage(null) updateCaptionsLanguage(null)
@ -339,7 +339,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
binding.sbSkipBtn.isGone = true binding.sbSkipBtn.isGone = true
mainMotionLayout.progress = 1F mainMotionLayout.progress = 1F
(activity as MainActivity).requestOrientationChange() (activity as MainActivity).requestOrientationChange()
} else if (currentId == sId) { } else if (currentId == transitionStartId) {
viewModel.isMiniPlayerVisible.value = false viewModel.isMiniPlayerVisible.value = false
// re-enable captions // re-enable captions
updateCaptionsLanguage(captionLanguage) updateCaptionsLanguage(captionLanguage)

View File

@ -51,7 +51,7 @@ class PlaylistFragment : Fragment() {
// general playlist information // general playlist information
private var playlistId: String? = null private var playlistId: String? = null
private var playlistName: String? = null private var playlistName: String? = null
private var playlistType: PlaylistType = PlaylistType.PUBLIC private var playlistType = PlaylistType.PUBLIC
// runtime variables // runtime variables
private var playlistFeed = mutableListOf<StreamItem>() private var playlistFeed = mutableListOf<StreamItem>()

View File

@ -29,7 +29,6 @@ import kotlinx.coroutines.withContext
class SearchFragment : Fragment() { class SearchFragment : Fragment() {
private var _binding: FragmentSearchBinding? = null private var _binding: FragmentSearchBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private val viewModel: SearchViewModel by activityViewModels() private val viewModel: SearchViewModel by activityViewModels()
private var query: String? = null private var query: String? = null

View File

@ -34,10 +34,10 @@ class SearchResultFragment : Fragment() {
private val binding get() = _binding!! private val binding get() = _binding!!
private var nextPage: String? = null private var nextPage: String? = null
private var query: String = "" private var query = ""
private lateinit var searchAdapter: SearchAdapter private lateinit var searchAdapter: SearchAdapter
private var apiSearchFilter: String = "all" private var apiSearchFilter = "all"
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -42,7 +42,7 @@ class SubscriptionsFragment : Fragment() {
private val viewModel: SubscriptionsViewModel by activityViewModels() private val viewModel: SubscriptionsViewModel by activityViewModels()
private val playerModel: PlayerViewModel by activityViewModels() private val playerModel: PlayerViewModel by activityViewModels()
private var channelGroups: List<SubscriptionGroup> = listOf() private var channelGroups = listOf<SubscriptionGroup>()
private var selectedFilterGroup = 0 private var selectedFilterGroup = 0
private var isCurrentTabSubChannels = false private var isCurrentTabSubChannels = false

View File

@ -17,13 +17,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class SubscriptionsViewModel : ViewModel() { class SubscriptionsViewModel : ViewModel() {
var videoFeed = MutableLiveData<List<StreamItem>?>().apply { var videoFeed = MutableLiveData<List<StreamItem>?>()
value = null
}
var subscriptions = MutableLiveData<List<Subscription>?>().apply { var subscriptions = MutableLiveData<List<Subscription>?>()
value = null
}
fun fetchFeed(context: Context) { fun fetchFeed(context: Context) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {

View File

@ -25,7 +25,7 @@ class EditChannelGroupSheet(
) : ExpandedBottomSheet() { ) : ExpandedBottomSheet() {
private val subscriptionsModel: SubscriptionsViewModel by activityViewModels() private val subscriptionsModel: SubscriptionsViewModel by activityViewModels()
private lateinit var binding: DialogEditChannelGroupBinding private lateinit var binding: DialogEditChannelGroupBinding
private var channels: List<Subscription> = listOf() private var channels = listOf<Subscription>()
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,

View File

@ -26,7 +26,7 @@ class MarkableTimeBar(
attributeSet: AttributeSet? = null attributeSet: AttributeSet? = null
) : DefaultTimeBar(context, attributeSet) { ) : DefaultTimeBar(context, attributeSet) {
private var segments: List<Segment> = listOf() private var segments = listOf<Segment>()
private var player: Player? = null private var player: Player? = null
private var length: Int = 0 private var length: Int = 0