Java Code Examples for android.graphics.Color
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project 2Degrees-Toolbox, under directory /android-color-picker/src/yuku/ambilwarna/.
Source file: AmbilWarnaDialog.java

private int hitungWarna(){ tmp01[0]=hue; tmp01[1]=sat; tmp01[2]=val; return Color.HSVToColor(tmp01); }
Example 2
From project 4308Cirrus, under directory /tendril-cirrus/src/main/java/edu/colorado/cs/cirrus/cirrus/.
Source file: BarGraph.java

public static GraphicalView getBarGraphView(Context context,float[] ySeries,String title,String xLabel,String yLabel){ CategorySeries series=new CategorySeries("BarGraph"); int max=0; int min=(int)ySeries[0]; for (int i=0; i < ySeries.length; i++) { series.add((i + 1) + "",ySeries[i]); if (ySeries[i] > max) max=(int)ySeries[i]; if (ySeries[i] < min) min=(int)ySeries[i]; } XYMultipleSeriesDataset dataset=new XYMultipleSeriesDataset(); dataset.addSeries(series.toXYSeries()); XYMultipleSeriesRenderer mRenderer=new XYMultipleSeriesRenderer(); XYSeriesRenderer renderer=new XYSeriesRenderer(); renderer.setDisplayChartValues(false); renderer.setChartValuesSpacing((float)0.5); renderer.setColor(Color.parseColor("#8DC63F")); renderer.setChartValuesTextSize(16); mRenderer.setMarginsColor(Color.WHITE); mRenderer.setChartTitle(title); mRenderer.setXTitle(xLabel); mRenderer.setYTitle(yLabel); mRenderer.setChartTitleTextSize(22); mRenderer.setAxisTitleTextSize(18); mRenderer.setLabelsTextSize(18); mRenderer.setShowLegend(false); mRenderer.setPanEnabled(false,false); mRenderer.setBackgroundColor(Color.WHITE); mRenderer.setApplyBackgroundColor(true); mRenderer.setLabelsColor(Color.BLACK); mRenderer.setShowLabels(true); mRenderer.setYAxisMin(.8 * min); mRenderer.setYAxisMax(max + (max * .1)); mRenderer.setXLabels(12); mRenderer.setMargins(new int[]{10,30,10,10}); mRenderer.setBarSpacing(0.1); mRenderer.addSeriesRenderer(renderer); GraphicalView view=ChartFactory.getBarChartView(context,dataset,mRenderer,Type.DEFAULT); return view; }
Example 3
From project abalone-android, under directory /src/com/bytopia/abalone/.
Source file: BoardRenderer.java

/** * Constructor that initializes brushes and images from resources. * @param view parent view to render the board onto */ public BoardRenderer(View view){ this.view=view; Resources r=view.getResources(); blackBallPicture=r.getDrawable(R.drawable.black_ball); whiteBallPicture=r.getDrawable(R.drawable.white_ball); emptyBallPicture=r.getDrawable(R.drawable.hole); defaultPaint=new Paint(Paint.ANTI_ALIAS_FLAG); defaultPaint.setColor(r.getColor(R.color.defaultColor)); blackP=new Paint(Paint.ANTI_ALIAS_FLAG); blackP.setColor(Color.BLACK); whiteP=new Paint(Paint.ANTI_ALIAS_FLAG); whiteP.setColor(Color.WHITE); emptyP=new Paint(Paint.ANTI_ALIAS_FLAG); emptyP.setColor(Color.GRAY); highlightedP=new Paint(Paint.ANTI_ALIAS_FLAG); highlightedP.setColor(Color.RED); highlightedP.setAlpha(100); selectedP=new Paint(Paint.ANTI_ALIAS_FLAG); selectedP.setColor(Color.GREEN); selectedP.setAlpha(100); boardP=new Paint(Paint.ANTI_ALIAS_FLAG); boardP.setColor(r.getColor(R.color.board)); dst=new Rect(); }
Example 4
From project AChartEngine, under directory /achartengine/src/org/achartengine/chart/.
Source file: BarChart.java

private int getGradientPartialColor(int minColor,int maxColor,float fraction){ int alpha=Math.round(fraction * Color.alpha(minColor) + (1 - fraction) * Color.alpha(maxColor)); int r=Math.round(fraction * Color.red(minColor) + (1 - fraction) * Color.red(maxColor)); int g=Math.round(fraction * Color.green(minColor) + (1 - fraction) * Color.green(maxColor)); int b=Math.round(fraction * Color.blue(minColor) + (1 - fraction) * Color.blue((maxColor))); return Color.argb(alpha,r,g,b); }
Example 5
From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/view/.
Source file: NoisePlot.java

@Override protected void onDraw(Canvas canvas){ Stopwatch stopwatch=new Stopwatch().start(); bottom=settingsHelper.getThreshold(sensor,MeasurementLevel.VERY_LOW); top=settingsHelper.getThreshold(sensor,MeasurementLevel.VERY_HIGH); drawBackground(canvas); if (!measurements.isEmpty()) { measurements=aggregator.smoothenSamplesToReduceCount(newArrayList(measurements),1000); Path path=new Path(); float lastY=project(measurements.get(0).getValue()); path.moveTo(0,lastY); for (int i=1; i < measurements.size(); i++) { Measurement measurement=measurements.get(i); Point place=place(measurement); path.lineTo(place.x,place.y); } Constants.logGraphPerformance("onDraw to path creation took " + stopwatch.elapsedMillis()); initializePaint(); canvas.drawPath(path,paint); Constants.logGraphPerformance("onDraw to path draw took " + stopwatch.elapsedMillis()); for ( Note note : notes) { drawNote(canvas,note); } if (settingsHelper.showGraphMetadata()) { String message="[" + measurements.size() + "] pts"; String message2="drawing took " + stopwatch.elapsedMillis(); long textSize=getResources().getDimensionPixelSize(R.dimen.debugFontSize); Paint textPaint=new Paint(); textPaint.setColor(Color.WHITE); textPaint.setAlpha(OPAQUE); textPaint.setAntiAlias(true); textPaint.setTextSize(textSize); float textWidth=Math.max(textPaint.measureText(message),textPaint.measureText(message2)); canvas.drawText(message,getWidth() - textWidth - 5,getHeight() - textSize - 5,textPaint); canvas.drawText(message2,getWidth() - textWidth - 5,getHeight() - 5,textPaint); } } }
Example 6
From project Airports, under directory /src/com/nadmm/airports/.
Source file: DownloadActivity.java

