Example usage for android.graphics Color YELLOW

List of usage examples for android.graphics Color YELLOW

Introduction

In this page you can find the example usage for android.graphics Color YELLOW.

Prototype

int YELLOW

To view the source code for android.graphics Color YELLOW.

Click Source Link

Usage

From source file:hmatalonga.greenhub.util.Notifier.java

public static void batteryWarningTemperature(final Context context) {
    if (sNotificationManager == null) {
        sNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    }//w  ww  . j  a v  a  2s.  c o m

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_alert_circle_white_24dp).setContentTitle("Battery warning")
            .setContentText("Temperature is getting warm").setAutoCancel(true).setOngoing(false)
            .setLights(Color.YELLOW, 500, 2000).setVibrate(new long[] { 0, 400, 1000 })
            .setPriority(SettingsUtils.fetchNotificationsPriority(context));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setVisibility(Notification.VISIBILITY_PUBLIC);
    }

    // Because the ID remains unchanged, the existing notification is updated.
    Notification notification = mBuilder.build();
    notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
    sNotificationManager.notify(Config.NOTIFICATION_TEMPERATURE_WARNING, notification);
}

From source file:org.blanco.techmun.android.MensajesActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0 && resultCode == RESULT_OK) {
        Cursor c = managedQuery(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null,
                "_id = " + 1, null, null);
        if (c != null && c.moveToNext()) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };

            Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
            cursor.moveToFirst();// w  w w  .  j  a v  a2  s .c  o m

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String filePath = cursor.getString(columnIndex);
            cursor.close();

            attachImage = BitmapFactory.decodeFile(filePath);
            //Mark the button as image attached
            btnAddImage.setBackgroundColor(Color.YELLOW);
            Log.i("techmun", "selected image" + filePath + " Loaded.");

        }
        Log.d("techmun", "Returned from image pick");

    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.github.andrewlord1990.snackbarbuildersample.SampleActivity.java

private void setupData() {
    samples = new LinkedHashMap<>();
    samples.put(MESSAGE, new OnClickListener() {
        @Override/*  ww  w.  ja  v a  2s. c o  m*/
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).build().show();
        }
    });
    samples.put(ACTION, new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION)
                    .actionClickListener(getActionClickListener()).build().show();
        }
    });
    samples.put("Custom Text Colours Using Resources", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message("Message in different color").actionText(ACTION)
                    .actionClickListener(getActionClickListener()).messageTextColorRes(R.color.red)
                    .actionTextColorRes(R.color.green).build().show();
        }
    });
    samples.put("Custom Text Colours Using Colors", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message("Message in different color").actionText(ACTION)
                    .actionClickListener(getActionClickListener()).messageTextColor(green).actionTextColor(red)
                    .build().show();
        }
    });
    samples.put("Standard callback", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION)
                    .callback(createCallback()).build().show();
        }
    });
    samples.put("SnackbarBuilder callback", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION)
                    .snackbarCallback(createSnackbarCallback()).build().show();
        }
    });
    samples.put("Timeout callback", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION)
                    .timeoutDismissCallback(new SnackbarTimeoutDismissCallback() {
                        @Override
                        public void onSnackbarTimedOut(Snackbar snackbar) {
                            showToast("Timed out");
                        }
                    }).build().show();
        }
    });
    samples.put("Lowercase action", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION).lowercaseAction()
                    .build().show();
        }
    });
    samples.put("Custom timeout", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message("This has a custom timeout").duration(10000)
                    .build().show();
        }
    });
    samples.put("Icon", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).icon(R.drawable.ic_android_24dp)
                    .iconMarginStartRes(R.dimen.snackbar_icon_margin)
                    .iconMarginEndRes(R.dimen.snackbar_icon_margin).message("This has an icon on it")
                    .duration(Snackbar.LENGTH_LONG).build().show();
        }
    });
    samples.put("Multicolour", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new SnackbarBuilder(SampleActivity.this).message("this").appendMessage(" message", Color.RED)
                    .appendMessage(" has", Color.GREEN).appendMessage(" lots", Color.BLUE)
                    .appendMessage(" of", Color.GRAY).appendMessage(" colors", Color.MAGENTA)
                    .duration(Snackbar.LENGTH_LONG).build().show();
        }
    });
    samples.put("Using wrapper", new OnClickListener() {
        @Override
        public void onClick(View view) {
            SnackbarWrapper wrapper = new SnackbarBuilder(SampleActivity.this).message("Using wrapper")
                    .duration(Snackbar.LENGTH_LONG).buildWrapper();
            wrapper.appendMessage(" to add more text", Color.YELLOW).show();
        }
    });
    samples.put("Toast with red text", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new ToastBuilder(SampleActivity.this).message("Custom toast").messageTextColor(Color.RED).build()
                    .show();
        }
    });
    samples.put("Toast with custom position", new OnClickListener() {
        @Override
        public void onClick(View view) {
            new ToastBuilder(SampleActivity.this).message("Positioned toast").duration(Toast.LENGTH_LONG)
                    .gravity(Gravity.TOP).gravityOffsetX(100).gravityOffsetY(300).build().show();
        }
    });
}

