use of android.support.v7.app.AppCompatActivity in project SeriesGuide by UweTrottmann.
the class OverviewFragment method populateShowViews.
private void populateShowViews(@NonNull Cursor show) {
// set show title in action bar
showTitle = show.getString(ShowQuery.SHOW_TITLE);
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(showTitle);
getActivity().setTitle(getString(R.string.description_overview) + showTitle);
}
if (getView() == null) {
return;
}
// status
final TextView statusText = (TextView) getView().findViewById(R.id.showStatus);
ShowTools.setStatusAndColor(statusText, show.getInt(ShowQuery.SHOW_STATUS));
// favorite
final ImageButton favorited = ButterKnife.findById(getView(), R.id.imageButtonFavorite);
boolean isFavorited = show.getInt(ShowQuery.SHOW_FAVORITE) == 1;
if (isFavorited) {
favorited.setImageResource(Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableStar));
} else {
favorited.setImageResource(Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableStar0));
}
favorited.setContentDescription(getString(isFavorited ? R.string.context_unfavorite : R.string.context_favorite));
CheatSheet.setup(favorited, isFavorited ? R.string.context_unfavorite : R.string.context_favorite);
favorited.setTag(isFavorited);
// poster background
TvdbImageTools.loadShowPosterAlpha(getActivity(), imageBackground, show.getString(ShowQuery.SHOW_POSTER));
// next release day and time
StringBuilder timeAndNetwork = new StringBuilder();
int releaseTime = show.getInt(ShowQuery.SHOW_RELEASE_TIME);
String network = show.getString(ShowQuery.SHOW_NETWORK);
if (releaseTime != -1) {
int weekDay = show.getInt(ShowQuery.SHOW_RELEASE_WEEKDAY);
Date release = TimeTools.getShowReleaseDateTime(getActivity(), TimeTools.getShowReleaseTime(releaseTime), weekDay, show.getString(ShowQuery.SHOW_RELEASE_TIMEZONE), show.getString(ShowQuery.SHOW_RELEASE_COUNTRY), network);
String dayString = TimeTools.formatToLocalDayOrDaily(getActivity(), release, weekDay);
String timeString = TimeTools.formatToLocalTime(getActivity(), release);
// "Mon 08:30"
timeAndNetwork.append(dayString).append(" ").append(timeString);
}
// network
if (!TextUtils.isEmpty(network)) {
if (timeAndNetwork.length() != 0) {
timeAndNetwork.append(" ");
}
timeAndNetwork.append(getString(R.string.show_on_network, network));
}
((TextView) getView().findViewById(R.id.showmeta)).setText(timeAndNetwork.toString());
// episode description might need show language, so update it here as well
populateEpisodeDescription();
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class DetailFragment method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.fab:
if (albumArtist != null) {
MusicUtils.shuffleAll(getActivity(), albumArtist.getSongsObservable());
} else if (album != null) {
MusicUtils.shuffleAll(getActivity(), album.getSongsObservable());
} else if (genre != null) {
MusicUtils.shuffleAll(getActivity(), genre.getSongsObservable(getContext()));
} else if (playlist != null) {
MusicUtils.shuffleAll(getActivity(), playlist.getSongsObservable(getContext()));
}
break;
case R.id.btn_overflow:
final PopupMenu menu = new PopupMenu(getActivity(), v);
if (album != null) {
MenuUtils.addAlbumMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, album);
menu.getMenu().add(ALBUM_FRAGMENT_GROUP_ID, VIEW_INFO, Menu.NONE, R.string.info);
} else if (albumArtist != null) {
MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, albumArtist);
menu.getMenu().add(ALBUM_FRAGMENT_GROUP_ID, VIEW_INFO, Menu.NONE, R.string.info);
} else if (genre != null) {
} else if (playlist != null) {
MenuUtils.addPlaylistMenuOptions(menu, playlist);
//Remove the delete menu option, since we're looking at the playlist we would delete.
if (menu.getMenu().findItem(MusicUtils.PlaylistMenuOrder.DELETE_PLAYLIST) != null) {
menu.getMenu().removeItem(MusicUtils.PlaylistMenuOrder.DELETE_PLAYLIST);
}
MenuUtils.addClickHandler(getActivity(), menu, playlist, (materialDialog, dialogAction) -> {
//The user might have changed the playlist name
lineOne.setText(playlist.name);
}, (materialDialog, dialogAction) -> {
//If the user clicked 'edit', they've probably set a new 'week' range. Restart the loader.
refreshAdapterItems();
});
}
menu.show();
break;
}
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class SongFragment method onOverflowClick.
@Override
public void onOverflowClick(View v, int position, final Song song) {
PopupMenu menu = new PopupMenu(SongFragment.this.getActivity(), v);
MenuUtils.addSongMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, song, item -> {
switch(item.getItemId()) {
case BLACKLIST:
{
BlacklistHelper.addToBlacklist(song);
return true;
}
}
return false;
});
menu.show();
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class SuggestedFragment method onOverflowClick.
@Override
public void onOverflowClick(View v, int position, Object item) {
if (item instanceof AlbumArtist) {
PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (AlbumArtist) item);
menu.show();
} else if (item instanceof Album) {
PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
MenuUtils.addAlbumMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (Album) item);
menu.show();
} else if (item instanceof Song) {
PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
MenuUtils.addSongMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (Song) item, menuItem -> {
switch(menuItem.getItemId()) {
case BLACKLIST:
{
BlacklistHelper.addToBlacklist(((Song) item));
suggestedAdapter.removeItem(position);
return true;
}
}
return false;
});
menu.show();
}
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class AlbumFragment method onOverflowClick.
@Override
public void onOverflowClick(View v, int position, Album album) {
PopupMenu menu = new PopupMenu(AlbumFragment.this.getActivity(), v);
MenuUtils.addAlbumMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, album);
menu.show();
}
Aggregations