Java 类com.facebook.react.uimanager.DisplayMetricsHolder 实例源码

项目:RNLearn_Project1    文件:DeviceInfoModule.java   
private WritableMap getDimensionsConstants() {
  DisplayMetrics windowDisplayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
  DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();

  WritableMap windowDisplayMetricsMap = Arguments.createMap();
  windowDisplayMetricsMap.putInt("width", windowDisplayMetrics.widthPixels);
  windowDisplayMetricsMap.putInt("height", windowDisplayMetrics.heightPixels);
  windowDisplayMetricsMap.putDouble("scale", windowDisplayMetrics.density);
  windowDisplayMetricsMap.putDouble("fontScale", mFontScale);
  windowDisplayMetricsMap.putDouble("densityDpi", windowDisplayMetrics.densityDpi);

  WritableMap screenDisplayMetricsMap = Arguments.createMap();
  screenDisplayMetricsMap.putInt("width", screenDisplayMetrics.widthPixels);
  screenDisplayMetricsMap.putInt("height", screenDisplayMetrics.heightPixels);
  screenDisplayMetricsMap.putDouble("scale", screenDisplayMetrics.density);
  screenDisplayMetricsMap.putDouble("fontScale", mFontScale);
  screenDisplayMetricsMap.putDouble("densityDpi", screenDisplayMetrics.densityDpi);

  WritableMap dimensionsMap = Arguments.createMap();
  dimensionsMap.putMap("windowPhysicalPixels", windowDisplayMetricsMap);
  dimensionsMap.putMap("screenPhysicalPixels", screenDisplayMetricsMap);

  return dimensionsMap;
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void checkForKeyboardEvents() {
  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
    DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:RNLearn_Project1    文件:DeviceInfoModule.java   
private WritableMap getDimensionsConstants() {
  DisplayMetrics windowDisplayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
  DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();

  WritableMap windowDisplayMetricsMap = Arguments.createMap();
  windowDisplayMetricsMap.putInt("width", windowDisplayMetrics.widthPixels);
  windowDisplayMetricsMap.putInt("height", windowDisplayMetrics.heightPixels);
  windowDisplayMetricsMap.putDouble("scale", windowDisplayMetrics.density);
  windowDisplayMetricsMap.putDouble("fontScale", mFontScale);
  windowDisplayMetricsMap.putDouble("densityDpi", windowDisplayMetrics.densityDpi);

  WritableMap screenDisplayMetricsMap = Arguments.createMap();
  screenDisplayMetricsMap.putInt("width", screenDisplayMetrics.widthPixels);
  screenDisplayMetricsMap.putInt("height", screenDisplayMetrics.heightPixels);
  screenDisplayMetricsMap.putDouble("scale", screenDisplayMetrics.density);
  screenDisplayMetricsMap.putDouble("fontScale", mFontScale);
  screenDisplayMetricsMap.putDouble("densityDpi", screenDisplayMetrics.densityDpi);

  WritableMap dimensionsMap = Arguments.createMap();
  dimensionsMap.putMap("windowPhysicalPixels", windowDisplayMetricsMap);
  dimensionsMap.putMap("screenPhysicalPixels", screenDisplayMetricsMap);

  return dimensionsMap;
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void checkForKeyboardEvents() {
  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
    DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:ReactNativeSignatureExample    文件:TextInputTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextInputManager(),
      });
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:ReactNativeSignatureExample    文件:ReactTextTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextViewManager(),
          new ReactRawTextManager(),
      });
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:react-native-ibeacon-android    文件:TextInputTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextInputManager(),
      });
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:react-native-ibeacon-android    文件:ReactTextTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextViewManager(),
          new ReactRawTextManager(),
      });
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:react-native-box-loaders    文件:TextInputTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextInputManager(),
      });
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:react-native-box-loaders    文件:ReactTextTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
  DisplayMetricsHolder.setScreenDisplayMetrics(displayMetrics);
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextViewManager(),
          new ReactRawTextManager(),
      });
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementation(reactContext, viewManagers));
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:Ironman    文件:ReactRootView.java   
private void checkForKeyboardEvents() {
  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
    DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:Ironman    文件:ReactRootView.java   
private void emitUpdateDimensionsEvent() {
  DisplayMetrics windowDisplayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
  DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();

  WritableMap windowDisplayMetricsMap = Arguments.createMap();
  windowDisplayMetricsMap.putInt("width", windowDisplayMetrics.widthPixels);
  windowDisplayMetricsMap.putInt("height", windowDisplayMetrics.heightPixels);
  windowDisplayMetricsMap.putDouble("scale", windowDisplayMetrics.density);
  windowDisplayMetricsMap.putDouble("fontScale", windowDisplayMetrics.scaledDensity);
  windowDisplayMetricsMap.putDouble("densityDpi", windowDisplayMetrics.densityDpi);

  WritableMap screenDisplayMetricsMap = Arguments.createMap();
  screenDisplayMetricsMap.putInt("width", screenDisplayMetrics.widthPixels);
  screenDisplayMetricsMap.putInt("height", screenDisplayMetrics.heightPixels);
  screenDisplayMetricsMap.putDouble("scale", screenDisplayMetrics.density);
  screenDisplayMetricsMap.putDouble("fontScale", screenDisplayMetrics.scaledDensity);
  screenDisplayMetricsMap.putDouble("densityDpi", screenDisplayMetrics.densityDpi);

  WritableMap dimensionsMap = Arguments.createMap();
  dimensionsMap.putMap("windowPhysicalPixels", windowDisplayMetricsMap);
  dimensionsMap.putMap("screenPhysicalPixels", screenDisplayMetricsMap);
  sendEvent("didUpdateDimensions", dimensionsMap);
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void checkForDeviceOrientationChanges() {
  final int rotation =
    ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
      .getDefaultDisplay().getRotation();
  if (mDeviceRotation == rotation) {
    return;
  }
  mDeviceRotation = rotation;
  // It's important to repopulate DisplayMetrics and export them before emitting the
  // orientation change event, so that the Dimensions object returns the correct new values.
  DisplayMetricsHolder.initDisplayMetrics(getContext());
  emitUpdateDimensionsEvent();
  emitOrientationChanged(rotation);
}
项目:RNLearn_Project1    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:RNLearn_Project1    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void checkForDeviceOrientationChanges() {
  final int rotation =
    ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
      .getDefaultDisplay().getRotation();
  if (mDeviceRotation == rotation) {
    return;
  }
  mDeviceRotation = rotation;
  // It's important to repopulate DisplayMetrics and export them before emitting the
  // orientation change event, so that the Dimensions object returns the correct new values.
  DisplayMetricsHolder.initDisplayMetrics(getContext());
  emitUpdateDimensionsEvent();
  emitOrientationChanged(rotation);
}
项目:RNLearn_Project1    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:RNLearn_Project1    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:ReactNativeSignatureExample    文件:ReactInstanceManagerImpl.java   
private static void setDisplayMetrics(Context context) {
  DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);

  DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
  screenDisplayMetrics.setTo(displayMetrics);
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();

  // Get the real display metrics if we are using API level 17 or higher.
  // The real metrics include system decor elements (e.g. soft menu bar).
  //
  // See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
  if (Build.VERSION.SDK_INT >= 17) {
    display.getRealMetrics(screenDisplayMetrics);
  } else {
    // For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real dimensions.
    // Since react-native only supports API level 16+ we don't have to worry about other cases.
    //
    // Reflection exceptions are rethrown at runtime.
    //
    // See: http://stackoverflow.com/questions/14341041/how-to-get-real-screen-height-and-width/23861333#23861333
    try {
      Method mGetRawH = Display.class.getMethod("getRawHeight");
      Method mGetRawW = Display.class.getMethod("getRawWidth");
      screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
      screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
    } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
      throw new RuntimeException("Error getting real dimensions for API level < 17", e);
    }
  }
  DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
}
项目:ReactNativeSignatureExample    文件:ReactRootView.java   
@Override
public void onGlobalLayout() {
  if (mReactInstanceManager == null || !mIsAttachedToInstance ||
      mReactInstanceManager.getCurrentReactContext() == null) {
    FLog.w(
        ReactConstants.TAG,
        "Unable to dispatch keyboard events in JS as the react instance has not been attached");
    return;
  }

  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
      DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:ReactNativeSignatureExample    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:ReactNativeSignatureExample    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:react-native-ibeacon-android    文件:ReactInstanceManagerImpl.java   
private static void setDisplayMetrics(Context context) {
  DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);

  DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
  screenDisplayMetrics.setTo(displayMetrics);
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();

  // Get the real display metrics if we are using API level 17 or higher.
  // The real metrics include system decor elements (e.g. soft menu bar).
  //
  // See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
  if (Build.VERSION.SDK_INT >= 17) {
    display.getRealMetrics(screenDisplayMetrics);
  } else {
    // For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real dimensions.
    // Since react-native only supports API level 16+ we don't have to worry about other cases.
    //
    // Reflection exceptions are rethrown at runtime.
    //
    // See: http://stackoverflow.com/questions/14341041/how-to-get-real-screen-height-and-width/23861333#23861333
    try {
      Method mGetRawH = Display.class.getMethod("getRawHeight");
      Method mGetRawW = Display.class.getMethod("getRawWidth");
      screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
      screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
    } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
      throw new RuntimeException("Error getting real dimensions for API level < 17", e);
    }
  }
  DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
}
项目:react-native-ibeacon-android    文件:ReactRootView.java   
@Override
public void onGlobalLayout() {
  if (mReactInstanceManager == null || !mIsAttachedToInstance ||
      mReactInstanceManager.getCurrentReactContext() == null) {
    FLog.w(
        ReactConstants.TAG,
        "Unable to dispatch keyboard events in JS as the react instance has not been attached");
    return;
  }

  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
      DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:react-native-ibeacon-android    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:react-native-ibeacon-android    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:react-native-box-loaders    文件:ReactInstanceManagerImpl.java   
private static void setDisplayMetrics(Context context) {
  DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
  DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);

  DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
  screenDisplayMetrics.setTo(displayMetrics);
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();

  // Get the real display metrics if we are using API level 17 or higher.
  // The real metrics include system decor elements (e.g. soft menu bar).
  //
  // See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
  if (Build.VERSION.SDK_INT >= 17) {
    display.getRealMetrics(screenDisplayMetrics);
  } else {
    // For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real dimensions.
    // Since react-native only supports API level 16+ we don't have to worry about other cases.
    //
    // Reflection exceptions are rethrown at runtime.
    //
    // See: http://stackoverflow.com/questions/14341041/how-to-get-real-screen-height-and-width/23861333#23861333
    try {
      Method mGetRawH = Display.class.getMethod("getRawHeight");
      Method mGetRawW = Display.class.getMethod("getRawWidth");
      screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
      screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
    } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
      throw new RuntimeException("Error getting real dimensions for API level < 17", e);
    }
  }
  DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
}
项目:react-native-box-loaders    文件:ReactRootView.java   
@Override
public void onGlobalLayout() {
  if (mReactInstanceManager == null || !mIsAttachedToInstance ||
      mReactInstanceManager.getCurrentReactContext() == null) {
    FLog.w(
        ReactConstants.TAG,
        "Unable to dispatch keyboard events in JS as the react instance has not been attached");
    return;
  }

  getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
  final int heightDiff =
      DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
  if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
    // keyboard is now showing, or the keyboard height has changed
    mKeyboardHeight = heightDiff;
    WritableMap params = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();
    coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
    coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
    coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
    coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
    params.putMap("endCoordinates", coordinates);
    sendEvent("keyboardDidShow", params);
  } else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
    // keyboard is now hidden
    mKeyboardHeight = 0;
    sendEvent("keyboardDidHide", null);
  }
}
项目:react-native-box-loaders    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:react-native-box-loaders    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:Ironman    文件:ReactRootView.java   
private void checkForDeviceOrientationChanges() {
  final int rotation =
    ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
      .getDefaultDisplay().getRotation();
  if (mDeviceRotation == rotation) {
    return;
  }
  mDeviceRotation = rotation;
  // It's important to repopulate DisplayMetrics and export them before emitting the
  // orientation change event, so that the Dimensions object returns the correct new values.
  DisplayMetricsHolder.initDisplayMetrics(getContext());
  emitUpdateDimensionsEvent();
  emitOrientationChanged(rotation);
}
项目:Ironman    文件:ReactTextInputPropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactTextInputManager();
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:Ironman    文件:ReactImagePropertyTest.java   
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
项目:RNLearn_Project1    文件:ARTVirtualNode.java   
public ARTVirtualNode() {
  mScale = DisplayMetricsHolder.getWindowDisplayMetrics().density;
}
项目:RNLearn_Project1    文件:DeviceInfoModule.java   
public DeviceInfoModule(Context context) {
  mReactApplicationContext = null;
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(context);
  mFontScale = context.getResources().getConfiguration().fontScale;
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModuleName,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  UIImplementationProvider uiImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  JSCConfig jscConfig,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyNativeModulesEnabled,
  boolean lazyViewManagersEnabled,
  boolean useStartupThread) {

  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mBundleLoader = bundleLoader;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport,
      redBoxHandler);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
  mUseStartupThread = useStartupThread;
}
项目:RNLearn_Project1    文件:ReactImagePropertyTest.java   
@After
public void teardown() {
  DisplayMetricsHolder.setWindowDisplayMetrics(null);
}
项目:RNLearn_Project1    文件:ARTVirtualNode.java   
public ARTVirtualNode() {
  mScale = DisplayMetricsHolder.getWindowDisplayMetrics().density;
}
项目:RNLearn_Project1    文件:DeviceInfoModule.java   
public DeviceInfoModule(Context context) {
  mReactApplicationContext = null;
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(context);
  mFontScale = context.getResources().getConfiguration().fontScale;
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModuleName,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  UIImplementationProvider uiImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  JSCConfig jscConfig,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyNativeModulesEnabled,
  boolean lazyViewManagersEnabled,
  boolean useStartupThread) {

  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mBundleLoader = bundleLoader;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport,
      redBoxHandler);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
  mUseStartupThread = useStartupThread;
}