android.database.CursorIndexOutOfBoundsException#com.google.android.media.tv.companionlibrary.model.Channel源码实例Demo

下面列出了android.database.CursorIndexOutOfBoundsException#com.google.android.media.tv.companionlibrary.model.Channel 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xipl   文件: XmlTvParser.java
private static TvListing parseTvListings(XmlPullParser parser)
        throws IOException, XmlPullParserException, ParseException {
    List<Channel> channels = new ArrayList<>();
    List<Program> programs = new ArrayList<>();
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) {
            Channel channel = parseChannel(parser);
            if (channel != null) {
                channels.add(channel);
            }
        }
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) {
            Program program = parseProgram(parser);
            if (program != null) {
                programs.add(program);
            }
        }
    }
    return new TvListing(channels, programs);
}
 
源代码2 项目: xipl   文件: XmlTvParser.java
private TvListing(List<Channel> channels, List<Program> programs) {
    this.mChannels = channels;
    this.mPrograms = new ArrayList<>(programs);
    // Place programs into the epg map
    mProgramMap = new HashMap<>();
    for (Channel channel : channels) {
        List<Program> programsForChannel = new ArrayList<>();
        Iterator<Program> programIterator = programs.iterator();
        while (programIterator.hasNext()) {
            Program program = programIterator.next();
            if (program.getChannelId() == channel.getOriginalNetworkId()) {
                programsForChannel.add(
                        new Program.Builder(program).setChannelId(channel.getId()).build());
                programIterator.remove();
            }
        }
        // Don't overwrite a channel's programs list if a key was already existent
        if (!mProgramMap.containsKey(channel.getOriginalNetworkId())) {
            mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel);
        }
    }
}
 
源代码3 项目: xipl   文件: EpgSyncJobServiceTest.java
@Test
public void testChannelsProgramSync() {
    // Tests that programs and channels were correctly obtained from the EpgSyncJobService
    Uri channelUri =  TvContract.buildChannelUri(mChannelMap.keyAt(0));
    Channel firstChannel = mChannelList.get(0);
    assertEquals("Test Channel", firstChannel.getDisplayName());
    assertNotNull(firstChannel.getInternalProviderData());
    assertTrue(firstChannel.getInternalProviderData().isRepeatable());

    mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs,
            mEndMs);
    assertEquals(1, mProgramList.size());

    channelUri =  TvContract.buildChannelUri(mChannelMap.keyAt(1));
    Channel secondChannel = mChannelList.get(1);
    assertEquals("XML Test Channel", secondChannel.getDisplayName());
    assertNotNull(secondChannel.getInternalProviderData());
    assertTrue(secondChannel.getInternalProviderData().isRepeatable());

    mProgramList = mSampleJobService.getProgramsForChannel(channelUri, secondChannel, mStartMs,
            mEndMs);
    assertEquals(5, mProgramList.size());
}
 
源代码4 项目: xipl   文件: EpgSyncJobServiceTest.java
@Test
public void testRequestSync() throws InterruptedException {
    // Tests that a sync can be requested and complete
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
            mSyncStatusChangedReceiver,
            new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED));
    mSyncStatusLatch = new CountDownLatch(2);
    EpgSyncJobService.cancelAllSyncRequests(getActivity());
    EpgSyncJobService.requestImmediateSync(getActivity(), TestTvInputService.INPUT_ID,
            1000 * 60 * 60, // 1 hour sync period
            new ComponentName(getActivity(), TestJobService.class));
    mSyncStatusLatch.await();

    // Sync is completed
    List<Channel> channelList = ModelUtils.getChannels(getActivity().getContentResolver());
    Log.d("TvContractUtils", channelList.toString());
    assertEquals(2, channelList.size());
    List<Program> programList = ModelUtils.getPrograms(getActivity().getContentResolver(),
            TvContract.buildChannelUri(channelList.get(0).getId()));
    assertEquals(5, programList.size());
}
 