From source file:com.example.firstocr.ViewfinderView.java

@SuppressWarnings("unused")
@Override//  w w w. j  ava  2s .  c  om
public void onDraw(Canvas canvas) {
    Rect frame = cameraManager.getFramingRect();
    if (frame == null) {
        return;
    }
    int width = canvas.getWidth();
    int height = canvas.getHeight();

    // Draw the exterior (i.e. outside the framing rect) darkened
    paint.setColor(maskColor);
    canvas.drawRect(0, 0, width, frame.top, paint);
    canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
    canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint);
    canvas.drawRect(0, frame.bottom + 1, width, height, paint);

    // If we have an OCR result, overlay its information on the viewfinder.
    if (resultText != null) {

        // Only draw text/bounding boxes on viewfinder if it hasn't been resized since the OCR was requested.
        Point bitmapSize = resultText.getBitmapDimensions();
        previewFrame = cameraManager.getFramingRectInPreview();
        if (bitmapSize.x == previewFrame.width() && bitmapSize.y == previewFrame.height()) {

            float scaleX = frame.width() / (float) previewFrame.width();
            float scaleY = frame.height() / (float) previewFrame.height();

            if (DRAW_REGION_BOXES) {
                regionBoundingBoxes = resultText.getRegionBoundingBoxes();
                for (int i = 0; i < regionBoundingBoxes.size(); i++) {
                    paint.setAlpha(0xA0);
                    paint.setColor(Color.MAGENTA);
                    paint.setStyle(Style.STROKE);
                    paint.setStrokeWidth(1);
                    rect = regionBoundingBoxes.get(i);
                    canvas.drawRect(frame.left + rect.left * scaleX, frame.top + rect.top * scaleY,
                            frame.left + rect.right * scaleX, frame.top + rect.bottom * scaleY, paint);
                }
            }

            if (DRAW_TEXTLINE_BOXES) {
                // Draw each textline
                textlineBoundingBoxes = resultText.getTextlineBoundingBoxes();
                paint.setAlpha(0xA0);
                paint.setColor(Color.RED);
                paint.setStyle(Style.STROKE);
                paint.setStrokeWidth(1);
                for (int i = 0; i < textlineBoundingBoxes.size(); i++) {
                    rect = textlineBoundingBoxes.get(i);
                    canvas.drawRect(frame.left + rect.left * scaleX, frame.top + rect.top * scaleY,
                            frame.left + rect.right * scaleX, frame.top + rect.bottom * scaleY, paint);
                }
            }

            if (DRAW_STRIP_BOXES) {
                stripBoundingBoxes = resultText.getStripBoundingBoxes();
                paint.setAlpha(0xFF);
                paint.setColor(Color.YELLOW);
                paint.setStyle(Style.STROKE);
                paint.setStrokeWidth(1);
                for (int i = 0; i < stripBoundingBoxes.size(); i++) {
                    rect = stripBoundingBoxes.get(i);
                    canvas.drawRect(frame.left + rect.left * scaleX, frame.top + rect.top * scaleY,
                            frame.left + rect.right * scaleX, frame.top + rect.bottom * scaleY, paint);
                }
            }

            if (DRAW_WORD_BOXES || DRAW_WORD_TEXT) {
                // Split the text into words
                wordBoundingBoxes = resultText.getWordBoundingBoxes();
                //      for (String w : words) {
                //        Log.e("ViewfinderView", "word: " + w);
                //      }
                //Log.d("ViewfinderView", "There are " + words.length + " words in the string array.");
                //Log.d("ViewfinderView", "There are " + wordBoundingBoxes.size() + " words with bounding boxes.");
            }

            if (DRAW_WORD_BOXES) {
                paint.setAlpha(0xFF);
                paint.setColor(0xFF00CCFF);
                paint.setStyle(Style.STROKE);
                paint.setStrokeWidth(1);
                for (int i = 0; i < wordBoundingBoxes.size(); i++) {
                    // Draw a bounding box around the word
                    rect = wordBoundingBoxes.get(i);
                    canvas.drawRect(frame.left + rect.left * scaleX, frame.top + rect.top * scaleY,
                            frame.left + rect.right * scaleX, frame.top + rect.bottom * scaleY, paint);
                }
            }

            if (DRAW_WORD_TEXT) {
                words = resultText.getText().replace("\n", " ").split(" ");
                int[] wordConfidences = resultText.getWordConfidences();
                for (int i = 0; i < wordBoundingBoxes.size(); i++) {
                    boolean isWordBlank = true;
                    try {
                        if (!words[i].equals("")) {
                            isWordBlank = false;
                        }
                    } catch (ArrayIndexOutOfBoundsException e) {
                        e.printStackTrace();
                    }

                    // Only draw if word has characters
                    if (!isWordBlank) {
                        // Draw a white background around each word
                        rect = wordBoundingBoxes.get(i);
                        paint.setColor(Color.WHITE);
                        paint.setStyle(Style.FILL);
                        if (DRAW_TRANSPARENT_WORD_BACKGROUNDS) {
                            // Higher confidence = more opaque, less transparent background
                            paint.setAlpha(wordConfidences[i] * 255 / 100);
                        } else {
                            paint.setAlpha(255);
                        }
                        canvas.drawRect(frame.left + rect.left * scaleX, frame.top + rect.top * scaleY,
                                frame.left + rect.right * scaleX, frame.top + rect.bottom * scaleY, paint);

                        // Draw the word in black text
                        paint.setColor(Color.BLACK);
                        paint.setAlpha(0xFF);
                        paint.setAntiAlias(true);
                        paint.setTextAlign(Align.LEFT);

                        // Adjust text size to fill rect
                        paint.setTextSize(100);
                        paint.setTextScaleX(1.0f);
                        // ask the paint for the bounding rect if it were to draw this text
                        Rect bounds = new Rect();
                        paint.getTextBounds(words[i], 0, words[i].length(), bounds);
                        // get the height that would have been produced
                        int h = bounds.bottom - bounds.top;
                        // figure out what textSize setting would create that height of text
                        float size = (((float) (rect.height()) / h) * 100f);
                        // and set it into the paint
                        paint.setTextSize(size);
                        // Now set the scale.
                        // do calculation with scale of 1.0 (no scale)
                        paint.setTextScaleX(1.0f);
                        // ask the paint for the bounding rect if it were to draw this text.
                        paint.getTextBounds(words[i], 0, words[i].length(), bounds);
                        // determine the width
                        int w = bounds.right - bounds.left;
                        // calculate the baseline to use so that the entire text is visible including the descenders
                        int text_h = bounds.bottom - bounds.top;
                        int baseline = bounds.bottom + ((rect.height() - text_h) / 2);
                        // determine how much to scale the width to fit the view
                        float xscale = ((float) (rect.width())) / w;
                        // set the scale for the text paint
                        paint.setTextScaleX(xscale);
                        canvas.drawText(words[i], frame.left + rect.left * scaleX,
                                frame.top + rect.bottom * scaleY - baseline, paint);
                    }

                }
            }

            //        if (DRAW_CHARACTER_BOXES || DRAW_CHARACTER_TEXT) {
            //          characterBoundingBoxes = resultText.getCharacterBoundingBoxes();
            //        }
            //
            //        if (DRAW_CHARACTER_BOXES) {
            //          // Draw bounding boxes around each character
            //          paint.setAlpha(0xA0);
            //          paint.setColor(0xFF00FF00);
            //          paint.setStyle(Style.STROKE);
            //          paint.setStrokeWidth(1);
            //          for (int c = 0; c < characterBoundingBoxes.size(); c++) {
            //            Rect characterRect = characterBoundingBoxes.get(c);
            //            canvas.drawRect(frame.left + characterRect.left * scaleX,
            //                frame.top + characterRect.top * scaleY, 
            //                frame.left + characterRect.right * scaleX, 
            //                frame.top + characterRect.bottom * scaleY, paint);
            //          }
            //        }
            //
            //        if (DRAW_CHARACTER_TEXT) {
            //          // Draw letters individually
            //          for (int i = 0; i < characterBoundingBoxes.size(); i++) {
            //            Rect r = characterBoundingBoxes.get(i);
            //
            //            // Draw a white background for every letter
            //            int meanConfidence = resultText.getMeanConfidence();
            //            paint.setColor(Color.WHITE);
            //            paint.setAlpha(meanConfidence * (255 / 100));
            //            paint.setStyle(Style.FILL);
            //            canvas.drawRect(frame.left + r.left * scaleX,
            //                frame.top + r.top * scaleY, 
            //                frame.left + r.right * scaleX, 
            //                frame.top + r.bottom * scaleY, paint);
            //
            //            // Draw each letter, in black
            //            paint.setColor(Color.BLACK);
            //            paint.setAlpha(0xFF);
            //            paint.setAntiAlias(true);
            //            paint.setTextAlign(Align.LEFT);
            //            String letter = "";
            //            try {
            //              char c = resultText.getText().replace("\n","").replace(" ", "").charAt(i);
            //              letter = Character.toString(c);
            //
            //              if (!letter.equals("-") && !letter.equals("_")) {
            //
            //                // Adjust text size to fill rect
            //                paint.setTextSize(100);
            //                paint.setTextScaleX(1.0f);
            //
            //                // ask the paint for the bounding rect if it were to draw this text
            //                Rect bounds = new Rect();
            //                paint.getTextBounds(letter, 0, letter.length(), bounds);
            //
            //                // get the height that would have been produced
            //                int h = bounds.bottom - bounds.top;
            //
            //                // figure out what textSize setting would create that height of text
            //                float size  = (((float)(r.height())/h)*100f);
            //
            //                // and set it into the paint
            //                paint.setTextSize(size);
            //
            //                // Draw the text as is. We don't really need to set the text scale, because the dimensions
            //                // of the Rect should already be suited for drawing our letter. 
            //                canvas.drawText(letter, frame.left + r.left * scaleX, frame.top + r.bottom * scaleY, paint);
            //              }
            //            } catch (StringIndexOutOfBoundsException e) {
            //              e.printStackTrace();
            //            } catch (Exception e) {
            //              e.printStackTrace();
            //            }
            //          }
            //        }
        }

    }
    // Draw a two pixel solid border inside the framing rect
    paint.setAlpha(0);
    paint.setStyle(Style.FILL);
    paint.setColor(frameColor);
    canvas.drawRect(frame.left, frame.top, frame.right + 1, frame.top + 2, paint);
    canvas.drawRect(frame.left, frame.top + 2, frame.left + 2, frame.bottom - 1, paint);
    canvas.drawRect(frame.right - 1, frame.top, frame.right + 1, frame.bottom - 1, paint);
    canvas.drawRect(frame.left, frame.bottom - 1, frame.right + 1, frame.bottom + 1, paint);

    // Draw the framing rect corner UI elements
    paint.setColor(cornerColor);
    canvas.drawRect(frame.left - 15, frame.top - 15, frame.left + 15, frame.top, paint);
    canvas.drawRect(frame.left - 15, frame.top, frame.left, frame.top + 15, paint);
    canvas.drawRect(frame.right - 15, frame.top - 15, frame.right + 15, frame.top, paint);
    canvas.drawRect(frame.right, frame.top - 15, frame.right + 15, frame.top + 15, paint);
    canvas.drawRect(frame.left - 15, frame.bottom, frame.left + 15, frame.bottom + 15, paint);
    canvas.drawRect(frame.left - 15, frame.bottom - 15, frame.left, frame.bottom, paint);
    canvas.drawRect(frame.right - 15, frame.bottom, frame.right + 15, frame.bottom + 15, paint);
    canvas.drawRect(frame.right, frame.bottom - 15, frame.right + 15, frame.bottom + 15, paint);

    // Request another update at the animation interval, but don't repaint the entire viewfinder mask.
    //postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom);
}

