Java Code Examples for android.graphics.Color#MAGENTA

The following examples show how to use android.graphics.Color#MAGENTA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Style getDefaultStyle()
        throws Exception
{
    switch (mGeometryType) {

        case GTPoint:
        case GTMultiPoint:
            return new SimpleMarkerStyle(
                    Color.RED, Color.BLACK, 6, SimpleMarkerStyle.MarkerStyleCircle);

        case GTLineString:
        case GTMultiLineString:
            return new SimpleLineStyle(Color.GREEN, Color.BLUE, SimpleLineStyle.LineStyleSolid);

        case GTPolygon:
        case GTMultiPolygon:
            return new SimplePolygonStyle(Color.MAGENTA, Color.MAGENTA);

        default:
            throw new Exception("Unknown geometry type: " + mGeometryType);
    }

}
 
Example 2
Source File: SvgHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static Integer getColorByName(String name) {
    switch (name.toLowerCase()) {
        case "black":
            return Color.BLACK;
        case "gray":
            return Color.GRAY;
        case "red":
            return Color.RED;
        case "green":
            return Color.GREEN;
        case "blue":
            return Color.BLUE;
        case "yellow":
            return Color.YELLOW;
        case "cyan":
            return Color.CYAN;
        case "magenta":
            return Color.MAGENTA;
        case "white":
            return Color.WHITE;
    }
    return null;
}
 
Example 3
Source File: TfLiteObjectDetection.java    From next18-ai-in-motion with Apache License 2.0 6 votes vote down vote up
private int getColor(int color) {
    if (color == 1 && !foundBlue) {
        foundBlue = true;
        return Color.BLUE;
    } else if (color == 2 && !foundGreen) {
        foundGreen = true;
        return Color.GREEN;
    } else if (color == 4 && !foundPink) {
        foundPink = true;
        return Color.MAGENTA;
    } else if (color == 5 && !foundRed) {
        foundRed = true;
        return Color.RED;
    } else if (color == 6) {
        return Color.WHITE;
    } else if (color == 7) {
        return Color.WHITE;
    } else if (color == 8) {
        return Color.LTGRAY;
    } else if (color == 9) {
        return Color.LTGRAY;
    }else {
        return Color.BLACK;
    }
}
 
Example 4
Source File: TextInputLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
void setTextAppearanceCompatWithErrorFallback(
    @NonNull TextView textView, @StyleRes int textAppearance) {
  boolean useDefaultColor = false;
  try {
    TextViewCompat.setTextAppearance(textView, textAppearance);

    if (VERSION.SDK_INT >= VERSION_CODES.M
        && textView.getTextColors().getDefaultColor() == Color.MAGENTA) {
      // Caused by our theme not extending from Theme.Design*. On API 23 and
      // above, unresolved theme attrs result in MAGENTA rather than an exception.
      // Flag so that we use a decent default
      useDefaultColor = true;
    }
  } catch (Exception e) {
    // Caused by our theme not extending from Theme.Design*. Flag so that we use
    // a decent default
    useDefaultColor = true;
  }
  if (useDefaultColor) {
    // Probably caused by our theme not extending from Theme.Design*. Instead
    // we manually set something appropriate
    TextViewCompat.setTextAppearance(textView, R.style.TextAppearance_AppCompat_Caption);
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_error));
  }
}
 
Example 5
Source File: DrawingView.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public DrawingView(Context context, AttributeSet attrs) {
	super(context, attrs);

	colors = new int[] { Color.BLUE, Color.CYAN, Color.GREEN,
			Color.MAGENTA, Color.YELLOW, Color.RED, Color.WHITE };

	random = new Random();
	nextColor = random.nextInt(colors.length);
	for (int i = 0; i < colors.length; i++) {
		Paint paint = new Paint();
		paint.setAntiAlias(true);
		paint.setColor(colors[i]);
		paint.setStyle(Paint.Style.STROKE);
		paint.setStrokeJoin(Paint.Join.ROUND);
		paint.setStrokeWidth(STROKE_WIDTH);
		paints.add(paint);
	}

}
 
