本文整理汇总了Java中com.o3dr.android.client.Drone.getBattery方法的典型用法代码示例。如果您正苦于以下问题:Java Drone.getBattery方法的具体用法?Java Drone.getBattery怎么用?Java Drone.getBattery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.o3dr.android.client.Drone
的用法示例。
在下文中一共展示了Drone.getBattery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateBattery
import com.o3dr.android.client.Drone; //导入方法依赖的package包/类
private void updateBattery(Drone drone) {
if (mInboxBuilder == null)
return;
Battery droneBattery = drone.getBattery();
String update = droneBattery == null ? "--" : String.format(
"%2.1fv (%2.0f%%)", droneBattery.getBatteryVoltage(),
droneBattery.getBatteryRemain());
mInboxBuilder.setLine(3, SpannableUtils.normal("Battery: ", SpannableUtils.bold(update)));
}
示例2: updateItemView
import com.o3dr.android.client.Drone; //导入方法依赖的package包/类
@Override
public void updateItemView(Context context, Drone drone) {
if (mItemView == null)
return;
String infoUpdate;
Battery droneBattery;
if (drone == null || !drone.isConnected() || ((droneBattery = drone.getBattery()) ==
null)) {
infoUpdate = sDefaultValue;
currentView.setText(sDefaultValue);
mAhView.setText(sDefaultValue);
} else {
Double discharge = droneBattery.getBatteryDischarge();
String dischargeText;
if (discharge == null) {
dischargeText = sDefaultValue;
}else{
dischargeText = String.format(Locale.ENGLISH, "%2.0f mAh", discharge);
}
mAhView.setText(String.format(Locale.ENGLISH,"Remaining %2.0f%%", droneBattery.getBatteryRemain()));
currentView.setText(String.format("Current %2.1f A", droneBattery.getBatteryCurrent()));
infoUpdate = String.format(Locale.ENGLISH,"%2.1fv\n", droneBattery.getBatteryVoltage());
infoUpdate = infoUpdate.concat(dischargeText);
}
mPopup.update();
((TextView) mItemView).setText(infoUpdate);
}