本文整理汇总了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);
}
});
}
示例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;
}
}
}
});
}
}