@Override public void bindView(View view,Context context,Cursor cursor){ TextView tv; tv=(TextView)view.findViewById(R.id.download_desc); tv.setText(cursor.getString(cursor.getColumnIndex(DownloadCursor.DESC))); tv=(TextView)view.findViewById(R.id.download_dates); String expired=cursor.getString(cursor.getColumnIndex(DownloadCursor.EXPIRED)); tv.setText(cursor.getString(cursor.getColumnIndex(DownloadCursor.DATES))); if (expired.equals("Y")) { tv.setText(tv.getText() + " (Expired)"); tv.setTextColor(Color.RED); } tv=(TextView)view.findViewById(R.id.download_msg); tv.setText(cursor.getString(cursor.getColumnIndex(DownloadCursor.MSG))); }
Example 7
From project alljoyn_java, under directory /samples/android/properties/PropertiesService/src/org/alljoyn/bus/samples/properties_service/.
Source file: PropertiesService.java

private void updateColor(){ String backgroundColor=mProperties.getBackGroundColor(); if (backgroundColor.equals(AllJoynProperties.COLOR_RED)) { mPrimarylayout.setBackgroundColor(Color.RED); mColorSpinner.setSelection(0); } else if (backgroundColor.equals(AllJoynProperties.COLOR_GREEN)) { mPrimarylayout.setBackgroundColor(Color.GREEN); mColorSpinner.setSelection(1); } else if (backgroundColor.equalsIgnoreCase(AllJoynProperties.COLOR_BLUE)) { mPrimarylayout.setBackgroundColor(Color.BLUE); mColorSpinner.setSelection(2); } else if (backgroundColor.equals(AllJoynProperties.COLOR_YELLOW)) { mPrimarylayout.setBackgroundColor(Color.YELLOW); mColorSpinner.setSelection(3); } }
Example 8
From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.
Source file: ObjektCompletionAdapter.java

@Override public View getView(final int position,View convertView,ViewGroup parent){ View row=convertView; Objekt objekt=getItem(position); if (row == null) { row=inflater.inflate(R.layout.dispute_list_item_objekt,parent,false); row.setTag(R.id.completion_item_name,row.findViewById(R.id.completion_item_name)); } TextView textView=(TextView)row.findViewById(R.id.completion_item_name); textView.setText(objekt.getName()); textView.setTypeface(amenTypeBold); textView.setTextColor(Color.WHITE); TextView description=(TextView)row.findViewById(R.id.default_description); description.setTypeface(amenTypeThin); description.setText(objekt.getDefaultDescription()); description.setTextColor(Color.WHITE); return row; }
Example 9
From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/mynote/.
Source file: MyNoteEditTextView.java

@Override public boolean changeBackgroundColour(){ if (ScreenSettings.isNightMode()) { setBackgroundColor(Color.BLACK); setTextColor(Color.WHITE); } else { setBackgroundColor(Color.WHITE); setTextColor(Color.BLACK); } return false; }
Example 10
From project andlytics, under directory /src/com/github/andlyticsproject/.
Source file: BaseChartListAdapter.java

private TextView createTextView(String string,boolean bold,boolean weight){ TextView view=new TextView(activity); view.setText(string); int top=(int)(2 * scale); int left=(int)(2 * scale); view.setPadding(left,top,left,top); view.setTextColor(Color.parseColor("#555555")); if (weight) { view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,.2f)); } else { view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); } view.setGravity(Gravity.RIGHT); if (bold) { view.setTypeface(view.getTypeface(),Typeface.BOLD); } return view; }
Example 11
From project Android, under directory /app/src/main/java/com/github/mobile/ui/issue/.
Source file: IssueListAdapter.java

/** * Update label views with values from given label models * @param labels * @param viewIndex */ protected void updateLabels(final List<Label> labels,final int viewIndex){ if (labels != null && !labels.isEmpty()) { int size=Math.min(labels.size(),MAX_LABELS); for (int i=0; i < size; i++) { String color=labels.get(i).getColor(); if (!TextUtils.isEmpty(color)) { View view=view(viewIndex + i); view.setBackgroundColor(Color.parseColor('#' + color)); ViewUtils.setGone(view,false); } else setGone(viewIndex + i,true); } for (int i=size; i < MAX_LABELS; i++) setGone(viewIndex + i,true); } else for (int i=0; i < MAX_LABELS; i++) setGone(viewIndex + i,true); }
Example 12
From project android-bankdroid, under directory /src/com/liato/bankdroid/adapters/.
Source file: AccountsAdapter.java

public View newAccountView(Account account,ViewGroup parent,View convertView){ if (account.isHidden() && !showHidden) { return convertView == null ? inflater.inflate(R.layout.empty,parent,false) : convertView; } if (convertView == null) { convertView=inflater.inflate(R.layout.listitem_accounts_item,parent,false); } convertView.findViewById(R.id.divider).setBackgroundColor(Color.argb(30,255,255,255)); TextView txtAccountName=((TextView)convertView.findViewById(R.id.txtListitemAccountsItemAccountname)); TextView txtBalance=((TextView)convertView.findViewById(R.id.txtListitemAccountsItemBalance)); txtAccountName.setText(account.getName()); txtBalance.setText(Helpers.formatBalance(account.getBalance(),account.getCurrency())); txtBalance.setText(Helpers.formatBalance(account.getBalance(),account.getCurrency(),prefs.getBoolean("round_balance",false) || !account.getBank().getDisplayDecimals())); if (account.isHidden()) { txtAccountName.setTextColor(Color.argb(255,191,191,191)); txtBalance.setTextColor(Color.argb(255,191,191,191)); } else { txtAccountName.setTextColor(Color.WHITE); txtBalance.setTextColor(Color.WHITE); } return convertView; }
Example 13
From project Android-Battery-Widget, under directory /src/com/em/batterywidget/.
Source file: BatteryUpdateService.java

