mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 17:49:03 +03:00
add loading indicator
This commit is contained in:
parent
7449825936
commit
017b6b5b7d
4 changed files with 62 additions and 19 deletions
|
@ -50,11 +50,20 @@ class Gestures(
|
||||||
when {
|
when {
|
||||||
e.x < width * 0.4F -> activity.doubleTapSeek(-interval, e)
|
e.x < width * 0.4F -> activity.doubleTapSeek(-interval, e)
|
||||||
e.x > width * 0.6F -> activity.doubleTapSeek(interval, e)
|
e.x > width * 0.6F -> activity.doubleTapSeek(interval, e)
|
||||||
else -> return false
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDoubleTapEvent(e: MotionEvent): Boolean {
|
||||||
|
if (activity.isLocked) return false
|
||||||
|
if (e.y < height * 0.05F || e.y > height * 0.95F || e.x < width * 0.05F || e.x > width * 0.95F) return false
|
||||||
|
if (e.action == MotionEvent.ACTION_UP && e.x > width * 0.4F && e.x < width * 0.6F) {
|
||||||
|
activity.toggleControls()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun onScroll(
|
override fun onScroll(
|
||||||
e1: MotionEvent,
|
e1: MotionEvent,
|
||||||
e2: MotionEvent,
|
e2: MotionEvent,
|
||||||
|
|
|
@ -271,8 +271,26 @@ class PlayerActivity :
|
||||||
binding.playbackSeekbar.setOnSeekBarChangeListener(seekBarChangeListener)
|
binding.playbackSeekbar.setOnSeekBarChangeListener(seekBarChangeListener)
|
||||||
// player.playFile(currentVideoList!!.first().videoUrl!!.toString())
|
// player.playFile(currentVideoList!!.first().videoUrl!!.toString())
|
||||||
|
|
||||||
binding.nextBtn.setOnClickListener { presenter.nextEpisode() }
|
binding.nextBtn.setOnClickListener {
|
||||||
binding.prevBtn.setOnClickListener { presenter.previousEpisode() }
|
val wasPlayerPaused = player.paused
|
||||||
|
player.paused = true
|
||||||
|
showLoadingIndicator(true)
|
||||||
|
presenter.nextEpisode {
|
||||||
|
if (wasPlayerPaused == false) {
|
||||||
|
player.paused = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.prevBtn.setOnClickListener {
|
||||||
|
val wasPlayerPaused = player.paused
|
||||||
|
player.paused = true
|
||||||
|
showLoadingIndicator(true)
|
||||||
|
presenter.previousEpisode {
|
||||||
|
if (wasPlayerPaused == false) {
|
||||||
|
player.paused = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (presenter?.needsInit() == true) {
|
if (presenter?.needsInit() == true) {
|
||||||
val anime = intent.extras!!.getLong("anime", -1)
|
val anime = intent.extras!!.getLong("anime", -1)
|
||||||
|
@ -288,7 +306,6 @@ class PlayerActivity :
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleControls() {
|
fun toggleControls() {
|
||||||
|
|
||||||
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
if (isLocked) {
|
if (isLocked) {
|
||||||
// Hide controls
|
// Hide controls
|
||||||
|
@ -307,6 +324,12 @@ class PlayerActivity :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showLoadingIndicator(visible: Boolean) {
|
||||||
|
if (binding.loadingIndicator.isVisible == visible) return
|
||||||
|
binding.playBtn.isVisible = !visible
|
||||||
|
binding.loadingIndicator.isVisible = visible
|
||||||
|
}
|
||||||
|
|
||||||
private fun pickAudio() {
|
private fun pickAudio() {
|
||||||
val restore = pauseForDialog()
|
val restore = pauseForDialog()
|
||||||
|
|
||||||
|
@ -397,16 +420,15 @@ class PlayerActivity :
|
||||||
val picker = SpeedPickerDialog()
|
val picker = SpeedPickerDialog()
|
||||||
|
|
||||||
val restore = pauseForDialog()
|
val restore = pauseForDialog()
|
||||||
genericPickerDialog(picker, R.string.title_speed_dialog, "speed") {
|
speedPickerDialog(picker, R.string.title_speed_dialog) {
|
||||||
updateSpeedButton()
|
updateSpeedButton()
|
||||||
restore()
|
restore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun genericPickerDialog(
|
private fun speedPickerDialog(
|
||||||
picker: PickerDialog,
|
picker: PickerDialog,
|
||||||
@StringRes titleRes: Int,
|
@StringRes titleRes: Int,
|
||||||
property: String,
|
|
||||||
restoreState: StateRestoreCallback
|
restoreState: StateRestoreCallback
|
||||||
) {
|
) {
|
||||||
val dialog = with(AlertDialog.Builder(this)) {
|
val dialog = with(AlertDialog.Builder(this)) {
|
||||||
|
@ -415,9 +437,9 @@ class PlayerActivity :
|
||||||
setPositiveButton(R.string.dialog_ok) { _, _ ->
|
setPositiveButton(R.string.dialog_ok) { _, _ ->
|
||||||
picker.number?.let {
|
picker.number?.let {
|
||||||
if (picker.isInteger()) {
|
if (picker.isInteger()) {
|
||||||
MPVLib.setPropertyInt(property, it.toInt())
|
MPVLib.setPropertyInt("speed", it.toInt())
|
||||||
} else {
|
} else {
|
||||||
MPVLib.setPropertyDouble(property, it)
|
MPVLib.setPropertyDouble("speed", it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +448,7 @@ class PlayerActivity :
|
||||||
create()
|
create()
|
||||||
}
|
}
|
||||||
|
|
||||||
picker.number = MPVLib.getPropertyDouble(property)
|
picker.number = MPVLib.getPropertyDouble("speed")
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,6 +814,7 @@ class PlayerActivity :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fileLoaded() {
|
private fun fileLoaded() {
|
||||||
|
launchUI { showLoadingIndicator(false) }
|
||||||
clearTracks()
|
clearTracks()
|
||||||
player.loadTracks()
|
player.loadTracks()
|
||||||
subTracks += player.tracks.getValue("sub")
|
subTracks += player.tracks.getValue("sub")
|
||||||
|
|
|
@ -185,7 +185,7 @@ class PlayerPresenter(
|
||||||
return source is AnimeHttpSource && !EpisodeLoader.isDownloaded(currentEpisode, anime)
|
return source is AnimeHttpSource && !EpisodeLoader.isDownloaded(currentEpisode, anime)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextEpisode() {
|
fun nextEpisode(callback: () -> Unit) {
|
||||||
val anime = anime ?: return
|
val anime = anime ?: return
|
||||||
val source = sourceManager.getOrStub(anime.source)
|
val source = sourceManager.getOrStub(anime.source)
|
||||||
|
|
||||||
|
@ -200,6 +200,7 @@ class PlayerPresenter(
|
||||||
{ activity, it ->
|
{ activity, it ->
|
||||||
currentVideoList = it
|
currentVideoList = it
|
||||||
activity.setVideoList(it)
|
activity.setVideoList(it)
|
||||||
|
callback()
|
||||||
},
|
},
|
||||||
PlayerActivity::setInitialEpisodeError
|
PlayerActivity::setInitialEpisodeError
|
||||||
)
|
)
|
||||||
|
@ -209,7 +210,7 @@ class PlayerPresenter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun previousEpisode() {
|
fun previousEpisode(callback: () -> Unit) {
|
||||||
val anime = anime ?: return
|
val anime = anime ?: return
|
||||||
val source = sourceManager.getOrStub(anime.source)
|
val source = sourceManager.getOrStub(anime.source)
|
||||||
|
|
||||||
|
@ -224,6 +225,7 @@ class PlayerPresenter(
|
||||||
{ activity, it ->
|
{ activity, it ->
|
||||||
currentVideoList = it
|
currentVideoList = it
|
||||||
activity.setVideoList(it)
|
activity.setVideoList(it)
|
||||||
|
callback()
|
||||||
},
|
},
|
||||||
PlayerActivity::setInitialEpisodeError
|
PlayerActivity::setInitialEpisodeError
|
||||||
)
|
)
|
||||||
|
|
|
@ -176,25 +176,25 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/controls_bottom"
|
android:id="@+id/controls_bottom"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/playBtn"
|
android:id="@+id/play_btn"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="Play/Pause"
|
android:contentDescription="Play/Pause"
|
||||||
android:maxWidth="50dp"
|
|
||||||
android:maxHeight="50dp"
|
|
||||||
android:onClick="playPause"
|
android:onClick="playPause"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
|
android:visibility="gone"
|
||||||
app:tint="?attr/colorOnPrimarySurface"
|
app:tint="?attr/colorOnPrimarySurface"
|
||||||
tools:src="@drawable/ic_play_arrow_100dp" />
|
tools:src="@drawable/ic_play_arrow_100dp"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -352,6 +352,15 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||||
|
android:id="@+id/loading_indicator"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="true"
|
||||||
|
app:indicatorColor="?attr/colorAccent"
|
||||||
|
app:indicatorSize="65dp" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gestureTextView"
|
android:id="@+id/gestureTextView"
|
||||||
|
|
Loading…
Reference in a new issue