bug fixes

This commit is contained in:
Bnyro 2022-08-13 20:11:56 +02:00
parent 1268dce7bd
commit 17626419a2
4 changed files with 16 additions and 3 deletions

View File

@ -4,6 +4,7 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android {
@ -74,6 +75,8 @@ android {
dependencies {
//debugImplementation libs.square.leakcanary
kapt "androidx.room:room-compiler:2.4.3"
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
implementation libs.androidx.legacySupport

View File

@ -16,6 +16,8 @@ object DatabaseHelper {
streams.thumbnailUrl,
streams.duration
)
DatabaseHolder.database.watchHistoryDao().insertAll(watchHistoryItem)
Thread {
DatabaseHolder.database.watchHistoryDao().insertAll(watchHistoryItem)
}.start()
}
}

View File

@ -11,6 +11,8 @@ import com.github.libretube.adapters.WatchHistoryAdapter
import com.github.libretube.database.DatabaseHolder
import com.github.libretube.databinding.FragmentWatchHistoryBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.obj.WatchHistoryItem
import kotlinx.coroutines.runBlocking
class WatchHistoryFragment : BaseFragment() {
private val TAG = "WatchHistoryFragment"
@ -28,7 +30,13 @@ class WatchHistoryFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val watchHistory = DatabaseHolder.database.watchHistoryDao().getAll()
var watchHistory = listOf<WatchHistoryItem>()
val thread = Thread {
watchHistory = DatabaseHolder.database.watchHistoryDao().getAll()
}
thread.start()
thread.join()
if (watchHistory.isEmpty()) return

View File

@ -6,7 +6,7 @@ import androidx.room.PrimaryKey
@Entity(tableName = "watchHistoryItem")
data class WatchHistoryItem(
@PrimaryKey val videoId: String? = null,
@PrimaryKey val videoId: String = "",
@ColumnInfo val title: String? = null,
@ColumnInfo val uploadDate: String? = null,
@ColumnInfo val uploader: String? = null,