Search in sources :

Example 71 with PopupMenu

use of android.widget.PopupMenu in project materialistic by hidroh.

the class ListFragmentViewHolderTest method testVoteItemPromptToLogin.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
    verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
    itemListener.getValue().onResponse(item);
    adapter.getViewHolder(0).itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), eq(item.getId()), voteCallback.capture());
    voteCallback.getValue().onDone(false);
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
Also used : Context(android.content.Context) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 72 with PopupMenu

use of android.widget.PopupMenu in project materialistic by hidroh.

the class ListFragmentViewHolderTest method testShare.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testShare() {
    TestApplication.addResolver(new Intent(Intent.ACTION_SEND));
    verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
    itemListener.getValue().onResponse(item);
    adapter.getViewHolder(0).itemView.performLongClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_share));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_SEND);
}
Also used : Intent(android.content.Intent) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 73 with PopupMenu

use of android.widget.PopupMenu in project materialistic by hidroh.

the class ItemFragmentSinglePageTest method testShare.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testShare() {
    TestApplication.addResolver(new Intent(Intent.ACTION_SEND));
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_share));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_SEND);
}
Also used : Intent(android.content.Intent) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 74 with PopupMenu

use of android.widget.PopupMenu in project materialistic by hidroh.

the class FavoriteActivityTest method testVoteItemPromptToLogin.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
    shadowAdapter.getViewHolder(0).itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    Assert.assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), userServicesCallback.capture());
    userServicesCallback.getValue().onDone(false);
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
Also used : Context(android.content.Context) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 75 with PopupMenu

use of android.widget.PopupMenu in project JamsMusicPlayer by psaravan.

the class PlaylistPagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = getActivity();
    mApp = (Common) mContext.getApplicationContext();
    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_playlist_pager_fill, container, false);
    mPosition = getArguments().getInt("POSITION");
    overflowIcon = (ImageView) mRootView.findViewById(R.id.now_playing_overflow_icon);
    coverArt = (ImageView) mRootView.findViewById(R.id.coverArt);
    bottomDarkPatch = (RelativeLayout) mRootView.findViewById(R.id.bottomDarkPatch);
    songInfoLayout = (RelativeLayout) mRootView.findViewById(R.id.songInfoLayout);
    songNameTextView = (TextView) mRootView.findViewById(R.id.songName);
    artistAlbumNameTextView = (TextView) mRootView.findViewById(R.id.artistAlbumName);
    mLyricsScrollView = (ScrollView) mRootView.findViewById(R.id.lyrics_scroll_view);
    mLyricsTextView = (TextView) mRootView.findViewById(R.id.lyrics);
    mLyricsEmptyTextView = (TextView) mRootView.findViewById(R.id.lyrics_empty);
    mLyricsTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mLyricsEmptyTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    songNameTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    artistAlbumNameTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    //Allow the TextViews to scroll if they extend beyond the layout margins.
    songNameTextView.setSelected(true);
    artistAlbumNameTextView.setSelected(true);
    //Initialize the pop up menu.
    popup = new PopupMenu(getActivity(), overflowIcon);
    popup.getMenuInflater().inflate(R.menu.now_playing_overflow_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(menuItemClickListener);
    mSongHelper = new SongHelper();
    mSongHelper.setAlbumArtLoadedListener(this);
    if (mApp.getOrientation() == Common.ORIENTATION_LANDSCAPE)
        mSongHelper.populateSongData(mContext, mPosition);
    else
        mSongHelper.populateSongData(mContext, mPosition, new PicassoMirrorReflectionTransformer());
    songNameTextView.setText(mSongHelper.getTitle());
    artistAlbumNameTextView.setText(mSongHelper.getAlbum() + " - " + mSongHelper.getArtist());
    overflowIcon.setOnClickListener(overflowClickListener);
    //Kitkat padding.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int navigationBarHeight = Common.getNavigationBarHeight(mContext);
        int bottomPadding = songInfoLayout.getPaddingBottom();
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) bottomDarkPatch.getLayoutParams();
        if (navigationBarHeight > 0) {
            /* The nav bar already has padding, so remove the extra 15dp
                 * padding that was applied in the layout file.
                 */
            int marginPixelsValue = (int) mApp.convertDpToPixels(15, mContext);
            bottomPadding -= marginPixelsValue;
            params.height -= marginPixelsValue;
        }
        bottomPadding += navigationBarHeight;
        songInfoLayout.setPadding(0, 0, 0, bottomPadding);
        params.height += navigationBarHeight;
        bottomDarkPatch.setLayoutParams(params);
    }
    return mRootView;
}
Also used : RelativeLayout(android.widget.RelativeLayout) PicassoMirrorReflectionTransformer(com.jams.music.player.ImageTransformers.PicassoMirrorReflectionTransformer) SongHelper(com.jams.music.player.Helpers.SongHelper) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.widget.PopupMenu)99 MenuItem (android.view.MenuItem)60 View (android.view.View)44 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)30 RecyclerView (android.support.v7.widget.RecyclerView)22 TargetApi (android.annotation.TargetApi)20 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)19 Test (org.junit.Test)19 ShadowPopupMenu (org.robolectric.shadows.ShadowPopupMenu)19 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)18 Intent (android.content.Intent)14 Context (android.content.Context)12 DialogAction (com.afollestad.materialdialogs.DialogAction)12 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)12 MenuInflater (android.view.MenuInflater)10 AdapterView (android.widget.AdapterView)10 ListView (android.widget.ListView)10 Menu (android.view.Menu)9 NonNull (android.support.annotation.NonNull)8