This commit is contained in:
Bnyro 2022-08-01 08:55:38 +02:00
parent 23f22f99bf
commit f4a4ad41bb
9 changed files with 15 additions and 19 deletions

View File

@ -25,8 +25,9 @@ class ChannelAdapter(
}
fun updateItems(newItems: List<StreamItem>) {
val feedSize = videoFeed.size
videoFeed.addAll(newItems)
notifyDataSetChanged()
notifyItemRangeInserted(feedSize, newItems.size)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChannelViewHolder {

View File

@ -81,9 +81,8 @@ class LoginDialog : DialogFragment() {
Toast.makeText(context, R.string.loggedIn, Toast.LENGTH_SHORT).show()
PreferenceHelper.setToken(response.token!!)
PreferenceHelper.setUsername(login.username!!)
val restartDialog = RequireRestartDialog()
restartDialog.show(parentFragmentManager, "RequireRestartDialog")
dialog?.dismiss()
activity?.recreate()
}
}
}

View File

@ -83,7 +83,7 @@ class ChannelFragment : Fragment() {
if (nextPage != null && !isLoading) {
isLoading = true
binding.channelRefresh.isRefreshing = true
fetchNextPage()
fetchChannelNextPage()
}
}
}
@ -217,7 +217,7 @@ class ChannelFragment : Fragment() {
run()
}
private fun fetchNextPage() {
private fun fetchChannelNextPage() {
fun run() {
lifecycleScope.launchWhenCreated {
val response = try {

View File

@ -563,7 +563,7 @@ class PlayerFragment : Fragment() {
exoPlayer.pause()
// start the background mode
BackgroundHelper.playOnBackground(requireContext(), videoId!!)
BackgroundHelper.playOnBackground(requireContext(), videoId!!, exoPlayer.currentPosition)
}
binding.playerScrollView.viewTreeObserver
@ -1080,7 +1080,7 @@ class PlayerFragment : Fragment() {
})
// check if livestream
if (response.duration!! > 0) {
if (response.duration > 0) {
// download clicked
binding.relPlayerDownload.setOnClickListener {
if (!Globals.IS_DOWNLOAD_RUNNING) {
@ -1148,7 +1148,6 @@ class PlayerFragment : Fragment() {
binding.playerMotionLayout.transitionToEnd()
}
if (token != "") {
val channelId = response.uploaderUrl?.toID()
isSubscribed()
binding.relPlayerSave.setOnClickListener {
val newFragment = AddtoPlaylistDialog()
@ -1241,11 +1240,6 @@ class PlayerFragment : Fragment() {
}
}
private fun toggleController() {
if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController()
else exoPlayerView.showController()
}
// enable seek bar preview
private fun enableSeekbarPreview() {
playerBinding.exoProgress.addListener(object : TimeBar.OnScrubListener {

View File

@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R
import com.github.libretube.adapters.SearchAdapter

View File

@ -66,10 +66,10 @@ class BackgroundMode : Service() {
override fun onCreate() {
super.onCreate()
if (Build.VERSION.SDK_INT >= 26) {
val channelId = "background service"
val channelId = BACKGROUND_CHANNEL_ID
val channel = NotificationChannel(
channelId,
"BackgroundPlay Service",
"Background Service",
NotificationManager.IMPORTANCE_DEFAULT
)
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
@ -77,7 +77,7 @@ class BackgroundMode : Service() {
val notification: Notification = Notification.Builder(this, channelId)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.playingOnBackground)).build()
startForeground(1, notification)
startForeground(PLAYER_NOTIFICATION_ID, notification)
}
}

View File

@ -8,7 +8,7 @@ object BackgroundHelper {
fun playOnBackground(
context: Context,
videoId: String,
position: Int? = null
position: Long? = null
) {
val intent = Intent(context, BackgroundMode::class.java)
intent.putExtra("videoId", videoId)

View File

@ -172,7 +172,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp">
android:layout_marginStart="10dp">
<TextView
android:id="@id/exo_position"
@ -194,7 +194,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_marginStart="10dp"
android:visibility="gone">
<TextView

View File

@ -23,6 +23,7 @@
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:checkedChip="@id/chip_all"
app:selectionRequired="true"
app:singleLine="true"
app:singleSelection="true">