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


Java Device.getState方法代码示例

本文整理汇总了Java中com.android.sdklib.devices.Device.getState方法的典型用法代码示例。如果您正苦于以下问题:Java Device.getState方法的具体用法?Java Device.getState怎么用?Java Device.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.sdklib.devices.Device的用法示例。


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

示例1: setDeviceState

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
@Override
public void setDeviceState(State state) {
  if (isOverridingDeviceState()) {
    super.setDeviceState(state);
  }
  else {
    if (isOverridingDevice()) {
      Device device = super.getDevice();
      if (device != null) {
        State equivalentState = device.getState(state.getName());
        if (equivalentState != null) {
          state = equivalentState;
        }
      }
    }
    myParent.setDeviceState(state);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NestedConfiguration.java

示例2: getState

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
/**
 * Returns the {@link com.android.sdklib.devices.State} by the given name for the given {@link com.android.sdklib.devices.Device}
 *
 * @param device the device
 * @param name   the name of the state
 */
@Contract("!null, _ -> !null")
@Nullable
static State getState(@Nullable Device device, @Nullable String name) {
  if (device == null) {
    return null;
  }
  else if (name != null) {
    State state = device.getState(name);
    if (state != null) {
      return state;
    }
  }

  return device.getDefaultState();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ConfigurationFileState.java

示例3: getDeviceState

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
@Override
@Nullable
public State getDeviceState() {
  if (isOverridingDeviceState()) {
    return super.getDeviceState();
  }
  State state = myParent.getDeviceState();
  if (isAlternatingDeviceState() && state != null) {
    State next = getNextDeviceState(state);
    if (next != null) {
      return next;
    } else {
      return state;
    }
  }
  else {
    if ((isAlternatingDevice() || isOverridingDevice()) && state != null) {
      // If the device differs, I need to look up a suitable equivalent state
      // on our device
      Device device = getDevice();
      if (device != null) {
        return device.getState(state.getName());
      }
    }

    return state;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:VaryingConfiguration.java

示例4: getDeviceState

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
@Override
@Nullable
public State getDeviceState() {
  if (isOverridingDeviceState()) {
    return super.getDeviceState();
  }
  else {
    State state = myParent.getDeviceState();
    if (isOverridingDevice()) {
      // If the device differs, I need to look up a suitable equivalent state
      // on our device
      if (state != null) {
        Device device = super.getDevice();
        if (device != null) {
          String name = state.getName();
          state = device.getState(name);
          if (state != null) {
            return state;
          }
          // No such state in this screen
          // Try to find a *similar* one. For example,
          // the parent may be "Landscape" and this device
          // may have "Landscape,Closed" and "Landscape,Open"
          // as is the case with device "3.2in HGVA slider (ADP1)".
          int nameLen = name.length();
          for (State s : device.getAllStates()) {
            String n = s.getName();
            if (n.regionMatches(0, name, 0, Math.min(nameLen, n.length()))) {
              return s;
            }
          }

          return device.getDefaultState();
        }
      }
    }

    return state;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:NestedConfiguration.java

示例5: setDevice

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
/**
 * Sets the device
 *
 * @param device        the device
 * @param preserveState if true, attempt to preserve the state associated with the config
 */
public void setDevice(Device device, boolean preserveState) {
  if (mySpecificDevice != device) {
    Device prevDevice = mySpecificDevice;
    State prevState = myState;

    myDevice = mySpecificDevice = device;

    int updateFlags = CFG_DEVICE;

    if (device != null) {
      State state = null;
      // Attempt to preserve the device state?
      if (preserveState && prevDevice != null) {
        if (prevState != null) {
          FolderConfiguration oldConfig = DeviceConfigHelper.getFolderConfig(prevState);
          if (oldConfig != null) {
            String stateName = getClosestMatch(oldConfig, device.getAllStates());
            state = device.getState(stateName);
          } else {
            state = device.getState(prevState.getName());
          }
        }
      } else if (preserveState && myStateName != null) {
        state = device.getState(myStateName);
      }
      if (state == null) {
        state = device.getDefaultState();
      }
      if (myState != state) {
        setDeviceStateName(state.getName());
        myState = state;
        updateFlags |= CFG_DEVICE_STATE;
      }
    }

    // TODO: Is this redundant with the stuff above?
    if (mySpecificDevice != null && myState == null) {
      setDeviceStateName(mySpecificDevice.getDefaultState().getName());
      myState = mySpecificDevice.getDefaultState();
      updateFlags |= CFG_DEVICE_STATE;
    }

    updated(updateFlags);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:Configuration.java

示例6: test

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
public void test() throws Exception {
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration configuration = Configuration.create(manager, null, new FolderConfiguration());
  assertNotNull(configuration);

  configuration.startBulkEditing();
  configuration.setDisplayName("myconfig");
  configuration.setTheme("@style/Theme1");
  configuration.setNightMode(NightMode.NIGHT);
  configuration.setActivity("tes.tpkg.MyActivity1");
  configuration.setUiMode(UiMode.TELEVISION);
  IAndroidTarget target = configuration.getConfigurationManager().getTarget();
  Device device = configuration.getConfigurationManager().getDefaultDevice();
  State deviceState = device != null ? device.getState("Portrait") : null;
  if (target != null) {
    configuration.setTarget(target);
  }
  if (device != null) {
    configuration.setDevice(device, false);
    assertNotNull(deviceState);
    configuration.setDeviceState(deviceState);
  }
  configuration.setLocale(Locale.create("en-rUS"));
  configuration.finishBulkEditing();

  assertEquals("myconfig", configuration.getDisplayName());
  assertEquals("@style/Theme1", configuration.getTheme());
  assertEquals(NightMode.NIGHT, configuration.getNightMode());
  assertEquals("tes.tpkg.MyActivity1", configuration.getActivity());
  assertEquals(UiMode.TELEVISION, configuration.getUiMode());
  assertEquals(Locale.create("en-rUS"), configuration.getLocale());
  if (target != null) {
    assertSame(target, configuration.getTarget());
  }
  if (device != null) {
    assertSame(device, configuration.getDevice());
    assertNotNull(deviceState);
    assertSame(deviceState, configuration.getDeviceState());
  }

  FolderConfiguration fullConfig = configuration.getFullConfig();
  LocaleQualifier languageQualifier = fullConfig.getLocaleQualifier();
  String configDisplayString = fullConfig.toDisplayString();
  assertNotNull(configDisplayString, languageQualifier);
  assertEquals("en", languageQualifier.getLanguage());
  String region = fullConfig.getLocaleQualifier().getRegion();
  assertNotNull(configDisplayString, region);
  assertEquals("US", region);
  assertEquals(UiMode.TELEVISION, fullConfig.getUiModeQualifier().getValue());
  assertEquals(NightMode.NIGHT, fullConfig.getNightModeQualifier().getValue());
  assertEquals(ScreenOrientation.PORTRAIT, fullConfig.getScreenOrientationQualifier().getValue());

  if (device != null) {
    State landscape = device.getState("Landscape");
    assertNotNull(landscape);
    configuration.setDeviceState(landscape);
    assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:ConfigurationTest.java

示例7: testCreateSimilar

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
public void testCreateSimilar() throws Exception {
  VirtualFile file1 = myFixture.copyFileToProject(TEST_FILE, "res/layout/layout1.xml");
  VirtualFile file2 = myFixture.copyFileToProject(TEST_FILE, "res/layout-no-rNO/layout1.xml");
  VirtualFile file3 = myFixture.copyFileToProject(TEST_FILE, "res/layout-xlarge-land/layout1.xml");
  myFixture.copyFileToProject(TEST_FILE, "res/layout-en/layout2.xml");

  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration configuration1 = manager.getConfiguration(file1);
  configuration1.getConfigurationManager().setLocale(Locale.create("en"));
  configuration1.setTheme("Theme.Dialog");
  Device device = manager.getDevices().get(manager.getDevices().size() / 2 - 2);
  State state = device.getAllStates().get(device.getAllStates().size() - 1);
  configuration1.getConfigurationManager().selectDevice(device);

  configuration1.setDeviceStateName(state.getName());
  configuration1.save();

  Configuration configuration2 = manager.createSimilar(file2, file1);
  assertEquals(configuration1.getTheme(), configuration2.getTheme());
  Device device2 = configuration2.getDevice();
  assertEquals(configuration1.getDevice(), device2);
  assertEquals(Locale.create("no-rNO"), configuration2.getLocale());
  assertEquals(Locale.create("en"), configuration1.getLocale());

  State portrait = device.getState("Portrait");
  assertNotNull(portrait);
  configuration1.setDeviceState(portrait);

  Configuration configuration3 = manager.createSimilar(file3, file1);
  assertEquals(configuration1.getTheme(), configuration3.getTheme());
  assertNotSame(configuration3.getDeviceState(), portrait);
  assertEquals("Landscape", configuration3.getDeviceState().getName());
  assertEquals(ScreenSize.XLARGE, configuration3.getDevice().getDefaultHardware().getScreen().getSize());
  assertEquals(configuration1.getLocale(), configuration3.getLocale());
  // Ensure project-wide location switching works: both locales should update
  configuration1.getConfigurationManager().setLocale(Locale.create("no"));
  assertEquals(Locale.create("no"), configuration1.getLocale());
  assertEquals(configuration1.getLocale(), configuration3.getLocale());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:ConfigurationTest.java

示例8: test

import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
public void test() throws Exception {
  VirtualFile file = myFixture.copyFileToProject(TEST_FILE, "res/layout/layout1.xml");
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration parent = Configuration.create(manager, file, new FolderConfiguration());
  assertNotNull(parent);

  parent.startBulkEditing();
  parent.setDisplayName("myconfig");
  parent.setTheme("@style/Theme1");
  parent.setNightMode(NightMode.NIGHT);
  parent.setActivity("tes.tpkg.MyActivity1");
  parent.setUiMode(UiMode.TELEVISION);
  IAndroidTarget target = parent.getConfigurationManager().getTarget();
  Device device = parent.getConfigurationManager().getDefaultDevice();
  State deviceState = device != null ? device.getState("Portrait") : null;
  if (target != null) {
    parent.setTarget(target);
  }
  if (device != null) {
    parent.setDevice(device, false);
    assertNotNull(deviceState);
    parent.setDeviceState(deviceState);
  }
  parent.setLocale(Locale.create("en-rUS"));
  parent.finishBulkEditing();

  VaryingConfiguration configuration = VaryingConfiguration.create(parent);
  configuration.setAlternateUiMode(true);
  assertEquals(UiMode.TELEVISION, parent.getUiMode());
  assertEquals(UiMode.APPLIANCE, configuration.getUiMode());
  parent.setUiMode(UiMode.APPLIANCE);
  assertEquals(UiMode.WATCH, configuration.getUiMode());

  assertNotNull(device);
  State portrait = device.getState("Portrait");
  State landscape = device.getState("Landscape");
  assertNotNull(portrait);
  assertNotNull(landscape);
  configuration.setAlternateDeviceState(true);
  assertTrue(configuration.isAlternatingDeviceState());
  assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  parent.setDeviceState(landscape);
  assertEquals(ScreenOrientation.PORTRAIT, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  assertEquals(portrait, configuration.getDeviceState());
  parent.setDeviceState(portrait);
  assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  assertEquals(landscape, configuration.getDeviceState());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:VaryingConfigurationTest.java


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