private RemoteViews getWidgetRemoteView(){ Preferences prefSettings=new Preferences(Constants.BATTERY_SETTINGS,this); Preferences prefBatteryInfo=new Preferences(Constants.BATTERY_INFO,this); level=prefBatteryInfo.getValue(Constants.LEVEL,0); status=prefBatteryInfo.getValue(Constants.STATUS,0); String color=prefSettings.getValue(Constants.TEXT_COLOUR_SETTINGS,Constants.DEFAULT_COLOUR); boolean charge=status == BatteryManager.BATTERY_STATUS_CHARGING; RemoteViews widgetView=new RemoteViews(this.getPackageName(),R.layout.widget_view); widgetView.setImageViewResource(R.id.battery_view,R.drawable.battery); widgetView.setViewVisibility(R.id.percent100,round(100) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent90,round(90) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent80,round(80) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent70,round(70) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent60,round(60) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent50,round(50) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent40,round(40) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent30,round(30) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent20,round(20) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.percent10,round(10) ? View.VISIBLE : View.INVISIBLE); widgetView.setViewVisibility(R.id.batterytext,View.VISIBLE); widgetView.setTextColor(R.id.batterytext,Color.parseColor(color)); widgetView.setTextViewText(R.id.batterytext,String.valueOf(level) + "%"); widgetView.setViewVisibility(R.id.charge_view,charge ? View.VISIBLE : View.INVISIBLE); NotificationsManager mNotificationsManager=new NotificationsManager(this); mNotificationsManager.updateNotificationIcon(prefSettings,prefBatteryInfo); Intent intent=new Intent(this,BatteryWidgetActivity.class); PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,0); widgetView.setOnClickPendingIntent(R.id.widget_view,pendingIntent); return widgetView; }
Example 14
From project android-client, under directory /xwiki-android-client/src/org/xwiki/android/client/launcher/.
Source file: IconLaunchPad.java

public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.launchpad); GridView gridview=(GridView)findViewById(R.id.gv_launchpad); gridview.setNumColumns(3); Intent intent=new Intent(XWikiIntentFilters.ACTION_MAIN); List<ResolveInfo> list=getPackageManager().queryIntentActivities(intent,PackageManager.GET_ACTIVITIES); List<ImageButton> imgBtns=new ArrayList<ImageButton>(); int i=0; for ( ResolveInfo r : list) { int iconId=r.getIconResource(); ImageButton btn=new ImageButton(this); btn.setImageResource(iconId); btn.setBackgroundColor(Color.TRANSPARENT); imgBtns.add(btn); Log.d(this.getClass().getSimpleName(),"Btn for:" + r.activityInfo.name + "icon id is:"+ iconId); btn.setTag(r.activityInfo.name); btn.setOnClickListener(this); i++; } ImgBtnAdapter adapter=new ImgBtnAdapter(imgBtns); gridview.setAdapter(adapter); }
Example 15
From project android-client_2, under directory /src/org/mifos/androidclient/util/.
Source file: TabColorUtils.java

public static void setTabColor(TabHost tabs){ for (int i=0; i < tabs.getTabWidget().getChildCount(); i++) { tabs.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#F2D1A6")); TextView tv=(TextView)tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(Color.parseColor("#000166")); tv.setTypeface(Typeface.DEFAULT_BOLD); } tabs.getTabWidget().getChildAt(tabs.getCurrentTab()).setBackgroundColor(Color.parseColor("#FF9600")); TextView tv=(TextView)tabs.getTabWidget().getChildAt(tabs.getCurrentTab()).findViewById(android.R.id.title); tv.setTextColor(Color.parseColor("#ffffff")); tv.setTypeface(Typeface.DEFAULT_BOLD); }
Example 16
From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/fragment/.
Source file: ActionbarFragment.java

private ArrayAdapter<String> getArrayAdapter(){ return new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,mOverflowActions){ @Override public View getView( int position, View convertView, ViewGroup parent){ View view=super.getView(position,convertView,parent); ((TextView)view).setTextColor(Color.WHITE); return view; } } ; }
Example 17
From project android-flip, under directory /FlipView/Demo/src/com/aphidmobile/flip/demo/views/.
Source file: NumberTextView.java

public NumberTextView(Context context,int number){ super(context); setNumber(number); setTextColor(Color.BLACK); setBackgroundColor(Color.WHITE); setGravity(Gravity.CENTER); }
Example 18
From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/.
Source file: BrowseGifsActivity.java

@Override public void onItemSelected(AdapterView<?> parent,View view,int position,long id){ if (this.mSS.mPosition <= position) { this.mSwitcher.setInAnimation(this.mInLeftAnim); this.mSwitcher.setOutAnimation(this.mOutLeftAnim); } else { this.mSwitcher.setInAnimation(this.mInRightAnim); this.mSwitcher.setOutAnimation(this.mOutRightAnim); } if (this.mAdapter.getCount() <= 0) this.finish(); else if (position > 0 && position >= this.mAdapter.getCount()) position=this.mAdapter.getCount() - 1; GifView nv=(GifView)this.mSwitcher.getNextView(); nv.loadGif(this.mAdapter.getItemPath(position)); this.mSS.mPosition=position; nv.setBackgroundColor(Color.TRANSPARENT); this.mSwitcher.showNext(); }
Example 19
From project android-joedayz, under directory /Proyectos/AndroidFoursquare/src/com/mycompany/fsq/.
Source file: FoursquareDialog.java

private void setUpTitle(){ requestWindowFeature(Window.FEATURE_NO_TITLE); Drawable icon=getContext().getResources().getDrawable(R.drawable.foursquare_icon); mTitle=new TextView(getContext()); mTitle.setText("Foursquare"); mTitle.setTextColor(Color.WHITE); mTitle.setTypeface(Typeface.DEFAULT_BOLD); mTitle.setBackgroundColor(0xFF0cbadf); mTitle.setPadding(MARGIN + PADDING,MARGIN,MARGIN,MARGIN); mTitle.setCompoundDrawablePadding(MARGIN + PADDING); mTitle.setCompoundDrawablesWithIntrinsicBounds(icon,null,null,null); mContent.addView(mTitle); }
Example 20
From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.
Source file: CanvasRenderer.java

@Override void setupRenderer(Bitmap bitmap){ this.canvas=new Canvas(bitmap); this.symbolMatrix=new Matrix(); this.bitmapFilterPaint=new Paint(Paint.FILTER_BITMAP_FLAG); this.tileFrame=new float[]{0,0,0,Tile.TILE_SIZE,0,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,0}; this.path=new Path(); this.path.setFillType(Path.FillType.EVEN_ODD); this.stringBuilder=new StringBuilder(16); PAINT_TILE_COORDINATES.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); PAINT_TILE_COORDINATES.setTextSize(20); PAINT_TILE_COORDINATES_STROKE.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); PAINT_TILE_COORDINATES_STROKE.setStyle(Paint.Style.STROKE); PAINT_TILE_COORDINATES_STROKE.setStrokeWidth(5); PAINT_TILE_COORDINATES_STROKE.setTextSize(20); PAINT_TILE_COORDINATES_STROKE.setColor(Color.WHITE); }
Example 21
From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.
Source file: CaptureActivity.java

