Search in sources :

Example 86 with AppCompatActivity

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();
}
Also used : ImageButton(android.widget.ImageButton) AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Date(java.util.Date)

Example 87 with AppCompatActivity

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;
    }
}
Also used : ModalMultiSelectorCallback(com.bignerdranch.android.multiselector.ModalMultiSelectorCallback) R(com.simplecity.amp_library.R) Genre(com.simplecity.amp_library.model.Genre) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Random(java.util.Random) ItemAdapter(com.simplecity.amp_library.ui.adapters.ItemAdapter) ColorStateList(android.content.res.ColorStateList) Song(com.simplecity.amp_library.model.Song) Priority(com.bumptech.glide.Priority) RequestManager(com.bumptech.glide.RequestManager) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) MediaStore(android.provider.MediaStore) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) Schedulers(rx.schedulers.Schedulers) View(android.view.View) DetailAdapter(com.simplecity.amp_library.ui.adapters.DetailAdapter) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) PreferenceManager(android.preference.PreferenceManager) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback) FloatingActionButton(android.support.design.widget.FloatingActionButton) SortManager(com.simplecity.amp_library.utils.SortManager) ActionMode(android.support.v7.view.ActionMode) Playlist(com.simplecity.amp_library.model.Playlist) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ObjectAnimator(android.animation.ObjectAnimator) IntentFilter(android.content.IntentFilter) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) BroadcastReceiver(android.content.BroadcastReceiver) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) BaseAdaptableItem(com.simplecity.amp_library.ui.modelviews.BaseAdaptableItem) NonScrollImageButton(com.simplecity.amp_library.ui.views.NonScrollImageButton) Serializable(java.io.Serializable) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) TextView(android.widget.TextView) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) GlideUtils(com.simplecity.amp_library.glide.utils.GlideUtils) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) Subscription(rx.Subscription) Context(android.content.Context) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) DrawableUtils(com.simplecity.amp_library.utils.DrawableUtils) Intent(android.content.Intent) StringUtils(com.simplecity.amp_library.utils.StringUtils) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Observable(rx.Observable) ThemeUtils(com.simplecity.amp_library.utils.ThemeUtils) ColorUtils(com.simplecity.amp_library.utils.ColorUtils) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) Menu(android.view.Menu) AnimatorSet(android.animation.AnimatorSet) WeakReference(java.lang.ref.WeakReference) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) SharedElementCallback(android.support.v4.app.SharedElementCallback) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) ViewType(com.simplecity.amp_library.ui.modelviews.ViewType) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DiscNumberView(com.simplecity.amp_library.ui.modelviews.DiscNumberView) DialogUtils(com.simplecity.amp_library.utils.DialogUtils) TimeUnit(java.util.concurrent.TimeUnit) CompositeSubscription(rx.subscriptions.CompositeSubscription) RecyclerView(android.support.v7.widget.RecyclerView) BlacklistHelper(com.simplecity.amp_library.sql.databases.BlacklistHelper) Glide(com.bumptech.glide.Glide) SharedPreferences(android.content.SharedPreferences) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) OvershootInterpolator(android.view.animation.OvershootInterpolator) MultiSelector(com.bignerdranch.android.multiselector.MultiSelector) ComparisonUtils(com.simplecity.amp_library.utils.ComparisonUtils) ViewTreeObserver(android.view.ViewTreeObserver) DataManager(com.simplecity.amp_library.utils.DataManager) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) ContentUris(android.content.ContentUris) AppCompatActivity(android.support.v7.app.AppCompatActivity) PopupMenu(android.support.v7.widget.PopupMenu)

Example 88 with AppCompatActivity

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();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 89 with AppCompatActivity

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();
    }
}
Also used : Song(com.simplecity.amp_library.model.Song) AppCompatActivity(android.support.v7.app.AppCompatActivity) Album(com.simplecity.amp_library.model.Album) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) PopupMenu(android.support.v7.widget.PopupMenu)

Example 90 with AppCompatActivity

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();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4