From 3a106c449b1a8e5cd3f9cbf58dfffe81e9e5cffc Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 3 Aug 2023 14:39:35 +0200 Subject: [PATCH] chore: remove unneeded type annotations --- .../libretube/services/ClosingService.kt | 4 +--- .../libretube/services/DownloadService.kt | 2 +- .../libretube/services/OnlinePlayerService.kt | 5 ++--- .../libretube/ui/activities/MainActivity.kt | 2 +- .../libretube/ui/dialogs/LogoutDialog.kt | 3 +-- .../github/libretube/ui/dialogs/StatsDialog.kt | 1 + .../ui/fragments/AudioPlayerFragment.kt | 14 +++++++------- .../libretube/ui/fragments/PlayerFragment.kt | 18 +++++++++--------- .../libretube/ui/fragments/PlaylistFragment.kt | 2 +- .../libretube/ui/fragments/SearchFragment.kt | 1 - .../ui/fragments/SearchResultFragment.kt | 4 ++-- .../ui/fragments/SubscriptionsFragment.kt | 2 +- .../ui/models/SubscriptionsViewModel.kt | 8 ++------ .../ui/sheets/EditChannelGroupSheet.kt | 2 +- .../libretube/ui/views/MarkableTimeBar.kt | 2 +- 15 files changed, 31 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/ClosingService.kt b/app/src/main/java/com/github/libretube/services/ClosingService.kt index e09aa8c47..33aadc0d4 100644 --- a/app/src/main/java/com/github/libretube/services/ClosingService.kt +++ b/app/src/main/java/com/github/libretube/services/ClosingService.kt @@ -9,9 +9,7 @@ import com.github.libretube.constants.PLAYER_NOTIFICATION_ID class ClosingService : Service() { - override fun onBind(intent: Intent?): IBinder? { - return null - } + override fun onBind(intent: Intent?) = null // Handle application closing override fun onTaskRemoved(rootIntent: Intent?) { diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 47d353183..e5e116824 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -183,7 +183,7 @@ class DownloadService : LifecycleService() { val sourceByte = con.inputStream.source() var lastTime = System.currentTimeMillis() / 1000 - var lastRead: Long = 0 + var lastRead = 0L try { // Check if downloading is still active and read next bytes. diff --git a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt index a5494583c..f0b4c1e1b 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -77,9 +77,8 @@ class OnlinePlayerService : LifecycleService() { /** * SponsorBlock Segment data */ - private var segments: List = listOf() - private var sponsorBlockConfig: MutableMap = - PlayerHelper.getSponsorBlockCategories() + private var segments = listOf() + private var sponsorBlockConfig = PlayerHelper.getSponsorBlockCategories() /** * [Notification] for the player diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 9af6cd3bf..f4810e9a2 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -60,7 +60,7 @@ class MainActivity : BaseActivity() { private var savedSearchQuery: String? = null - val autoRotationEnabled: Boolean by lazy { + val autoRotationEnabled by lazy { PreferenceHelper.getBoolean( PreferenceKeys.AUTO_ROTATION, resources.getBoolean(R.bool.config_default_auto_rotation_pref) diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/LogoutDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/LogoutDialog.kt index fad01e4fe..d017d2117 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/LogoutDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/LogoutDialog.kt @@ -19,8 +19,7 @@ class LogoutDialog( val user = PreferenceHelper.getUsername() - binding.user.text = - binding.user.text.toString() + " (" + user + ")" + binding.user.text = binding.user.text.toString() + " ($user)" binding.logout.setOnClickListener { Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show() diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/StatsDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/StatsDialog.kt index 60503757e..f8e64489c 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/StatsDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/StatsDialog.kt @@ -16,6 +16,7 @@ class StatsDialog( ) : DialogFragment() { @SuppressLint("SetTextI18n") + @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val binding = DialogStatsBinding.inflate(layoutInflater) binding.videoId.setText(videoId) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt index 585398e34..9345acf1e 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt @@ -53,11 +53,11 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { private val viewModel: PlayerViewModel by activityViewModels() // for the transition - private var sId: Int = 0 - private var eId: Int = 0 + private var transitionStartId = 0 + private var transitionEndId = 0 private var handler = Handler(Looper.getMainLooper()) - private var isPaused: Boolean = false + private var isPaused = false private var playerService: OnlinePlayerService? = null @@ -215,15 +215,15 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { progress: Float ) { mainMotionLayout.progress = abs(progress) - eId = endId - sId = startId + transitionEndId = endId + transitionStartId = startId } override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { - if (currentId == eId) { + if (currentId == transitionEndId) { viewModel.isMiniPlayerVisible.value = true mainMotionLayout.progress = 1F - } else if (currentId == sId) { + } else if (currentId == transitionStartId) { viewModel.isMiniPlayerVisible.value = false mainMotionLayout.progress = 0F } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 09f1d6f96..2ab74a84e 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -146,8 +146,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { private lateinit var videoId: String private var playlistId: String? = null private var channelId: String? = null - private var keepQueue: Boolean = false - private var timeStamp: Long = 0 + private var keepQueue = false + private var timeStamp = 0L /** * Video information fetched at runtime @@ -157,8 +157,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { /** * for the transition */ - private var sId: Int = 0 - private var eId: Int = 0 + private var transitionStartId = 0 + private var transitionEndId = 0 private var isTransitioning = true /** @@ -166,7 +166,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { */ private lateinit var exoPlayer: ExoPlayer private lateinit var trackSelector: DefaultTrackSelector - private var captionLanguage: String? = PlayerHelper.defaultSubtitleCode + private var captionLanguage = PlayerHelper.defaultSubtitleCode private val cronetDataSourceFactory = CronetDataSource.Factory( CronetHelper.cronetEngine, @@ -323,14 +323,14 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.player.hideController() binding.player.useController = false commentsViewModel.setCommentSheetExpand(false) - eId = endId - sId = startId + transitionEndId = endId + transitionStartId = startId } override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { if (_binding == null) return - if (currentId == eId) { + if (currentId == transitionEndId) { viewModel.isMiniPlayerVisible.value = true // disable captions temporarily updateCaptionsLanguage(null) @@ -339,7 +339,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.sbSkipBtn.isGone = true mainMotionLayout.progress = 1F (activity as MainActivity).requestOrientationChange() - } else if (currentId == sId) { + } else if (currentId == transitionStartId) { viewModel.isMiniPlayerVisible.value = false // re-enable captions updateCaptionsLanguage(captionLanguage) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index 30a7fce94..bbb097d4f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -51,7 +51,7 @@ class PlaylistFragment : Fragment() { // general playlist information private var playlistId: String? = null private var playlistName: String? = null - private var playlistType: PlaylistType = PlaylistType.PUBLIC + private var playlistType = PlaylistType.PUBLIC // runtime variables private var playlistFeed = mutableListOf() diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SearchFragment.kt index a1466bf22..4885eeccd 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SearchFragment.kt @@ -29,7 +29,6 @@ import kotlinx.coroutines.withContext class SearchFragment : Fragment() { private var _binding: FragmentSearchBinding? = null private val binding get() = _binding!! - private val viewModel: SearchViewModel by activityViewModels() private var query: String? = null diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt index 132d8bfc6..0389d18d9 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt @@ -34,10 +34,10 @@ class SearchResultFragment : Fragment() { private val binding get() = _binding!! private var nextPage: String? = null - private var query: String = "" + private var query = "" private lateinit var searchAdapter: SearchAdapter - private var apiSearchFilter: String = "all" + private var apiSearchFilter = "all" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index 6df337b7a..abc5d22f3 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -42,7 +42,7 @@ class SubscriptionsFragment : Fragment() { private val viewModel: SubscriptionsViewModel by activityViewModels() private val playerModel: PlayerViewModel by activityViewModels() - private var channelGroups: List = listOf() + private var channelGroups = listOf() private var selectedFilterGroup = 0 private var isCurrentTabSubChannels = false diff --git a/app/src/main/java/com/github/libretube/ui/models/SubscriptionsViewModel.kt b/app/src/main/java/com/github/libretube/ui/models/SubscriptionsViewModel.kt index 478c38564..2f74a4d30 100644 --- a/app/src/main/java/com/github/libretube/ui/models/SubscriptionsViewModel.kt +++ b/app/src/main/java/com/github/libretube/ui/models/SubscriptionsViewModel.kt @@ -17,13 +17,9 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch class SubscriptionsViewModel : ViewModel() { - var videoFeed = MutableLiveData?>().apply { - value = null - } + var videoFeed = MutableLiveData?>() - var subscriptions = MutableLiveData?>().apply { - value = null - } + var subscriptions = MutableLiveData?>() fun fetchFeed(context: Context) { viewModelScope.launch(Dispatchers.IO) { diff --git a/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt index 7924ea98a..728f6a59a 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt @@ -25,7 +25,7 @@ class EditChannelGroupSheet( ) : ExpandedBottomSheet() { private val subscriptionsModel: SubscriptionsViewModel by activityViewModels() private lateinit var binding: DialogEditChannelGroupBinding - private var channels: List = listOf() + private var channels = listOf() override fun onCreateView( inflater: LayoutInflater, diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index d0ab57fa4..356dcd69a 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -26,7 +26,7 @@ class MarkableTimeBar( attributeSet: AttributeSet? = null ) : DefaultTimeBar(context, attributeSet) { - private var segments: List = listOf() + private var segments = listOf() private var player: Player? = null private var length: Int = 0