Example 6
Source File: AppIndexingUtil.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
private static List<StickerBuilder> getStickerBuilders(Context context) throws IOException {
    List<StickerBuilder> stickerBuilders = new ArrayList<>();
    int[] stickerColors = new int[] {Color.GREEN, Color.RED, Color.BLUE,
            Color.YELLOW, Color.MAGENTA};

    File stickersDir = new File(context.getFilesDir(), "stickers");

    if (!stickersDir.exists() && !stickersDir.mkdirs()) {
        throw new IOException("Stickers directory does not exist");
    }

    for (int i = 0; i < stickerColors.length; i++) {
        String stickerFilename = getStickerFilename(i);
        File stickerFile = new File(stickersDir, stickerFilename);
        String imageUrl = getStickerUrl(stickerFilename);
        writeSolidColorBitmapToFile(stickerFile, stickerColors[i]);

        StickerBuilder stickerBuilder = Indexables.stickerBuilder()
                .setName(getStickerFilename(i))
                // Firebase App Indexing unique key that must match an intent-filter
                // (e.g. mystickers://sticker/0)
                .setUrl(String.format(STICKER_URL_PATTERN, i))
                // http url or content uri that resolves to the sticker
                // (e.g. http://www.google.com/sticker.png or content://some/path/0)
                .setImage(imageUrl)
                .setDescription("content description")
                .setIsPartOf(Indexables.stickerPackBuilder()
                        .setName(STICKER_PACK_NAME))
                .put("keywords", "tag1", "tag2");
        stickerBuilders.add(stickerBuilder);
    }

    return stickerBuilders;
}
 
Example 7
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // get a reference to the scene view
  mSceneView = findViewById(R.id.sceneView);
  // create a scene and add it to the scene view
  ArcGISScene scene = new ArcGISScene(Basemap.createImagery());
  mSceneView.setScene(scene);

  // add base surface for elevation data
  final Surface surface = new Surface();
  ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
      getString(R.string.elevation_image_service_url));
  surface.getElevationSources().add(elevationSource);
  scene.setBaseSurface(surface);

  // add a camera and initial camera position
  Camera camera = new Camera(28.9, 45, 12000, 0, 45, 0);
  mSceneView.setViewpointCamera(camera);

  // add graphics overlay(s)
  GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
  graphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.ABSOLUTE);
  mSceneView.getGraphicsOverlays().add(graphicsOverlay);

  int[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA, Color.CYAN, Color.WHITE };
  SimpleMarkerSceneSymbol.Style[] symbolStyles = SimpleMarkerSceneSymbol.Style.values();

  // for each symbol style (cube, cone, cylinder, diamond, sphere, tetrahedron)
  for (int i = 0; i < symbolStyles.length; i++) {
    SimpleMarkerSceneSymbol simpleMarkerSceneSymbol = new SimpleMarkerSceneSymbol(symbolStyles[i], colors[i], 200,
        200, 200, SceneSymbol.AnchorPosition.CENTER);
    Graphic graphic = new Graphic(new Point(44.975 + .01 * i, 29, 500, SpatialReferences.getWgs84()),
        simpleMarkerSceneSymbol);
    graphicsOverlay.getGraphics().add(graphic);
  }
}
 