/** * Displays information relating to the results of a successful real-time OCR request. * @param ocrResult Object representing successful OCR results */ void handleOcrContinuousDecode(OcrResult ocrResult){ lastResult=ocrResult; viewfinderView.addResultText(new OcrResultText(ocrResult.getText(),ocrResult.getWordConfidences(),ocrResult.getMeanConfidence(),ocrResult.getBitmapDimensions(),ocrResult.getRegionBoundingBoxes(),ocrResult.getTextlineBoundingBoxes(),ocrResult.getStripBoundingBoxes(),ocrResult.getWordBoundingBoxes(),ocrResult.getCharacterBoundingBoxes())); Integer meanConfidence=ocrResult.getMeanConfidence(); if (CONTINUOUS_DISPLAY_RECOGNIZED_TEXT) { statusViewTop.setText(ocrResult.getText()); int scaledSize=Math.max(22,32 - ocrResult.getText().length() / 4); statusViewTop.setTextSize(TypedValue.COMPLEX_UNIT_SP,scaledSize); statusViewTop.setTextColor(Color.BLACK); statusViewTop.setBackgroundResource(R.color.status_top_text_background); statusViewTop.getBackground().setAlpha(meanConfidence * (255 / 100)); } if (CONTINUOUS_DISPLAY_METADATA) { long recognitionTimeRequired=ocrResult.getRecognitionTimeRequired(); statusViewBottom.setTextSize(14); statusViewBottom.setText("OCR: " + sourceLanguageReadable + " - Mean confidence: "+ meanConfidence.toString()+ " - Time required: "+ recognitionTimeRequired+ " ms"); } }
Example 22
From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.
Source file: ViewLoadBalancerActivity.java

private void loadVirutalIpData(){ int layoutIndex=0; LinearLayout layout=(LinearLayout)this.findViewById(R.id.vip_addresses); layout.removeAllViews(); ArrayList<VirtualIp> virtualIps=loadBalancer.getVirtualIps(); if (virtualIps != null) { for (int i=0; i < virtualIps.size(); i++) { TextView tv=new TextView(this.getBaseContext()); tv.setLayoutParams(((TextView)findViewById(R.id.view_port)).getLayoutParams()); tv.setTypeface(tv.getTypeface(),1); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,20); tv.setTextColor(Color.WHITE); tv.setText(virtualIps.get(i).getAddress()); tv.setGravity(((TextView)findViewById(R.id.view_port)).getGravity()); layout.addView(tv,layoutIndex++); } } loadNodeData(); }
Example 23
From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/util/.
Source file: TextColours.java

private int[] parseColourString(String[] colourStrings){ int[] colours=new int[colourStrings.length]; for (int i=0; i < colourStrings.length; i++) { String colourString='#' + colourStrings[i].substring(1); Log.d(cTag,"Parsing " + colourString); colours[i]=Color.parseColor(colourString); } return colours; }
Example 24
From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/extpack/com/facebook/android/.
Source file: FbDialog.java

@Override public void onPageFinished(WebView view,String url){ super.onPageFinished(view,url); mSpinner.dismiss(); mContent.setBackgroundColor(Color.TRANSPARENT); mWebView.setVisibility(View.VISIBLE); }
Example 25
From project android-tether, under directory /facebook/src/com/facebook/android/.
Source file: FbDialog.java

@Override public void onPageFinished(WebView view,String url){ super.onPageFinished(view,url); try { mSpinner.dismiss(); } catch ( IllegalArgumentException e) { e.printStackTrace(); } mContent.setBackgroundColor(Color.TRANSPARENT); mWebView.setVisibility(View.VISIBLE); mCrossImage.setVisibility(View.VISIBLE); }
Example 26
From project android-thaiime, under directory /common/src/com/android/ex/editstyledtext/.
Source file: EditStyledText.java

public String getPreviewHtml(){ mEST.clearComposingText(); mEST.onRefreshZeoWidthChar(); String html=mHtml.toHtml(mEST.getText(),true,getMaxImageWidthDip(),getPaddingScale()); int bgColor=mEST.getBackgroundColor(); html=String.format("<body bgcolor=\"#%02X%02X%02X\">%s</body>",Color.red(bgColor),Color.green(bgColor),Color.blue(bgColor),html); if (DBG) { Log.d(TAG,"--- getPreviewHtml:" + html + ","+ mEST.getWidth()); } return html; }
Example 27
From project android-voip-service, under directory /src/main/java/org/linphone/ui/.
Source file: ToggleImageButton.java

