本文整理汇总了Java中com.qualcomm.ftcrobotcontroller.R类的典型用法代码示例。如果您正苦于以下问题:Java R类的具体用法?Java R怎么用?Java R使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
R类属于com.qualcomm.ftcrobotcontroller包,在下文中一共展示了R类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
/**
* {@link #register(OpModeManager)} is called by the SDK game in order to register
* OpMode classes or instances that will participate in an FTC game.
*
* There are two mechanisms by which an OpMode may be registered.
*
* 1) The preferred method is by means of class annotations in the OpMode itself.
* See, for example the class annotations in {@link ConceptNullOp}.
*
* 2) The other, retired, method is to modify this {@link #register(OpModeManager)}
* method to include explicit calls to OpModeManager.register().
* This method of modifying this file directly is discouraged, as it
* makes updates to the SDK harder to integrate into your code.
*
* @param manager the object which contains methods for carrying out OpMode registrations
*
* @see com.qualcomm.robotcore.eventloop.opmode.TeleOp
* @see com.qualcomm.robotcore.eventloop.opmode.Autonomous
*/
public void register(OpModeManager manager) {
/**
* Register OpModes implemented in the Blocks visual programming language.
*/
BlocksOpMode.registerAll(manager);
/**
* Register OpModes that use the annotation-based registration mechanism.
*/
//AnnotatedOpModeRegistrar.register(manager);
try {
final HashMap<String, Integer> integers = DataBinder.getInstance().integers();
integers.put(DataBinder.RC_VIEW, R.id.entire_screen);
integers.put(DataBinder.CAMERA_VIEW, R.id.cameraMonitorViewId);
AnnotationFtcRegister.loadOpModes(manager); // Use the Xtensible version
} catch (Exception ex) {
AnnotatedOpModeRegistrar.register(manager); // Use the FIRST version, in case of error
}
/**
* Any manual OpMode class registrations should go here.
*/
}
示例2: stop
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public void stop() {
final RelativeLayout layout = ((RelativeLayout) ((Activity) hardwareMap.appContext)
.findViewById(R.id.RelativeLayout));
runOnUiThread(new Runnable() {
@Override
public void run() {
layout.removeView(scrollView);
}
});
textView = null;
scrollView = null;
Class klazz = this.getClass();
}
示例3: onActivityResult
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
protected void onActivityResult(int request, int result, Intent intent) {
if (request == REQUEST_CONFIG_WIFI_CHANNEL) {
if (result == RESULT_OK) {
AppUtil.getInstance().showToast(context, context.getString(R.string.toastWifiConfigurationComplete));
}
}
if (request == LaunchActivityConstantsList.FTC_CONFIGURE_REQUEST_CODE_ROBOT_CONTROLLER) {
// We always do a refresh, whether it was a cancel or an OK, for robustness
cfgFileMgr.getActiveConfigAndUpdateUI();
}
}
示例4: runOpMode
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public void runOpMode() {
// hsvValues is an array that will hold the hue, saturation, and value information.
float hsvValues[] = {0F,0F,0F};
// values is a reference to the hsvValues array.
final float values[] = hsvValues;
// get a reference to the RelativeLayout so we can change the background
// color of the Robot Controller app to match the hue detected by the RGB sensor.
final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout);
// bPrevState and bCurrState represent the previous and current state of the button.
boolean bPrevState = false;
boolean bCurrState = false;
// bLedOn represents the state of the LED.
boolean bLedOn = true;
// get a reference to our ColorSensor object.
colorSensor = hardwareMap.colorSensor.get("sensor_color");
// Set the LED in the beginning
colorSensor.enableLed(bLedOn);
// wait for the start button to be pressed.
waitForStart();
// while the op mode is active, loop and read the RGB data.
// Note we use opModeIsActive() as our loop condition because it is an interruptible method.
while (opModeIsActive()) {
// check the status of the x button on either gamepad.
bCurrState = gamepad1.x;
// check for button state transitions.
if ((bCurrState == true) && (bCurrState != bPrevState)) {
// button is transitioning to a pressed state. So Toggle LED
bLedOn = !bLedOn;
colorSensor.enableLed(bLedOn);
}
// update previous state variable.
bPrevState = bCurrState;
// convert the RGB values to HSV values.
Color.RGBToHSV(colorSensor.red() * 8, colorSensor.green() * 8, colorSensor.blue() * 8, hsvValues);
// send the info back to driver station using telemetry function.
telemetry.addData("LED", bLedOn ? "On" : "Off");
telemetry.addData("Clear", colorSensor.alpha());
telemetry.addData("Red ", colorSensor.red());
telemetry.addData("Green", colorSensor.green());
telemetry.addData("Blue ", colorSensor.blue());
telemetry.addData("Hue", hsvValues[0]);
// change the background color to match the color detected by the RGB sensor.
// pass a reference to the hue, saturation, and value array as an argument
// to the HSVToColor method.
relativeLayout.post(new Runnable() {
public void run() {
relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
}
});
telemetry.update();
}
}
示例5: readNetworkType
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
protected void readNetworkType() {
// The code here used to defer to the value found in a configuration file
// to configure the network type. If the file was absent, then it initialized
// it with a default.
//
// However, bugs have been reported with that approach (empty config files, specifically).
// Moreover, the non-Wifi-Direct networking is end-of-life, so the simplest and most robust
// (e.g.: no one can screw things up by messing with the contents of the config file) fix is
// to do away with configuration file entirely.
networkType = NetworkType.WIFIDIRECT;
// update the app_settings
preferencesHelper.writeStringPrefIfDifferent(context.getString(R.string.pref_network_connection_type), networkType.toString());
}
示例6: onActivityResult
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
protected void onActivityResult(int request, int result, Intent intent) {
if (request == REQUEST_CONFIG_WIFI_CHANNEL) {
if (result == RESULT_OK) {
AppUtil.getInstance().showToast(UILocation.BOTH, context, context.getString(R.string.toastWifiConfigurationComplete));
}
}
// was some historical confusion about launch codes here, so we err safely
if (request == RequestCode.CONFIGURE_ROBOT_CONTROLLER.ordinal() || request == RequestCode.SETTINGS_ROBOT_CONTROLLER.ordinal()) {
// We always do a refresh, whether it was a cancel or an OK, for robustness
cfgFileMgr.getActiveConfigAndUpdateUI();
}
}
示例7: requestRobotRestart
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
private void requestRobotRestart() {
AppUtil.getInstance().showToast(UILocation.BOTH, AppUtil.getDefContext().getString(R.string.toastRestartingRobot));
//
shutdownRobot();
requestRobotSetup();
//
AppUtil.getInstance().showToast(UILocation.BOTH, AppUtil.getDefContext().getString(R.string.toastRestartRobotComplete));
}
示例8: register
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
/**
* The Op Mode Manager will call this method when it wants a list of all
* available op modes. Add your op mode to the list to enable it.
*
* @param manager op mode manager
*/
public void register(OpModeManager manager) {
/*
* register your op modes here.
* The first parameter is the name of the op mode
* The second parameter is the op mode class property
*
* If two or more op modes are registered with the same name, the app will display an error.
*/
FtcSimpleBootstrap.configure(manager, R.id.RelativeLayout);
}
示例9: onActivityResult
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
protected void onActivityResult(int request, int result, Intent intent) {
if (request == REQUEST_CONFIG_WIFI_CHANNEL) {
if (result == RESULT_OK) {
AppUtil.getInstance().showToast(context, context.getString(R.string.toastWifiConfigurationComplete));
}
}
if (request == LaunchActivityConstantsList.FTC_CONFIGURE_REQUEST_CODE_ROBOT_CONTROLLER) {
// We always do a refresh, whether it was a cancel or an OK, for robustness
cfgFileMgr.getActiveConfigAndUpdateUI();
}
}
示例10: onCreateOptionsMenu
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.ftc_robot_controller, menu);
return true;
}
示例11: onOptionsItemSelected
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_programming_mode) {
if (cfgFileMgr.getActiveConfig().isNoConfig()) {
// Tell the user they must configure the robot before starting programming mode.
AppUtil.getInstance().showToast(
context, context.getString(R.string.toastConfigureRobotBeforeProgrammingMode));
} else {
Intent programmingModeIntent = new Intent(ProgrammingModeActivity.launchIntent);
programmingModeIntent.putExtra(
LaunchActivityConstantsList.PROGRAMMING_MODE_ACTIVITY_NETWORK_TYPE, networkType);
startActivity(programmingModeIntent);
}
return true;
} else if (id == R.id.action_inspection_mode) {
Intent inspectionModeIntent = new Intent(RcInspectionActivity.rcLaunchIntent);
startActivity(inspectionModeIntent);
return true;
}
else if (id == R.id.action_blocks) {
Intent blocksIntent = new Intent(BlocksActivity.launchIntent);
startActivity(blocksIntent);
return true;
}
else if (id == R.id.action_restart_robot) {
dimmer.handleDimTimer();
AppUtil.getInstance().showToast(context, context.getString(R.string.toastRestartingRobot));
requestRobotRestart();
return true;
}
else if (id == R.id.action_configure_robot) {
EditParameters parameters = new EditParameters();
Intent intentConfigure = new Intent(FtcLoadFileActivity.launchIntent);
parameters.putIntent(intentConfigure);
startActivityForResult(intentConfigure, LaunchActivityConstantsList.FTC_CONFIGURE_REQUEST_CODE_ROBOT_CONTROLLER);
}
else if (id == R.id.action_settings) {
Intent settingsIntent = new Intent(FtcRobotControllerSettingsActivity.launchIntent);
startActivityForResult(settingsIntent, LaunchActivityConstantsList.FTC_CONFIGURE_REQUEST_CODE_ROBOT_CONTROLLER);
return true;
}
else if (id == R.id.action_about) {
Intent intent = new Intent(AboutActivity.launchIntent);
intent.putExtra(LaunchActivityConstantsList.ABOUT_ACTIVITY_CONNECTION_TYPE, networkType);
startActivity(intent);
return true;
}
else if (id == R.id.action_exit_app) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
示例12: runOpMode
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public void runOpMode() {
// hsvValues is an array that will hold the hue, saturation, and value information.
float hsvValues[] = {0F,0F,0F};
// values is a reference to the hsvValues array.
final float values[] = hsvValues;
// get a reference to the RelativeLayout so we can change the background
// color of the Robot Controller app to match the hue detected by the RGB sensor.
final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout);
// bPrevState and bCurrState represent the previous and current state of the button.
boolean bPrevState = false;
boolean bCurrState = false;
// bLedOn represents the state of the LED.
boolean bLedOn = true;
// get a reference to our ColorSensor object.
colorSensor = hardwareMap.colorSensor.get("sensor_color");
// turn the LED on in the beginning, just so user will know that the sensor is active.
colorSensor.enableLed(bLedOn);
// wait for the start button to be pressed.
waitForStart();
// loop and read the RGB data.
// Note we use opModeIsActive() as our loop condition because it is an interruptible method.
while (opModeIsActive()) {
// check the status of the x button on either gamepad.
bCurrState = gamepad1.x;
// check for button state transitions.
if ((bCurrState == true) && (bCurrState != bPrevState)) {
// button is transitioning to a pressed state. Toggle LED.
// on button press, enable the LED.
bLedOn = !bLedOn;
colorSensor.enableLed(bLedOn);
}
// update previous state variable.
bPrevState = bCurrState;
// convert the RGB values to HSV values.
Color.RGBToHSV(colorSensor.red(), colorSensor.green(), colorSensor.blue(), hsvValues);
// send the info back to driver station using telemetry function.
telemetry.addData("LED", bLedOn ? "On" : "Off");
telemetry.addData("Clear", colorSensor.alpha());
telemetry.addData("Red ", colorSensor.red());
telemetry.addData("Green", colorSensor.green());
telemetry.addData("Blue ", colorSensor.blue());
telemetry.addData("Hue", hsvValues[0]);
// change the background color to match the color detected by the RGB sensor.
// pass a reference to the hue, saturation, and value array as an argument
// to the HSVToColor method.
relativeLayout.post(new Runnable() {
public void run() {
relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
}
});
telemetry.update();
}
}
示例13: runOpMode
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
public void runOpMode() {
// hsvValues is an array that will hold the hue, saturation, and value information.
float hsvValues[] = {0F,0F,0F};
// values is a reference to the hsvValues array.
final float values[] = hsvValues;
// get a reference to the RelativeLayout so we can change the background
// color of the Robot Controller app to match the hue detected by the RGB sensor.
final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout);
// bPrevState and bCurrState represent the previous and current state of the button.
boolean bPrevState = false;
boolean bCurrState = false;
// bLedOn represents the state of the LED.
boolean bLedOn = true;
// get a reference to our DeviceInterfaceModule object.
cdim = hardwareMap.deviceInterfaceModule.get("dim");
// set the digital channel to output mode.
// remember, the Adafruit sensor is actually two devices.
// It's an I2C sensor and it's also an LED that can be turned on or off.
cdim.setDigitalChannelMode(LED_CHANNEL, DigitalChannelController.Mode.OUTPUT);
// get a reference to our ColorSensor object.
sensorRGB = hardwareMap.colorSensor.get("sensor_color");
// turn the LED on in the beginning, just so user will know that the sensor is active.
cdim.setDigitalChannelState(LED_CHANNEL, bLedOn);
// wait for the start button to be pressed.
waitForStart();
// loop and read the RGB data.
// Note we use opModeIsActive() as our loop condition because it is an interruptible method.
while (opModeIsActive()) {
// check the status of the x button on gamepad.
bCurrState = gamepad1.x;
// check for button-press state transitions.
if ((bCurrState == true) && (bCurrState != bPrevState)) {
// button is transitioning to a pressed state. Toggle the LED.
bLedOn = !bLedOn;
cdim.setDigitalChannelState(LED_CHANNEL, bLedOn);
}
// update previous state variable.
bPrevState = bCurrState;
// convert the RGB values to HSV values.
Color.RGBToHSV((sensorRGB.red() * 255) / 800, (sensorRGB.green() * 255) / 800, (sensorRGB.blue() * 255) / 800, hsvValues);
// send the info back to driver station using telemetry function.
telemetry.addData("LED", bLedOn ? "On" : "Off");
telemetry.addData("Clear", sensorRGB.alpha());
telemetry.addData("Red ", sensorRGB.red());
telemetry.addData("Green", sensorRGB.green());
telemetry.addData("Blue ", sensorRGB.blue());
telemetry.addData("Hue", hsvValues[0]);
// change the background color to match the color detected by the RGB sensor.
// pass a reference to the hue, saturation, and value array as an argument
// to the HSVToColor method.
relativeLayout.post(new Runnable() {
public void run() {
relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
}
});
telemetry.update();
}
}
示例14: onSharedPreferenceChanged
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(context.getString(R.string.pref_app_theme))) {
ThemedActivity.restartForAppThemeChange(getTag(), getString(R.string.appThemeChangeRestartNotifyRC));
}
}
示例15: onCreate
import com.qualcomm.ftcrobotcontroller.R; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RobotLog.writeLogcatToDisk();
RobotLog.vv(TAG, "onCreate()");
receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue<UsbDevice>();
eventLoop = null;
setContentView(R.layout.activity_ftc_controller);
context = this;
utility = new Utility(this);
appUtil.setThisApp(new PeerAppRobotController(context));
entireScreenLayout = (LinearLayout) findViewById(R.id.entire_screen);
buttonMenu = (ImageButton) findViewById(R.id.menu_buttons);
buttonMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AppUtil.getInstance().openOptionsMenuFor(FtcRobotControllerActivity.this);
}
});
BlocksOpMode.setActivityAndWebView(this, (WebView) findViewById(R.id.webViewBlocksRuntime));
ClassManagerFactory.processClasses();
cfgFileMgr = new RobotConfigFileManager(this);
// Clean up 'dirty' status after a possible crash
RobotConfigFile configFile = cfgFileMgr.getActiveConfig();
if (configFile.isDirty()) {
configFile.markClean();
cfgFileMgr.setActiveConfig(false, configFile);
}
textDeviceName = (TextView) findViewById(R.id.textDeviceName);
textNetworkConnectionStatus = (TextView) findViewById(R.id.textNetworkConnectionStatus);
textRobotStatus = (TextView) findViewById(R.id.textRobotStatus);
textOpMode = (TextView) findViewById(R.id.textOpMode);
textErrorMessage = (TextView) findViewById(R.id.textErrorMessage);
textGamepad[0] = (TextView) findViewById(R.id.textGamepad1);
textGamepad[1] = (TextView) findViewById(R.id.textGamepad2);
immersion = new ImmersiveMode(getWindow().getDecorView());
dimmer = new Dimmer(this);
dimmer.longBright();
programmingModeController = new ProgrammingModeControllerImpl(
this, (TextView) findViewById(R.id.textRemoteProgrammingMode));
updateUI = createUpdateUI();
callback = createUICallback(updateUI);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "");
hittingMenuButtonBrightensScreen();
if (USE_DEVICE_EMULATION) { HardwareFactory.enableDeviceEmulation(); }
wifiLock.acquire();
callback.networkConnectionUpdate(WifiDirectAssistant.Event.DISCONNECTED);
readNetworkType(NETWORK_TYPE_FILENAME);
bindToService();
}