Example 8
Source File: SuntimesThemeTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public TestTheme(Context context)
{
    super();
    this.themeVersion = TESTDEF_VERSION;
    this.themeName = TESTDEF_NAME;
    this.themeIsDefault = true;
    this.themeDisplayString = TESTDEF_DISPLAYSTRING;
    this.themeBackground = TESTDEF_BACKGROUND;
    this.themePadding = TESTDEF_PADDING;
    this.themeTitleSize = TESTDEF_TITLESIZE;
    this.themeTextSize = TESTDEF_TEXTSIZE;
    this.themeTimeSize = TESTDEF_TIMESIZE;
    this.themeTimeSuffixSize = TESTDEF_TIMESUFFIXSIZE;
    this.themeTitleColor = ContextCompat.getColor(context, TESTDEF_TITLECOLOR_ID);
    this.themeTextColor = ContextCompat.getColor(context, TESTDEF_TEXTCOLOR_ID);
    this.themeTimeColor = ContextCompat.getColor(context, TESTDEF_TIMECOLOR_ID);
    this.themeTimeSuffixColor = ContextCompat.getColor(context, TESTDEF_TIMESUFFIXCOLOR_ID);

    this.themeSunriseTextColor = ContextCompat.getColor(context, TESTDEF_SUNRISECOLOR_ID);
    this.themeSunriseIconColor = Color.GREEN;
    this.themeSunriseIconStrokeColor = Color.YELLOW;
    this.themeSunriseIconStrokeWidth = 1;

    this.themeNoonTextColor = Color.WHITE;
    this.themeNoonIconColor = Color.CYAN;
    this.themeNoonIconStrokeColor = Color.MAGENTA;
    this.themeNoonIconStrokeWidth = 2;

    this.themeSunsetTextColor = ContextCompat.getColor(context, TESTDEF_SUNSETCOLOR_ID);
    this.themeSunsetIconColor = Color.BLUE;
    this.themeSunsetIconStrokeColor = Color.RED;
    this.themeSunsetIconStrokeWidth = 3;

    this.themeWinterColor = Color.BLUE;
    this.themeSpringColor = Color.GREEN;
    this.themeSummerColor = Color.YELLOW;
    this.themeFallColor = Color.RED;
}
 
Example 9
Source File: ColorPicker.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private Bitmap createColorWheelBitmap(int width, int height) {
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    LinearGradient gradientShader = new LinearGradient(0, 0, width, 0, new int[]{Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.RED}, null, Shader.TileMode.CLAMP);
    LinearGradient alphaShader = new LinearGradient(0, (height / 3), 0, height, new int[]{Color.WHITE, Color.TRANSPARENT}, null, Shader.TileMode.CLAMP);
    ComposeShader composeShader = new ComposeShader(alphaShader, gradientShader, PorterDuff.Mode.MULTIPLY);

    colorWheelPaint.setShader(composeShader);

    Canvas canvas = new Canvas(bitmap);
    canvas.drawRect(0, 0, width, height, colorWheelPaint);

    return bitmap;
}
 
Example 10
Source File: PieActivity.java    From Chart with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.piechart);
    update();
    final PieChart pieChart = (PieChart) findViewById(R.id.piechart);
    final int[] colors = new int[]{Color.RED,Color.BLACK,Color.BLUE,Color.GREEN,Color.GRAY,
            Color.YELLOW,Color.LTGRAY,Color.CYAN,Color.MAGENTA};
    final PieChartData pieChartData = PieChartData.builder()
            .setDatas(datas)
            //.setColors(colors)
            //.setTextColor(Color.RED)
            //.setTextSize(36)
            //.setSeparationDegree(3)
            .setPieItemClickListener(new OnPieItemClickListener() {
                @Override
                public void onPieItemClick(int position) {
                    Toast.makeText(PieActivity.this,"click->"+position,Toast.LENGTH_SHORT).show();
                }
            }).build();
    pieChart.setChartData(pieChartData);
    findViewById(R.id.update).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            update();
            pieChartData.setDatas(datas);
            pieChart.update(pieChartData);
        }
    });
}
 
Example 11
Source File: ColorStateListUtils.java    From MagicaSakura with Apache License 2.0 5 votes vote down vote up
static ColorStateList inflateColorStateList(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
    final int innerDepth = parser.getDepth() + 1;
    int depth;
    int type;

    LinkedList<int[]> stateList = new LinkedList<>();
    LinkedList<Integer> colorList = new LinkedList<>();

    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
        if (type != XmlPullParser.START_TAG || depth > innerDepth
                || !parser.getName().equals("item")) {
            continue;
        }

        TypedArray a1 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.color});
        final int value = a1.getResourceId(0, Color.MAGENTA);
        final int baseColor = value == Color.MAGENTA ? Color.MAGENTA : ThemeUtils.replaceColorById(context, value);
        a1.recycle();
        TypedArray a2 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.alpha});
        final float alphaMod = a2.getFloat(0, 1.0f);
        a2.recycle();
        colorList.add(alphaMod != 1.0f
                ? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alphaMod))
                : baseColor);

        stateList.add(extractStateSet(attrs));
    }

    if (stateList.size() > 0 && stateList.size() == colorList.size()) {
        int[] colors = new int[colorList.size()];
        for (int i = 0; i < colorList.size(); i++) {
            colors[i] = colorList.get(i);
        }
        return new ColorStateList(stateList.toArray(new int[stateList.size()][]), colors);
    }
    return null;
}
 