From source file:com.near.chimerarevo.services.NewsService.java

private int getLEDColor() {
    int index = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(this)
            .getString("notification_light_color_pref", "4"));

    switch (index) {
    case 0:/*from   w ww  .  j a  v  a 2  s.  c om*/
        return Color.BLUE;
    case 1:
        return Color.CYAN;
    case 2:
        return Color.GREEN;
    case 3:
        return Color.MAGENTA;
    case 4:
        return Color.RED;
    case 5:
        return Color.WHITE;
    case 6:
        return Color.YELLOW;
    default:
        return Color.RED;
    }
}

From source file:org.openbitcoinwidget.WidgetProvider.java

private static int getColor(ColorMode colorMode, WidgetColor widgetColor) {
    if (colorMode.equals(ColorMode.Default)) {
        switch (widgetColor) {
        case Warning:
            return Color.parseColor("#ff3030");
        case StartValue:
            return Color.YELLOW;
        case Normal:
            return Color.LTGRAY;
        case Increase:
            return Color.GREEN;
        case Decrease:
            return Color.parseColor("#ff3030");
        default:/*from  ww w.j av  a 2s. c  o  m*/
            throw new IllegalArgumentException("No color defined for " + widgetColor);
        }
    } else if (colorMode.equals(ColorMode.Grayscale)) {
        switch (widgetColor) {
        case Warning:
            return Color.WHITE;
        case StartValue:
            return Color.LTGRAY;
        case Normal:
            return Color.LTGRAY;
        case Increase:
            return Color.WHITE;
        case Decrease:
            return Color.GRAY;
        default:
            throw new IllegalArgumentException("No color defined for " + widgetColor);
        }
    } else {
        throw new IllegalArgumentException("No color mode defined for " + colorMode);
    }
}