源代码5 项目: xipl   文件: ProviderTvInputService.java
@Override
public void onPlayChannel(Channel channel) {
    if (channel.getInternalProviderData() !=  null) {
        mProviderTvPlayer = new ProviderTvPlayer(mContext, channel.getInternalProviderData().getVideoUrl());
        mProviderTvPlayer.addListener(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            notifyTimeShiftStatusChanged(TvInputManager.TIME_SHIFT_STATUS_UNSUPPORTED);
        }

        if (DEBUG) {
            Log.d(getClass().getSimpleName(), "Video Url: " + channel.getInternalProviderData().getVideoUrl());
            Log.d(getClass().getSimpleName(), "Video format: " + channel.getVideoFormat());
        }

        // Notify when the video is available so the channel surface can be shown to the screen.
        mProviderTvPlayer.play();
    } else {
        Toast.makeText(mContext, R.string.channel_stream_failure, Toast.LENGTH_SHORT).show();
    }
}
 
源代码6 项目: CumulusTV   文件: CumulusXmlParser.java
private static TvListing parseTvListings(XmlPullParser parser)
        throws IOException, XmlPullParserException, ParseException {
    List<Channel> channels = new ArrayList<>();
    List<Program> programs = new ArrayList<>();
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) {
            channels.add(parseChannel(parser));
        }
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) {
            programs.add(parseProgram(parser));
        }
    }
    return new TvListing(channels, programs);
}
 
源代码7 项目: CumulusTV   文件: CumulusXmlParser.java
private TvListing(List<Channel> channels, List<Program> programs) {
    this.mChannels = channels;
    this.mPrograms = new ArrayList<>(programs);
    // Place programs into the epg map
    mProgramMap = new HashMap<>();
    for (Channel channel: channels) {
        List<Program> programsForChannel = new ArrayList<>();
        Iterator<Program> programIterator = programs.iterator();
        while (programIterator.hasNext()) {
            Program program = programIterator.next();
            if (program.getChannelId() == channel.getOriginalNetworkId()) {
                programsForChannel.add(new Program.Builder(program)
                        .setChannelId(channel.getId())
                        .build());
                programIterator.remove();
            }
        }
        mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel);
    }
}
 
源代码8 项目: CumulusTV   文件: CumulusBrowseService.java
@Override
public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result) {
    List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
    ChannelDatabase channelDatabase = ChannelDatabase.getInstance(getApplicationContext());
    if (parentId.equals(MEDIA_ROOT_ID)) {
        try {
            for (Channel channel : channelDatabase.getChannels()) {
                MediaDescriptionCompat descriptionCompat = new MediaDescriptionCompat.Builder()
                        .setMediaId(channel.getInternalProviderData().getVideoUrl())
                        .setTitle(channel.getDisplayName())
                        .setIconUri(Uri.parse(channel.getChannelLogo()))
                        .setSubtitle(getString(R.string.channel_no_xxx, channel.getDisplayNumber()))
                        .setDescription(channel.getDescription())
                        .setMediaUri(Uri.parse(channel.getInternalProviderData().getVideoUrl()))
                        .build();
                mediaItems.add(new MediaBrowserCompat.MediaItem(descriptionCompat,
                        MediaBrowserCompat.MediaItem.FLAG_PLAYABLE));
            }
            result.sendResult(mediaItems);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
 
源代码9 项目: CumulusTV   文件: JsonChannelUnitTest.java
/**
 * Tests that we can use the .toChannel method to successfully create a channel object.
 */
@Test
public void testSuccessfulChannelConversion() {
    JsonChannel jsonChannel = new JsonChannel.Builder()
            .setAudioOnly(AUDIO_ONLY)
            .setEpgUrl(EPG_URL)
            .setGenres(GENRES)
            .setLogo(LOGO)
            .setMediaUrl(MEDIA_URL)
            .setName(NAME)
            .setNumber(NUMBER)
            .setSplashscreen(SPLASHSCREEN)
            .build();
    Channel channel = jsonChannel.toChannel();
    assertEquals(channel.getDisplayName(), jsonChannel.getName());
}
 
源代码10 项目: androidtv-sample-inputs   文件: XmlTvParser.java
private static TvListing parseTvListings(XmlPullParser parser)
        throws IOException, XmlPullParserException, ParseException {
    List<Channel> channels = new ArrayList<>();
    List<Program> programs = new ArrayList<>();
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) {
            channels.add(parseChannel(parser));
        }
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) {
            programs.add(parseProgram(parser));
        }
    }
    return new TvListing(channels, programs);
}
 