Example 12
Source File: ColorList.java    From ui with Apache License 2.0 5 votes vote down vote up
ColorList() {
    num = 0; //set to first color in list
    colors = new ColorData[]{
        new ColorData("Red", Color.RED),
        new ColorData("Blue", Color.BLUE),
        new ColorData("Cyan", Color.CYAN),
        new ColorData("Orange", Color.rgb(255, 165, 0)),
        //Android's green is lime.
        //new ColorData("Green", Color.GREEN),
        new ColorData("Green", Color.rgb(0, 128, 0)),
        new ColorData("Magenta", Color.MAGENTA),
        new ColorData("Pink", Color.rgb(255, 192, 203)),
        new ColorData("Yellow", Color.YELLOW),
        new ColorData("Gray", Color.GRAY),
        new ColorData("Light Gray", Color.LTGRAY),
        new ColorData("Dark Gray", Color.DKGRAY),
        new ColorData("Lime", Color.rgb(0, 255, 0)),
        new ColorData("Olive", Color.rgb(128, 128, 0)),
        new ColorData("Purple", Color.rgb(128, 0, 128)),
        new ColorData("Teal", Color.rgb(0, 128, 128)),
        new ColorData("Navy", Color.rgb(0, 0, 128)),
        new ColorData("Golden Rod", Color.rgb(218, 165, 32)),
        new ColorData("Dark Olive Green", Color.rgb(85, 107, 47)),
        new ColorData("Khaki", Color.rgb(240, 230, 140)),
        new ColorData("Steel Blue", Color.rgb(70, 130, 180)),
        new ColorData("Dark Orchid", Color.rgb(153, 50, 204)),
        new ColorData("White", Color.WHITE),
        new ColorData()  //black.
    };

}
 
Example 13
Source File: ColorWheelView.java    From SimpleDialogFragments with Apache License 2.0 5 votes vote down vote up
private void updateShader(){
    int[] gradient = new int[]{Color.RED, Color.YELLOW, Color.GREEN,
            Color.CYAN, Color.BLUE, Color.MAGENTA, Color.RED};
    SweepGradient rainbow = new SweepGradient(center.x, center.y, gradient, null);

    paint.setShader(rainbow);
}
 
Example 14
Source File: ColorPicker.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private Bitmap createColorWheelBitmap(int width, int height) {
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    LinearGradient gradientShader = new LinearGradient(0, 0, width, 0, new int[]{Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.RED}, null, Shader.TileMode.CLAMP);
    LinearGradient alphaShader = new LinearGradient(0, (height / 3), 0, height, new int[]{Color.WHITE, Color.TRANSPARENT}, null, Shader.TileMode.CLAMP);
    ComposeShader composeShader = new ComposeShader(alphaShader, gradientShader, PorterDuff.Mode.MULTIPLY);

    colorWheelPaint.setShader(composeShader);

    Canvas canvas = new Canvas(bitmap);
    canvas.drawRect(0, 0, width, height, colorWheelPaint);

    return bitmap;
}
 
Example 15
Source File: DetectedSpheroBall.java    From next18-ai-in-motion with Apache License 2.0 5 votes vote down vote up
private float getXTarget() {
    if (recognition.getColor() == Color.BLUE) {
        return 0.1f;
    } else if (recognition.getColor() == Color.GREEN) {
        return 0.9f;
    } else if (recognition.getColor() == Color.MAGENTA) {
        return 0.9f;
    } else {
        return 0.1f;
    }
}
 
Example 16
Source File: MaskedColorView.java    From dialogflow-android-client with Apache License 2.0 4 votes vote down vote up
private int getCurrentColor(final int[] stateSet) {
	return colorStateList == null
		   ? Color.MAGENTA
		   : colorStateList.getColorForState(stateSet, colorStateList.getDefaultColor());
}
 
