當前位置: 首頁>>代碼示例>>Java>>正文


Java DeviceEventManagerModule類代碼示例

本文整理匯總了Java中com.facebook.react.modules.core.DeviceEventManagerModule的典型用法代碼示例。如果您正苦於以下問題:Java DeviceEventManagerModule類的具體用法?Java DeviceEventManagerModule怎麽用?Java DeviceEventManagerModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DeviceEventManagerModule類屬於com.facebook.react.modules.core包,在下文中一共展示了DeviceEventManagerModule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SendEvent

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
public void SendEvent(String eventName, Object... args) {
	WritableArray argsList = Arguments.createArray();
	for (Object arg : args) {
		if (arg == null)
			argsList.pushNull();
		else if (arg instanceof Boolean)
			argsList.pushBoolean((Boolean)arg);
		else if (arg instanceof Integer)
			argsList.pushInt((Integer)arg);
		else if (arg instanceof Double)
			argsList.pushDouble((Double)arg);
		else if (arg instanceof String)
			argsList.pushString((String)arg);
		else if (arg instanceof WritableArray)
			argsList.pushArray((WritableArray)arg);
		else {
			//Assert(arg instanceof WritableMap, "Event args must be one of: WritableArray, Boolean")
			if (!(arg instanceof WritableMap))
				throw new RuntimeException("Event args must be one of: Boolean, Integer, Double, String, WritableArray, WritableMap");
			argsList.pushMap((WritableMap)arg);
		}
	}

	DeviceEventManagerModule.RCTDeviceEventEmitter jsModuleEventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
	jsModuleEventEmitter.emit(eventName, argsList);
}
 
開發者ID:Venryx,項目名稱:react-native-libmuse,代碼行數:27,代碼來源:LibMuseModule.java

示例2: listenVolume

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
private void listenVolume(final ReactApplicationContext reactContext) {
    volumeBR = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) {
                WritableMap para = Arguments.createMap();
                para.putDouble("value", getNormalizationVolume(VOL_MUSIC));
                para.putDouble(VOL_VOICE_CALL, getNormalizationVolume(VOL_VOICE_CALL));
                para.putDouble(VOL_SYSTEM, getNormalizationVolume(VOL_SYSTEM));
                para.putDouble(VOL_RING, getNormalizationVolume(VOL_RING));
                para.putDouble(VOL_MUSIC, getNormalizationVolume(VOL_MUSIC));
                para.putDouble(VOL_ALARM, getNormalizationVolume(VOL_ALARM));
                para.putDouble(VOL_NOTIFICATION, getNormalizationVolume(VOL_NOTIFICATION));
                reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                        .emit("EventVolume", para);
            }
        }
    };
    filter = new IntentFilter("android.media.VOLUME_CHANGED_ACTION");

    reactContext.registerReceiver(volumeBR, filter);
}
 
開發者ID:c19354837,項目名稱:react-native-system-setting,代碼行數:23,代碼來源:SystemSetting.java

示例3: handleMediaRowData

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
private void handleMediaRowData(String data, long dateTaken, int width, int height) {
    if (checkScreenShot(data, dateTaken, width, height)) {
        Log.d(TAG, "ScreenShot: path = " + data + "; size = " + width + " * " + height
                + "; date = " + dateTaken);
        WritableMap map = Arguments.createMap();

        try {
            map.putString("url", data);
            map.putDouble("timeStamp", dateTaken);
            // TODO 回調方法。
            if (!checkCallback(data)) {

                mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                        .emit(ScreenShotEvent, map);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        // 如果在觀察區間媒體數據庫有數據改變,又不符合截屏規則,則輸出到 log 待分析
        Log.w(TAG, "Media content changed, but not screenshot: path = " + data
                + "; size = " + width + " * " + height + "; date = " + dateTaken);
    }
}
 
開發者ID:fenglu09,項目名稱:react-native-screenshot-detect,代碼行數:26,代碼來源:ScreenShotDetectModule.java

示例4: onReceive

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
  final String action = intent.getAction();

  if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
    final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
            BluetoothAdapter.ERROR);
    boolean active = false;
    switch (state) {
      case BluetoothAdapter.STATE_OFF:
        active = false;
        break;
      case BluetoothAdapter.STATE_ON:
        active = true;
        break;
    }

    final WritableMap eventMap = new WritableNativeMap();
    eventMap.putString(EVENT_TYPE, "bluetooth");
    eventMap.putBoolean(EVENT_STATUS, active);
    getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(RN_CONNECTIVITY_STATUS_TOPIC, eventMap);
  }
}
 