From source file:survivingwithandroid.com.uvindex.MainActivity.java

private void handleConnection(Location loc) {

    double lat = loc.getLatitude();
    double lon = loc.getLongitude();

    // Make HTTP request according to Openweathermap API
    String url = UV_URL + ((int) lat) + "," + ((int) lon) + "/current.json?appid=" + APP_ID;
    System.out.println("URL [" + url + "]");
    Request request = new Request.Builder().url(url).build();
    httpClient.newCall(request).enqueue(new Callback() {
        @Override//from w w  w.j ava2 s. c o m
        public void onFailure(Call call, IOException e) {
            // Handle failure in HTTP request
        }

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            // Ok we have the response...parse it
            try {
                JSONObject obj = new JSONObject(response.body().string());
                final double uvIndex = obj.optDouble("data");
                System.out.println("UV Index [" + uvIndex + "]");
                JSONObject jsonLoc = obj.getJSONObject("location");
                final double cLon = jsonLoc.getDouble("longitude");
                final double cLat = jsonLoc.getDouble("latitude");

                Handler handler = new Handler(MainActivity.this.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        coordView.setText(cLat + "," + cLon);
                        uvView.setText(String.valueOf(uvIndex));
                        if (uvIndex <= 2.9) {
                            uvView.setTextColor(Color.GREEN);
                            msgView.setText("Low");
                        } else if (uvIndex <= 5.9) {
                            uvView.setTextColor(Color.YELLOW);
                            msgView.setText("Moderate");
                        } else if (uvIndex <= 7.9) {
                            uvView.setTextColor(Color.parseColor("#DF7401"));
                            msgView.setText("High");
                        } else if (uvIndex <= 10.9) {
                            uvView.setTextColor(Color.RED);
                            msgView.setText("Very High");
                        } else if (uvIndex >= 11) {
                            uvView.setTextColor(Color.parseColor("#8258FA"));
                            msgView.setText("Extreme");
                        }
                    }
                });
            } catch (JSONException jex) {
                jex.printStackTrace();
            }
        }
    });
}