源代码11 项目: androidtv-sample-inputs   文件: XmlTvParser.java
private TvListing(List<Channel> channels, List<Program> programs) {
    this.mChannels = channels;
    this.mPrograms = new ArrayList<>(programs);
    // Place programs into the epg map
    mProgramMap = new HashMap<>();
    for (Channel channel : channels) {
        List<Program> programsForChannel = new ArrayList<>();
        Iterator<Program> programIterator = programs.iterator();
        while (programIterator.hasNext()) {
            Program program = programIterator.next();
            if (program.getChannelId() == channel.getOriginalNetworkId()) {
                programsForChannel.add(
                        new Program.Builder(program).setChannelId(channel.getId()).build());
                programIterator.remove();
            }
        }
        mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel);
    }
}
 
@Test
public void testOriginalChannelsProgramSync() throws EpgSyncException {
    // Tests that programs and channels were correctly obtained from the EpgSyncJobService
    Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0));
    Channel firstChannel = mChannelList.get(0);
    assertEquals("Test Channel", firstChannel.getDisplayName());
    assertNotNull(firstChannel.getInternalProviderData());
    assertTrue(firstChannel.getInternalProviderData().isRepeatable());

    mProgramList =
            mSampleJobService.getOriginalProgramsForChannel(
                    channelUri, firstChannel, mStartMs, mEndMs);
    assertEquals(1, mProgramList.size());

    channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(1));
    Channel secondChannel = mChannelList.get(1);
    assertEquals("XML Test Channel", secondChannel.getDisplayName());
    assertNotNull(secondChannel.getInternalProviderData());
    assertTrue(secondChannel.getInternalProviderData().isRepeatable());

    mProgramList =
            mSampleJobService.getOriginalProgramsForChannel(
                    channelUri, secondChannel, mStartMs, mEndMs);
    assertEquals(5, mProgramList.size());
}
 
@Test
public void testRequestSync() throws InterruptedException {
    // Tests that a sync can be requested and complete
    LocalBroadcastManager.getInstance(getActivity())
            .registerReceiver(
                    mSyncStatusChangedReceiver,
                    new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED));
    mSyncStatusLatch = new CountDownLatch(2);
    EpgSyncJobService.cancelAllSyncRequests(getActivity());
    EpgSyncJobService.requestImmediateSync(
            getActivity(),
            TestTvInputService.INPUT_ID,
            1000 * 60 * 60, // 1 hour sync period
            new ComponentName(getActivity(), TestJobService.class));
    mSyncStatusLatch.await();

    // Sync is completed
    List<Channel> channelList = ModelUtils.getChannels(getActivity().getContentResolver());
    Log.d("TvContractUtils", channelList.toString());
    assertEquals(2, channelList.size());
    List<Program> programList =
            ModelUtils.getPrograms(
                    getActivity().getContentResolver(),
                    TvContract.buildChannelUri(channelList.get(0).getId()));
    assertEquals(5, programList.size());
}
 
源代码14 项目: xipl   文件: EpgSyncWithAdsJobService.java
/**
 * Calls {@link #getOriginalProgramsForChannel(Uri, Channel, long, long)} and then repeats and
 * inserts ads as needed.
 */
@Override
public final List<Program> getProgramsForChannel(
        Uri channelUri, Channel channel, long startMs, long endMs) throws EpgSyncException {
    return repeatAndInsertAds(
            channel,
            getOriginalProgramsForChannel(channelUri, channel, startMs, endMs),
            startMs,
            endMs);
}
 
