Example usage for com.facebook.react.uimanager PixelUtil toDIPFromPixel

List of usage examples for com.facebook.react.uimanager PixelUtil toDIPFromPixel

Introduction

In this page you can find the example usage for com.facebook.react.uimanager PixelUtil toDIPFromPixel.

Prototype

public static float toDIPFromPixel(float value) 

Source Link

Document

Convert from PX to DP

Usage

From source file:com.zulipmobile.AnchorScrollEvent.java

License:Open Source License

private WritableMap serializeEventData() {
    WritableMap contentInset = Arguments.createMap();
    contentInset.putDouble("top", 0);
    contentInset.putDouble("bottom", 0);
    contentInset.putDouble("left", 0);
    contentInset.putDouble("right", 0);

    WritableMap contentOffset = Arguments.createMap();
    contentOffset.putDouble("x", PixelUtil.toDIPFromPixel(mScrollX));
    contentOffset.putDouble("y", PixelUtil.toDIPFromPixel(mScrollY));

    WritableMap contentSize = Arguments.createMap();
    contentSize.putDouble("width", PixelUtil.toDIPFromPixel(mContentWidth));
    contentSize.putDouble("height", PixelUtil.toDIPFromPixel(mContentHeight));

    WritableMap layoutMeasurement = Arguments.createMap();
    layoutMeasurement.putDouble("width", PixelUtil.toDIPFromPixel(mScrollViewWidth));
    layoutMeasurement.putDouble("height", PixelUtil.toDIPFromPixel(mScrollViewHeight));

    // Zulip changes
    WritableArray visibleIds = Arguments.createArray();
    if (mVisibleIds != null) {
        for (String id : mVisibleIds) {
            visibleIds.pushString(id);/*from   w ww  . j a va 2s. com*/
        }
    }

    WritableMap event = Arguments.createMap();
    event.putMap("contentInset", contentInset);
    event.putMap("contentOffset", contentOffset);
    event.putMap("contentSize", contentSize);
    event.putMap("layoutMeasurement", layoutMeasurement);
    event.putArray("visibleIds", visibleIds);
    event.putBoolean("humanInteraction", mHumanInteraction);

    event.putInt("target", getViewTag());
    event.putBoolean("responderIgnoreScroll", true);
    return event;
}