List of usage examples for android.graphics Color MAGENTA
int MAGENTA
To view the source code for android.graphics Color MAGENTA.
Click Source Link
From source file:com.presisco.example.slidingtabsicons.slidingtabsicons.SlidingTabsIconsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (populate_tabs) /**/*from w w w . ja v a 2s .c om*/ * Populate our tab list with tabs. Each item contains a title, indicator color and divider * color, which are used by {@link SlidingTabLayout}. */ mTabs.add(new SamplePagerItem("Title1", Color.BLUE, Color.GRAY, R.drawable.tabs_title_icon1, R.drawable.tabs_title_selected1)); mTabs.add(new SamplePagerItem("Title2", Color.CYAN, Color.BLACK, R.drawable.tabs_title_icon2, R.drawable.tabs_title_selected2)); mTabs.add(new SamplePagerItem("Title3", Color.GREEN, Color.MAGENTA, R.drawable.tabs_title_icon3, R.drawable.tabs_title_selected3)); // mTabs.add(new SamplePagerItem( // getString(R.string.tab_stream), // Title // Color.BLUE, // Indicator color // Color.GRAY // Divider color // )); // END_INCLUDE (populate_tabs) }
From source file:com.ubergeek42.WeechatAndroid.ChatLinesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder;//from w ww . j a v a2s . co m // If we don't have the view, or we were using a filteredView, inflate a new one if (convertView == null) { convertView = inflater.inflate(R.layout.chatview_line, null); holder = new ViewHolder(); holder.timestamp = (TextView) convertView.findViewById(R.id.chatline_timestamp); holder.prefix = (TextView) convertView.findViewById(R.id.chatline_prefix); holder.message = (TextView) convertView.findViewById(R.id.chatline_message); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // Change the font sizes holder.timestamp.setTextSize(textSize); holder.prefix.setTextSize(textSize); holder.message.setTextSize(textSize); BufferLine chatLine = (BufferLine) getItem(position); // Render the timestamp if (enableTimestamp) { holder.timestamp.setText(timestampFormat.format(chatLine.getTimestamp())); holder.timestamp.setPadding(holder.timestamp.getPaddingLeft(), holder.timestamp.getPaddingTop(), 5, holder.timestamp.getPaddingBottom()); } else { holder.timestamp.setText(""); holder.timestamp.setPadding(holder.timestamp.getPaddingLeft(), holder.timestamp.getPaddingTop(), 0, holder.timestamp.getPaddingBottom()); } // Recalculate the prefix width based on the size of one character(fixed width font) if (prefixWidth == 0) { holder.prefix.setMinimumWidth(0); StringBuilder sb = new StringBuilder(); for (int i = 0; i < maxPrefix; i++) { sb.append("m"); } holder.prefix.setText(sb.toString()); holder.prefix.measure(convertView.getWidth(), convertView.getHeight()); prefixWidth = holder.prefix.getMeasuredWidth(); } // Render the prefix if (chatLine.getHighlight()) { String prefixStr = chatLine.getPrefix(); Spannable highlightText = new SpannableString(prefixStr); highlightText.setSpan(new ForegroundColorSpan(Color.YELLOW), 0, prefixStr.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); highlightText.setSpan(new BackgroundColorSpan(Color.MAGENTA), 0, prefixStr.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); holder.prefix.setText(highlightText); } else { if (enableColor) { holder.prefix.setText(Html.fromHtml(chatLine.getPrefixHTML()), TextView.BufferType.SPANNABLE); } else { holder.prefix.setText(chatLine.getPrefix()); } } if (prefix_align.equals("right")) { holder.prefix.setGravity(Gravity.RIGHT); holder.prefix.setMinimumWidth(prefixWidth); } else if (prefix_align.equals("left")) { holder.prefix.setGravity(Gravity.LEFT); holder.prefix.setMinimumWidth(prefixWidth); } else { holder.prefix.setGravity(Gravity.LEFT); holder.prefix.setMinimumWidth(0); } // Render the message if (enableColor) { holder.message.setText(Html.fromHtml(chatLine.getMessageHTML()), TextView.BufferType.SPANNABLE); } else { holder.message.setText(chatLine.getMessage()); } return convertView; }
From source file:com.example.firstocr.ViewfinderView.java
@SuppressWarnings("unused") @Override/*from w w w. j av a2s .c o m*/ 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:ng.uavp.ch.ngusbterminal.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { thisview = inflater.inflate(R.layout.settings, container, false); SharedPreferences sharedPref = getActivity().getSharedPreferences("uart_settings", Context.MODE_PRIVATE); UartSettings defaults = new UartSettings(); Spinner spinner1 = (Spinner) thisview.findViewById(R.id.spinnerBaud); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(getActivity(), R.array.baud_array, R.layout.spinner_item_settings); // Specify the layout to use when the list of choices appears adapter1.setDropDownViewResource(R.layout.spinner_item_settings); // Apply the adapter to the spinner spinner1.setAdapter(adapter1);/*from ww w .j a v a2 s . co m*/ SetSpinnerSelection(sharedPref, spinner1, "baudrate", defaults.baudrate); Spinner spinner2 = (Spinner) thisview.findViewById(R.id.spinnerBits); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(getActivity(), R.array.databits_array, R.layout.spinner_item_settings); // Specify the layout to use when the list of choices appears adapter2.setDropDownViewResource(R.layout.spinner_item_settings); // Apply the adapter to the spinner spinner2.setAdapter(adapter2); SetSpinnerSelection(sharedPref, spinner2, "databits", defaults.dataBits); Spinner spinner3 = (Spinner) thisview.findViewById(R.id.spinnerParity); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter3 = ArrayAdapter.createFromResource(getActivity(), R.array.parity_array, R.layout.spinner_item_settings); // Specify the layout to use when the list of choices appears adapter3.setDropDownViewResource(R.layout.spinner_item_settings); // Apply the adapter to the spinner spinner3.setAdapter(adapter3); spinner3.setSelection(sharedPref.getInt("parity", defaults.parity)); Spinner spinner4 = (Spinner) thisview.findViewById(R.id.spinnerStopbits); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter4 = ArrayAdapter.createFromResource(getActivity(), R.array.stopbits_array, R.layout.spinner_item_settings); // Specify the layout to use when the list of choices appears adapter4.setDropDownViewResource(R.layout.spinner_item_settings); // Apply the adapter to the spinner spinner4.setAdapter(adapter4); SetSpinnerSelection(sharedPref, spinner4, "stopbits", defaults.stopBits); Spinner spinner5 = (Spinner) thisview.findViewById(R.id.spinnerFlow); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter5 = ArrayAdapter.createFromResource(getActivity(), R.array.flowcontrol, R.layout.spinner_item_settings); // Specify the layout to use when the list of choices appears adapter5.setDropDownViewResource(R.layout.spinner_item_settings); // Apply the adapter to the spinner spinner5.setAdapter(adapter5); spinner5.setSelection(sharedPref.getInt("flowcontrol", defaults.flowControl)); String[] devList; try { devList = usb.createDeviceList(); usbDevicesFound = devList.length; } catch (D2xxManager.D2xxException e) { devList = new String[1]; devList[0] = e.getLocalizedMessage(); } if (devList.length == 0) { devList = new String[1]; devList[0] = getString(R.string.error_noAdapter); } Spinner spinner6 = (Spinner) thisview.findViewById(R.id.spinnerInterfce); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(activity, R.layout.spinner_item_settings, devList); spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_item_settings); spinner6.setAdapter(spinnerArrayAdapter); Button button1 = (Button) thisview.findViewById(R.id.button1); button1.setEnabled(usbDevicesFound > 0); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub doConnect(); } }); if (usbDevicesFound == 0) spinner6.setBackgroundColor(Color.MAGENTA); else spinner6.setBackgroundColor(Color.TRANSPARENT); return thisview; }
From source file:com.example.milos.msattackczm.ui.ProcedureDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.procedure_codes, container, false); context = getActivity();/*from w ww. j a v a 2 s. co m*/ mPathView = (PathView) rootView.findViewById(R.id.pathView); mPathView.setOnTouchListener(MyOnTouchListener); TextView primaryCodeTextView = (TextView) rootView.findViewById(R.id.primary_code_textView); TextView secondaryCodeTextView = (TextView) rootView.findViewById(R.id.secondary_code_textView); TextView CodeTextView = (TextView) rootView.findViewById(R.id.code_textView); loadSettings(); switch (mItem) { case 0: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_vision_loss); break; case 1: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_double_vision); break; case 2: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_weakness); break; case 3: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_walking); break; case 4: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_vertigo); break; case 5: primaryCodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault_Medium); //primaryCodeTextView.textAppearance secondaryCodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault); CodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault); primaryCodeTextView.setText(R.string.code_attack1); secondaryCodeTextView.setText(R.string.code_attack2); CodeTextView.setText(R.string.code_attack3); primaryCodeTextView.setTextColor(Color.MAGENTA); break; default: break; } // set up buttons return rootView; }
From source file:com.github.andrewlord1990.snackbarbuildersample.SampleActivity.java
private void setupData() { samples = new LinkedHashMap<>(); samples.put(MESSAGE, new OnClickListener() { @Override// ww w. jav a 2s . co 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.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 a2 s .c o m 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.shaastra.helper.SuperAwesomeCardFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w ww .ja va2s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); //v.setBackgroundResource(R.drawable.background_card); v.setText("CARD " + (position + 1)); if (position == 0) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eintroduction); return v1; } else if (position == 1) { String Venue = new String(); Venue = evenue; final String SAC = elatlong; //String start=String.valueOf(l.getLatitude())+String.valueOf(l.getLongitude()); /* View v1=inflater.inflate(R.layout.map, container,false); v1.setLayoutParams(params); WebView wv=(WebView)v1.findViewById(R.id.wv1); wv.setWebChromeClient(new WebChromeClient()); //wv.loadUrl("https://maps.google.com/maps?saddr=13,80&daddr=13,80.02"); //wv.loadUrl("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false"); wv.loadUrl("http://maps.google.com/maps?f=d&daddr=51.448,-0.972"); wv.getSettings().getBuiltInZoomControls(); */ View v1 = inflater.inflate(R.layout.map, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView location = (TextView) v1.findViewById(R.id.locationText); Button mapButton = (Button) v1.findViewById(R.id.mapButton); if (evenue.equalsIgnoreCase("NONE")) { mapButton.setAlpha(0); } else { mapButton.setAlpha(1); } location.setText(Venue); mapButton.setOnTouchListener(new View.OnTouchListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setAlpha((float) 0.4); v.animate().setInterpolator(new DecelerateInterpolator()).scaleX(0.9f).scaleY(0.9f); } if (event.getAction() == MotionEvent.ACTION_UP) { v.setAlpha((float) 0.75); v.animate().setInterpolator(new OvershootInterpolator()).scaleX(1f).scaleY(1f); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&daddr=" + SAC)); intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); startActivity(intent); } return false; } }); return v1; } else if (position == 2) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eformat); return v1; } else if (position == 3) { View v1 = inflater.inflate(R.layout.prize, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.prizeText); t1.setText(eprize); return v1; } else if (position == 4) { v.setBackgroundColor(Color.GREEN); } else if (position == 5) { v.setBackgroundColor(Color.MAGENTA); } else if (position == 6) { v.setBackgroundColor(Color.MAGENTA); } fl.addView(v); return fl; }
From source file:com.zandbee.floatingtitlebar.FloatingTitleBarActivity.java
private int getThemePrimaryColor() { final TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); int[] attribute = new int[] { R.attr.colorPrimary }; final TypedArray array = obtainStyledAttributes(typedValue.resourceId, attribute); return array.getColor(0, Color.MAGENTA); }
From source file:com.example.vendrisample.HelloEffects.java
License:asdf
private void initEffect() { EffectFactory effectFactory = mEffectContext.getFactory(); if (mEffect != null) { mEffect.release();/*from w w w .j av a2s . c o m*/ } /** * Initialize the correct effect based on the selected menu/action item */ switch (mCurrentEffect) { case R.id.none: break; case R.id.autofix: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_AUTOFIX); mEffect.setParameter("scale", 0.5f); break; case R.id.bw: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BLACKWHITE); mEffect.setParameter("black", .1f); mEffect.setParameter("white", .7f); break; case R.id.brightness: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BRIGHTNESS); mEffect.setParameter("brightness", 2.0f); break; case R.id.contrast: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CONTRAST); mEffect.setParameter("contrast", 1.4f); break; case R.id.crossprocess: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CROSSPROCESS); break; case R.id.documentary: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DOCUMENTARY); break; case R.id.duotone: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DUOTONE); mEffect.setParameter("first_color", Color.YELLOW); mEffect.setParameter("second_color", Color.DKGRAY); break; case R.id.filllight: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FILLLIGHT); mEffect.setParameter("strength", .8f); break; case R.id.fisheye: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FISHEYE); mEffect.setParameter("scale", .5f); break; case R.id.flipvert: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP); mEffect.setParameter("vertical", true); break; case R.id.fliphor: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP); mEffect.setParameter("horizontal", true); break; case R.id.grain: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAIN); mEffect.setParameter("strength", 1.0f); break; case R.id.grayscale: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAYSCALE); break; case R.id.lomoish: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_LOMOISH); break; case R.id.negative: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_NEGATIVE); break; case R.id.posterize: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_POSTERIZE); break; case R.id.rotate: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_ROTATE); mEffect.setParameter("angle", 180); break; case R.id.saturate: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SATURATE); mEffect.setParameter("scale", .5f); break; case R.id.sepia: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SEPIA); break; case R.id.sharpen: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SHARPEN); break; case R.id.temperature: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TEMPERATURE); mEffect.setParameter("scale", .9f); break; case R.id.tint: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TINT); mEffect.setParameter("tint", Color.MAGENTA); break; case R.id.vignette: mEffect = effectFactory.createEffect(EffectFactory.EFFECT_VIGNETTE); mEffect.setParameter("scale", .5f); break; default: break; } }