源代码15 项目: xipl   文件: TestTvInputService.java
@Override
public void onStopRecordingChannel(Channel channelToRecord) {
    mIsRecording = false;
    // Add a sample program into our DVR
    notifyRecordingStopped(new RecordedProgram.Builder()
            .setInputId(mInputId)
            .setTitle("That Gmail Blue Video")
            .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL)
            .setStartTimeUtcMillis(System.currentTimeMillis())
            .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60)
            .build());
}
 
源代码16 项目: xipl   文件: EpgSyncJobServiceTest.java
@Override
public void beforeActivityLaunched() {
    super.beforeActivityLaunched();
    getActivity();
    // Delete all channels
    getActivity().getContentResolver().delete(TvContract.buildChannelsUriForInput(
            TestTvInputService.INPUT_ID), null, null);

    mSampleJobService = new TestJobService();
    mSampleJobService.mContext = getActivity();
    mChannelList = mSampleJobService.getChannels();
    ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, mChannelList, null);
    mChannelMap = ModelUtils.buildChannelMap(getActivity().getContentResolver(),
            TestTvInputService.INPUT_ID);
    assertNotNull(mChannelMap);
    assertEquals(2, mChannelMap.size());

    // Round start time to the current hour
    mStartMs = System.currentTimeMillis() - System.currentTimeMillis() % (1000 * 60 * 60);
    mEndMs = mStartMs + 1000 * 60 * 60 * 24 * 7 * 2; // Two week long sync period
    assertTrue(mStartMs < mEndMs);

    Uri channelUri =  TvContract.buildChannelUri(mChannelMap.keyAt(0));
    Channel firstChannel = mChannelList.get(0);
    assertEquals("Test Channel", firstChannel.getDisplayName());
    assertNotNull(firstChannel.getInternalProviderData());
    assertTrue(firstChannel.getInternalProviderData().isRepeatable());

    mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs,
            mEndMs);
}
 
源代码17 项目: xipl   文件: EpgSyncJobServiceTest.java
@Test
public void testJobService() {
    // Tests whether methods to get channels and programs are successful and valid
    List<Channel> channelList = mSampleJobService.getChannels();
    assertEquals(2, channelList.size());
    ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, channelList, null);
    LongSparseArray<Channel> channelMap = ModelUtils.buildChannelMap(
            getActivity().getContentResolver(), TestTvInputService.INPUT_ID);
    assertNotNull(channelMap);
    assertEquals(channelMap.size(), channelList.size());
}
 
源代码18 项目: xipl   文件: EpgSyncJobServiceTest.java
@Test
public void testEpgSyncTask_GetPrograms() {
    // For repeating channels, test that the program list will continually repeat for the
    // desired length of time
    Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0));
    Channel firstChannel = mChannelList.get(0);
    TestJobService.TestEpgSyncTask epgSyncTask = mSampleJobService.getDefaultEpgSyncTask();
    mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs,
            mEndMs);
    List<Program> continuousProgramsList = epgSyncTask.getPrograms(
            firstChannel, mProgramList, mStartMs, mEndMs);
    // There are 336 hours in a two week period, and each program is 15m long
    assertEquals(336 * 60 / 15, continuousProgramsList.size());
}
 
源代码19 项目: xipl   文件: TestJobService.java
@Override
public List<Channel> getChannels() {
    Assert.assertNotNull("Please set the static mContext before running", mContext);
    // Wrap our list in an ArrayList so we will be able to make modifications if necessary
    Assert.assertNotNull("Set TestJobService.mContext.", mContext);
    InternalProviderData internalProviderData = new InternalProviderData();
    internalProviderData.setRepeatable(true);
    ArrayList<Channel> testChannels = new ArrayList<>();
    testChannels.add(new Channel.Builder()
            .setOriginalNetworkId(0)
            .setDisplayName("Test Channel")
            .setDisplayNumber("1")
            .setInternalProviderData(internalProviderData)
            .build());

    // Add an XML parsed channel
    Uri xmlUri = Uri.parse("android.resource://" + mContext.getPackageName()
            + "/" + com.google.android.media.tv.companionlibrary.test.R.raw.xmltv)
            .normalizeScheme();
    try {
        InputStream inputStream = mContext.getContentResolver()
                .openInputStream(xmlUri);
        Assert.assertNotNull(inputStream);
        testChannels.addAll(XmlTvParser.parse(inputStream).getChannels());
    } catch (FileNotFoundException | XmlTvParser.XmlTvParseException e) {
        throw new RuntimeException("Exception found of type " + e.getClass().getCanonicalName()
                + ": " + e.getMessage());
    }

    return testChannels;
}
 
