private void processSearchHint(SearchHint hint) {
    if (hint == null) return;

    Intent intent;

    if (hint.getType().equalsIgnoreCase("series")) {
      intent = new Intent(SearchResultsActivity.this, SeriesViewActivity.class);
    } else if (hint.getType().equalsIgnoreCase("musicartist")
        || hint.getType().equalsIgnoreCase("musicalbum")
        || hint.getType().equalsIgnoreCase("audio")) {
      MainApplication.getInstance()
          .API
          .GetItemAsync(
              hint.getItemId(),
              MainApplication.getInstance().API.getCurrentUserId(),
              getItemResponse);
      return;
    } else if (hint.getType().equalsIgnoreCase("photo")) {
      intent = new Intent(SearchResultsActivity.this, PhotoDetailsActivity.class);
    } else if (hint.getType().equalsIgnoreCase("book")) {
      intent = new Intent(SearchResultsActivity.this, BookDetailsActivity.class);
    } else if (hint.getType().equalsIgnoreCase("folder")
        || hint.getType().equalsIgnoreCase("boxset")) {
      intent = new Intent(SearchResultsActivity.this, LibraryPresentationActivity.class);
    } else if (hint.getType().equalsIgnoreCase("movie")
        || hint.getType().equalsIgnoreCase("episode")) {
      intent = new Intent(SearchResultsActivity.this, MediaDetailsActivity.class);
    } else if (hint.getType().equalsIgnoreCase("person")) {
      intent = new Intent(SearchResultsActivity.this, ActorBioActivity.class);
      intent.putExtra("ActorName", hint.getName());
      intent.putExtra("ActorId", hint.getItemId());
    } else {
      Toast.makeText(SearchResultsActivity.this, "Type is: " + hint.getType(), Toast.LENGTH_LONG)
          .show();
      intent = null;
    }

    if (intent != null) {
      BaseItemDto item = new BaseItemDto();
      item.setId(hint.getItemId());
      item.setName(hint.getName());
      item.setType(hint.getType());

      String jsonData = MainApplication.getInstance().getJsonSerializer().SerializeToString(item);
      intent.putExtra("Item", jsonData);

      startActivity(intent);
      this.finish();
    } else {
      AppLogger.getLogger().Info("intent is null");
    }
  }
  private String getValue(BaseItemDto baseItemDto) {

    String val = baseItemDto.getSortName();

    if (tangible.DotNetToJavaStringHelper.isNullOrEmpty(val)) {
      val = baseItemDto.getName();
    }

    if (tangible.DotNetToJavaStringHelper.isNullOrEmpty(val)) {
      val = "";
    }

    return val;
  }
Ejemplo n.º 3
0
 public BaseRowItem(
     int index,
     BaseItemDto item,
     boolean preferParentThumb,
     boolean staticHeight,
     SelectAction selectAction) {
   this.index = index;
   this.baseItem = item;
   type =
       item.getType().equals("Program")
           ? ItemType.LiveTvProgram
           : item.getType().equals("Recording") ? ItemType.LiveTvRecording : ItemType.BaseItem;
   this.preferParentThumb = preferParentThumb;
   this.staticHeight = staticHeight;
   this.selectAction = selectAction;
 }
        @Override
        public void onResponse(BaseItemDto album) {

          Intent intent = new Intent(SearchResultsActivity.this, MusicAlbumActivity.class);
          intent.putExtra("AlbumId", album.getId());
          startActivity(intent);
          SearchResultsActivity.this.finish();
        }
Ejemplo n.º 5
0
  public long getRuntimeTicks() {
    switch (type) {
      case LiveTvRecording:
      case BaseItem:
        return baseItem.getRunTimeTicks() != null ? baseItem.getRunTimeTicks() : 0;
      case Person:
        break;
      case Server:
        break;
      case User:
        break;
      case Chapter:
        break;
      case SearchHint:
        break;
      case LiveTvChannel:
        break;
      case GridButton:
        break;
      case LiveTvProgram:
        return ((baseItem.getStartDate() != null) && (baseItem.getEndDate() != null))
            ? (baseItem.getEndDate().getTime() - (baseItem.getStartDate().getTime() * 10000))
            : 0;
    }

    return 0;
  }
Ejemplo n.º 6
0
  public Drawable getBadgeImage() {
    switch (type) {
      case BaseItem:
        if (baseItem.getType().equals("Movie") && baseItem.getCriticRating() != null) {
          return baseItem.getCriticRating() > 59
              ? TvApp.getApplication().getDrawableCompat(R.drawable.fresh)
              : TvApp.getApplication().getDrawableCompat(R.drawable.rotten);
        }
        break;
      case Person:
        break;
      case Server:
        break;
      case User:
        if (user.getHasPassword()) {
          return TvApp.getApplication().getDrawableCompat(R.drawable.lock);
        }
        break;
      case Chapter:
        break;
    }

    return TvApp.getApplication().getDrawableCompat(R.drawable.blank10x10);
  }
