Search in sources :

Example 1 with TargetApi

use of android.annotation.TargetApi in project cw-omnibus by commonsguy.

the class MainActivity method handleRoute.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void handleRoute(RouteInfo route) {
    if (route == null) {
        clearPreso();
    } else {
        Display display = route.getPresentationDisplay();
        if (route.isEnabled() && display != null) {
            if (preso == null) {
                showPreso(route);
                Log.d(getClass().getSimpleName(), "enabled route");
            } else if (preso.getDisplay().getDisplayId() != display.getDisplayId()) {
                clearPreso();
                showPreso(route);
                Log.d(getClass().getSimpleName(), "switched route");
            } else {
            // no-op: should already be set
            }
        } else {
            clearPreso();
            Log.d(getClass().getSimpleName(), "disabled route");
        }
    }
}
Also used : Display(android.view.Display) TargetApi(android.annotation.TargetApi)

Example 2 with TargetApi

use of android.annotation.TargetApi in project cw-omnibus by commonsguy.

the class MainActivity method initPort.

@TargetApi(Build.VERSION_CODES.M)
private void initPort() {
    final WebMessagePort[] channel = wv.createWebMessageChannel();
    port = channel[0];
    port.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {

        @Override
        public void onMessage(WebMessagePort port, WebMessage message) {
            postLux();
        }
    });
    wv.postWebMessage(new WebMessage("", new WebMessagePort[] { channel[1] }), Uri.EMPTY);
}
Also used : WebMessagePort(android.webkit.WebMessagePort) WebMessage(android.webkit.WebMessage) TargetApi(android.annotation.TargetApi)

Example 3 with TargetApi

use of android.annotation.TargetApi in project materialistic by hidroh.

the class ItemFragmentSinglePageTest method testReply.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testReply() {
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_comment));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ComposeActivity.class).hasExtra(ComposeActivity.EXTRA_PARENT_ID, "1");
}
Also used : 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 4 with TargetApi

use of android.annotation.TargetApi in project materialistic by hidroh.

the class ItemFragmentSinglePageTest method testVote.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVote() {
    viewHolder.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), any(), voteCallback.capture());
    voteCallback.getValue().onDone(true);
    assertEquals(activity.getString(R.string.voted), ShadowToast.getTextOfLatestToast());
}
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 5 with TargetApi

use of android.annotation.TargetApi in project materialistic by hidroh.

the class FavoriteActivityTest method testReply.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testReply() {
    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_comment));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ComposeActivity.class);
}
Also used : 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)

Aggregations

TargetApi (android.annotation.TargetApi)1365 Intent (android.content.Intent)153 View (android.view.View)147 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)53 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)42 ImageView (android.widget.ImageView)40