源代码20 项目: xipl   文件: XmlTvAdvertisementTest.java
@Test
public void testAdvertisementParsing() throws XmlTvParser.XmlTvParseException, ParseException {
    long epochStartTime = 0;
    String requestUrl1 = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480" +
            "&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s" +
            "&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1" +
            "&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=";
    String requestUrl2 = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480" +
            "&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s" +
            "&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1" +
            "&cust_params=deployment%3Ddevsite%26sample_ct%3Dredirectlinear&correlator=";
    String testXmlFile = "xmltv.xml";
    InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(testXmlFile);
    XmlTvParser.TvListing listings = XmlTvParser.parse(inputStream);
    // Channel 1 should have one VAST advertisement.
    Channel adChannel = listings.getChannels().get(1);
    assertNotNull(adChannel.getInternalProviderData());
    List<Advertisement> adChannelAds = adChannel.getInternalProviderData().getAds();
    assertEquals(1, adChannelAds.size());
    assertEquals(epochStartTime, adChannelAds.get(0).getStartTimeUtcMillis());
    assertEquals(epochStartTime, adChannelAds.get(0).getStopTimeUtcMillis());
    assertEquals(Advertisement.TYPE_VAST, adChannelAds.get(0).getType());
    // Channel 0 should not have any advertisement.
    Channel noAdChannel = listings.getChannels().get(0);
    assertNotNull(noAdChannel.getInternalProviderData());
    List<Advertisement> noAdChannelAds = noAdChannel.getInternalProviderData().getAds();
    assertEquals(0, noAdChannelAds.size());
    // Program 7 should have 2 advertisements with different request tags.
    Program adProgram = listings.getAllPrograms().get(7);
    assertNotNull(adProgram.getInternalProviderData());
    InternalProviderData adProgramData = adProgram.getInternalProviderData();
    List<Advertisement> adProgramAds = adProgramData.getAds();
    assertEquals(2, adProgramAds.size());
    assertEquals(requestUrl1, adProgramAds.get(0).getRequestUrl());
    assertEquals(requestUrl2, adProgramAds.get(1).getRequestUrl());
}
 
源代码21 项目: xipl   文件: ProviderEpgService.java
@Override
public void onProcessSuccess(List<Channel> channels, XmlTvParser.TvListing listing) {
    mChannels = channels;
    mTvListing = listing;
    EpgSyncTask epgSyncTask = new EpgSyncTask(mJobParameters);
    epgSyncTask.execute();
}
 
源代码22 项目: xipl   文件: ProviderChannelUtil.java
/**
 * Gets a list of channels based on the M3U playlist of a given user.
 *
 * @param playlist List of the playlist lines containing the user's channels
 * @param context  the context required for some other operations (Getting the genre for example)
 * @return the list of channels for a given user
 */