public ToggleImageButton(Context context,AttributeSet attrs){ super(context,attrs); stateChecked=getResources().getDrawable(attrs.getAttributeResourceValue(ns,"checked",-1)); stateUnChecked=getResources().getDrawable(attrs.getAttributeResourceValue(ns,"unchecked",-1)); setBackgroundColor(Color.TRANSPARENT); setOnClickListener(this); handleCheckChanged(); }
Example 28
From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/widget/.
Source file: FiveLabelsItemView.java

/** * Draws text labels for portrait text view <pre> ,-----. | | title (big) | | subtitle subtitleRight | | bottomtitle bottomRight `-----' </pre> * @param canvas Canvas to draw on */ protected void drawPortraitText(Canvas canvas){ final int width=mWidth; final boolean isSelected=isSelected() || isPressed(); PAINT.setTextAlign(Align.LEFT); PAINT.setColor(Color.WHITE); PAINT.setFakeBoldText(false); PAINT.setTextAlign(Align.LEFT); PAINT.setAntiAlias(true); if (title != null) { PAINT.setColor(isSelected ? Color.WHITE : Color.BLACK); PAINT.setTextSize(size18); canvas.drawText(title,posterWidth + padding,size25,PAINT); } PAINT.setColor(isSelected ? Color.WHITE : Color.rgb(80,80,80)); PAINT.setTextSize(size12); PAINT.setTextAlign(Align.RIGHT); int subtitleRightWidth=0; if (subtitleRight != null) { subtitleRightWidth=(int)PAINT.measureText(subtitleRight); canvas.drawText(subtitleRight,width - padding,size42,PAINT); } int bottomrightWidth=0; if (bottomright != null) { PAINT.setTextSize(size20); PAINT.setFakeBoldText(true); PAINT.setColor(isSelected ? Color.WHITE : Color.argb(68,0,0,0)); bottomrightWidth=(int)PAINT.measureText(subtitleRight); canvas.drawText(bottomright,width - padding,size65,PAINT); } PAINT.setColor(isSelected ? Color.WHITE : Color.rgb(80,80,80)); PAINT.setTextSize(size12); PAINT.setTextAlign(Align.LEFT); PAINT.setFakeBoldText(false); if (subtitle != null) { canvas.drawText(ellipse(subtitle,width - subtitleRightWidth - size50- (3 * padding)),size55,size42,PAINT); } if (bottomtitle != null) { canvas.drawText(ellipse(bottomtitle,width - bottomrightWidth - size50- (3 * padding)),size55,size59,PAINT); } }
Example 29
From project AndroidExamples, under directory /DrawingExample1/src/com/robertszkutak/drawingexample1/.
Source file: DrawingExample1Activity.java

@Override public void onDraw(Canvas canvas){ Bitmap ship=BitmapFactory.decodeResource(getResources(),R.drawable.ship); int x=canvas.getWidth() / 2 - ship.getWidth() / 2; int y=canvas.getHeight() / 2 - ship.getHeight() / 2; canvas.drawColor(Color.BLACK); canvas.drawBitmap(ship,x,y,null); }
Example 30
From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.
Source file: TiledMapView.java

public void init(Context context){ tileSize=context.getResources().getDimensionPixelSize(R.dimen.tiledMap_tile); gridPaint=new Paint(Paint.ANTI_ALIAS_FLAG); gridPaint.setColor(Color.WHITE); gridPaint.setStrokeWidth(1.5f); gridPaint.setAlpha(128); debugPaint=new Paint(gridPaint); debugPaint.setColor(Color.CYAN); debugPaint.setAlpha(255); SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); mustDrawGrid=prefs.getBoolean(C.PREFS_MAP_SHOW_GRID,C.DEFAULT_MAP_SHOW_GRID); mustExportGrid=prefs.getBoolean(C.PREFS_EXPORT_SHOW_GRID,C.DEFAULT_EXPORT_SHOW_GRID); emptyTileColor=prefs.getInt(C.PREFS_MAP_COLOR_EMPTY_TILE,C.DEFAULT_MAP_COLOR_EMPTY_TILE); prefs.registerOnSharedPreferenceChangeListener(this); emptyTilePaint=new Paint(Paint.ANTI_ALIAS_FLAG); emptyTilePaint.setColor(emptyTileColor); emptyTilePaint.setStyle(Paint.Style.FILL_AND_STROKE); mapRect=new RectF(0,0,0,0); currentTouchPoint=new PointInfo(); fingerDownPoint=new PointInfo(); }
Example 31
From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.
Source file: HapticAdjust.java

private void checkRowColors(){ if (counter == 1) { int target=counter + 400; TextView tv=(TextView)findViewById(target); tv.setTextColor(Color.WHITE); String str=" " + getString(R.string.haptic_vibe_desc); tv.setText(str); tv.requestLayout(); } else if (counter > 1) { int target=401; TextView tv=(TextView)findViewById(target); tv.setTextColor(Color.RED); String str=" " + getString(R.string.haptic_delay_desc); tv.setText(str); tv.requestLayout(); } else { revertChanges(); } }
Example 32
From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/ui/.
Source file: AlbumLabelMaker.java

private static TextPaint getTextPaint(int textSize,int color,boolean isBold){ TextPaint paint=new TextPaint(); paint.setTextSize(textSize); paint.setAntiAlias(true); paint.setColor(color); paint.setShadowLayer(2f,0f,0f,Color.BLACK); if (isBold) { paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); } return paint; }
Example 33
From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.
Source file: SimpleStringTexture.java

@Override protected Bitmap load(RenderView view){ StringTexture.Config config=mConfig; Paint paint=new Paint(); paint.setAntiAlias(true); paint.setColor(Shared.argb(config.a,config.r,config.g,config.b)); paint.setShadowLayer(config.shadowRadius,0f,0f,Color.BLACK); paint.setTypeface(config.bold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); paint.setTextSize(config.fontSize); paint.setUnderlineText(config.underline); paint.setStrikeThruText(config.strikeThrough); if (config.italic) { paint.setTextSkewX(-0.25f); } String string=mString; Rect bounds=new Rect(); paint.getTextBounds(string,0,string.length(),bounds); Paint.FontMetricsInt metrics=paint.getFontMetricsInt(); int height=metrics.bottom - metrics.top; int padding=1 + config.shadowRadius; Bitmap bitmap=Bitmap.createBitmap(bounds.width() + padding + padding,height + padding + padding,Bitmap.Config.ARGB_8888); Canvas canvas=new Canvas(bitmap); canvas.translate(padding,padding - metrics.ascent); canvas.drawText(string,0,0,paint); mBaselineHeight=padding + metrics.bottom; return bitmap; }
Example 34
From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.
Source file: AppListFragment.java

