rework the player activity starting behaviour
* add callbacks on player finish to update episode watch head progress in gui * directly start the player from the fragment and not from MainActivity
This commit is contained in:
@ -9,7 +9,6 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.commit
|
||||
import org.mosad.teapod.R
|
||||
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
@ -25,20 +24,6 @@ fun FragmentActivity.showFragment(fragment: Fragment) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the player as new activity.
|
||||
*
|
||||
* @param seasonId The ID of the season the episode to be played is in
|
||||
* @param episodeId The ID of the episode to play
|
||||
*/
|
||||
fun Activity.startPlayer(seasonId: String, episodeId: String) {
|
||||
val intent = Intent(this, PlayerActivity::class.java).apply {
|
||||
putExtra(getString(R.string.intent_season_id), seasonId)
|
||||
putExtra(getString(R.string.intent_episode_id), episodeId)
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
/**
|
||||
* hide the status and navigation bar
|
||||
*/
|
||||
|
@ -1,16 +1,31 @@
|
||||
package org.mosad.teapod.util
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.mosad.teapod.R
|
||||
import org.mosad.teapod.parser.crunchyroll.Collection
|
||||
import org.mosad.teapod.parser.crunchyroll.ContinueWatchingItem
|
||||
import org.mosad.teapod.parser.crunchyroll.Item
|
||||
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Create a Intent for PlayerActivity with season and episode id.
|
||||
*
|
||||
* @param seasonId The ID of the season the episode to be played is in
|
||||
* @param episodeId The ID of the episode to play
|
||||
*/
|
||||
fun Fragment.playerIntent(seasonId: String, episodeId: String) = Intent(context, PlayerActivity::class.java).apply {
|
||||
putExtra(getString(R.string.intent_season_id), seasonId)
|
||||
putExtra(getString(R.string.intent_episode_id), episodeId)
|
||||
}
|
||||
|
||||
fun TextView.setDrawableTop(drawable: Int) {
|
||||
this.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user