mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Format Java code in xplat/js/react-native-github
Summary: This diff formats the Java class files inside xplat/js/react-native-github. Since google-java-format was enabled in D16071401 we want to codemode the existing code so that users don't have to deal with formatter lint noise at diff-time. ```arc f --paths-cmd 'hg files -I "**/*.java"'``` drop-conflicts Reviewed By: cpojer Differential Revision: D16071725 fbshipit-source-id: fc6e3852e45742c109f0c5ac4065d64201c74204
This commit is contained in:
committed by
Facebook Github Bot
parent
61e95e5cbf
commit
6c0f73b322
+25
-36
@@ -1,47 +1,42 @@
|
||||
/**
|
||||
* 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.
|
||||
* <p>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;
|
||||
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Responsible for dispatching events specific for hardware inputs.
|
||||
*/
|
||||
/** Responsible for dispatching events specific for hardware inputs. */
|
||||
public class ReactAndroidHWInputDeviceHelper {
|
||||
|
||||
/**
|
||||
* Contains a mapping between handled KeyEvents and the corresponding navigation event
|
||||
* that should be fired when the KeyEvent is received.
|
||||
* Contains a mapping between handled KeyEvents and the corresponding navigation event that should
|
||||
* be fired when the KeyEvent is received.
|
||||
*/
|
||||
private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.<Integer, String>builder()
|
||||
.put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
|
||||
.put(KeyEvent.KEYCODE_ENTER, "select")
|
||||
.put(KeyEvent.KEYCODE_SPACE, "select")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
|
||||
.put(KeyEvent.KEYCODE_DPAD_UP, "up")
|
||||
.put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
|
||||
.put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
|
||||
.put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
|
||||
.build();
|
||||
private static final Map<Integer, String> KEY_EVENTS_ACTIONS =
|
||||
MapBuilder.<Integer, String>builder()
|
||||
.put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
|
||||
.put(KeyEvent.KEYCODE_ENTER, "select")
|
||||
.put(KeyEvent.KEYCODE_SPACE, "select")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
|
||||
.put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
|
||||
.put(KeyEvent.KEYCODE_DPAD_UP, "up")
|
||||
.put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
|
||||
.put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
|
||||
.put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
|
||||
.build();
|
||||
|
||||
/**
|
||||
* We keep a reference to the last focused view id
|
||||
* so that we can send it as a target for key events
|
||||
* and be able to send a blur event when focus changes.
|
||||
* We keep a reference to the last focused view id so that we can send it as a target for key
|
||||
* events and be able to send a blur event when focus changes.
|
||||
*/
|
||||
private int mLastFocusedViewId = View.NO_ID;
|
||||
|
||||
@@ -51,21 +46,17 @@ public class ReactAndroidHWInputDeviceHelper {
|
||||
this.mReactRootView = mReactRootView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from {@link ReactRootView}.
|
||||
* This is the main place the key events are handled.
|
||||
*/
|
||||
/** Called from {@link ReactRootView}. This is the main place the key events are handled. */
|
||||
public void handleKeyEvent(KeyEvent ev) {
|
||||
int eventKeyCode = ev.getKeyCode();
|
||||
int eventKeyAction = ev.getAction();
|
||||
if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) && KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
|
||||
if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN)
|
||||
&& KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
|
||||
dispatchEvent(KEY_EVENTS_ACTIONS.get(eventKeyCode), mLastFocusedViewId, eventKeyAction);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from {@link ReactRootView} when focused view changes.
|
||||
*/
|
||||
/** Called from {@link ReactRootView} when focused view changes. */
|
||||
public void onFocusChanged(View newFocusedView) {
|
||||
if (mLastFocusedViewId == newFocusedView.getId()) {
|
||||
return;
|
||||
@@ -77,9 +68,7 @@ public class ReactAndroidHWInputDeviceHelper {
|
||||
dispatchEvent("focus", newFocusedView.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from {@link ReactRootView} when the whole view hierarchy looses focus.
|
||||
*/
|
||||
/** Called from {@link ReactRootView} when the whole view hierarchy looses focus. */
|
||||
public void clearFocus() {
|
||||
if (mLastFocusedViewId != View.NO_ID) {
|
||||
dispatchEvent("blur", mLastFocusedViewId);
|
||||
|
||||
Reference in New Issue
Block a user