Esempio n. 1
0
  public void updateMedia() {
    AudioServiceController audioController = AudioServiceController.getInstance();
    if (audioController == null) return;

    removeAllViews();

    hasPrevious = false;
    previousPosition = 0;

    LayoutInflater inflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (audioController.hasPrevious()) {
      addMediaView(
          inflater,
          audioController.getTitlePrev(),
          audioController.getArtistPrev(),
          audioController.getCoverPrev());
      hasPrevious = true;
    }
    if (audioController.hasMedia())
      addMediaView(
          inflater,
          audioController.getTitle(),
          audioController.getArtist(),
          audioController.getCover());
    if (audioController.hasNext())
      addMediaView(
          inflater,
          audioController.getTitleNext(),
          audioController.getArtistNext(),
          audioController.getCoverNext());

    if (audioController.hasPrevious() && audioController.hasMedia()) {
      previousPosition = 1;
      scrollTo(1);
    } else scrollTo(0);
  }