/**
  * Cursor to timer.
  *
  * @param c the c
  * @return the timerĀ“
  * @author RayBa
  * @date 07.04.2013
  */
 private Timer cursorToTimer(Cursor c) {
   String name = c.getString(c.getColumnIndex(ChannelTbl.NAME));
   long channelID = c.getLong(c.getColumnIndex(ChannelTbl.CHANNEL_ID));
   String epgTitle =
       !c.isNull(c.getColumnIndex(EpgTbl.TITLE))
           ? c.getString(c.getColumnIndex(EpgTbl.TITLE))
           : name;
   long epgStart = c.getLong(c.getColumnIndex(EpgTbl.START));
   long epgEnd = c.getLong(c.getColumnIndex(EpgTbl.END));
   DVBViewerPreferences prefs = new DVBViewerPreferences(getSherlockActivity());
   int epgBefore = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_BEFORE, 5);
   int epgAfter = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_AFTER, 5);
   Date start = epgStart > 0 ? new Date(epgStart) : new Date();
   Date end = epgEnd > 0 ? new Date(epgEnd) : new Date(start.getTime() + (1000 * 60 * 120));
   Log.i(ChannelList.class.getSimpleName(), "start: " + start.toString());
   Log.i(ChannelList.class.getSimpleName(), "end: " + end.toString());
   start = DateUtils.addMinutes(start, 0 - epgBefore);
   end = DateUtils.addMinutes(end, epgAfter);
   Timer timer = new Timer();
   timer.setTitle(epgTitle);
   timer.setChannelId(channelID);
   timer.setChannelName(name);
   timer.setStart(start);
   timer.setEnd(end);
   timer.setTimerAction(
       prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, 0));
   return timer;
 }
  /*
   * (non-Javadoc)
   *
   * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getActivity().getApplicationContext();

    ConnectivityManager connManager =
        (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    mNetworkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

    prefs = new DVBViewerPreferences(getActivity());
    showFavs = prefs.getPrefs().getBoolean(DVBViewerPreferences.KEY_CHANNELS_USE_FAVS, false);
    showNowPlaying =
        prefs.getPrefs().getBoolean(DVBViewerPreferences.KEY_CHANNELS_SHOW_NOW_PLAYING, true);
    showNowPlayingWifi =
        prefs
            .getPrefs()
            .getBoolean(DVBViewerPreferences.KEY_CHANNELS_SHOW_NOW_PLAYING_WIFI_ONLY, true);
    mAdapter = new ChannelAdapter(getActivity());
    if (getArguments() != null) {
      if (getArguments().containsKey(ChannelList.KEY_HAS_OPTIONMENU)) {
        hasOptionsMenu = getArguments().getBoolean(KEY_HAS_OPTIONMENU);
      }
    }
    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(KEY_SELECTED_POSITION)) {
        selectedPosition = savedInstanceState.getInt(KEY_SELECTED_POSITION);
      }
    } else {
      selectedPosition =
          getActivity().getIntent().getIntExtra(KEY_SELECTED_POSITION, selectedPosition);
    }
    setHasOptionsMenu(hasOptionsMenu);
  }
 /**
  * Persist channel config config.
  *
  * @author RayBa
  * @date 05.07.2012
  */
 public void persistChannelConfigConfig() {
   Editor editor = prefs.getPrefs().edit();
   editor.putBoolean(DVBViewerPreferences.KEY_CHANNELS_USE_FAVS, showFavs);
   editor.commit();
   super.onPause();
 }