mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
cleanup
This commit is contained in:
parent
6da00f912e
commit
7eb83716c5
@ -89,7 +89,10 @@ class MainActivity : BaseActivity() {
|
|||||||
if (!ConnectionHelper.isNetworkAvailable(this)) {
|
if (!ConnectionHelper.isNetworkAvailable(this)) {
|
||||||
val noInternetIntent = Intent(this, NoInternetActivity::class.java)
|
val noInternetIntent = Intent(this, NoInternetActivity::class.java)
|
||||||
startActivity(noInternetIntent)
|
startActivity(noInternetIntent)
|
||||||
} else {
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
@ -158,7 +161,6 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.toolbar.title = ThemeHelper.getStyledAppName(this)
|
binding.toolbar.title = ThemeHelper.getStyledAppName(this)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle error logs
|
* handle error logs
|
||||||
|
@ -3,6 +3,8 @@ package com.github.libretube.database
|
|||||||
import com.github.libretube.obj.Streams
|
import com.github.libretube.obj.Streams
|
||||||
import com.github.libretube.obj.WatchHistoryItem
|
import com.github.libretube.obj.WatchHistoryItem
|
||||||
import com.github.libretube.obj.WatchPosition
|
import com.github.libretube.obj.WatchPosition
|
||||||
|
import com.github.libretube.preferences.PreferenceHelper
|
||||||
|
import com.github.libretube.preferences.PreferenceKeys
|
||||||
import com.github.libretube.util.toID
|
import com.github.libretube.util.toID
|
||||||
|
|
||||||
object DatabaseHelper {
|
object DatabaseHelper {
|
||||||
@ -19,6 +21,15 @@ object DatabaseHelper {
|
|||||||
)
|
)
|
||||||
Thread {
|
Thread {
|
||||||
DatabaseHolder.database.watchHistoryDao().insertAll(watchHistoryItem)
|
DatabaseHolder.database.watchHistoryDao().insertAll(watchHistoryItem)
|
||||||
|
val maxHistorySize = PreferenceHelper.getString(PreferenceKeys.WATCH_HISTORY_SIZE, "unlimited")
|
||||||
|
if (maxHistorySize == "unlimited") return@Thread
|
||||||
|
|
||||||
|
// delete the first watch history entry if the limit is reached
|
||||||
|
val watchHistory = DatabaseHolder.database.watchHistoryDao().getAll()
|
||||||
|
if (watchHistory.size > maxHistorySize.toInt()) {
|
||||||
|
DatabaseHolder.database.watchHistoryDao()
|
||||||
|
.delete(watchHistory.first())
|
||||||
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user