List of usage examples for android.graphics.drawable ShapeDrawable ShapeDrawable
public ShapeDrawable(Shape s)
From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;//from w w w .j a v a 2s.c o m } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(EventDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/*from w ww. j av a2 s .c o m*/ } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/*from www. j av a2 s . co m*/ } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater .inflate(com.saarang.samples.apps.iosched.R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null || !isAdded()) { return;//from ww w . jav a2 s . co m } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getActivity()); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { getActivity().finish(); // TODO: better encapsulation Intent intent = new Intent(getActivity(), BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;//from w w w . j a va 2s. c o m } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(CurrentSessionActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Generates rainbow gradient and sets it as #mSeekBarHighlight progress drawable. *//*www . j av a 2s . c o m*/ private void drawRainbow() { float gradientWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 256, getResources().getDisplayMetrics()); int[] colors = { 0xFFFFFFFF, 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFF888888, 0xFF000000 }; LinearGradient rainbowGradient = new LinearGradient(0f, 0f, gradientWidth, 0f, colors, null, Shader.TileMode.CLAMP); float r = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); ShapeDrawable shape = new ShapeDrawable( new RoundRectShape(new float[] { r, r, r, r, r, r, r, r }, null, null)); shape.getPaint().setShader(rainbowGradient); mSeekBarHighlight.setProgressDrawable(shape); // Generate bitmap with the same rainbow gradient and cache it for later use to retrieve color at given position. Bitmap bitmap = Bitmap.createBitmap((int) gradientWidth, 1, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); paint.setShader(rainbowGradient); canvas.drawRect(0, 0, gradientWidth, 1, paint); mRainbow = bitmap; // Set max value to gradient's width and restore relative position. mSeekBarHighlight.setMax((int) (gradientWidth - 1)); mSeekBarHighlight.setProgress((int) ((gradientWidth - 1) * mHighlightPosition)); }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeControls() { this.removeControls(); Theme theme = getCurrentTheme();// www.j a v a2 s. c o m int bs = 38; if (this.isRotationLocked) rotationButton = this.makeImageButton(9000, R.drawable.rotationlocked2x, ps(42), ps(42)); else rotationButton = this.makeImageButton(9000, R.drawable.rotation2x, ps(42), ps(42)); listButton = this.makeImageButton(9001, R.drawable.list2x, getPS(bs), getPS(bs)); fontButton = this.makeImageButton(9002, R.drawable.font2x, getPS(bs), getPS(bs)); searchButton = this.makeImageButton(9003, R.drawable.search2x, getPS(bs), getPS(bs)); rotationButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(rotationButton)); listButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(listButton)); fontButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(fontButton)); searchButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(searchButton)); titleLabel = this.makeLabel(3000, title, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35)); // setTextSize in android uses sp (Scaled Pixel) as default, they say that sp guarantees the device dependent size, but as usual in android it can't be 100% sure. authorLabel = this.makeLabel(3000, author, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35)); pageIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13, Color.argb(240, 94, 61, 35)); secondaryIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13, Color.argb(240, 94, 61, 35)); // rv.customView.addView(rotationButton); // rv.customView.addView(listButton); // rv.customView.addView(fontButton); // rv.customView.addView(searchButton); rv.customView.addView(titleLabel); rv.customView.addView(authorLabel); ePubView.addView(rotationButton); ePubView.addView(listButton); ePubView.addView(fontButton); if (!rv.isScrollMode()) ePubView.addView(searchButton); // ePubView.addView(titleLabel); // ePubView.addView(authorLabel); ePubView.addView(pageIndexLabel); ePubView.addView(secondaryIndexLabel); seekBar = new SkySeekBar(this); seekBar.setMax(999); seekBar.setId(999); RectShape rectShape = new RectShape(); ShapeDrawable thumb = new ShapeDrawable(rectShape); thumb.getPaint().setColor(theme.seekThumbColor); thumb.setIntrinsicHeight(getPS(28)); thumb.setIntrinsicWidth(getPS(28)); seekBar.setThumb(thumb); seekBar.setBackgroundColor(Color.TRANSPARENT); seekBar.setOnSeekBarChangeListener(new SeekBarDelegate()); seekBar.setProgressDrawable(new DottedDrawable(theme.seekBarColor)); seekBar.setThumbOffset(-3); seekBar.setMinimumHeight(24); int filterColor = theme.controlColor; rotationButton.setColorFilter(filterColor); listButton.setColorFilter(filterColor); fontButton.setColorFilter(filterColor); searchButton.setColorFilter(filterColor); authorLabel.setTextColor(filterColor); titleLabel.setTextColor(filterColor); pageIndexLabel.setTextColor(filterColor); secondaryIndexLabel.setTextColor(filterColor); ePubView.addView(seekBar); }