Ejemplo n.º 7
0
  public boolean isPlayed() {
    switch (type) {
      case BaseItem:
      case LiveTvRecording:
      case LiveTvProgram:
        return baseItem.getUserData() != null && baseItem.getUserData().getPlayed();
      case Person:
        break;
      case Server:
        break;
      case User:
        break;
      case Chapter:
        break;
      case SearchHint:
        break;
      case LiveTvChannel:
        break;
      case GridButton:
        break;
    }

    return false;
  }
        @Override
        public void onResponse(BaseItemDto item) {

          if (item == null) return;

          Intent intent;
          if (item.getType().equalsIgnoreCase("musicartist")) {
            intent = new Intent(SearchResultsActivity.this, ArtistActivity.class);
            intent.putExtra("ArtistId", item.getId());
          } else if (item.getType().equalsIgnoreCase("musicalbum")) {
            intent = new Intent(SearchResultsActivity.this, MusicAlbumActivity.class);
            intent.putExtra("AlbumId", item.getId());
          } else { // It's a song
            MainApplication.getInstance()
                .API
                .GetItemAsync(
                    item.getParentId(),
                    MainApplication.getInstance().API.getCurrentUserId(),
                    getAlbumResponse);
            return;
          }
          startActivity(intent);
          SearchResultsActivity.this.finish();
        }
Ejemplo n.º 9
0
  public String getSummary() {
    switch (type) {
      case BaseItem:
      case LiveTvRecording:
      case LiveTvProgram:
        return baseItem.getOverview();
      case Person:
        break;
      case Server:
        break;
      case User:
        break;
      case Chapter:
        break;
      case SearchHint:
        break;
      case LiveTvChannel:
        break;
      case GridButton:
        break;
    }

    return "";
  }
Ejemplo n.º 10
0
  public String getType() {
    switch (type) {
      case BaseItem:
      case LiveTvRecording:
      case LiveTvProgram:
        return baseItem.getType();
      case Person:
        return person.getType();
      case Server:
        break;
      case User:
        break;
      case Chapter:
        break;
      case SearchHint:
        return searchHint.getType();
      case LiveTvChannel:
        return channelInfo.getType();
      case GridButton:
        return "GridButton";
    }

    return "";
  }
Ejemplo n.º 11
0
  public String getItemId() {
    switch (type) {
      case BaseItem:
      case LiveTvProgram:
      case LiveTvRecording:
        return baseItem.getId();
      case Person:
        return person.getId();
      case Chapter:
        return chapterInfo.getItemId();
      case Server:
        return serverInfo.getId();
      case User:
        return user.getId();
      case LiveTvChannel:
        return channelInfo.getId();
      case GridButton:
        return null;
      case SearchHint:
        return searchHint.getItemId();
    }

    return null;
  }
Ejemplo n.º 12
0
  public String getName() {
    switch (type) {
      case BaseItem:
      case LiveTvRecording:
      case LiveTvProgram:
        return baseItem.getName();
      case Person:
        return person.getName();
      case Server:
        return serverInfo.getName();
      case User:
        return user.getName();
      case Chapter:
        return chapterInfo.getName();
      case SearchHint:
        return searchHint.getName();
      case LiveTvChannel:
        return channelInfo.getName();
      case GridButton:
        return gridButton.getText();
    }

    return TvApp.getApplication().getString(R.string.lbl_bracket_unknown);
  }
Ejemplo n.º 13
0
  public String getSubText() {
    switch (type) {
      case BaseItem:
        return Utils.GetSubName(baseItem);
      case Person:
        return person.getRole();
      case Chapter:
        Long pos = chapterInfo.getStartPositionTicks() / 10000;
        return Utils.formatMillis(pos.intValue());
      case Server:
        return serverInfo.getLocalAddress().substring(7);
      case LiveTvChannel:
        return channelInfo.getNumber();
      case LiveTvProgram:
        Calendar start = Calendar.getInstance();
        start.setTime(Utils.convertToLocalDate(baseItem.getStartDate()));
        int day = start.get(Calendar.DAY_OF_YEAR);
        return baseItem.getChannelName()
            + " - "
            + (baseItem.getEpisodeTitle() != null ? baseItem.getEpisodeTitle() : "")
            + " "
            + ((day != Calendar.getInstance().get(Calendar.DAY_OF_YEAR)
                    ? new SimpleDateFormat("d MMM").format(start.getTime()) + " "
                    : "")
                + android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                    .format(start.getTime())
                + "-"
                + android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                    .format(Utils.convertToLocalDate(baseItem.getEndDate())));
      case LiveTvRecording:
        return (baseItem.getChannelName() != null ? baseItem.getChannelName() + " - " : "")
            + (baseItem.getEpisodeTitle() != null ? baseItem.getEpisodeTitle() : "")
            + " "
            + new SimpleDateFormat("d MMM")
                .format(Utils.convertToLocalDate(baseItem.getStartDate()))
            + " "
            + (android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                    .format(Utils.convertToLocalDate(baseItem.getStartDate()))
                + "-"
                + android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                    .format(Utils.convertToLocalDate(baseItem.getEndDate())));
      case User:
        Date date = user.getLastActivityDate();
        return date != null
            ? DateUtils.getRelativeTimeSpanString(Utils.convertToLocalDate(date).getTime())
                .toString()
            : TvApp.getApplication().getString(R.string.lbl_never);
      case SearchHint:
        return searchHint.getType();
    }

    return "";
  }
Ejemplo n.º 14
0
 public boolean isFolder() {
   return type == ItemType.BaseItem && baseItem != null && baseItem.getIsFolder();
 }