From 14d823ad3d12b12a688986c08e8c96dfed7883c1 Mon Sep 17 00:00:00 2001 From: Xilin Jia <6257601+XilinJia@users.noreply.github.com> Date: Sun, 18 Feb 2024 20:06:15 +0100 Subject: [PATCH] minor bug fixes --- app/build.gradle | 4 ++-- .../java/ac/mdiq/podvinci/fragment/EpisodesListFragment.kt | 4 ++-- .../java/ac/mdiq/podvinci/fragment/FeedItemlistFragment.kt | 2 +- .../main/java/ac/mdiq/podvinci/fragment/SearchFragment.kt | 6 +++--- .../java/ac/mdiq/podvinci/fragment/SubscriptionFragment.kt | 4 ++-- .../mdiq/podvinci/core/service/playback/PlaybackService.kt | 1 - .../ac/mdiq/podvinci/core/util/download/MediaSizeLoader.kt | 4 ++-- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 86943d07..0cba373e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,8 +22,8 @@ android { // Version code schema: // "1.2.3-beta4" -> 1020304 // "1.2.3" -> 1020395 - versionCode 3020096 - versionName "3.2.1" + versionCode 3020097 + versionName "3.2.2" def commit = "" try { diff --git a/app/src/main/java/ac/mdiq/podvinci/fragment/EpisodesListFragment.kt b/app/src/main/java/ac/mdiq/podvinci/fragment/EpisodesListFragment.kt index f2c314aa..af611714 100644 --- a/app/src/main/java/ac/mdiq/podvinci/fragment/EpisodesListFragment.kt +++ b/app/src/main/java/ac/mdiq/podvinci/fragment/EpisodesListFragment.kt @@ -326,8 +326,8 @@ abstract class EpisodesListFragment : Fragment(), SelectableAdapter.OnSelectMode @UnstableApi @Subscribe(threadMode = ThreadMode.MAIN) fun onEventMainThread(event: PlaybackPositionEvent) { for (i in 0 until listAdapter.itemCount) { - val holder: EpisodeItemViewHolder = recyclerView.findViewHolderForAdapterPosition(i) as EpisodeItemViewHolder - if (holder.isCurrentlyPlayingItem) { + val holder: EpisodeItemViewHolder? = recyclerView.findViewHolderForAdapterPosition(i) as? EpisodeItemViewHolder + if (holder != null && holder.isCurrentlyPlayingItem) { holder.notifyPlaybackPositionUpdated(event) break } diff --git a/app/src/main/java/ac/mdiq/podvinci/fragment/FeedItemlistFragment.kt b/app/src/main/java/ac/mdiq/podvinci/fragment/FeedItemlistFragment.kt index 67cb4567..6b9b2064 100644 --- a/app/src/main/java/ac/mdiq/podvinci/fragment/FeedItemlistFragment.kt +++ b/app/src/main/java/ac/mdiq/podvinci/fragment/FeedItemlistFragment.kt @@ -336,7 +336,7 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba fun onEventMainThread(event: PlaybackPositionEvent) { for (i in 0 until adapter.itemCount) { val holder: EpisodeItemViewHolder? = - viewBinding.recyclerView.findViewHolderForAdapterPosition(i) as EpisodeItemViewHolder? + viewBinding.recyclerView.findViewHolderForAdapterPosition(i) as? EpisodeItemViewHolder if (holder != null && holder.isCurrentlyPlayingItem) { holder.notifyPlaybackPositionUpdated(event) break diff --git a/app/src/main/java/ac/mdiq/podvinci/fragment/SearchFragment.kt b/app/src/main/java/ac/mdiq/podvinci/fragment/SearchFragment.kt index 62932f6c..777bc311 100644 --- a/app/src/main/java/ac/mdiq/podvinci/fragment/SearchFragment.kt +++ b/app/src/main/java/ac/mdiq/podvinci/fragment/SearchFragment.kt @@ -286,9 +286,9 @@ class SearchFragment : Fragment(), SelectableAdapter.OnSelectModeListener { @UnstableApi @Subscribe(threadMode = ThreadMode.MAIN) fun onEventMainThread(event: PlaybackPositionEvent) { for (i in 0 until adapter.itemCount) { - val holder: EpisodeItemViewHolder = - recyclerView.findViewHolderForAdapterPosition(i) as EpisodeItemViewHolder - if (holder.isCurrentlyPlayingItem) { + val holder: EpisodeItemViewHolder? = + recyclerView.findViewHolderForAdapterPosition(i) as? EpisodeItemViewHolder + if (holder != null && holder.isCurrentlyPlayingItem) { holder.notifyPlaybackPositionUpdated(event) break } diff --git a/app/src/main/java/ac/mdiq/podvinci/fragment/SubscriptionFragment.kt b/app/src/main/java/ac/mdiq/podvinci/fragment/SubscriptionFragment.kt index c64fb89b..25b181fb 100644 --- a/app/src/main/java/ac/mdiq/podvinci/fragment/SubscriptionFragment.kt +++ b/app/src/main/java/ac/mdiq/podvinci/fragment/SubscriptionFragment.kt @@ -59,10 +59,10 @@ class SubscriptionFragment : Fragment(), Toolbar.OnMenuItemClickListener, Select private lateinit var toolbar: MaterialToolbar private lateinit var swipeRefreshLayout: SwipeRefreshLayout private lateinit var progressBar: ProgressBar - private lateinit var displayedFolder: String private lateinit var prefs: SharedPreferences private lateinit var speedDialView: SpeedDialView - + + private var displayedFolder: String = "" private var displayUpArrow = false private var disposable: Disposable? = null diff --git a/core/src/main/java/ac/mdiq/podvinci/core/service/playback/PlaybackService.kt b/core/src/main/java/ac/mdiq/podvinci/core/service/playback/PlaybackService.kt index 4875e314..d917473e 100644 --- a/core/src/main/java/ac/mdiq/podvinci/core/service/playback/PlaybackService.kt +++ b/core/src/main/java/ac/mdiq/podvinci/core/service/playback/PlaybackService.kt @@ -165,7 +165,6 @@ class PlaybackService : MediaBrowserServiceCompat() { stateManager = PlaybackServiceStateManager(this) notificationBuilder = PlaybackServiceNotificationBuilder(this) - // TODO: this shit doesn't work if (Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { registerReceiver(autoStateUpdated, IntentFilter("com.google.android.gms.car.media.STATUS"), RECEIVER_NOT_EXPORTED) registerReceiver(shutdownReceiver, IntentFilter(PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE), RECEIVER_NOT_EXPORTED) diff --git a/core/src/main/java/ac/mdiq/podvinci/core/util/download/MediaSizeLoader.kt b/core/src/main/java/ac/mdiq/podvinci/core/util/download/MediaSizeLoader.kt index c6dab87e..9e4703fb 100644 --- a/core/src/main/java/ac/mdiq/podvinci/core/util/download/MediaSizeLoader.kt +++ b/core/src/main/java/ac/mdiq/podvinci/core/util/download/MediaSizeLoader.kt @@ -48,9 +48,9 @@ object MediaSizeLoader { try { val response = client.newCall(httpReq.build()).execute() if (response.isSuccessful) { - val contentLength = response.header("Content-Length") + val contentLength = response.header("Content-Length")?:"0" try { - size = contentLength!!.toInt().toLong() + size = contentLength.toInt().toLong() } catch (e: NumberFormatException) { Log.e(TAG, Log.getStackTraceString(e)) }