本文整理汇总了Java中com.o3dr.services.android.lib.drone.attribute.AttributeEvent类的典型用法代码示例。如果您正苦于以下问题:Java AttributeEvent类的具体用法?Java AttributeEvent怎么用?Java AttributeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeEvent类属于com.o3dr.services.android.lib.drone.attribute包,在下文中一共展示了AttributeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case AttributeEvent.STATE_ARMING:
case AttributeEvent.STATE_CONNECTED:
case AttributeEvent.STATE_DISCONNECTED:
case AttributeEvent.STATE_UPDATED:
setupButtonsByFlightState();
break;
case AttributeEvent.STATE_VEHICLE_MODE:
updateFlightModeButtons();
break;
}
}
示例2: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action){
case AttributeEvent.MISSION_RECEIVED:
case AttributeEvent.MISSION_UPDATED:
final MissionProxy missionProxy = getMissionProxy();
if(missionProxy != null) {
mission = drone.getAttribute(AttributeType.MISSION);
waypointSelectorAdapter = new NumericWheelAdapter(context, R.layout.wheel_text_centered,
missionProxy.getFirstWaypoint(), missionProxy.getLastWaypoint(), "%3d");
waypointSelector.setViewAdapter(waypointSelectorAdapter);
}
break;
case AttributeEvent.MISSION_ITEM_UPDATED:
mission = drone.getAttribute(AttributeType.MISSION);
nextWaypoint = intent.getIntExtra(AttributeEventExtra.EXTRA_MISSION_CURRENT_WAYPOINT, 0);
waypointSelector.setCurrentValue(nextWaypoint);
break;
case AttributeEvent.GPS_POSITION:
updateMission();
break;
}
}
示例3: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case AttributeEvent.STATE_CONNECTED:
onDroneConnected();
break;
case AttributeEvent.STATE_DISCONNECTED:
onDroneDisconnected();
break;
case SettingsFragment.ACTION_ADVANCED_MENU_UPDATED:
supportInvalidateOptionsMenu();
break;
}
}
示例4: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case MissionProxy.ACTION_MISSION_PROXY_UPDATE:
if (mAppPrefs.isZoomToFitEnable()) gestureMapFragment.getMapFragment().zoomToFit();
// FALL THROUGH
case AttributeEvent.PARAMETERS_REFRESH_COMPLETED:
case DroidPlannerPrefs.PREF_VEHICLE_DEFAULT_SPEED:
case AttributeEvent.STATE_CONNECTED:
case AttributeEvent.HEARTBEAT_RESTORED:
updateMissionLength();
break;
case AttributeEvent.MISSION_RECEIVED:
final EditorMapFragment planningMapFragment = gestureMapFragment.getMapFragment();
if (planningMapFragment != null) {
planningMapFragment.zoomToFit();
}
break;
}
}
示例5: changedConnectionStateTest
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Test
public void changedConnectionStateTest() throws Exception {
Altitude altitude = new Altitude();
altitude.setAltitude(100);
altitude.setTargetAltitude(150);
Speed speed = new Speed();
speed.setGroundSpeed(5);
speed.setVerticalSpeed(1);
Type type = new Type();
type.setFirmware(Type.Firmware.ARDU_COPTER);
when(drone.getAttribute(AttributeType.ALTITUDE)).thenReturn(altitude);
when(drone.getAttribute(AttributeType.SPEED)).thenReturn(speed);
when(drone.getAttribute(AttributeType.TYPE)).thenReturn(type);
service.addConnectionListener(droneConnectionListener);
service.onDroneEvent(AttributeEvent.STATE_CONNECTED, new Bundle());
DroneState droneState = new DroneStateMapper().getDroneState(drone);
droneState.setIsConnected(true);
verify(droneConnectionListener).onDroneStateChange(droneState);
}
示例6: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (AttributeEvent.STATE_DISCONNECTED.equals(action)) {
updateMavlinkVersionPreference(null);
updateFirmwareVersionPreference(null);
} else if (AttributeEvent.HEARTBEAT_FIRST.equals(action)
|| AttributeEvent.HEARTBEAT_RESTORED.equals(action)) {
int mavlinkVersion = intent.getIntExtra(AttributeEventExtra.EXTRA_MAVLINK_VERSION, -1);
if (mavlinkVersion == -1)
updateMavlinkVersionPreference(null);
else
updateMavlinkVersionPreference(String.valueOf(mavlinkVersion));
} else if (AttributeEvent.TYPE_UPDATED.equals(action)) {
Drone drone = dpApp.getDrone();
if (drone.isConnected()) {
updateFirmwareVersionPreference(drone.getType().getFirmwareVersion());
} else
updateFirmwareVersionPreference(null);
}
}
示例7: newEstimation
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void newEstimation(FitPoints fit, List<ThreeSpacePoint> points) {
double fitness = fit.getFitness();
double[] fitCenter = fit.center.isNaN()
? null
: new double[]{fit.center.getEntry(0), fit.center.getEntry(1), fit.center.getEntry(2)};
double[] fitRadii = fit.radii.isNaN()
? null
: new double[]{fit.radii.getEntry(0), fit.radii.getEntry(1), fit.radii.getEntry(2)};
Bundle paramsBundle = new Bundle(4);
paramsBundle.putDouble(AttributeEventExtra.EXTRA_CALIBRATION_MAG_FITNESS, fitness);
paramsBundle.putDoubleArray(AttributeEventExtra.EXTRA_CALIBRATION_MAG_FIT_CENTER, fitCenter);
paramsBundle.putDoubleArray(AttributeEventExtra.EXTRA_CALIBRATION_MAG_FIT_RADII, fitRadii);
double[][] pointsArr = MathUtils.threeSpacePointToPointsArray(points);
paramsBundle.putSerializable(AttributeEventExtra.EXTRA_CALIBRATION_MAG_POINTS_X, pointsArr[0]);
paramsBundle.putSerializable(AttributeEventExtra.EXTRA_CALIBRATION_MAG_POINTS_Y, pointsArr[1]);
paramsBundle.putSerializable(AttributeEventExtra.EXTRA_CALIBRATION_MAG_POINTS_Z, pointsArr[2]);
notifyAttributeUpdate(AttributeEvent.CALIBRATION_MAG_ESTIMATION, paramsBundle);
}
示例8: notifyAttributeUpdated
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
void notifyAttributeUpdated(final String attributeEvent, final Bundle extras) {
if (AttributeEvent.STATE_UPDATED.equals(attributeEvent)) {
if (getState().isFlying())
startTimer();
else
stopTimer();
} else if (AttributeEvent.SPEED_UPDATED.equals(attributeEvent)) {
checkForGroundCollision();
}
if (droneListeners.isEmpty())
return;
handler.post(new Runnable() {
@Override
public void run() {
for (DroneListener listener : droneListeners)
listener.onDroneEvent(attributeEvent, extras);
}
});
}
示例9: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case AttributeEvent.AUTOPILOT_ERROR:
final String errorName = intent.getStringExtra(AttributeEventExtra.EXTRA_AUTOPILOT_ERROR_ID);
final ErrorType errorType = ErrorType.getErrorById(errorName);
if (errorType != null && ErrorType.NO_ERROR != errorType) {
final HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
.setCategory(GAUtils.Category.FAILSAFE)
.setAction("Autopilot error")
.setLabel(errorType.getLabel(context).toString());
GAUtils.sendEvent(eventBuilder);
}
break;
}
}
示例10: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
final Drone drone = getDrone();
switch (action) {
case AttributeEvent.ATTITUDE_UPDATED:
final Attitude attitude = drone.getAttribute(AttributeType.ATTITUDE);
onOrientationUpdate(attitude);
break;
case AttributeEvent.SPEED_UPDATED:
final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
onSpeedUpdate(droneSpeed);
final Altitude droneAltitude = drone.getAttribute(AttributeType.ALTITUDE);
onAltitudeUpdate(droneAltitude);
break;
case AttributeEvent.STATE_UPDATED:
updateFlightTimer();
break;
}
}
示例11: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case AttributeEvent.PARAMETERS_REFRESH_ENDED:
case MissionProxy.ACTION_MISSION_PROXY_UPDATE:
updateMissionLength();
break;
case AttributeEvent.MISSION_RECEIVED:
final EditorMapFragment planningMapFragment = gestureMapFragment.getMapFragment();
if (planningMapFragment != null) {
planningMapFragment.zoomToFit();
}
break;
}
}
示例12: onDroneEvent
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onDroneEvent(String event, Bundle extras) {
switch (event) {
case AttributeEvent.STATE_CONNECTED:
handler.removeCallbacks(disconnectionTask);
if (notificationHandler == null) {
notificationHandler = new NotificationHandler(getApplicationContext(), drone);
}
break;
case AttributeEvent.STATE_DISCONNECTED:
shouldWeTerminate();
break;
}
lbm.sendBroadcast(new Intent(ACTION_DRONE_EVENT).putExtra(EXTRA_DRONE_EVENT, event));
final Intent droneIntent = new Intent(event);
if (extras != null)
droneIntent.putExtras(extras);
lbm.sendBroadcast(droneIntent);
}
示例13: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
boolean showNotification = true;
final String action = intent.getAction();
switch (action) {
case AttributeEvent.GPS_POSITION:
updateHome(drone);
break;
case AttributeEvent.GPS_FIX:
case AttributeEvent.GPS_COUNT:
updateGps(drone);
break;
case AttributeEvent.BATTERY_UPDATED:
updateBattery(drone);
break;
case AttributeEvent.HOME_UPDATED:
updateHome(drone);
break;
case AttributeEvent.SIGNAL_UPDATED:
updateRadio(drone);
break;
case AttributeEvent.STATE_UPDATED:
updateDroneState(drone);
break;
case AttributeEvent.STATE_VEHICLE_MODE:
case AttributeEvent.TYPE_UPDATED:
updateFlightMode(drone);
break;
default:
showNotification = false;
break;
}
if (showNotification) {
showNotification();
}
}
示例14: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final Activity activity = getActivity();
if(activity == null)
return;
final String action = intent.getAction();
switch (action) {
case AttributeEvent.STATE_DISCONNECTED:
updateFirmwareVersionPreference(null);
break;
case AttributeEvent.STATE_CONNECTED:
case AttributeEvent.TYPE_UPDATED:
Drone drone = dpApp.getDrone();
if (drone.isConnected()) {
Type droneType = drone.getAttribute(AttributeType.TYPE);
updateFirmwareVersionPreference(droneType);
} else
updateFirmwareVersionPreference(null);
break;
case ACTION_PREF_UNIT_SYSTEM_UPDATE:
setupAltitudePreferences();
setupSpeedPreferences();
break;
}
}
示例15: onReceive
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case AttributeEvent.CALIBRATION_MAG_CANCELLED:
updateUI(STEP_CALIBRATION_CANCELLED);
stopTimeout();
break;
case AttributeEvent.CALIBRATION_MAG_COMPLETED:
final MagnetometerCalibrationResult result = intent.getParcelableExtra(AttributeEventExtra
.EXTRA_CALIBRATION_MAG_RESULT);
handleMagResult(result);
stopTimeout();
break;
case AttributeEvent.CALIBRATION_MAG_PROGRESS:
final MagnetometerCalibrationProgress progress = intent.getParcelableExtra(AttributeEventExtra
.EXTRA_CALIBRATION_MAG_PROGRESS);
handleMagProgress(progress);
break;
case AttributeEvent.STATE_CONNECTED:
break;
case AttributeEvent.STATE_DISCONNECTED:
cancelCalibration();
break;
}
}