@Override public void configurePinnedHeader(View header,int position,int alpha){ PinnedHeaderCache cache=(PinnedHeaderCache)header.getTag(); if (cache == null) { cache=new PinnedHeaderCache(); cache.titleView=(TextView)header.findViewById(R.id.header_text); cache.textColor=cache.titleView.getTextColors(); cache.background=header.getBackground(); header.setTag(cache); } int section=getSectionForPosition(position); String title=mSections[section]; cache.titleView.setText(title); if (alpha == 255) { header.setBackgroundDrawable(cache.background); cache.titleView.setTextColor(cache.textColor); } else { int red=Color.red(mPinnedHeaderBackgroundColor); int green=Color.green(mPinnedHeaderBackgroundColor); int blue=Color.blue(mPinnedHeaderBackgroundColor); header.setBackgroundColor(Color.rgb(255 - alpha * (255 - red) / 255,255 - alpha * (255 - green) / 255,255 - alpha * (255 - blue) / 255)); int textColor=cache.textColor.getDefaultColor(); cache.titleView.setTextColor(Color.argb(alpha,Color.red(textColor),Color.green(textColor),Color.blue(textColor))); } }
Example 35
From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.
Source file: WriteTagActivity.java

void setStatus(String message,boolean success){ mStatus.setText(message); if (!success) { mStatus.setTextColor(Color.RED); } else { mStatus.setTextColor(Color.GREEN); } }
Example 36
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/accessibility/.
Source file: AccessibleKeyboardViewProxy.java

private void initInternal(InputMethodService inputMethod,SharedPreferences prefs){ final Paint paint=new Paint(); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(14.0f); paint.setAntiAlias(true); paint.setColor(Color.YELLOW); mInputMethod=inputMethod; mGestureDetector=new KeyboardFlickGestureDetector(inputMethod); }
Example 37
From project android_packages_wallpapers_basic, under directory /src/com/android/wallpaper/polarclock/.
Source file: PolarClockWallpaper.java

public static FixedClockPalette getFallback(){ if (sFallbackPalette == null) { sFallbackPalette=new FixedClockPalette(); sFallbackPalette.mId="default"; sFallbackPalette.mBackgroundColor=Color.WHITE; sFallbackPalette.mSecondColor=sFallbackPalette.mMinuteColor=sFallbackPalette.mHourColor=sFallbackPalette.mDayColor=sFallbackPalette.mMonthColor=Color.BLACK; } return sFallbackPalette; }
Example 38
From project android_wallpaper_flier, under directory /src/fi/harism/wallpaper/flier/.
Source file: FlierRenderer.java

/** * Loads three component RGB values from preferences. * @param resId Color preference key resource id. * @param preferences Preferences to load value from. * @return Three element float RGB array. */ private float[] loadColor(int resId,SharedPreferences preferences){ String key=mContext.getString(resId); int color=preferences.getInt(key,0); float[] retVal=new float[3]; retVal[0]=(float)Color.red(color) / 255; retVal[1]=(float)Color.green(color) / 255; retVal[2]=(float)Color.blue(color) / 255; return retVal; }
Example 39
From project android_wallpaper_flowers, under directory /src/fi/harism/wallpaper/flowers/.
Source file: FlowerObjects.java

/** * Called once Surface has been created. * @param context Context to read resources from. */ public void onSurfaceCreated(Context context){ mShaderSpline.setProgram(context.getString(R.string.shader_spline_vs),context.getString(R.string.shader_spline_fs)); mShaderTexture.setProgram(context.getString(R.string.shader_texture_vs),context.getString(R.string.shader_texture_fs)); GLES20.glDeleteTextures(1,mFlowerTextureId,0); GLES20.glGenTextures(1,mFlowerTextureId,0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,mFlowerTextureId[0]); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR); Bitmap bitmap=Bitmap.createBitmap(256,256,Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.BLACK); Canvas canvas=new Canvas(bitmap); Paint paint=new Paint(); paint.setStyle(Paint.Style.FILL); int borderColor=Color.rgb((int)(.8f * 255),0,0); int mainColor=Color.rgb(255,0,0); float leafDist=1.7f * 128 / 3f; float leafPositions[]=new float[10]; for (int i=0; i < 5; ++i) { double r=Math.PI * 2 * i / 5; leafPositions[i * 2 + 0]=128 + (float)(Math.sin(r) * leafDist); leafPositions[i * 2 + 1]=128 + (float)(Math.cos(r) * leafDist); } paint.setColor(borderColor); for (int i=0; i < 5; ++i) { canvas.drawCircle(leafPositions[i * 2 + 0],leafPositions[i * 2 + 1],48,paint); } paint.setColor(mainColor); for (int i=0; i < 5; ++i) { canvas.drawCircle(leafPositions[i * 2 + 0],leafPositions[i * 2 + 1],36,paint); } paint.setColor(borderColor); canvas.drawCircle(128,128,48,paint); paint.setColor(Color.BLACK); canvas.drawCircle(128,128,36,paint); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0); bitmap.recycle(); }
Example 40
From project Anki-Android, under directory /src/com/ichi2/anki/.
Source file: AnkiDroidWidget.java