public static List<Channel> createChannelList(InputStream playlist, Context context, ChannelProperties properties) {

    List<AvContent> channelContents = AvContentUtil.getAvContentsList(playlist);
    List<Channel> tempList = new ArrayList<>();
    int channelNumber = 1;

    /*
     Google is kind of "weird" when it comes to the way it has of tuning channel/program
     data. In most cases, the TIF expects to have a program available for each channels in order
     to play them.

     However, a provider might not have all programs available for a given channel so simply save the EPG
     id and leave the parsing to when programs will get created.
     */

    for (int i = 0; i < channelContents.size(); i++) {
        Channel channel;
        String tempName = channelContents.get(i).getTitle();
        String tempLogo = channelContents.get(i).getLogo();
        String tempLink = channelContents.get(i).getContentLink();
        String tempGroup = channelContents.get(i).getGroup();
        int tempId = channelContents.get(i).getId();

        if (properties.hasChannelLogo()) {
            channel = createChannel(tempName, Integer.toString(i + 1), tempId, tempLogo, tempLink, tempGroup, getProgramGenre(tempName, context));
        } else {
            channel = createChannel(tempName, Integer.toString(i + 1), tempId, null, tempLink, tempGroup, getProgramGenre(tempName, context));
        }

        // Some users might have playlist items that aren't valid channels, remove them.
        if (properties.isLiveChannel(channel) && properties.isChannelRegionValid(channel) && properties.isChannelGenreValid(channel) && properties.isChannelGroupValid(channel)) {
            // Some channels might get filtered so let's use a counter which will only register "valid" ones.
            channel = createChannel(channel, Integer.toString(channelNumber));
            tempList.add(channel);
            channelNumber++;
        }
    }
    return (tempList);
}
 
源代码23 项目: xipl   文件: ProviderChannelUtil.java
/**
 * Creates a {@link Channel} that can be used by the Android TV framework and the Live Channels application.
 *
 * @param displayName   the display name of the channel
 * @param displayNumber the display number of the channel
 * @param epgId         the id as defined in {@link com.google.android.media.tv.companionlibrary.xmltv.XmlTvParser}
 * @param logo          the logo url link
 * @param url           the video url link
 * @return the channel to be used by the system.
 */
private static Channel createChannel(String displayName, String displayNumber, int epgId, String logo, String url, String group, String[] genres) {

    /*
     In order to map correctly the programs to a given channel, store the EPG id somewhere in the
     channel so we can retrieve it when we'll need to find programs

     Using the EPG ID as a good way to have an original network id but it might create channel
     duplicates. Since some channels either don't have an EPG id (which makes 0 as a hash) or might
     share the same id altogether, (same channel in SD/HD for example) they get recreated
     as their original id isn't really original anymore...

     In that case, let's use the display name as the original network id instead of the EPG id.
     Let's also retrieve the an example genre for the channel so it can be passed on the side
     of the EPG guide.
    */

    Channel.Builder builder = new Channel.Builder();
    InternalProviderData internalProviderData = new InternalProviderData();

    try {
        JSONArray genresJsonArray = new JSONArray(genres);
        internalProviderData.put(Constants.EPG_ID_PROVIDER, epgId);
        internalProviderData.put(Constants.CHANNEL_GENRES_PROVIDER, genresJsonArray);
    } catch (InternalProviderData.ParseException ps) {
        // Can't do anything about this...
    } catch (JSONException json) {
        json.printStackTrace();
    }

    internalProviderData.setVideoUrl(url);
    builder.setDisplayName(displayName);
    builder.setDisplayNumber(displayNumber);
    builder.setOriginalNetworkId(displayName.hashCode());
    builder.setChannelLogo(logo);
    builder.setNetworkAffiliation(group);
    builder.setInternalProviderData(internalProviderData);
    return (builder.build());
}
 
源代码24 项目: CumulusTV   文件: ChannelDatabase.java
public List<Channel> getChannels() throws JSONException {
    List<JsonChannel> jsonChannelList = getJsonChannels();
    List<Channel> channelList = new ArrayList<>();
    for (int i = 0; i < jsonChannelList.size(); i++) {
        JsonChannel jsonChannel = jsonChannelList.get(i);
        Channel channel = jsonChannel.toChannel();
        channelList.add(channel);
    }
    return channelList;
}
 
源代码25 项目: CumulusTV   文件: ChannelDatabase.java
public List<Channel> getChannels(InternalProviderData providerData) throws JSONException {
    List<JsonChannel> jsonChannelList = getJsonChannels();
    List<Channel> channelList = new ArrayList<>();
    for (int i = 0; i < jsonChannelList.size(); i++) {
        JsonChannel jsonChannel = jsonChannelList.get(i);
        Channel channel = jsonChannel.toChannel(providerData);
        channelList.add(channel);
    }
    return channelList;
}
 
