List of usage examples for android.graphics.drawable ShapeDrawable getPaint
public Paint getPaint()
From source file:com.google.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/*from www.j a v a 2 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.ncode.android.apps.schedo.ui.EventDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/* w w w . ja va 2 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(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.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
private void updateSeekbartheme(int color) { /*/*w ww. j a v a 2s.com*/ * ShapeDrawable pgDrawable = new ShapeDrawable(new RectShape()); * * // Sets the progressBar color pgDrawable.getPaint().setColor(color); * * // Adds the drawable to your progressBar ClipDrawable progress = new * ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); * mProgress.setProgressDrawable(progress); * mProgress.setBackgroundDrawable * (getResources().getDrawable(R.drawable.progress_shape)); */ ShapeDrawable shape = new ShapeDrawable(); shape.getPaint().setStyle(Style.FILL); shape.getPaint().setColor(getResources().getColor(R.color.transparent_black)); ShapeDrawable shapeD = new ShapeDrawable(); shapeD.getPaint().setStyle(Style.FILL); shapeD.getPaint().setColor(getResources().getColor(R.color.white)); ClipDrawable clipDrawable = new ClipDrawable(shapeD, Gravity.LEFT, ClipDrawable.HORIZONTAL); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { shape, clipDrawable }); mProgress.setProgressDrawable(layerDrawable); }
From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java
private void initGridV(ShapeDrawable drawable, Path path, int color, int width, int height) { path.rewind();/*from w w w .j a va 2s. c o m*/ float cellWidth = width / NUM_COLUMNS; for (int i = 0; i < NUM_COLUMNS; ++i) { path.moveTo(i * cellWidth, 0); path.lineTo(i * cellWidth, height); } float offset = NUM_ROWS * 5; drawable.setShape(new PathShape(path, width, height)); drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setColor(color); drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (height - offset) / offset }, 0)); drawable.setBounds(0, 0, width, height); }
From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java
private void initGridH(ShapeDrawable drawable, Path path, int color, int width, int height) { path.rewind();/* ww w. j a va2s. co m*/ float cellHeight = height / NUM_ROWS; for (int i = 0; i < NUM_ROWS; ++i) { path.moveTo(0, i * cellHeight); path.lineTo(width, i * cellHeight); } float offset = NUM_COLUMNS * 5; drawable.setShape(new PathShape(path, width, height)); drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setColor(color); drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (width - offset) / offset }, 0)); drawable.setBounds(0, 0, width, height); }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.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(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:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null || !isAdded()) { return;// 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(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.saarang.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;// www . j a v a 2 s. com } 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:io.puzzlebox.orbit.ui.OrbitFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_orbit, container, false); // requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // setContentView(R.layout.main); // getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); buttonConnectOrbit = (Button) v.findViewById(R.id.buttonConnectOrbit); buttonConnectOrbit.setOnClickListener(new View.OnClickListener() { @Override/*from w ww.j ava 2 s .com*/ public void onClick(View v) { setOrbitActivate(); } }); Button buttonTestFlight = (Button) v.findViewById(R.id.buttonTestFlight); buttonTestFlight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { demoMode(v); } }); progressBarAttention = (ProgressBar) v.findViewById(R.id.progressBarAttention); final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; ShapeDrawable progressBarAttentionDrawable = new ShapeDrawable( new RoundRectShape(roundedCorners, null, null)); String progressBarAttentionColor = "#FF0000"; progressBarAttentionDrawable.getPaint().setColor(Color.parseColor(progressBarAttentionColor)); ClipDrawable progressAttention = new ClipDrawable(progressBarAttentionDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarAttention.setProgressDrawable(progressAttention); progressBarAttention .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); progressBarMeditation = (ProgressBar) v.findViewById(R.id.progressBarMeditation); ShapeDrawable progressBarMeditationDrawable = new ShapeDrawable( new RoundRectShape(roundedCorners, null, null)); String progressBarMeditationColor = "#0000FF"; progressBarMeditationDrawable.getPaint().setColor(Color.parseColor(progressBarMeditationColor)); ClipDrawable progressMeditation = new ClipDrawable(progressBarMeditationDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarMeditation.setProgressDrawable(progressMeditation); progressBarMeditation .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); progressBarSignal = (ProgressBar) v.findViewById(R.id.progressBarSignal); ShapeDrawable progressBarSignalDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String progressBarSignalColor = "#00FF00"; progressBarSignalDrawable.getPaint().setColor(Color.parseColor(progressBarSignalColor)); ClipDrawable progressSignal = new ClipDrawable(progressBarSignalDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarSignal.setProgressDrawable(progressSignal); progressBarSignal.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); // progressBarSignal.setProgress(tgSignal); progressBarPower = (ProgressBar) v.findViewById(R.id.progressBarPower); ShapeDrawable progressBarPowerDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String progressBarPowerColor = "#FFFF00"; progressBarPowerDrawable.getPaint().setColor(Color.parseColor(progressBarPowerColor)); ClipDrawable progressPower = new ClipDrawable(progressBarPowerDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarPower.setProgressDrawable(progressPower); progressBarPower.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); seekBarAttention = (SeekBar) v.findViewById(R.id.seekBarAttention); seekBarAttention.setOnSeekBarChangeListener(this); seekBarMeditation = (SeekBar) v.findViewById(R.id.seekBarMeditation); seekBarMeditation.setOnSeekBarChangeListener(this); imageViewStatus = (ImageView) v.findViewById(R.id.imageViewStatus); textViewLabelScores = (TextView) v.findViewById(R.id.textViewLabelScores); textViewLabelScore = (TextView) v.findViewById(R.id.textViewLabelScore); textViewLabelLastScore = (TextView) v.findViewById(R.id.textViewLabelLastScore); textViewLabelHighScore = (TextView) v.findViewById(R.id.textViewLabelHighScore); viewSpaceScore = (View) v.findViewById(R.id.viewSpaceScore); viewSpaceScoreLast = (View) v.findViewById(R.id.viewSpaceScoreLast); viewSpaceScoreHigh = (View) v.findViewById(R.id.viewSpaceScoreHigh); textViewScore = (TextView) v.findViewById(R.id.textViewScore); textViewLastScore = (TextView) v.findViewById(R.id.textViewLastScore); textViewHighScore = (TextView) v.findViewById(R.id.textViewHighScore); // Hide the "Scores" label by default textViewLabelScores.setVisibility(View.GONE); viewSpaceScore.setVisibility(View.GONE); /** * AudioHandler */ if (!OrbitSingleton.getInstance().audioHandler.isAlive()) { /** * Prepare audio stream */ maximizeAudioVolume(); // Automatically set media volume to maximum /** Set the hardware buttons to control the audio output */ getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); /** Preload the flight control WAV file into memory */ OrbitSingleton.getInstance().soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); OrbitSingleton.getInstance().soundPool .setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { OrbitSingleton.getInstance().loaded = true; } }); OrbitSingleton.getInstance().soundID = OrbitSingleton.getInstance().soundPool .load(getActivity().getApplicationContext(), OrbitSingleton.getInstance().audioFile, 1); OrbitSingleton.getInstance().audioHandler.start(); } if (OrbitSingleton.getInstance().flightActive) buttonTestFlight.setText(getResources().getString(R.string.button_stop_test)); /** * Update settings according to default UI */ updateScreenLayout(); updatePowerThresholds(); // updatePower(); return v; }
From source file:org.de.jmg.learn.SettingsActivity.java
public void init(boolean blnRestart) throws Exception { if (_Intent == null || _main == null || SettingsView == null || _blnInitialized) { return;//from www . j a v a 2 s. c o m } try { //lib.ShowToast(_main, "Settings Start"); RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutSettings); // id fetch from xml ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class int pxPadding = lib.dpToPx(10); rectShapeDrawable.setPadding(pxPadding, pxPadding, pxPadding, pxPadding * ((lib.NookSimpleTouch()) ? 2 : 1)); Paint paint = rectShapeDrawable.getPaint(); paint.setColor(Color.BLACK); paint.setStyle(Style.STROKE); paint.setStrokeWidth(5); // you can change the value of 5 lib.setBg(layout, rectShapeDrawable); mainView = _main.findViewById(Window.ID_ANDROID_CONTENT); //Thread.setDefaultUncaughtExceptionHandler(ErrorHandler); prefs = _main.getPreferences(Context.MODE_PRIVATE); TextView txtSettings = (TextView) findViewById(R.id.txtSettings); SpannableString Settings = new SpannableString(txtSettings.getText()); Settings.setSpan(new UnderlineSpan(), 0, Settings.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); txtSettings.setText(Settings); initCheckBoxes(); initSpinners(blnRestart); initButtons(); initHelp(); edDataDir = (EditText) findViewById(R.id.edDataDir); edDataDir.setSingleLine(true); edDataDir.setText(_main.JMGDataDirectory); edDataDir.setImeOptions(EditorInfo.IME_ACTION_DONE); edDataDir.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { String strDataDir = edDataDir.getText().toString(); File fileSelected = new File(strDataDir); if (fileSelected.isDirectory() && fileSelected.exists()) { _main.setJMGDataDirectory(fileSelected.getPath()); edDataDir.setText(_main.JMGDataDirectory); Editor editor = prefs.edit(); editor.putString("JMGDataDirectory", fileSelected.getPath()); editor.commit(); } } return true; } }); edDataDir.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ShowDataDirDialog(); return true; } }); if (!(lib.NookSimpleTouch()) && !_main.isSmallDevice) { SettingsView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Ensure you call it only once : lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this); // Here you can get the size :) resize(0); //lib.ShowToast(_main, "Resize End"); } }); } else { //resize(1.8f); mScale = 1.0f; } _blnInitialized = true; } catch (Exception ex) { lib.ShowException(_main, ex); } }