diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6e2ebcdc7..993e6f6a0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,8 +28,8 @@ android { applicationId = "com.github.andreyasadchy.xtra" minSdk = 21 targetSdk = 34 - versionCode = 237 - versionName = "2.31.2" + versionCode = 238 + versionName = "2.31.3" resourceConfigurations += listOf("ar", "de", "en", "es", "fr", "in", "it", "ja", "pt-rBR", "ru", "tr", "zh-rTW", "zh-rCN") } diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/db/VideosDao.kt b/app/src/main/java/com/github/andreyasadchy/xtra/db/VideosDao.kt index f3e8e2668..70904bc26 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/db/VideosDao.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/db/VideosDao.kt @@ -20,8 +20,11 @@ interface VideosDao { @Query("SELECT * FROM videos WHERE url = :url") fun getByUrl(url: String): OfflineVideo? + @Query("SELECT * FROM videos WHERE videoId = :id") + fun getByVideoId(id: String): List + @Query("SELECT * FROM videos WHERE channel_id = :id") - fun getByUserId(id: Int): List + fun getByUserId(id: String): List @Insert fun insert(video: OfflineVideo): Long diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/repository/ApiRepository.kt b/app/src/main/java/com/github/andreyasadchy/xtra/repository/ApiRepository.kt index eee5401f7..aeb0ea1a6 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/repository/ApiRepository.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/repository/ApiRepository.kt @@ -664,7 +664,7 @@ class ApiRepository @Inject constructor( addProperty("channel_id", channelId) addProperty("broadcast_id", streamId) addProperty("player", "site") - addProperty("user_id", userId?.toInt()) + addProperty("user_id", userId?.toLong()) }) } val spadeRequest = Base64.encodeToString(json.toString().toByteArray(), Base64.NO_WRAP).toRequestBody() diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/repository/BookmarksRepository.kt b/app/src/main/java/com/github/andreyasadchy/xtra/repository/BookmarksRepository.kt index 2a5f7a09f..505649f12 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/repository/BookmarksRepository.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/repository/BookmarksRepository.kt @@ -38,10 +38,10 @@ class BookmarksRepository @Inject constructor( } suspend fun deleteBookmark(context: Context, item: Bookmark) = withContext(Dispatchers.IO) { - if (!item.videoId.isNullOrBlank() && videosDao.getById(item.videoId.toInt()) == null) { + if (!item.videoId.isNullOrBlank() && videosDao.getByVideoId(item.videoId).isEmpty()) { File(context.filesDir.path + File.separator + "thumbnails" + File.separator + "${item.videoId}.png").delete() } - if (!item.userId.isNullOrBlank() && localFollowsChannelDao.getByUserId(item.userId) == null && videosDao.getByUserId(item.userId.toInt()).isEmpty()) { + if (!item.userId.isNullOrBlank() && localFollowsChannelDao.getByUserId(item.userId) == null && videosDao.getByUserId(item.userId).isEmpty()) { File(context.filesDir.path + File.separator + "profile_pics" + File.separator + "${item.userId}.png").delete() } bookmarksDao.delete(item) diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/repository/LocalFollowChannelRepository.kt b/app/src/main/java/com/github/andreyasadchy/xtra/repository/LocalFollowChannelRepository.kt index d9a9f5ea7..35f0e5e7e 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/repository/LocalFollowChannelRepository.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/repository/LocalFollowChannelRepository.kt @@ -30,7 +30,7 @@ class LocalFollowChannelRepository @Inject constructor( } suspend fun deleteFollow(context: Context, item: LocalFollowChannel) = withContext(Dispatchers.IO) { - if (!item.userId.isNullOrBlank() && bookmarksDao.getByUserId(item.userId).isEmpty() && videosDao.getByUserId(item.userId.toInt()).isEmpty()) { + if (!item.userId.isNullOrBlank() && bookmarksDao.getByUserId(item.userId).isEmpty() && videosDao.getByUserId(item.userId).isEmpty()) { File(context.filesDir.path + File.separator + "profile_pics" + File.separator + "${item.userId}.png").delete() } localFollowsChannelDao.delete(item) diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/repository/OfflineRepository.kt b/app/src/main/java/com/github/andreyasadchy/xtra/repository/OfflineRepository.kt index 1ce33846f..71d42a92f 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/repository/OfflineRepository.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/repository/OfflineRepository.kt @@ -34,7 +34,7 @@ class OfflineRepository @Inject constructor( videosDao.getByUrl(url) } - suspend fun getVideosByUserId(id: Int) = withContext(Dispatchers.IO) { + suspend fun getVideosByUserId(id: String) = withContext(Dispatchers.IO) { videosDao.getByUserId(id) } diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/repository/datasource/FollowedChannelsDataSource.kt b/app/src/main/java/com/github/andreyasadchy/xtra/repository/datasource/FollowedChannelsDataSource.kt index 2c338c21b..668f8a07e 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/repository/datasource/FollowedChannelsDataSource.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/repository/datasource/FollowedChannelsDataSource.kt @@ -257,7 +257,7 @@ class FollowedChannelsDataSource( val downloadedLogo = DownloadUtils.savePng(context, TwitchApiHelper.getTemplateUrl(profileImageURL, "profileimage"), "profile_pics", userId) localFollowsChannel.getFollowByUserId(userId)?.let { localFollowsChannel.updateFollow(it.apply { channelLogo = downloadedLogo }) } - for (i in offlineRepository.getVideosByUserId(userId.toInt())) { + for (i in offlineRepository.getVideosByUserId(userId)) { offlineRepository.updateVideo(i.apply { channelLogo = downloadedLogo }) } diff --git a/app/src/main/java/com/github/andreyasadchy/xtra/ui/channel/ChannelPagerViewModel.kt b/app/src/main/java/com/github/andreyasadchy/xtra/ui/channel/ChannelPagerViewModel.kt index 76b194b9d..793a56f69 100644 --- a/app/src/main/java/com/github/andreyasadchy/xtra/ui/channel/ChannelPagerViewModel.kt +++ b/app/src/main/java/com/github/andreyasadchy/xtra/ui/channel/ChannelPagerViewModel.kt @@ -166,7 +166,7 @@ class ChannelPagerViewModel @Inject constructor( userLogin = user.channelLogin userName = user.channelName channelLogo = downloadedLogo }) } - for (i in offlineRepository.getVideosByUserId(user.channelId.toInt())) { + for (i in offlineRepository.getVideosByUserId(user.channelId)) { offlineRepository.updateVideo(i.apply { channelLogin = user.channelLogin channelName = user.channelName