当前位置: 首页>>代码示例>>Java>>正文


Java UIDevice类代码示例

本文整理汇总了Java中org.robovm.apple.uikit.UIDevice的典型用法代码示例。如果您正苦于以下问题:Java UIDevice类的具体用法?Java UIDevice怎么用?Java UIDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UIDevice类属于org.robovm.apple.uikit包,在下文中一共展示了UIDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateBatteryLevel

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
private void updateBatteryLevel() {
    float batteryLevel = UIDevice.getCurrentDevice().getBatteryLevel();
    if (batteryLevel < 0) {
        // -1.0 means battery state is UIDeviceBatteryState.Unknown
        levelLabel.setText(NSString.getLocalizedString("Unknown"));
    } else {
        NSNumberFormatter numberFormatter = null;
        if (numberFormatter == null) {
            numberFormatter = new NSNumberFormatter();
            numberFormatter.setNumberStyle(NSNumberFormatterStyle.Percent);
            numberFormatter.setMaximumFractionDigits(1);
        }

        NSNumber levelObj = NSNumber.valueOf(batteryLevel);
        levelLabel.setText(numberFormatter.format(levelObj));
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:BatStatViewController.java

示例2: updateBatteryState

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
private void updateBatteryState() {
    UITableViewCell[] batteryStateCells = new UITableViewCell[] { unknownCell, unpluggedCell, chargingCell,
        fullCell };

    UIDeviceBatteryState currentState = UIDevice.getCurrentDevice().getBatteryState();

    for (int i = 0; i < batteryStateCells.length; i++) {
        UITableViewCell cell = batteryStateCells[i];

        if (i + UIDeviceBatteryState.Unknown.value() == currentState.value()) {
            cell.setAccessoryType(UITableViewCellAccessoryType.Checkmark);
        } else {
            cell.setAccessoryType(UITableViewCellAccessoryType.None);
        }
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:17,代码来源:BatStatViewController.java

示例3: viewDidLoad

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    // Register for battery level and state change notifications.
    UIDevice.Notifications.observeBatteryLevelDidChange(new Runnable() {
        @Override
        public void run() {
            updateBatteryLevel();
        }
    });
    UIDevice.Notifications.observeBatteryStateDidChange(new Runnable() {
        @Override
        public void run() {
            updateBatteryLevel();
            updateBatteryState();
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:BatStatViewController.java

示例4: didFinishLaunching

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // create and initialize the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.All;
  RoboPlatform pf = RoboPlatform.create(window, config);
  addStrongRef(pf);

  final Showcase game = new Showcase(pf, new Showcase.DeviceService() {
                        public String info () {
                          UIDevice device = UIDevice.getCurrentDevice();
                          return "iOS [model=" + device.getModel() +
                            ", os=" + device.getSystemName() + "/" + device.getSystemVersion() +
                            ", name=" + device.getName() +
                            ", orient=" + device.getOrientation() + "]";
                        }
  });
  pf.orient.connect(new Slot<RoboOrientEvent>() {
    public void onEmit (RoboOrientEvent event) {
      if (event instanceof RoboOrientEvent.DidRotate) {
        game.rotate.emit(game);
      }
    }
  });

  // make our main window visible (the platform starts when the window becomes viz)
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:35,代码来源:ShowcaseRoboVM.java

示例5: crateStatsRequestVO

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected StatsRequestVO crateStatsRequestVO() throws IllegalAccessException, InstantiationException {
    U statsReporterVO = (U) requestType.newInstance();
    statsReporterVO.udid = UIDevice.getCurrentDevice().getIdentifierForVendor().asString();
    statsReporterVO.model = UIDevice.getCurrentDevice().getModel();
    statsReporterVO.version = String.valueOf(NSBundle.getMainBundle().getInfoDictionary().asStringMap().get("CFBundleVersion"));
    //System.out.println(statsReporterVO);
    return statsReporterVO;
}
 
开发者ID:UnderwaterApps,项目名称:submarine,代码行数:11,代码来源:IOSStatsReporter.java

示例6: setupPeripherals

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
void setupPeripherals () {
	//motionManager = new CMMotionManager();
	setupAccelerometer();
	setupCompass();
	UIDevice device = UIDevice.getCurrentDevice();
	if (device.getModel().equalsIgnoreCase("iphone")) hasVibrator = true;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:IOSInput.java

示例7: createApplication

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
@Override
protected IOSApplication createApplication() {
	String deviceName = UIDevice.getCurrentDevice().getModel();
	double screenWidth = UIScreen.getMainScreen().getBounds().getWidth();
	double screenHeight = UIScreen.getMainScreen().getBounds().getHeight();
	System.out.println("Device Model: " + deviceName);
    IOSApplicationConfiguration config = new IOSApplicationConfiguration();
    return new IOSApplication(new CDGame(new DesktopGoogleServices(), "Touch", false, (int)screenWidth, (int)screenHeight), config);
}
 
开发者ID:buzzbyte,项目名称:CatchDROP,代码行数:10,代码来源:IOSLauncher.java

示例8: viewDidLayoutSubviews

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
@Override
public void viewDidLayoutSubviews() {
    // Enable battery monitoring.
    UIDevice.getCurrentDevice().setBatteryMonitoringEnabled(true);
    updateBatteryLevel();
    updateBatteryState();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:8,代码来源:BatStatViewController.java

示例9: MyMovieViewController

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
public MyMovieViewController() {
    movieBackgroundImageView = new UIImageView(UIImage.getImage("images/movieBackground.jpg"));
    movieBackgroundImageView.setFrame(new CGRect(0, 0, 240, 128));

    backgroundView = new UIView(new CGRect(0, 0, 320, 460));
    backgroundView.setBackgroundColor(UIColor.fromWhiteAlpha(0.66, 1));

    overlayController = new MyOverlayViewController(this);

    if (Integer.valueOf(UIDevice.getCurrentDevice().getSystemVersion().substring(0, 1)) >= 7) {
        setEdgesForExtendedLayout(UIRectEdge.None);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:14,代码来源:MyMovieViewController.java

示例10: setupPeripherals

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
void setupPeripherals() {
	// motionManager = new CMMotionManager();
	setupAccelerometer();
	setupCompass();
	UIDevice device = UIDevice.getCurrentDevice();
	if (device.getModel().equalsIgnoreCase("iphone"))
		hasVibrator = true;
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:9,代码来源:IOSMini2DxInput.java

示例11: getIosVersion

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
private int getIosVersion() {
    String systemVersion = UIDevice.getCurrentDevice().getSystemVersion().substring(0, 1);
    return Integer.parseInt(systemVersion);
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:5,代码来源:IOS_Launcher.java

示例12: useHalfSize

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
private static boolean useHalfSize (RoboPlatform.Config config) {
  boolean isPad = UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad;
  return isPad && config.iPadLikePhone;
}
 
开发者ID:playn,项目名称:playn,代码行数:5,代码来源:RoboGraphics.java

示例13: boundsChanged

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
void boundsChanged(CGRect bounds) {
  viewportChanged(scale().scaledCeil((float)bounds.getWidth()),
                  scale().scaledCeil((float)bounds.getHeight()));
  orientDetailM.update(toOrientationDetail(UIDevice.getCurrentDevice().getOrientation()));
}
 
开发者ID:playn,项目名称:playn,代码行数:6,代码来源:RoboGraphics.java

示例14: getOSVersion

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
private int getOSVersion () {
  String systemVersion = UIDevice.getCurrentDevice().getSystemVersion();
  int version = Integer.parseInt(systemVersion.split("\\.")[0]);
  return version;
}
 
开发者ID:playn,项目名称:playn,代码行数:6,代码来源:RoboPlatform.java

示例15: didFinishLaunching

import org.robovm.apple.uikit.UIDevice; //导入依赖的package包/类
final boolean didFinishLaunching (UIApplication uiApp, UIApplicationLaunchOptions options) {
	Gdx.app = this;
	this.uiApp = uiApp;

	// enable or disable screen dimming
	UIApplication.getSharedApplication().setIdleTimerDisabled(config.preventScreenDimming);

	Gdx.app.debug("IOSApplication", "iOS version: " + UIDevice.getCurrentDevice().getSystemVersion());
	// fix the scale factor if we have a retina device (NOTE: iOS screen sizes are in "points" not pixels by default!)

	float scale = (float)(getIosVersion() >= 8 ? UIScreen.getMainScreen().getNativeScale() : UIScreen.getMainScreen()
		.getScale());
	if (scale >= 2.0f) {
		Gdx.app.debug("IOSApplication", "scale: " + scale);
		if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad) {
			// it's an iPad!
			displayScaleFactor = config.displayScaleLargeScreenIfRetina * scale;
		} else {
			// it's an iPod or iPhone
			displayScaleFactor = config.displayScaleSmallScreenIfRetina * scale;
		}
	} else {
		// no retina screen: no scaling!
		if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad) {
			// it's an iPad!
			displayScaleFactor = config.displayScaleLargeScreenIfNonRetina;
		} else {
			// it's an iPod or iPhone
			displayScaleFactor = config.displayScaleSmallScreenIfNonRetina;
		}
	}

	GL20 gl20 = new IOSGLES20();

	Gdx.gl = gl20;
	Gdx.gl20 = gl20;

	// setup libgdx
	this.input = new IOSInput(this);
	this.graphics = new IOSGraphics(getBounds(null), scale, this, config, input, gl20);
	this.files = new IOSFiles();
	this.audio = new IOSAudio(config);
	this.net = new IOSNet(this);

	Gdx.files = this.files;
	Gdx.graphics = this.graphics;
	Gdx.audio = this.audio;
	Gdx.input = this.input;
	Gdx.net = this.net;

	this.input.setupPeripherals();

	this.uiWindow = new UIWindow(UIScreen.getMainScreen().getBounds());
	this.uiWindow.setRootViewController(this.graphics.viewController);
	this.uiWindow.makeKeyAndVisible();
	Gdx.app.debug("IOSApplication", "created");
	return true;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:59,代码来源:IOSApplication.java


注:本文中的org.robovm.apple.uikit.UIDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。