public interface DeviceInfo extends UserAgentInspector
UserAgentInspector
Modifier and Type | Field and Description |
---|---|
static String |
SESSION_ATTRIBUTE_NAME
Name of the session attribute to cache DeviceInfo instance
|
Modifier and Type | Method and Description |
---|---|
static DeviceInfo |
create(String userAgentHeader,
String httpAcceptHeader)
Build a DeviceInfo instance using given header values
|
static DeviceInfo |
create(com.vaadin.server.VaadinRequest request)
Build a DeviceInfo instance using a
VaadinRequest |
static Optional<DeviceInfo> |
ensureInited(com.vaadin.server.VaadinSession session)
Ensure that a
DeviceInfo is available from given Vaadin session . |
static Optional<DeviceInfo> |
get()
Get the current DeviceInfo instance, if available.
|
int |
getScreenHeight()
Get client screen height in pixels
|
int |
getScreenWidth()
Get client screen width in pixels
|
int |
getViewPortHeight()
Get application viewport height in pixels
|
int |
getViewPortWidth()
Get application viewport width in pixels
|
static DeviceInfo |
require()
Get the current DeviceInfo instance, or throw an
IllegalStateException if not available. |
getAcceptHeader, getUserAgentHeader, isAndroid, isAndroidPhone, isAndroidTablet, isGameConsole, isIOs, isIPad, isIPhone, isIPod, isKindle, isMobile, isNintendo, isPlaystation, isSmartphone, isTablet, isWebKit, isWindowsPhone, isXbox
static final String SESSION_ATTRIBUTE_NAME
int getScreenWidth()
-1
if not available at method call timeint getScreenHeight()
-1
if not available at method call timeint getViewPortWidth()
-1
if not available at method call timeint getViewPortHeight()
-1
if not available at method call timestatic DeviceInfo create(String userAgentHeader, String httpAcceptHeader)
create
in interface UserAgentInspector
userAgentHeader
- the User-Agent headerhttpAcceptHeader
- the Accept headerDeviceInfo
static DeviceInfo create(com.vaadin.server.VaadinRequest request)
VaadinRequest
create
in interface UserAgentInspector
request
- Vaadin request (not null)DeviceInfo
static Optional<DeviceInfo> get()
DeviceInfo is created using current VaadinRequest
, if available. It is cached into VaadinSession
for further requests.
static DeviceInfo require()
IllegalStateException
if not available.get()
static Optional<DeviceInfo> ensureInited(com.vaadin.server.VaadinSession session)
DeviceInfo
is available from given Vaadin session
. For successful
initialization, a VaadinService.getCurrentRequest()
must be available.session
- Vaadin session (not null)DeviceInfo
instance, if a request is availableCopyright © 2019 The Holon Platform. All rights reserved.