Search in sources :

Example 1 with DetailFragment

use of com.simplecity.amp_library.ui.fragments.DetailFragment in project Shuttle by timusus.

the class MainActivity method swapFragments.

public void swapFragments(Serializable item, View transitionView) {
    String transitionName = ViewCompat.getTransitionName(transitionView);
    DetailFragment detailFragment = DetailFragment.newInstance(item, transitionName);
    if (ShuttleUtils.hasLollipop()) {
        Transition moveTransition = TransitionInflater.from(this).inflateTransition(R.transition.image_transition);
        detailFragment.setSharedElementEnterTransition(moveTransition);
        detailFragment.setEnterTransition(new Fade());
        getCurrentFragment().setExitTransition(new Fade());
    }
    getSupportFragmentManager().beginTransaction().addSharedElement(transitionView, transitionName).replace(R.id.main_container, detailFragment).addToBackStack(null).commit();
}
Also used : Transition(android.transition.Transition) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment) Fade(android.transition.Fade)

Example 2 with DetailFragment

use of com.simplecity.amp_library.ui.fragments.DetailFragment in project Shuttle by timusus.

the class MainActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    PlaylistUtils.isFavorite(this, MusicUtils.getSong()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(isFavorite -> {
        if (isFavorite) {
            final MenuItem favItem = menu.findItem(R.id.menu_favorite);
            int[] attrs = new int[] { R.attr.btn_fav_pressed };
            TypedArray ta = obtainStyledAttributes(attrs);
            if (ta != null) {
                Drawable drawableFromTheme = ta.getDrawable(0);
                ta.recycle();
                if (favItem != null) {
                    favItem.setIcon(drawableFromTheme);
                }
            }
        }
    });
    MenuItem whiteListItem = menu.findItem(R.id.whitelist);
    MenuItem sortingItem = menu.findItem(R.id.sort);
    MenuItem viewAsItem = menu.findItem(R.id.view_as);
    if (mSlidingUpPanelLayout == null || !mIsSlidingEnabled || mSlidingUpPanelLayout.getPanelState() != SlidingUpPanelLayout.PanelState.EXPANDED) {
        if (whiteListItem != null) {
            whiteListItem.setVisible(true);
        }
        if (sortingItem != null) {
            sortingItem.setVisible(true);
        }
        if (viewAsItem != null) {
            viewAsItem.setVisible(true);
        }
    } else {
        if (whiteListItem != null) {
            whiteListItem.setVisible(false);
        }
        if (sortingItem != null) {
            sortingItem.setVisible(false);
        }
        if (viewAsItem != null) {
            viewAsItem.setVisible(false);
        }
    }
    if (getCurrentFragment() instanceof DetailFragment) {
        if (sortingItem != null) {
            sortingItem.setVisible(false);
        }
    }
    return super.onPrepareOptionsMenu(menu);
}
Also used : TypedArray(android.content.res.TypedArray) Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment)

Aggregations

DetailFragment (com.simplecity.amp_library.ui.fragments.DetailFragment)2 TypedArray (android.content.res.TypedArray)1 Drawable (android.graphics.drawable.Drawable)1 Fade (android.transition.Fade)1 Transition (android.transition.Transition)1 MenuItem (android.view.MenuItem)1