List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:com.example.grayapps.contextaware.BarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.bargraph, container, false); // Init first chart mUpdateOne = true;/*from w w w.j a v a 2 s . c om*/ mChartOne = (BarChartView) layout.findViewById(R.id.barchart1); CardView barCard = (CardView) layout.findViewById(R.id.cardContent); if (mStressColor == "#db0c42")//stressed { barCard.setCardBackgroundColor(Color.parseColor(getResources().getString(R.color.colorStressBar))); } else if (mStressColor == "#2c93d0")//relaxed { barCard.setCardBackgroundColor(Color.parseColor(getResources().getString(R.color.colorNoiseBar))); } else if (mStressColor == "#3ac298")//relaxed { barCard.setCardBackgroundColor(Color.parseColor(getResources().getString(R.color.colorAnxiousBar))); } else { barCard.setCardBackgroundColor(Color.parseColor(getResources().getString(R.color.colorNeutralBar))); } showChart(0, mChartOne); //showChart(1, mChartTwo, mPlayTwo); //showChart(2, mChartThree, mPlayThree); return layout; }
From source file:illab.nabal.proxy.AuthWebDialog.java
/** * Sets up dialog title bar.//from w w w . ja v a 2 s . co m */ private void setUpTitle() { mTitle = new TextView(getContext()); mTitle.setBackgroundColor(Color.parseColor(mNetworkWebViewClient.getWebViewTitleColor())); mTitle.setText(mSystemProperties.getLocalizedOAuthDialogTitle()); mTitle.setTextColor(Color.WHITE); mTitle.setTypeface(Typeface.DEFAULT_BOLD); mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN); mLayout.addView(mTitle); }
From source file:org.sirimangalo.meditationplus.AdapterMed.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/*from w w w. j a va 2 s . c o m*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_med, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); TextView walk = (TextView) rowView.findViewById(R.id.one_walking); TextView sit = (TextView) rowView.findViewById(R.id.one_sitting); ImageView status = (ImageView) rowView.findViewById(R.id.one_status); TextView name = (TextView) rowView.findViewById(R.id.one_med); ImageView flag = (ImageView) rowView.findViewById(R.id.one_flag); View anuView = rowView.findViewById(R.id.anumodana_shell); TextView anuText = (TextView) rowView.findViewById(R.id.anumodana); try { String wo = p.getString("walking"); String so = p.getString("sitting"); int wi = Integer.parseInt(wo); int si = Integer.parseInt(so); int ti = Integer.parseInt(p.getString("start")); int ei = Integer.parseInt(p.getString("end")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; boolean finished = false; String ws = "0"; String ss = "0"; if (ei > now) { float secs = now - ti; if (secs > wi * 60 || wi == 0) { //walking done float ssecs = (int) (secs - (wi * 60)); if (ssecs < si * 60) // still sitting ss = Integer.toString((int) Math.floor(si - ssecs / 60)); status.setImageResource(R.drawable.sitting_icon); } else { // still walking ws = Integer.toString((int) Math.floor(wi - secs / 60)); ss = so; status.setImageResource(R.drawable.walking_icon); } ws += "/" + wo; ss += "/" + so; } else { ws = wo; ss = so; double age = 1 - (now - ei) / MAX_AGE; String ageColor = Integer.toHexString((int) (255 * age)); if (ageColor.length() == 1) ageColor = "0" + ageColor; int alpha = Color.parseColor("#" + ageColor + "000000"); walk.setTextColor(alpha); sit.setTextColor(alpha); name.setTextColor(alpha); status.setAlpha((float) age); flag.setAlpha((float) age); } walk.setText(ws); sit.setText(ss); if (p.has("country")) { int id = context.getResources().getIdentifier("flag_" + p.getString("country").toLowerCase(), "drawable", context.getPackageName()); flag.setImageResource(id); flag.setVisibility(View.VISIBLE); } final String username = p.getString("username"); final String edit = p.getString("can_edit"); name.setText(username); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.showProfile(username); } }); String type = p.getString("type"); if ("love".equals(type)) status.setImageResource(R.drawable.love_icon); String anu = p.getString("anumodana"); if (!anu.equals("0")) anuText.setText(anu); if (p.getString("anu_me").equals("1")) { anuText.setTextColor(0xFF00BB00); anuText.setTypeface(null, Typeface.BOLD); } final String sid = p.getString("sid"); anuView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "anu clicked"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String loggedUsername = prefs.getString("username", ""); String loginToken = prefs.getString("login_token", ""); ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("form_id", "anumed_" + sid)); nvp.add(new BasicNameValuePair("login_token", loginToken)); nvp.add(new BasicNameValuePair("submit", "Refresh")); nvp.add(new BasicNameValuePair("username", loggedUsername)); nvp.add(new BasicNameValuePair("source", "android")); PostTaskRunner postTask = new PostTaskRunner(postHandler, context); postTask.doPostTask(nvp); } }); } catch (Exception e) { e.printStackTrace(); } return rowView; }
From source file:com.example.android.enghack_receipt_scanner.OcrCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*w w w .ja v a 2s.c om*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ocr_capture); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ActionBar topBar = getSupportActionBar(); if (topBar != null) { topBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#6A8347"))); } mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, true); boolean useFlash = getIntent().getBooleanExtra(UseFlash, false); // Check for the ocr_capture permission before accessing the ocr_capture. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(autoFocus, useFlash); } else { requestCameraPermission(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show(); }
From source file:com.example.imen.facebookfalseprofile.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); facebookSDKInitialize();/*from ww w . j a va 2 s . c o m*/ setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#1A237E"))); Firebase.setAndroidContext(this); if (getString(R.string.subscription_key).startsWith("Please")) { new AlertDialog.Builder(this).setTitle(getString(R.string.add_subscription_key_tip_title)) .setMessage(getString(R.string.add_subscription_key_tip)).setCancelable(false).show(); } LoginButton loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setReadPermissions(Arrays.asList("public_profile", "email", "user_photos", "user_friends")); // Toast.makeText(getApplicationContext(),AccessToken.getCurrentAccessToken().getUserId(), Toast.LENGTH_SHORT).show(); getLoginDetails(loginButton); /* ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPageAndroid); AndroidImageAdapter adapterView = new AndroidImageAdapter(this); dotsCount = adapterView.getCount(); dots = new TextView[dotsCount]; mViewPager.setAdapter(adapterView);*/ initViews(); setViewPagerItemsWithAdapter(); setUiPageViewController(); if (AccessToken.getCurrentAccessToken() != null) { startActivity(new Intent(MainActivity.this, SelectImageActivity.class)); finish(); } }
From source file:com.esprit.android.inart.FillableLoaderPage.java
private void setupFillableLoader(int pageNum) { if (pageNum == 3) { int viewSize = getResources().getDimensionPixelSize(R.dimen.fourthSampleViewSize); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(viewSize, viewSize); params.gravity = Gravity.CENTER; FillableLoaderBuilder loaderBuilder = new FillableLoaderBuilder(); fillableLoader = loaderBuilder.parentView((FrameLayout) rootView).svgPath(Paths.pinceau) .layoutParams(params).originalDimensions(1610, 1350).strokeColor(Color.parseColor("#FFFFFF")) .fillColor(Color.parseColor("#FFFFFF")).strokeDrawingDuration(1500) .clippingTransform(new WavesClippingTransform()).fillDuration(2000) .build();/*www .jav a 2 s . co m*/ } else { try { fillableLoader.setSvgPath(pageNum == 0 ? Paths.RONALDO : pageNum == 1 ? Paths.INDOMINUS_REX : pageNum == 2 ? Paths.Photo : pageNum == 4 ? Paths.GITHUB : pageNum == 5 ? Paths.in : Paths.GITHUB); } catch (Exception e) { System.out.println(e.toString()); } } fillableLoader.setOnStateChangeListener(this); }
From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java
public ArrayList<ImageView> DrawSVG(Context context, ImageView orgnlImageView, RelativeLayout rel_anm_lo) { paint.setColor(Color.WHITE);//from w ww. j a va 2 s. c om paint.setStyle(Paint.Style.FILL); LoadSVG.SVGData data = AnimActivity.svg_data; ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); imgViews.add(orgnlImageView); if (data.symbl != null) { ArrayList<String> sprt_ordr = data.svg.ordr; int sym_mbr = 0; Bitmap bitmap; Canvas canvas; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); data.svg.initScl = new float[sprt_nmbr]; float[] initScl = data.svg.initScl; for (int sprt_mbr = 1; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); // e.g., id="g2_0" if (Integer.parseInt(sprt_id.substring(sprt_id.indexOf('_') + 1)) > 0) { // The symbol is already drawn; replicate the view String init_sprt = sprt_id.substring(0, sprt_id.indexOf('_') + 1) + '0'; String svg_ordr = data.svg.svg_ordr; String cnt_str = svg_ordr.substring(0, svg_ordr.indexOf(init_sprt)); ImageView init_vw = imgViews.get(StringUtils.countMatches(cnt_str, ",")); Bitmap initBmp = ((BitmapDrawable) init_vw.getDrawable()).getBitmap(); bitmap = Bitmap.createBitmap(initBmp.getWidth(), initBmp.getHeight(), initBmp.getConfig()); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); } else { // The symbol needs to be drawn; a new view is used bitmap = getCreatBmp(rel_anm_lo); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); // - Set the init values xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); // - Draw the bitmap LoadSVG.symbol crt_sym = data.symbl.get(sym_mbr); ArrayList<LoadSVG.path> pths = crt_sym.pths; int pth_nmbr = pths.size(); // Loop through the paths for (int pth_mbr = 0; pth_mbr < pth_nmbr; pth_mbr += 1) { LoadSVG.path crt_pth = pths.get(pth_mbr); final Path path = new Path(); final Paint paint = new Paint(); /* Debug if (pth_mbr + 1 == pth_nmbr) { String log_str = "Paths: pth_mbr = " + String.valueOf(pth_mbr) + "; color = " + crt_pth.clr; Log.d("DrawSVG", log_str); } */ paint.setColor(Color.parseColor(crt_pth.clr)); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); ld_pth_pnts(crt_pth.pth, path); path.close(); path.setFillType(Path.FillType.EVEN_ODD); canvas.drawPath(path, paint); } canvas.restore(); sym_mbr += 1; } ImageView iv = new ImageView(context); iv.setImageBitmap(bitmap); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); iv.draw(canvas); iv.setLayoutParams(rlp); iv.setBackgroundColor(Color.TRANSPARENT); imgViews.add(iv); } // sprites } // if symbol return imgViews; }
From source file:com.carinsurance.pagerslidingtabstrip.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);// w ww . j av a 2s.c om setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); selectTextColor = Color.parseColor("#00a2d0"); pageListener = new PageListener(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(0, tabTextSize); tabTextColor = a.getColor(1, tabTextColor); // pstsSelectTabsColor a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); selectTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsSelectTabsColor, selectTextColor); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.funny.developers.musicstylelist.view.SlidingTabLayout.java
/** * Sets the colors to be used for indicating the selected tab. These colors are treated as a * circular array. Providing one color will mean that all tabs are indicated with the same color. *//*www. ja va 2s .co m*/ public void setSelectedIndicatorColors(String colors) { mTabStrip.setSelectedIndicatorColors(Color.parseColor(colors)); }