private CharSequence getDeckText(){ String deckName=formatDeckName(); SpannableStringBuilder sb=new SpannableStringBuilder(); sb.append(deckName); sb.append(" "); SpannableString red=new SpannableString(Integer.toString(mFailedCards)); red.setSpan(new ForegroundColorSpan(Color.RED),0,red.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); SpannableString black=new SpannableString(Integer.toString(mDueCards)); black.setSpan(new ForegroundColorSpan(Color.BLACK),0,black.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); SpannableString blue=new SpannableString(Integer.toString(mNewCards)); blue.setSpan(new ForegroundColorSpan(Color.BLUE),0,blue.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sb.append(red); sb.append(" "); sb.append(black); sb.append(" "); sb.append(blue); return sb; }
Example 41
From project apps-for-android, under directory /Amazed/src/com/example/amazed/.
Source file: AmazedView.java

@Override public void onDraw(Canvas canvas){ mCanvas=canvas; mPaint.setColor(Color.WHITE); mCanvas.drawRect(0,0,mCanvasWidth,mCanvasHeight,mPaint); switch (mCurState) { case GAME_RUNNING: mMaze.draw(mCanvas,mPaint); mMarble.draw(mCanvas,mPaint); drawHUD(); break; case GAME_OVER: drawGameOver(); break; case GAME_COMPLETE: drawGameComplete(); break; case GAME_LANDSCAPE: drawLandscapeMode(); break; } gameTick(); }
Example 42
From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/io/.
Source file: LocalTracksHandler.java

private static ContentProviderOperation parseTrack(XmlPullParser parser) throws XmlPullParserException, IOException { final int depth=parser.getDepth(); final ContentProviderOperation.Builder builder=ContentProviderOperation.newInsert(Tracks.CONTENT_URI); String tag=null; int type; while (((type=parser.next()) != END_TAG || parser.getDepth() > depth) && type != END_DOCUMENT) { if (type == START_TAG) { tag=parser.getName(); } else if (type == END_TAG) { tag=null; } else if (type == TEXT) { final String text=parser.getText(); if (Tags.NAME.equals(tag)) { final String trackId=sanitizeId(text); builder.withValue(Tracks.TRACK_ID,trackId); builder.withValue(Tracks.TRACK_NAME,text); } else if (Tags.COLOR.equals(tag)) { final int color=Color.parseColor(text); builder.withValue(Tracks.TRACK_COLOR,color); } else if (Tags.ABSTRACT.equals(tag)) { builder.withValue(Tracks.TRACK_ABSTRACT,text); } } } return builder.build(); }
Example 43
From project Backyard-Brains-Android-App, under directory /src/com/backyardbrains/view/.
Source file: UIFactory.java

public static void setupMsLineView(BackyardAndroidActivity context){ ImageView msLineView=new ImageView(context); Bitmap bmp=BitmapFactory.decodeResource(context.getResources(),R.drawable.msline); int width=context.getWindowManager().getDefaultDisplay().getWidth() / 3; int height=2; Bitmap resizedbitmap=Bitmap.createScaledBitmap(bmp,width,height,false); msLineView.setImageBitmap(resizedbitmap); msLineView.setBackgroundColor(Color.BLACK); msLineView.setScaleType(ScaleType.CENTER); LayoutParams rl=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); rl.setMargins(0,0,0,20); rl.addRule(RelativeLayout.ABOVE,R.id.millisecondsView); rl.addRule(RelativeLayout.CENTER_HORIZONTAL); RelativeLayout parentLayout=(RelativeLayout)context.findViewById(R.id.parentLayout); parentLayout.addView(msLineView,rl); }
Example 44
From project Barcamp-Bangalore-Android-App, under directory /bcb_app/src/com/bangalore/barcamp/.
Source file: BCBUtils.java

public static void createActionBarOnActivity(final Activity activity,boolean isHome){ ActionBar actionbar=(ActionBar)activity.findViewById(R.id.actionBar1); actionbar.setHomeLogo(R.drawable.home); actionbar.setHomeAction(new Action(){ @Override public void performAction( View view){ ((SlidingMenuActivity)activity).toggle(); } @Override public int getDrawable(){ return R.drawable.home; } } ); actionbar.setTitle(R.string.app_title_text); TextView logo=(TextView)activity.findViewById(R.id.actionbar_title); Shader textShader=new LinearGradient(0,0,0,logo.getHeight(),new int[]{Color.WHITE,0xff999999},null,TileMode.CLAMP); logo.getPaint().setShader(textShader); actionbar.setOnTitleClickListener(new OnClickListener(){ @Override public void onClick( View v){ } } ); }
Example 45
From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/activities/alliances/.
Source file: UserAlliance.java

public UserAlliance(Context context,int section,String allianceID){ super(context,R.style.ThemeBeintoo); setContentView(R.layout.useralliance); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); current=this; currentContext=context; ratio=(context.getApplicationContext().getResources().getDisplayMetrics().densityDpi / 160d); double pixels=ratio * 40; RelativeLayout beintooBar=(RelativeLayout)findViewById(R.id.beintoobarsmall); beintooBar.setBackgroundDrawable(new BDrawableGradient(0,(int)pixels,BDrawableGradient.BAR_GRADIENT)); listView=(ListView)findViewById(R.id.listView); listView.setVisibility(LinearLayout.GONE); listView.setCacheColorHint(0); content=(LinearLayout)findViewById(R.id.goodcontent); content.addView(progressLoading()); TextView title=(TextView)findViewById(R.id.dialogTitle); title.setTextColor(Color.WHITE); if (section == ENTRY_VIEW) { title.setText(current.getContext().getString(R.string.alliance)); loadEntryView(); } else if (section == CREATE_ALLIANCE) { title.setText(current.getContext().getString(R.string.alliancemaincreate)); createAllianceForm(); } else if (section == SHOW_ALLIANCE) { showAlliance(allianceID); } else if (section == PENDING_REQUESTS) { title.setText(current.getContext().getString(R.string.allianceviewpending)); pendingRequests(); } else if (section == ALLIANCES_LIST) { title.setText(current.getContext().getString(R.string.alliancemainlist)); loadAlliancesList(); } }
Example 46
From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/activity/profile/soldier/.
Source file: ProfileStatsFragment.java

