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
private fun onSecondaryActionPressed(action: Action) { | |
val adapter = controlsRow.secondaryActionsAdapter as? ArrayObjectAdapter ?: return | |
if (action is PlaybackControlsRow.MultiAction) { | |
action.nextIndex() | |
notifyItemChanged(adapter, action) | |
} | |
when (action) { | |
shuffleAction -> { | |
playerAdapter.setShuffleAction(shuffleAction.index) | |
if (shuffleAction.index == PlaybackControlsRow.ShuffleAction.INDEX_ON) { |
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
private fun onSecondaryActionPressed(action: Action) { | |
val adapter = controlsRow.secondaryActionsAdapter as? ArrayObjectAdapter ?: return | |
if (action is PlaybackControlsRow.MultiAction) { | |
action.nextIndex() | |
notifyItemChanged(adapter, action) | |
} | |
when (action) { | |
shuffleAction -> { | |
playerAdapter.setShuffleAction(shuffleAction.index) | |
if (shuffleAction.index == PlaybackControlsRow.ShuffleAction.INDEX_ON) { |
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
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
if (savedInstanceState == null) { | |
(adapter.presenterSelector as ClassPresenterSelector) | |
.addClassPresenter(ListRow::class.java, ListRowPresenter()) | |
upNextAdapter = ArrayObjectAdapter(CardPresenter()) | |
val upNextRow = ListRow(1L, HeaderItem("Up Next"), upNextAdapter) | |
(adapter as ArrayObjectAdapter).add(upNextRow) | |
} | |
... |
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
setOnItemViewClickedListener { _, item, _, row -> | |
if (row is ListRow && row.adapter == upNextAdapter) { | |
val movie = item as Movie | |
val movieIndexInPlaylist = transportControlGlue.getPlaylist().indexOf(movie) | |
transportControlGlue.loadMovie(movieIndexInPlaylist) | |
} | |
} |
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
<receiver | |
android:name=".InitProgramsBroadcastReceiver" | |
android:exported="true"> | |
<intent-filter> | |
<action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter> | |
</receiver> |
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
val existingChannel = queryChannels().firstOrNull { | |
it.internalProviderId == category.id.toString() | |
} | |
val channelBuilder = when (existingChannel) { | |
null -> Channel.Builder() | |
else -> Channel.Builder(existingChannel) | |
} | |
val channel = channelBuilder | |
.setType(TvContractCompat.Channels.TYPE_PREVIEW) | |
.setDisplayName(category.title) |
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
when (existingChannel) { | |
null -> context.contentResolver.insert( | |
TvContractCompat.Channels.CONTENT_URI, | |
channel.toContentValues() | |
) | |
else -> context.contentResolver.update( | |
TvContractCompat.Channels.CONTENT_URI, | |
channel.toContentValues(), | |
null, | |
null |
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
try { | |
val intent = Intent(TvContractCompat.ACTION_REQUEST_CHANNEL_BROWSABLE) | |
intent.putExtra(TvContractCompat.EXTRA_CHANNEL_ID, channelId) | |
startActivityForResult(intent, REQUEST_CHANNEL_BROWSABLE) | |
} catch (exception: ActivityNotFoundException) { | |
// Handle exception | |
} |
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
class InitChannelsBroadcastReceiver : BroadcastReceiver() { | |
override fun onReceive(context: Context, intent: Intent?) { | |
if (defaultChannelAlreadyAdded) { | |
// Make sure we are not trying to re-create the channel if it's already added. | |
// You can save this on your shared preferences or database. | |
return | |
} | |
val channelHelper = PreviewChannelHelper(context) | |
val channel = Channel.Builder() | |
.setType(TvContractCompat.Channels.TYPE_PREVIEW) |
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
public static final String[] PROJECTION = { | |
Channels._ID, | |
Channels.COLUMN_PACKAGE_NAME, | |
Channels.COLUMN_TYPE, | |
Channels.COLUMN_DISPLAY_NAME, | |
Channels.COLUMN_DESCRIPTION, | |
Channels.COLUMN_APP_LINK_INTENT_URI, | |
Channels.COLUMN_INTERNAL_PROVIDER_ID, | |
Channels.COLUMN_INTERNAL_PROVIDER_DATA, | |
Channels.COLUMN_INTERNAL_PROVIDER_FLAG1, |