-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add play all button to all pages with scenes or markers (#385)
Follow up to #381 Closes #20 Adds a `Play All` button to every page that has scenes or scene markers allowing to play them as a playlist. `StashGridFragment` now defaults to showing the sort & play all buttons since that is the desired behavior in every page except in `FilterListActivity` which explicitly turns them off anyway.
- Loading branch information
1 parent
68733fa
commit 62913ef
Showing
5 changed files
with
117 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/github/damontecres/stashapp/views/PlayAllOnClickListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.github.damontecres.stashapp.views | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.view.View | ||
import android.view.View.OnClickListener | ||
import com.github.damontecres.stashapp.data.DataType | ||
import com.github.damontecres.stashapp.data.SortAndDirection | ||
import com.github.damontecres.stashapp.playback.PlaylistActivity | ||
import com.github.damontecres.stashapp.playback.PlaylistMarkersFragment | ||
import com.github.damontecres.stashapp.suppliers.FilterArgs | ||
|
||
class PlayAllOnClickListener( | ||
private val context: Context, | ||
private val dataType: DataType, | ||
private val getFilter: () -> FilterArgs, | ||
) : OnClickListener { | ||
override fun onClick(v: View) { | ||
when (dataType) { | ||
DataType.MARKER -> { | ||
showSimpleListPopupWindow(v, listOf("15 seconds", "20 seconds", "30 seconds", "60 seconds")) { | ||
val duration = | ||
when (it) { | ||
0 -> 15_000L | ||
1 -> 20_000L | ||
2 -> 30_000L | ||
3 -> 60_000L | ||
else -> 30_000L | ||
} | ||
val intent = Intent(context, PlaylistActivity::class.java) | ||
intent.putExtra(PlaylistActivity.INTENT_FILTER, getFilter()) | ||
intent.putExtra(PlaylistMarkersFragment.INTENT_DURATION_ID, duration) | ||
context.startActivity(intent) | ||
} | ||
} | ||
|
||
DataType.SCENE -> { | ||
showSimpleListPopupWindow(v, listOf("In order", "Shuffle")) { | ||
val filter = | ||
when (it) { | ||
0 -> getFilter() | ||
1 -> getFilter().with(SortAndDirection.random()) | ||
else -> throw IllegalStateException("$it") | ||
} | ||
val intent = Intent(context, PlaylistActivity::class.java) | ||
intent.putExtra(PlaylistActivity.INTENT_FILTER, filter) | ||
context.startActivity(intent) | ||
} | ||
} | ||
|
||
else -> throw UnsupportedOperationException("DataType $dataType") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters