public String getFullName() { switch (type) { case BaseItem: case LiveTvProgram: case LiveTvRecording: return Utils.GetFullName(baseItem); case Person: return person.getName(); case Chapter: return chapterInfo.getName(); case Server: return serverInfo.getName(); case User: return user.getName(); case LiveTvChannel: return channelInfo.getName(); case GridButton: return gridButton.getText(); case SearchHint: return (searchHint.getSeries() != null ? searchHint.getSeries() + " - " : "") + searchHint.getName(); } return TvApp.getApplication().getString(R.string.lbl_bracket_unknown); }
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 ""; }
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 ""; }
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; }
public String getPrimaryImageUrl(int maxHeight) { switch (type) { case BaseItem: case LiveTvProgram: case LiveTvRecording: return Utils.getPrimaryImageUrl( baseItem, TvApp.getApplication().getApiClient(), true, preferParentThumb, maxHeight); case Person: return Utils.getPrimaryImageUrl(person, TvApp.getApplication().getApiClient(), maxHeight); case User: return Utils.getPrimaryImageUrl(user, TvApp.getApplication().getLoginApiClient()); case Chapter: return chapterInfo.getImagePath(); case LiveTvChannel: return Utils.getPrimaryImageUrl(channelInfo, TvApp.getApplication().getApiClient()); case Server: return "android.resource://tv.emby.embyatv/" + R.drawable.server; case GridButton: return "android.resource://tv.emby.embyatv/" + gridButton.getImageIndex(); case SearchHint: return !Utils.IsEmpty(searchHint.getPrimaryImageTag()) ? Utils.getImageUrl( searchHint.getItemId(), ImageType.Primary, searchHint.getPrimaryImageTag(), TvApp.getApplication().getApiClient()) : !Utils.IsEmpty(searchHint.getThumbImageItemId()) ? Utils.getImageUrl( searchHint.getThumbImageItemId(), ImageType.Thumb, searchHint.getThumbImageTag(), TvApp.getApplication().getApiClient()) : null; } return null; }
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"); } }