private void populateStatistics(List<Statistics> statistics,TableLayout layout){ for ( Statistics ps : statistics) { TableRow tr=new TableRow(getContext()); tr.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)); if (ps.getStyle() == R.style.InfoSubHeading) { tr.setBackgroundColor(Color.parseColor("#EEEEEE")); } TextView title=new TextView(getContext()); title.setText(ps.getTitle()); title.setTextColor(Color.parseColor("#000000")); title.setPadding(5,5,5,5); tr.addView(title); TextView value=new TextView(getContext()); value.setText(ps.getValue()); value.setTextColor(Color.parseColor("#000000")); value.setPadding(5,5,5,5); tr.addView(value); layout.addView(tr); } }
Example 47
From project BibleQuote-for-Android, under directory /src/com/BibleQuote/controls/ColorPicker/.
Source file: ColorPickerPreference.java

private Bitmap getPreviewBitmap(){ int d=(int)(mDensity * 31); int color=getValue(); Bitmap bm=Bitmap.createBitmap(d,d,Config.ARGB_8888); int w=bm.getWidth(); int h=bm.getHeight(); int c=color; for (int i=0; i < w; i++) { for (int j=i; j < h; j++) { c=(i <= 1 || j <= 1 || i >= w - 2 || j >= h - 2) ? Color.GRAY : color; bm.setPixel(i,j,c); if (i != j) { bm.setPixel(j,i,c); } } } return bm; }
Example 48
From project Binaural-Beats, under directory /src/com/ihunda/android/binauralbeat/.
Source file: CanvasVizualizationView.java

void drawClear(){ Canvas c=null; try { c=mSurfaceHolder.lockCanvas(null); if (c != null) synchronized (mSurfaceHolder) { c.drawColor(Color.BLACK); } } finally { if (c != null) { mSurfaceHolder.unlockCanvasAndPost(c); } } }
Example 49
From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.
Source file: BirthdayWidget.java

private void addSpan(SpannableString caption,int daysToEvent){ if (daysToEvent < 6) { caption.setSpan(new StyleSpan(Typeface.BOLD),0,caption.length(),0); } if (daysToEvent < 2) { caption.setSpan(new ForegroundColorSpan(Color.RED),0,caption.length(),0); } }
Example 50
From project Birthdays, under directory /src/com/rexmenpara/birthdays/util/.
Source file: CalendarHelper.java

public String createCalendar(String name){ PackageInfo pInfo=null; try { pInfo=context.getPackageManager().getPackageInfo("com.android.providers.calendar",PackageManager.GET_META_DATA); } catch ( NameNotFoundException e) { return null; } resetCalendars(); ContentValues calendar=new ContentValues(); int color=Color.RED; color|=0xff000000; calendar.put(ACalendar.KEY_NAME,name); calendar.put(ACalendar.KEY_DISPLAYNAME,name); calendar.put(ACalendar.KEY_TIMEZONE,this.timezone); calendar.put(ACalendar.KEY_ACCESS_LEVEL,700); calendar.put(ACalendar.KEY_COLOR,color); calendar.put(ACalendar.KEY_OWNER_ACCOUNT,"Birthdays"); calendar.put(ACalendar.KEY_SYNC_EVENTS,1); calendar.put(ACalendar.KEY_SYNC_ACCOUNT,"Birthdays"); calendar.put(ACalendar.KEY_SYNC_ACCOUNT_TYPE,"com.google"); Uri result=context.getContentResolver().insert(calendars,calendar); String something=result.getLastPathSegment(); calendar=new ContentValues(); try { calendar.put(ACalendar.KEY_SYNC_SOURCE,3); calendar.put(ACalendar.KEY_DISPLAY_ORDER,0); calendar.put(ACalendar.KEY_SYNC_TIME,new Date().getTime()); calendar.put(ACalendar.KEY_URL,"http://www.rakshitmenpara.com"); int rowsUpdated=context.getContentResolver().update(result,calendar,null,null); Log.d(Constants.TAG,String.valueOf(rowsUpdated)); } catch ( Exception e) { } return something; }
Example 51
From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/util/.
Source file: CircularProgressView.java

public CircularProgressView(final Context context,final AttributeSet attrs){ super(context,attrs); final float density=getResources().getDisplayMetrics().density; fillPaint.setStyle(Style.FILL); fillPaint.setColor(Color.parseColor("#44ff44")); fillPaint.setAntiAlias(true); strokePaint.setStyle(Style.STROKE); strokePaint.setColor(Color.DKGRAY); strokePaint.setStrokeWidth(1 * density); strokePaint.setAntiAlias(true); }
Example 52
From project bitfluids, under directory /src/main/java/at/bitcoin_austria/bitfluids/.
Source file: Utils.java

public static Bitmap getQRCodeBitmap(final String url,final int size){ try { final Hashtable<EncodeHintType,Object> hints=new Hashtable<EncodeHintType,Object>(); hints.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.M); final BitMatrix result=QR_CODE_WRITER.encode(url,BarcodeFormat.QR_CODE,size,size,hints); final int width=result.getWidth(); final int height=result.getHeight(); final int[] pixels=new int[width * height]; for (int y=0; y < height; y++) { final int offset=y * width; for (int x=0; x < width; x++) { pixels[offset + x]=result.get(x,y) ? Color.BLACK : Color.WHITE; } } final Bitmap bitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels,0,width,0,0,width,height); return bitmap; } catch ( final WriterException x) { x.printStackTrace(); return null; } }
Example 53
private ImageButton button(int src,OnClickListener l,int position){ ImageButton btn=new ImageButton(context); LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,Gravity.CENTER_VERTICAL); Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int margin=Math.min((display.getWidth() - 3 * 128) / 3,80); params.leftMargin=margin; params.rightMargin=margin; if (position == 0) params.gravity=Gravity.LEFT | Gravity.CENTER_VERTICAL; if (position == 1) params.gravity=Gravity.RIGHT | Gravity.CENTER_VERTICAL; btn.setLayoutParams(params); btn.setImageDrawable(context.getResources().getDrawable(src)); btn.setScaleType(ScaleType.CENTER_INSIDE); btn.setBackgroundColor(Color.TRANSPARENT); btn.setOnClickListener(l); return btn; }