Example 17
Source File: CustomStatusBarFragment.java    From AndroidNavigation with MIT License 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    textView.setText("");
    switch (buttonView.getId()) {
        case R.id.insets:
            // 慎重,会影响整个 Activity
            setStatusBarTranslucent(isChecked);
            getWindow().getDecorView().requestLayout();
            textView.setText("将影响整个 Activity,打开 Drawer 看看");
            break;
        case R.id.tinting:
            statusBarColor = isChecked ? Color.MAGENTA : Color.TRANSPARENT;
            setNeedsStatusBarAppearanceUpdate();
            if (statusBarHidden && isChecked) {
                textView.setText("只有显示状态栏才能看到效果");
            }
            break;
        case R.id.dark: // 深色状态栏 6.0 以上生效
            statusBarStyle = isChecked ? BarStyle.DarkContent : BarStyle.LightContent;
            setNeedsStatusBarAppearanceUpdate();

            if (statusBarHidden && isChecked) {
                textView.setText("只有显示状态栏才能看到效果");
            }

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
                textView.setText("只有在 6.0 以上系统才能看到效果");
            }

            break;
        case R.id.hidden:
            statusBarHidden = isChecked;
            setNeedsStatusBarAppearanceUpdate();
            break;
        case R.id.adjust:
            if (isChecked) {
                appendStatusBarPadding(toolbar);
            } else {
                removeStatusBarPadding(toolbar);
            }
            break;
    }
}
 
Example 18
Source File: DuotoneEffect.java    From VidEffects with Apache License 2.0 4 votes vote down vote up
public DuotoneEffect() {
    this(Color.MAGENTA, Color.YELLOW);
}
 
Example 19
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 4 votes vote down vote up
private void startNavigation(RouteTask routeTask, RouteParameters routeParameters, RouteResult routeResult) {

    // clear any graphics from the current graphics overlay
    mMapView.getGraphicsOverlays().get(0).getGraphics().clear();

    // get the route's geometry from the route result
    Polyline routeGeometry = routeResult.getRoutes().get(0).getRouteGeometry();
    // create a graphic (with a dashed line symbol) to represent the route
    mRouteAheadGraphic = new Graphic(routeGeometry,
        new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, Color.MAGENTA, 5f));
    mMapView.getGraphicsOverlays().get(0).getGraphics().add(mRouteAheadGraphic);
    // create a graphic (solid) to represent the route that's been traveled (initially empty)
    mRouteTraveledGraphic = new Graphic(routeGeometry,
        new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 5f));
    mMapView.getGraphicsOverlays().get(0).getGraphics().add(mRouteTraveledGraphic);

    // get the map view's location display
    LocationDisplay locationDisplay = mMapView.getLocationDisplay();
    // set up a simulated location data source which simulates movement along the route
    mSimulatedLocationDataSource = new SimulatedLocationDataSource();
    SimulationParameters simulationParameters = new SimulationParameters(Calendar.getInstance(), 35, 5, 5);
    mSimulatedLocationDataSource.setLocations(routeGeometry, simulationParameters);

    // set the simulated location data source as the location data source for this app
    locationDisplay.setLocationDataSource(mSimulatedLocationDataSource);
    locationDisplay.setAutoPanMode(LocationDisplay.AutoPanMode.NAVIGATION);
    // if the user navigates the map view away from the location display, activate the recenter button
    locationDisplay.addAutoPanModeChangedListener(autoPanModeChangedEvent -> mRecenterButton.setEnabled(true));
    // set up a RouteTracker for navigation along the calculated route
    mRouteTracker = new RouteTracker(getApplicationContext(), routeResult, 0);
    mRouteTracker.enableReroutingAsync(routeTask, routeParameters,
        RouteTracker.ReroutingStrategy.TO_NEXT_WAYPOINT, true);
    // get a reference to navigation text views
    TextView distanceRemainingTextView = findViewById(R.id.distanceRemainingTextView);
    TextView timeRemainingTextView = findViewById(R.id.timeRemainingTextView);
    TextView nextDirectionTextView = findViewById(R.id.nextDirectionTextView);

    // listen for changes in location
    locationDisplay.addLocationChangedListener(locationChangedEvent -> {
      // track the location and update route tracking status
      ListenableFuture<Void> trackLocationFuture = mRouteTracker.trackLocationAsync(locationChangedEvent.getLocation());
      trackLocationFuture.addDoneListener(() -> {
        // listen for new voice guidance events
        mRouteTracker.addNewVoiceGuidanceListener(newVoiceGuidanceEvent -> {
          // use Android's text to speech to speak the voice guidance
          speakVoiceGuidance(newVoiceGuidanceEvent.getVoiceGuidance().getText());
          nextDirectionTextView
              .setText(getString(R.string.next_direction, newVoiceGuidanceEvent.getVoiceGuidance().getText()));
        });

        // get the route's tracking status
        TrackingStatus trackingStatus = mRouteTracker.getTrackingStatus();
        // set geometries for the route ahead and the remaining route
        mRouteAheadGraphic.setGeometry(trackingStatus.getRouteProgress().getRemainingGeometry());
        mRouteTraveledGraphic.setGeometry(trackingStatus.getRouteProgress().getTraversedGeometry());

        // get remaining distance information
        TrackingStatus.Distance remainingDistance = trackingStatus.getDestinationProgress().getRemainingDistance();
        // covert remaining minutes to hours:minutes:seconds
        String remainingTimeString = DateUtils
            .formatElapsedTime((long) (trackingStatus.getDestinationProgress().getRemainingTime() * 60));

        // update text views
        distanceRemainingTextView.setText(getString(R.string.distance_remaining, remainingDistance.getDisplayText(),
            remainingDistance.getDisplayTextUnits().getPluralDisplayName()));
        timeRemainingTextView.setText(getString(R.string.time_remaining, remainingTimeString));

        // if a destination has been reached
        if (trackingStatus.getDestinationStatus() == DestinationStatus.REACHED) {
          // if there are more destinations to visit. Greater than 1 because the start point is considered a "stop"
          if (mRouteTracker.getTrackingStatus().getRemainingDestinationCount() > 1) {
            // switch to the next destination
            mRouteTracker.switchToNextDestinationAsync();
            Toast.makeText(this, "Navigating to the second stop, the Fleet Science Center.", Toast.LENGTH_LONG).show();
          } else {
            Toast.makeText(this, "Arrived at the final destination.", Toast.LENGTH_LONG).show();
          }
        }
      });
    });

    // start the LocationDisplay, which starts the SimulatedLocationDataSource
    locationDisplay.startAsync();
    Toast.makeText(this, "Navigating to the first stop, the USS San Diego Memorial.", Toast.LENGTH_LONG).show();
  }
 
Example 20
Source File: RemoteControlActivity.java    From next18-ai-in-motion with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_remote_control);

    vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    // Setup Joystick UI to match sphero ball color
    JoyStick joy1 = findViewById(R.id.joy1);
    joy1.setListener(this);
    joy1.setPadBackground(R.drawable.gray_pad);
    if (MainActivity.spheroColor == Color.BLUE) {
        joy1.setButtonDrawable(R.drawable.blue_btn);
    } else if (MainActivity.spheroColor == Color.GREEN) {
        joy1.setButtonDrawable(R.drawable.green_btn);
    } else if (MainActivity.spheroColor == Color.YELLOW) {
        joy1.setButtonDrawable(R.drawable.orange_btn);
    } else if (MainActivity.spheroColor == Color.MAGENTA) {
        joy1.setButtonDrawable(R.drawable.pink_btn);
    } else {
        joy1.setButtonDrawable(R.drawable.btn_1);
    }


    fallBackTimer = new Handler();
    runnable = new Runnable() {
        public void run() {
            UserSetup.joinedGame = false;
            finish();
        }
    };

    fallBackTimer.postDelayed(runnable, 60000);

    countDownTimer = findViewById(R.id.countDownText);

    setEventListeners();


    if (!UserSetup.joinedGame) {
        headingEventListener = new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                int angle = Integer.valueOf(String.valueOf(dataSnapshot.getValue()));
                if (!UserSetup.joinedGame && angle >= 0) {
                    MainActivity.robot.drive((float) angle, 0.18f);
                    disableJoystick = true;
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        };

        MainActivity.databaseReference.child("heading").addValueEventListener(headingEventListener);
    }
}