Example #1
0
  public LayoutDevice addUserDevice(String name, float xdpi, float ydpi) {
    LayoutDevice d = new LayoutDevice(name);
    d.setXDpi(xdpi);
    d.setYDpi(ydpi);
    mUserLayoutDevices.add(d);
    combineLayoutDevices();

    return d;
  }
Example #2
0
  /**
   * Replaces a device with a new one with new name and/or x/y dpi, and return the new device. If
   * the name and dpi values are identical the given device is returned an nothing is done
   *
   * @param device the {@link LayoutDevice} to replace
   * @param newName the new name.
   * @param newXDpi the new X dpi value
   * @param newYDpi the new Y dpi value.
   * @return the new LayoutDevice
   */
  public LayoutDevice replaceUserDevice(
      LayoutDevice device, String newName, float newXDpi, float newYDpi) {
    if (device.getName().equals(newName)
        && device.getXDpi() == newXDpi
        && device.getYDpi() == newYDpi) {
      return device;
    }

    // else create a new device
    LayoutDevice newDevice = new LayoutDevice(newName);
    newDevice.setXDpi(newXDpi);
    newDevice.setYDpi(newYDpi);

    // and get the Folderconfiguration
    List<DeviceConfig> configs = device.getConfigs();
    newDevice.addConfigs(configs);

    // replace the old device with the new
    mUserLayoutDevices.remove(device);
    mUserLayoutDevices.add(newDevice);
    combineLayoutDevices();

    return newDevice;
  }