From source file:ansteph.com.beecabfordrivers.view.registration.RegistrationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_registration, container, false);

    txtFullName = (EditText) rootView.findViewById(R.id.input_name);
    txtEmail = (EditText) rootView.findViewById(R.id.input_email);
    txtCompanyName = (EditText) rootView.findViewById(R.id.input_companyname);
    txtMobile = (EditText) rootView.findViewById(R.id.input_mobile);
    txtCarModel = (EditText) rootView.findViewById(R.id.input_model);

    txtNumPlate = (EditText) rootView.findViewById(R.id.input_plate);
    txtLicence = (EditText) rootView.findViewById(R.id.input_cablicence);
    txtYear = (EditText) rootView.findViewById(R.id.input_year);
    txtPassword = (EditText) rootView.findViewById(R.id.input_password);
    txtConPassword = (EditText) rootView.findViewById(R.id.input_confirm_password);

    imgValid = (ImageView) rootView.findViewById(R.id.imgValid);

    txtReg = (TextView) rootView.findViewById(R.id.txtRegistration);

    requestQueue = Volley.newRequestQueue(getActivity());
    Button btnCreateAcc = (Button) rootView.findViewById(R.id.btn_signup);

    driverClass = ((Registration) getActivity()).getDriverClass();

    txtConPassword.addTextChangedListener(new TextWatcher() {
        @Override//w w  w  . j  a v  a 2 s. com
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            String npwd = txtPassword.getText().toString().trim();
            String cpwd = txtConPassword.getText().toString().trim();
            if (!npwd.isEmpty() && npwd.length() == cpwd.length()) {
                if (npwd.equals(cpwd)) {
                    //show the tick mark
                    imgValid.setVisibility(View.VISIBLE);

                } else {
                    //no show the tick mark
                    imgValid.setVisibility(View.INVISIBLE);
                }
            } else {
                //no show the tick mark
                imgValid.setVisibility(View.INVISIBLE);
            }
        }
    });

    txtPassword.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            String npwd = txtPassword.getText().toString().trim();
            String cpwd = txtConPassword.getText().toString().trim();
            if (!npwd.isEmpty() && npwd.length() == cpwd.length()) {
                if (npwd.equals(cpwd)) {
                    //show the tick mark
                    imgValid.setVisibility(View.VISIBLE);

                } else {
                    //no show the tick mark
                    imgValid.setVisibility(View.INVISIBLE);
                }
            } else {
                //no show the tick mark
                imgValid.setVisibility(View.INVISIBLE);
            }
        }
    });

    btnCreateAcc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //Do registration

            if (!isEmailOk()) {
                txtReg.setText(getString(R.string.invalid_email));
                txtReg.setTextColor(Color.RED);
                return;
            }

            if (txtFullName.getText().toString().isEmpty() || txtMobile.getText().toString().isEmpty()) {
                txtReg.setText(getString(R.string.missing_info));
                txtReg.setTextColor(Color.YELLOW);
                return;
            }

            if (txtPassword.getText().toString().length() < 6) {
                txtReg.setText(getString(R.string.pwd_short));
                txtReg.setTextColor(Color.YELLOW);
                return;
            }

            if (imgValid.getVisibility() == View.VISIBLE) {
                //Do registration
                try {
                    registerClient();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                txtReg.setText(getString(R.string.pwd_mismatch));
                txtReg.setTextColor(Color.RED);
            }

        }
    });

    return rootView;
}

