<commit_before>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.views.textinput;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.uimanager.events.RCTModernEventEmitter;

/** Event emitted by EditText native view when key pressed */
public class ReactTextInputKeyPressEvent extends Event<ReactTextInputEvent> {

  public static final String EVENT_NAME = "topKeyPress";

  private String mKey;

  @Deprecated
  ReactTextInputKeyPressEvent(int viewId, final String key) {
    this(-1, viewId, key);
  }

  ReactTextInputKeyPressEvent(int surfaceId, int viewId, final String key) {
    super(surfaceId, viewId);
    mKey = key;
  }

  @Override
  public String getEventName() {
    return EVENT_NAME;
  }

  @Override
  public boolean canCoalesce() {
    // We don't want to miss any textinput event, as event data is incremental.
    return false;
  }

  @Override
  public void dispatch(RCTEventEmitter rctEventEmitter) {
    rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData());
  }

  @Override
  public void dispatchModern(RCTModernEventEmitter rctEventEmitter) {
    rctEventEmitter.receiveEvent(
        getSurfaceId(), getViewTag(), getEventName(), serializeEventData());
  }

  private WritableMap serializeEventData() {
    WritableMap eventData = Arguments.createMap();
    eventData.putString("key", mKey);

    return eventData;
  }
}<commit_msg>Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputKeyPressEvent Event class<commit_after>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.views.textinput;

import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

/** Event emitted by EditText native view when key pressed */
public class ReactTextInputKeyPressEvent extends Event<ReactTextInputEvent> {

  public static final String EVENT_NAME = "topKeyPress";

  private String mKey;

  @Deprecated
  ReactTextInputKeyPressEvent(int viewId, final String key) {
    this(-1, viewId, key);
  }

  ReactTextInputKeyPressEvent(int surfaceId, int viewId, final String key) {
    super(surfaceId, viewId);
    mKey = key;
  }

  @Override
  public String getEventName() {
    return EVENT_NAME;
  }

  @Nullable
  @Override
  protected WritableMap getEventData() {
    WritableMap eventData = Arguments.createMap();
    eventData.putString("key", mKey);
    return eventData;
  }

  @Override
  public boolean canCoalesce() {
    // We don't want to miss any textinput event, as event data is incremental.
    return false;
  }
}
{'fraction_non_alphanumeric': 0.08859536082474227, 'fraction_numerical': 0.0006443298969072165, 'mean_word_length': 4.32590051457976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2566851', 'n_tokens_mistral': 922, 'n_tokens_neox': 904, 'n_words': 263}