当前位置: 首页>>代码示例>>Java>>正文


Java MuseListener类代码示例

本文整理汇总了Java中com.choosemuse.libmuse.MuseListener的典型用法代码示例。如果您正苦于以下问题:Java MuseListener类的具体用法?Java MuseListener怎么用?Java MuseListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MuseListener类属于com.choosemuse.libmuse包,在下文中一共展示了MuseListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AddMuseListListener

import com.choosemuse.libmuse.MuseListener; //导入依赖的package包/类
void AddMuseListListener() {
	// Register a listener to receive notifications of what Muse headbands we can connect to.
	manager.setMuseListener(new MuseListener() {
		@Override public void museListChanged() {
			List<Muse> muses = manager.getMuses();
			WritableArray museList = Arguments.createArray();
			for (Muse muse : muses) {
				WritableMap museInfo = Arguments.createMap();
				museInfo.putString("name", muse.getName());
				museInfo.putString("macAddress", muse.getMacAddress());
				museInfo.putDouble("lastDiscoveredTime", muse.getLastDiscoveredTime());
				museInfo.putDouble("rssi", muse.getRssi());
				museList.pushMap(museInfo);
			}
			SendEvent("OnChangeMuseList", museList);
		}
	});
}
 
开发者ID:Venryx,项目名称:react-native-libmuse,代码行数:19,代码来源:LibMuseModule.java

示例2: onCreate

import com.choosemuse.libmuse.MuseListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Initialize Muse first up.
  MuseManagerAndroid.getInstance().setContext(this);

  // Bind viewmodel to the view.
  ActivityDeviceDetailsBinding binding =
      DataBindingUtil.setContentView(this, R.layout.activity_device_details);
  binding.setDeviceVM(deviceVM);
  binding.setIsGoodVM(new SensorGoodViewModel(deviceVM));
  binding.setConnectionVM(new ConnectionStrengthViewModel(deviceVM));
  binding.setRawVM(  deviceVM.createRawTimeSeries(Eeg.EEG3, DURATION_SEC));
  binding.setThetaVM(deviceVM.createFrequencyLiveValue(Band.THETA, ValueType.SCORE));
  binding.setDeltaVM(deviceVM.createFrequencyLiveValue(Band.DELTA, ValueType.SCORE));
  binding.setAlphaVM(deviceVM.createFrequencyLiveValue(Band.ALPHA, ValueType.SCORE));
  binding.setBetaVM( deviceVM.createFrequencyLiveValue(Band.BETA,  ValueType.SCORE));

  // Bind action bar, seems like this can't be done in the layout :(
  deviceVM.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable sender, int propertyId) {
      DeviceDetailsActivity.this.getSupportActionBar().setTitle(
          String.format("%s: %s", deviceVM.getName(), deviceVM.getConnectionState())
      );
    }
  });

  // And attach the desired muse to the VM once connected.
  final String macAddress = getIntent().getExtras().getString("mac");
  if (macAddress != null) {
    MuseManagerAndroid.getInstance().startListening();
    MuseManagerAndroid.getInstance().setMuseListener(new MuseListener() {
      @Override
      public void museListChanged() {
        for (Muse muse : MuseManagerAndroid.getInstance().getMuses()) {
          if (macAddress.equals(muse.getMacAddress())) {
            DeviceDetailsActivity.this.deviceVM.setMuse(muse);
            MuseManagerAndroid.getInstance().stopListening();
            break;
          }
        }
      }
    });
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:48,代码来源:DeviceDetailsActivity.java


注:本文中的com.choosemuse.libmuse.MuseListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。