開發者ID:nearit,項目名稱:react-native-connectivity-status,代碼行數:24,代碼來源:RNConnectivityStatusModule.java

示例5: onNewIntent

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
/**
 * This method will give JS the opportunity to receive intents via Linking.
 */
public void onNewIntent(Intent intent) {
  if (mCurrentReactContext == null) {
    FLog.w(ReactConstants.TAG, "Instance detached from instance manager");
  } else {
    String action = intent.getAction();
    Uri uri = intent.getData();

    if (Intent.ACTION_VIEW.equals(action) && uri != null) {
      DeviceEventManagerModule deviceEventManagerModule =
              Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
      deviceEventManagerModule.emitNewIntentReceived(uri);
    }

    mCurrentReactContext.onNewIntent(mCurrentActivity, intent);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:20,代碼來源:ReactInstanceManager.java

示例6: createJSModules

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:20,代碼來源:CoreModulesPackage.java

示例7: startListeningToAnimatedNodeValue

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@ReactMethod
public void startListeningToAnimatedNodeValue(final int tag) {
  final AnimatedNodeValueListener listener = new AnimatedNodeValueListener() {
    public void onValueUpdate(double value) {
      WritableMap onAnimatedValueData = Arguments.createMap();
      onAnimatedValueData.putInt("tag", tag);
      onAnimatedValueData.putDouble("value", value);
      getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
          .emit("onAnimatedValueUpdate", onAnimatedValueData);
    }
  };

  mOperations.add(new UIThreadOperation() {
    @Override
    public void execute(NativeAnimatedNodesManager animatedNodesManager) {
      animatedNodesManager.startListeningToAnimatedNodeValue(tag, listener);
    }
  });
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:20,代碼來源:NativeAnimatedModule.java

示例8: onSensorChanged

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onSensorChanged(SensorEvent event) {
    if( event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR ){
        // calculate th rotation matrix
        SensorManager.getRotationMatrixFromVector(rMat, event.values);
        // get the azimuth value (orientation[0]) in degree

        newAzimuth = (int) ((((( Math.toDegrees( SensorManager.getOrientation( rMat, orientation )[0] ) + 360 ) % 360) -
                      ( Math.toDegrees( SensorManager.getOrientation( rMat, orientation )[2] ))) +360) % 360);

        //dont react to changes smaller than the filter value
        if (Math.abs(mAzimuth - newAzimuth) < mFilter) {
            return;
        }

        getReactApplicationContext()
                .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit("headingUpdated", (int) newAzimuth);

        mAzimuth = newAzimuth;
    }
}
 
開發者ID:yonahforst,項目名稱:react-native-heading,代碼行數:23,代碼來源:ReactNativeHeadingModule.java

示例9: receiveMessage

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
private void receiveMessage(SmsMessage message) {
    if (mContext == null) {
        return;
    }

    if (! mContext.hasActiveCatalystInstance()) {
        return;
    }

    Log.d(
        SmsListenerPackage.TAG,
        String.format("%s: %s", message.getOriginatingAddress(), message.getMessageBody())
    );

    WritableNativeMap receivedMessage = new WritableNativeMap();

    receivedMessage.putString("originatingAddress", message.getOriginatingAddress());
    receivedMessage.putString("body", message.getMessageBody());

    mContext
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit(EVENT, receivedMessage);
}
 
開發者ID:CentaurWarchief,項目名稱:react-native-android-sms-listener,代碼行數:24,代碼來源:SmsReceiver.java

示例10: onError

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onError(final Exception ex, final VoiceSearchInfo voiceSearchInfo) {
    Log.d("MirrorApp", voiceSearchInfo.getErrorType().toString() + "\n\n" + exceptionToString(ex));

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    String json = new String();

    WritableMap params = Arguments.createMap();
    params.putString("error", json);

    ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
    reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
            .emit("houndifyResponseError", params);

    if ( phraseSpotterReader == null ) {
        startPhraseSpotting();
    }
}
 
開發者ID:soundhound,項目名稱:houndify-smart-mirror,代碼行數:20,代碼來源:MainActivity.java

示例11: onNewIntent

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onNewIntent(Intent intent) {
  if (mCurrentReactContext == null) {
    FLog.w(ReactConstants.TAG, "Instance detached from instance manager");
  } else {
    String action = intent.getAction();
    Uri uri = intent.getData();

    if (Intent.ACTION_VIEW.equals(action) && uri != null) {
      DeviceEventManagerModule deviceEventManagerModule =
              Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
      deviceEventManagerModule.emitNewIntentReceived(uri);
    }

    mCurrentReactContext.onNewIntent(mCurrentActivity, intent);
  }
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:18,代碼來源:XReactInstanceManagerImpl.java

示例12: onSensorChanged

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onSensorChanged(SensorEvent event) {
    if( event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR ){
        // calculate th rotation matrix
        SensorManager.getRotationMatrixFromVector(rMat, event.values);
        // get the azimuth value (orientation[0]) in degree
        int newAzimuth = (int) ( Math.toDegrees( SensorManager.getOrientation( rMat, orientation )[0] ) + 360 ) % 360;

        //dont react to changes smaller than the filter value
        if (Math.abs(mAzimuth - newAzimuth) < mFilter) {
            return;
        }

        mAzimuth = newAzimuth;

        getReactApplicationContext()
                .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit("HeadingUpdated", mAzimuth);
    }
}
 
開發者ID:vnil,項目名稱:react-native-simple-compass,代碼行數:21,代碼來源:RNSimpleCompassModule.java

示例13: onReceive

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();

    // Focus the application
    String packageName = context.getApplicationContext().getPackageName();
    Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter();

    focusIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

    final Activity activity = getActivity();
    if (activity != null) {
        activity.startActivity(focusIntent);
    }

    // Send event to JS
    WritableMap params = Arguments.createMap();
    params.putInt("id", extras.getInt(NotificationEventReceiver.NOTIFICATION_ID));
    params.putString("payload", extras.getString(NotificationEventReceiver.PAYLOAD));

    getReactApplicationContext()
            .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
            .emit("RNNotification:press", params);

    this.setResultCode(Activity.RESULT_OK);
}
 
開發者ID:mehcode,項目名稱:rn-notification,代碼行數:27,代碼來源:NotificationModule.java

示例14: sendEvent

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
private static void sendEvent(ReactApplicationContext context, String type, Object value) {
    WritableMap data = Arguments.createMap();
    data.putString("name", type);

    if(value == null) {
        // NOOP
    } else if(value instanceof Double || value instanceof Float) {
        data.putDouble("value", (double)value);
    } else if(value instanceof Boolean) {
        data.putBoolean("value", (boolean)value);
    } else if(value instanceof Integer) {
        data.putInt("value", (int)value);
    }

    context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("RNMusicControlEvent", data);
}
 
開發者ID:tanguyantoine,項目名稱:react-native-music-control,代碼行數:17,代碼來源:MusicControlListener.java

示例15: onActivityResult

import com.facebook.react.modules.core.DeviceEventManagerModule; //導入依賴的package包/類
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    SysSettings setting = SysSettings.get(requestCode);
    if (setting != SysSettings.UNKNOW) {
        mContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit(setting.event, null);
        mContext.removeActivityEventListener(this);
    }
}
 
開發者ID:c19354837,項目名稱:react-native-system-setting,代碼行數:10,代碼來源:SystemSetting.java


注:本文中的com.facebook.react.modules.core.DeviceEventManagerModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。