源代码26 项目: CumulusTV   文件: JsonChannel.java
public Channel toChannel() {
    InternalProviderData ipd = new InternalProviderData();
    ipd.setVideoUrl(getMediaUrl());
    ipd.setVideoType(TvContractUtils.SOURCE_TYPE_HLS);
    return new Channel.Builder()
            .setDisplayName(getName())
            .setDisplayNumber(getNumber())
            .setChannelLogo(getLogo())
            .setInternalProviderData(ipd)
            .setOriginalNetworkId(getMediaUrl().hashCode())
            .build();
}
 
源代码27 项目: CumulusTV   文件: JsonChannel.java
public Channel toChannel(InternalProviderData providerData) {
    providerData.setVideoUrl(getMediaUrl());
    // TODO Add app linking
    return new Channel.Builder()
            .setDisplayName(getName())
            .setDisplayNumber(getNumber())
            .setChannelLogo(getLogo())
            .setInternalProviderData(providerData)
            .setOriginalNetworkId(getMediaUrl().hashCode())
            .build();
}
 
源代码28 项目: CumulusTV   文件: CumulusJobService.java
@Override
    public List<Channel> getChannels() {
        // Build advertisement list for the channel.
        Advertisement channelAd = new Advertisement.Builder()
                .setType(Advertisement.TYPE_VAST)
                .setRequestUrl(TEST_AD_REQUEST_URL)
                .build();
        List<Advertisement> channelAdList = new ArrayList<>();
        channelAdList.add(channelAd);

        InternalProviderData ipd = new InternalProviderData();
//        ipd.setAds(channelAdList);
        ipd.setRepeatable(true);
        ipd.setVideoType(TvContractUtils.SOURCE_TYPE_HLS);

        try {
            List<Channel> channels = ChannelDatabase.getInstance(this).getChannels(ipd);
            // Add app linking
            for (int i = 0; i < channels.size(); i++) {
                JsonChannel jsonChannel =
                        ChannelDatabase.getInstance(this).findChannelByMediaUrl(
                                channels.get(i).getInternalProviderData().getVideoUrl());
                Channel channel = new Channel.Builder(channels.get(i))
                    .setAppLinkText(getString(R.string.quick_settings))
                    .setAppLinkIconUri("https://github.com/Fleker/CumulusTV/blob/master/app/src/m" +
                        "ain/res/drawable-xhdpi/ic_play_action_normal.png?raw=true")
                    .setAppLinkPosterArtUri(channels.get(i).getChannelLogo())
                    .setAppLinkIntent(PlaybackQuickSettingsActivity.getIntent(this, jsonChannel))
                    .build();
                Log.d(TAG, "Adding channel " + channel.getDisplayName());
                channels.set(i, channel);
            }
            Log.d(TAG, "Returning with " + channels.size() + " channels");
            return channels;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.w(TAG, "No channels found");
        return null;
    }
 
源代码29 项目: CumulusTV   文件: TifDatabaseIntegrationTest.java
/**
 * Test generating a {@link JsonChannel} and inserting that correctly.
 */
@Test
public void testJsonChannelConverter() {
    JsonChannel jsonChannel = new JsonChannel.Builder()
            .setName("Hello")
            .setMediaUrl(MEDIA_URL)
            .setNumber("1234")
            .build();
    Channel channel = jsonChannel.toChannel();
    // This cannot be done until we update the Channel model.
}
 
源代码30 项目: CumulusTV   文件: VolatileChannelDatabase.java
@Override
public List<Channel> getChannels() throws JSONException {
    List<Channel> channelList = new ArrayList<>();
    for (int i = 0; i < mJsonChannels.size(); i++) {
        JsonChannel jsonChannel = (JsonChannel) mJsonChannels.get(i);
        Channel channel = jsonChannel.toChannel();
        channelList.add(channel);
    }
    return channelList;
}