org.springframework.mobile.device.Device.isTablet()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.springframework.mobile.device.Device.isTablet()方法的一些代码示例,展示了Device.isTablet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device.isTablet()方法的具体详情如下:
包路径:org.springframework.mobile.device.Device
类名称:Device
方法名:isTablet

Device.isTablet介绍

[英]True if this device is a tablet device such as an Apple iPad or a Motorola Xoom. Could be used by a pre-handle interceptor to redirect the user to a dedicated tablet web site. Could be used to apply a different page layout or stylesheet when the device is a tablet device.
[中]如果此设备是平板设备,如苹果iPad或摩托罗拉Xoom,则为True。可由预处理拦截器用于将用户重定向到专用平板电脑网站。当设备为平板电脑设备时,可用于应用不同的页面布局或样式表。

代码示例

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

protected void resolveDeviceType(final HttpServletRequest request) {
  final Device device = deviceResolver.resolveDevice(request);
  String type = "UNKNOWN";
  
  if (device != null) {
    if (device.isMobile()) {
      type = "MOBILE";
    } else if (device.isTablet()) {
      type = "TABLET";
    } else if (device.isNormal()) {
      type = "NORMAL";
    }
  }
  BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties().put(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, WebRequestDeviceType.getInstance(type));
}

代码示例来源:origin: spring-projects/spring-mobile

/**
 * Should the combination of {@link Device} and {@link SitePreference} be handled
 * as a tablet device
 * @param device the resolved device
 * @param sitePreference the specified site preference
 * @return true if tablet
 */
public static boolean isTablet(Device device, SitePreference sitePreference) {
  return sitePreference == SitePreference.TABLET || device != null && device.isTablet() && sitePreference == null;
}

代码示例来源:origin: org.springframework.mobile/spring-mobile-device

/**
 * Should the combination of {@link Device} and {@link SitePreference} be handled
 * as a tablet device
 * @param device the resolved device
 * @param sitePreference the specified site preference
 * @return true if tablet
 */
public static boolean isTablet(Device device, SitePreference sitePreference) {
  return sitePreference == SitePreference.TABLET || device != null && device.isTablet() && sitePreference == null;
}

代码示例来源:origin: stackoverflow.com

@RequestMapping("/")
public String home(Device device) {
  if (device.isMobile()) {
    return "mobile/home/index";
  } else if (device.isTablet()) {
    return "tablet/home/index";
  } else {
    return "desktop/home/index";       
  }
}

代码示例来源:origin: org.springframework.mobile/spring-mobile-device

private boolean handleTabletIsMobile(Device device, SitePreference sitePreference) {
  return tabletIsMobile == true && (sitePreference == SitePreference.TABLET || sitePreference == null)
      && (device.isTablet() || device.isMobile());
}

代码示例来源:origin: org.springframework.mobile/spring-mobile-device

private boolean handleTabletIsNormal(Device device, SitePreference sitePreference) {
  return sitePreference == SitePreference.TABLET && tabletIsMobile == false
      && (device.isTablet() || device.isMobile());
}

代码示例来源:origin: spring-projects/spring-mobile

private boolean handleTabletIsNormal(Device device, SitePreference sitePreference) {
  return sitePreference == SitePreference.TABLET && tabletIsMobile == false
      && (device.isTablet() || device.isMobile());
}

代码示例来源:origin: spring-projects/spring-mobile

private boolean handleTabletIsMobile(Device device, SitePreference sitePreference) {
  return tabletIsMobile == true && (sitePreference == SitePreference.TABLET || sitePreference == null)
      && (device.isTablet() || device.isMobile());
}

代码示例来源:origin: bfwg/springboot-jwt-starter

private Date generateExpirationDate(Device device) {
  long expiresIn = device.isTablet() || device.isMobile() ? MOBILE_EXPIRES_IN : EXPIRES_IN;
  return new Date(timeProvider.now().getTime() + expiresIn * 1000);
}

代码示例来源:origin: bfwg/springboot-jwt-starter

private String generateAudience(Device device) {
  String audience = AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}

代码示例来源:origin: koldaman/springboot-jwt-swagger

private String generateAudience(Device device) {
  String audience = AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}

代码示例来源:origin: liumapp/spring-security-mybatis-demo

private String generateAudience(Device device) {
  String audience = AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}

代码示例来源:origin: TomChen001/xmanager

private String generateAudience(Device device) {
  String audience = AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}

代码示例来源:origin: jonsychen/rest-security-demo

private String generateAudience(Device device) {
  String audience = AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}

代码示例来源:origin: org.togglz/togglz-spring-mobile

@Override
  public boolean isActive(FeatureState featureState, FeatureUser user) {

    HttpServletRequest request = HttpServletRequestHolder.get();
    if (request != null) {
      Device device = DeviceUtils.getCurrentDevice(request);
      DeviceType deviceType = device.isMobile() ? MOBILE : (device.isTablet() ? TABLET : NORMAL);
      return (YES.equalsIgnoreCase(featureState.getParameter(deviceType.name())));

    }
    return false;

  }
}

代码示例来源:origin: spring-projects/spring-mobile

@Test
public void resolveDevice() throws Exception {
  MockHttpServletRequest request = new MockHttpServletRequest();
  MockHttpServletResponse response = new MockHttpServletResponse();
  DeviceResolverHandlerInterceptor interceptor = (DeviceResolverHandlerInterceptor) this.context
      .getBean("deviceResolverHandlerInterceptor");
  interceptor.preHandle(request, response, null);
  Device device = DeviceUtils.getCurrentDevice(request);
  assertThat(device.isNormal()).isTrue();
  assertThat(device.isMobile()).isFalse();
  assertThat(device.isTablet()).isFalse();
  assertThat(device.getDevicePlatform()).isEqualByComparingTo(DevicePlatform.UNKNOWN);
}

代码示例来源:origin: spring-projects/spring-mobile

private void assertMobile(MockMobileRequest request) {
  Device device = resolver.resolveDevice(request);
  assertFalse(device.isNormal());
  assertTrue(device.isMobile());
  assertFalse(device.isTablet());
  assertEquals(device.toString(), MOBILE_TO_STRING);
}

代码示例来源:origin: spring-projects/spring-mobile

private void assertTablet(MockMobileRequest request) {
  Device device = resolver.resolveDevice(request);
  assertFalse(device.isNormal());
  assertFalse(device.isMobile());
  assertTrue(device.isTablet());
  assertEquals(device.toString(), TABLET_TO_STRING);
}

代码示例来源:origin: spring-projects/spring-mobile

private void assertNormal(MockMobileRequest request) {
  Device device = resolver.resolveDevice(request);
  assertTrue(device.isNormal());
  assertFalse(device.isMobile());
  assertFalse(device.isTablet());
  assertEquals(device.toString(), NORMAL_TO_STRING);
}

代码示例来源:origin: spring-projects/spring-mobile

@Test
public void constructorNormalDeviceOverride() {
  String[] normalDevices = new String[] { "android", "iphone" };
  LiteDeviceResolver resolver2 = new LiteDeviceResolver(
      Arrays.asList(normalDevices));
  request.setUserAgentHeader(UserAgent.IPHONE_IOS5_STRING);
  Device device = resolver2.resolveDevice(request);
  assertTrue(device.isNormal());
  assertFalse(device.isMobile());
  assertFalse(device.isTablet());
  assertEquals(device.toString(), NORMAL_TO_STRING);
  assertIOSPlatform(request);
}

相关文章