Package tvbrowser.core

Examples of tvbrowser.core.TvDataBase


   * @param date The date when the program is shown.
   * @param progID The ID of the program.
   * @return The program or <code>null</code> if there is no such program.
   */
  public Program getProgram(Date date, String progID) {
    TvDataBase db = TvDataBase.getInstance();
   
    Channel ch = getChannelFromProgId(progID);
    if (ch != null && ChannelList.isSubscribedChannel(ch)) {
      int index = progID.lastIndexOf('_');
      String timeString = progID.substring(index + 1);
      int hourIndex = timeString.indexOf(':');
      int offsetIndex = timeString.lastIndexOf(':');

      if(hourIndex != offsetIndex) {
        int timeZoneOffset = Integer.parseInt(timeString.substring(offsetIndex + 1));
        int currentTimeZoneOffset = TimeZone.getDefault().getRawOffset()/60000;
       
        if(timeZoneOffset != currentTimeZoneOffset) {
          String[] hourMinute = timeString.split(":");
          int timeZoneDiff = currentTimeZoneOffset - timeZoneOffset;
         
          int hour = Integer.parseInt(hourMinute[0]) + (timeZoneDiff/60);
          int minute = Integer.parseInt(hourMinute[1]) + (timeZoneDiff%60);
         
          if(hour >= 24) {
            hour -= 24;
            date = date.addDays(1);
          }
          else if(hour < 0) {
            hour += 24;
            date = date.addDays(-1);
          }
         
          hourMinute[0] = String.valueOf(hour);
          hourMinute[1] = String.valueOf(minute);
          hourMinute[2] = String.valueOf(currentTimeZoneOffset);
         
          StringBuilder newId = new StringBuilder(progID.substring(0, index + 1));
          newId.append(hourMinute[0]).append(":").append(hourMinute[1]).append(":").append(hourMinute[2]);
         
          progID = newId.toString();
        }
      }
      else {
        String[] hourMinute = timeString.split(":");
        StringBuilder newId = new StringBuilder(progID.substring(0, index + 1));
        newId.append(hourMinute[0]).append(":").append(hourMinute[1]).append(":").append(TimeZone.getDefault().getRawOffset()/60000);
       
        progID = newId.toString();
      }
     
      if(ch.getTimeZone().getRawOffset() != TimeZone.getDefault().getRawOffset()) {
        String[] hourMinute = timeString.split(":");
        int milliSeconds = Integer.parseInt(hourMinute[0]) * 60 * 60 * 1000 + Integer.parseInt(hourMinute[1]) * 60 * 1000;

        int diff = Math.abs(ch.getTimeZone().getRawOffset() - TimeZone.getDefault().getRawOffset());
       
        if(ch.getTimeZone().getRawOffset() < TimeZone.getDefault().getRawOffset()) {
          if(milliSeconds < diff) {
            date = date.addDays(-1);
          }
        }
        else if(milliSeconds + diff >= 86400 * 1000) {
          date = date.addDays(1);
        }
      }
     
      ChannelDayProgram dayProg = db.getDayProgram(date, ch);
     
      if (dayProg != null) {
        Program prog = dayProg.getProgram(progID);
        if (prog != null) {
          return prog;
View Full Code Here


   
    checkThread();
    mOnAirRows = null;
    deregisterFromPrograms(mProgramColumn);

    TvDataBase db = TvDataBase.getInstance();

    if (monitor != null) {
      monitor.setMaximum(mChannelArr.length - 1);
      monitor.setValue(0);
    }

    Date nextDay = mMainDay.addDays(1);
    for (int i = 0; i < mChannelArr.length; i++) {
      mProgramColumn[i].clear();
      DateRange dateRange = mDateRangeForChannel.get(mChannelArr[i]);
      ChannelDayProgram[] cdp = new ChannelDayProgram[dateRange.getCount()];

      for (int d = 0; d<cdp.length; d++) {
        cdp[d] = db.getDayProgram(mMainDay.addDays(dateRange.getBegin() + d), mChannelArr[i]);
      }
      addChannelDayProgram(i, cdp, mMainDay, mTodayEarliestTime, nextDay, mTomorrowLatestTime);

      if (monitor != null) {
        monitor.setValue(i);
View Full Code Here

TOP

Related Classes of tvbrowser.core.TvDataBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.