@Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String TAG = StaticBlob.TAG();
   current_episode = view;
   Intent viewEpisode = new Intent(ShowList.this, EpisodeDesc.class);
   long clickedID =
       Long.parseLong((String) ((TextView) view.findViewById(R.id.hiddenId)).getText());
   viewEpisode.putExtra("id", clickedID);
   Log.v(TAG, "Selected ID: " + clickedID);
   setProgressBarIndeterminateVisibility(true);
   startActivity(viewEpisode);
 }
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   String TAG = StaticBlob.TAG();
   Long id =
       Long.parseLong(
           (String)
               ((TextView) ((View) buttonView.getParent()).findViewById(R.id.hiddenId))
                   .getText());
   StaticBlob.databaseConnector.markNew(id, isChecked);
   Log.v(TAG, "Toggling new for:" + id + " is " + isChecked);
   Cursor c = StaticBlob.databaseConnector.getOneEpisode(id);
   c.moveToFirst();
 }
    public View getView(int pos, View inView, ViewGroup parent) {
      String TAG = StaticBlob.TAG();
      View v = inView;
      if (v == null) {
        LayoutInflater inflater =
            (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = inflater.inflate(R.layout.row, null);
      }
      this.c = getCursor();
      this.c.moveToPosition(pos);

      Date tempDate =
          new Date(); // We use this variable to get thisYear as well as parsing the actual date
      // later
      int thisYear =
          tempDate.getYear(); // If the date for the show is this year, no need to show the year
      // Set the data From->To

      // Get info for selected episode
      long id = this.c.getLong(this.c.getColumnIndex("_id"));
      this.c = StaticBlob.databaseConnector.getOneEpisode(id);
      this.c.moveToFirst();
      String date = this.c.getString(this.c.getColumnIndex("date"));
      String title = this.c.getString(this.c.getColumnIndex("title"));
      String mp3_link = this.c.getString(this.c.getColumnIndex("mp3link"));
      String vid_link = this.c.getString(this.c.getColumnIndex("vidlink"));

      // _id
      ((TextView) v.findViewById(R.id.hiddenId)).setText(Long.toString(id));
      // title
      ((TextView) v.findViewById(R.id.rowTextView)).setText(title);
      LinearLayout.LayoutParams lp =
          (LinearLayout.LayoutParams) v.findViewById(R.id.rowTextView).getLayoutParams();
      lp.setMargins((int) (10 * StaticBlob.DP), lp.topMargin, lp.rightMargin, lp.bottomMargin);
      ;
      // date
      String d = date;
      try {
        tempDate = StaticBlob.sdfRaw.parse(d);
        if (tempDate.getYear() == thisYear) d = StaticBlob.sdfHuman.format(tempDate);
        else d = StaticBlob.sdfHumanLong.format(tempDate);
        // d = Callisto.sdfDestination.format();
      } catch (ParseException e) {
        Log.e(TAG + ":ParseException", "Error parsing a date from the SQLite db: ");
        Log.e(TAG + ":ParseException", d);
        Log.e(TAG + ":ParseException", "(This should never happen).");
        e.printStackTrace();
      }
      ((TextView) v.findViewById(R.id.rowSubTextView)).setText(d);

      File music_file_location = null, video_file_location = null;
      try {
        music_file_location = new File(StaticBlob.storage_path + File.separator + currentShow);
        music_file_location =
            new File(
                music_file_location,
                StaticBlob.sdfFile.format(tempDate)
                    + "__"
                    + StaticBlob.makeFileFriendly(title)
                    + EpisodeDesc.getExtension(mp3_link));
      } catch (NullPointerException npe) {
        Log.e(TAG, "Null pointer when determining file status: Audio");
      }
      try {
        video_file_location = new File(StaticBlob.storage_path + File.separator + currentShow);
        video_file_location =
            new File(
                video_file_location,
                StaticBlob.sdfFile.format(tempDate)
                    + "__"
                    + StaticBlob.makeFileFriendly(title)
                    + EpisodeDesc.getExtension(vid_link));
      } catch (NullPointerException npe) {
        Log.e(TAG, "Null pointer when determining file status: Video");
      }

      runOnUiThread(
          new updateBoldOrItalic(
              id,
              v,
              music_file_location,
              video_file_location,
              this.c.getLong(this.c.getColumnIndex("mp3size")),
              this.c.getLong(this.c.getColumnIndex("vidsize"))));

      // Mark current queue item
      Cursor c = StaticBlob.databaseConnector.currentQueueItem();
      if (currentQueueItem == null || currentQueueItem == v) {
        if (c.getCount() > 0) {
          c.moveToFirst();
          if (c.getLong(c.getColumnIndex("identity")) == id) currentQueueItem = v;
          else currentQueueItem = null;
        } else currentQueueItem = null;
      }
      // Mark current download item
      c = StaticBlob.databaseConnector.getActiveDownloads();
      if (currentDownloadItem == null || currentDownloadItem == v) {
        if (c.getCount() > 0) {
          c.moveToFirst();
          Log.i(
              TAG,
              "  currentDownloadItem =? "
                  + currentDownloadItem
                  + "   "
                  + c.getLong(c.getColumnIndex("identity"))
                  + " == "
                  + id);
          if (c.getLong(c.getColumnIndex("identity")) == id) currentDownloadItem = v;
          else currentDownloadItem = null;
        } else currentDownloadItem = null;
      }
      Log.i(TAG, "currentDownloadItem == " + currentDownloadItem);

      // Hide the specific views
      int[] hide = new int[] {R.id.remove, R.id.progress, R.id.grabber, R.id.rightTextView};
      for (int i = 0; i < hide.length; i++) v.findViewById(hide[i]).setVisibility(View.GONE);

      // Check the Jupiter icon if it is new
      boolean is_new = this.c.getInt(this.c.getColumnIndex("new")) > 0;
      CheckBox rb = ((CheckBox) v.findViewById(R.id.img));
      rb.setChecked(is_new);
      rb.setOnCheckedChangeListener(toggleNew);

      return (v);
    }
  /**
   * Called when the activity is resumed, like when you return from another activity or also when it
   * is first created.
   */
  @Override
  public void onResume() {
    String TAG = StaticBlob.TAG();
    super.onResume();
    thisInstance = this;
    setProgressBarIndeterminateVisibility(false);
    StaticBlob.playerInfo.update(ShowList.this); // Update player controls
    if (StaticBlob.audioFocus != null) StaticBlob.audioFocus.setContext(this);
    if (CallistoService.audioJackReceiver != null)
      CallistoService.audioJackReceiver.setContext(this);

    if (current_episode == null) // If we aren't returning from an EpisodeDesc, we're done.
    return;

    try {
      long id =
          Long.parseLong(
              (String)
                  ((TextView) current_episode.findViewById(R.id.hiddenId))
                      .getText()); // Get the id of the episode that was visited in an EpisodeDesc
      Cursor c = StaticBlob.databaseConnector.getOneEpisode(id);
      c.moveToFirst();

      // New marker
      boolean is_new = c.getInt(c.getColumnIndex("new")) > 0;
      ((CheckBox) current_episode.findViewById(R.id.img)).setChecked(is_new);

      Date tempDate =
          StaticBlob.sdfRaw.parse(
              c.getString(c.getColumnIndex("date"))); // Need this for file location
      String title = c.getString(c.getColumnIndex("title")),
          mp3_link = c.getString(c.getColumnIndex("mp3link")), // Need this for file extension
          vid_link = c.getString(c.getColumnIndex("vidlink")); // ^
      File music_file_location = new File(StaticBlob.storage_path + File.separator + currentShow);
      music_file_location =
          new File(
              music_file_location,
              StaticBlob.sdfFile.format(tempDate)
                  + "__"
                  + StaticBlob.makeFileFriendly(title)
                  + EpisodeDesc.getExtension(mp3_link));
      File video_file_location = new File(StaticBlob.storage_path + File.separator + currentShow);
      video_file_location =
          new File(
              video_file_location,
              StaticBlob.sdfFile.format(tempDate)
                  + "__"
                  + StaticBlob.makeFileFriendly(title)
                  + EpisodeDesc.getExtension(vid_link));

      runOnUiThread(
          new updateBoldOrItalic(
              id,
              current_episode,
              music_file_location,
              video_file_location,
              c.getLong(c.getColumnIndex("mp3size")),
              c.getLong(c.getColumnIndex("vidsize"))));

      c = StaticBlob.databaseConnector.currentQueueItem();
      if (currentQueueItem == null || currentQueueItem == current_episode) {
        if (c.getCount() > 0) {
          c.moveToFirst();
          if (c.getLong(c.getColumnIndex("identity")) == id) currentQueueItem = current_episode;
          else currentQueueItem = null;
        } else currentQueueItem = null;
      }
      // Mark current download item
      c = StaticBlob.databaseConnector.getActiveDownloads();
      if (currentDownloadItem == null || currentDownloadItem == current_episode) {
        if (c.getCount() > 0) {
          c.moveToFirst();
          Log.i(
              TAG,
              "  currentDownloadItem =? "
                  + currentDownloadItem
                  + "   "
                  + c.getLong(c.getColumnIndex("identity"))
                  + " == "
                  + id);
          if (c.getLong(c.getColumnIndex("identity")) == id) currentDownloadItem = current_episode;
          else currentDownloadItem = null;
        } else currentDownloadItem = null;
      }

    } catch (Exception e) {
      Log.e(
          TAG,
          "Error: " + e.getClass() + " - " + e.getMessage() + "(this should never happen...?)");
    }
    current_episode = null;
  }