From source file:org.croudtrip.fragments.join.JoinDrivingFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Register local broadcasts
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(joinRequestExpiredReceiver,
            new IntentFilter(Constants.EVENT_JOIN_REQUEST_EXPIRED));

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(nfcScannedReceiver,
            new IntentFilter(Constants.EVENT_NFC_TAG_SCANNED));

    IntentFilter filter = new IntentFilter();
    filter.addAction(Constants.EVENT_SECONDARY_DRIVER_ACCEPTED);
    filter.addAction(Constants.EVENT_SECONDARY_DRIVER_DECLINED);
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(secondaryDriverAcceptedDeclinedReceiver,
            filter);/*from  w w w.j av  a2  s. c  o m*/

    //Register nfc adapter
    nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
    if (nfcAdapter != null) {
        nfcPendingIntent = PendingIntent.getActivity(getActivity(), 0,
                new Intent(getActivity(), getActivity().getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
                0);
    }

    //Initialize colors for different routes on the map
    colors = new ArrayList<>();
    colors.add(Color.BLUE);
    colors.add(Color.GREEN);
    colors.add(Color.RED);
    colors.add(Color.YELLOW);

    shadesOfGray = new ArrayList<>();
    shadesOfGray.add(Color.GRAY);
    shadesOfGray.add(Color.DKGRAY);
    shadesOfGray.add(Color.LTGRAY);
}