List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:com.bookstore.qr_codescan.danmakuFlame.master.flame.danmaku.danmaku.parser.android.AcFunDanmakuParser.java
private Danmakus _parse(JSONObject jsonObject, Danmakus danmakus) { if (danmakus == null) { danmakus = new Danmakus(); }/*from w w w . ja va 2 s. c om*/ if (jsonObject == null || jsonObject.length() == 0) { return danmakus; } for (int i = 0; i < jsonObject.length(); i++) { try { JSONObject obj = jsonObject; String c = obj.getString("c"); String[] values = c.split(","); if (values.length > 0) { int type = Integer.parseInt(values[2]); // if (type == 7) // FIXME : hard code // TODO : parse advance danmaku json continue; long time = (long) (Float.parseFloat(values[0]) * 1000); // int color = Integer.parseInt(values[1]) | 0xFF000000; // float textSize = Float.parseFloat(values[3]); // ? BaseDanmaku item = mContext.mDanmakuFactory.createDanmaku(type, mContext); if (item != null) { item.time = time; item.textSize = textSize * (mDispDensity - 0.6f); item.textColor = color; item.textShadowColor = color <= Color.BLACK ? Color.WHITE : Color.BLACK; DanmakuUtils.fillText(item, obj.optString("m", "....")); item.index = i; item.setTimer(mTimer); danmakus.addItem(item); } } } catch (JSONException e) { } catch (NumberFormatException e) { } } return danmakus; }
From source file:com.kabootar.GlassMemeGenerator.ImageOverlay.java
/** * Draws the given string centered, as big as possible, on either the top or * bottom 20% of the image given.//w ww . ja va 2 s. co m */ private static void drawStringCentered(Canvas g, String text, Bitmap image, boolean top, Context baseContext) throws InterruptedException { if (text == null) text = ""; int height = 0; int fontSize = MAX_FONT_SIZE; int maxCaptionHeight = image.getHeight() / 5; int maxLineWidth = image.getWidth() - SIDE_MARGIN * 2; String formattedString = ""; Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); Paint stkPaint = new Paint(Paint.ANTI_ALIAS_FLAG); stkPaint.setStyle(STROKE); stkPaint.setStrokeWidth(8); stkPaint.setColor(Color.BLACK); //Typeface tf = Typeface.create("Arial", Typeface.BOLD); Typeface tf = Typeface.createFromAsset(baseContext.getAssets(), "fonts/impact.ttf"); paint.setTypeface(tf); stkPaint.setTypeface(tf); do { paint.setTextSize(fontSize); // first inject newlines into the text to wrap properly StringBuilder sb = new StringBuilder(); int left = 0; int right = text.length() - 1; while (left < right) { String substring = text.substring(left, right + 1); Rect stringBounds = new Rect(); paint.getTextBounds(substring, 0, substring.length(), stringBounds); while (stringBounds.width() > maxLineWidth) { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } // look for a space to break the line boolean spaceFound = false; for (int i = right; i > left; i--) { if (text.charAt(i) == ' ') { right = i - 1; spaceFound = true; break; } } substring = text.substring(left, right + 1); paint.getTextBounds(substring, 0, substring.length(), stringBounds); // If we're down to a single word and we are still too wide, // the font is just too big. if (!spaceFound && stringBounds.width() > maxLineWidth) { break; } } sb.append(substring).append("\n"); left = right + 2; right = text.length() - 1; } formattedString = sb.toString(); // now determine if this font size is too big for the allowed height height = 0; for (String line : formattedString.split("\n")) { Rect stringBounds = new Rect(); paint.getTextBounds(line, 0, line.length(), stringBounds); height += stringBounds.height(); } fontSize--; } while (height > maxCaptionHeight); // draw the string one line at a time int y = 0; if (top) { y = TOP_MARGIN; } else { y = image.getHeight() - height - BOTTOM_MARGIN; } for (String line : formattedString.split("\n")) { // Draw each string twice for a shadow effect Rect stringBounds = new Rect(); paint.getTextBounds(line, 0, line.length(), stringBounds); //paint.setColor(Color.BLACK); //g.drawText(line, (image.getWidth() - (int) stringBounds.width()) / 2 + 2, y + stringBounds.height() + 2, paint); paint.setColor(Color.WHITE); g.drawText(line, (image.getWidth() - (int) stringBounds.width()) / 2, y + stringBounds.height(), paint); //stroke Rect strokeBounds = new Rect(); stkPaint.setTextSize(fontSize); stkPaint.getTextBounds(line, 0, line.length(), strokeBounds); g.drawText(line, (image.getWidth() - (int) strokeBounds.width()) / 2, y + strokeBounds.height(), stkPaint); y += stringBounds.height(); } }
From source file:com.nick.documents.widget.FlexibleImageView.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FlexibleImageView, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBgColor = a.getColor(R.styleable.FlexibleImageView_background_color, DEFAULT_CIRCLE_BG_LIGHT); mInnerRadius = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mTextSize = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.FlexibleImageView_progress_text_color, Color.BLACK); mCircleBackgroundEnabled = a.getBoolean(R.styleable.FlexibleImageView_enable_circle_background, true); mProgress = a.getInt(R.styleable.FlexibleImageView_progress, 0); mMax = a.getInt(R.styleable.FlexibleImageView_max_flip, 100); int textVisible = a.getInt(R.styleable.FlexibleImageView_progress_text_visibility, 1); if (textVisible != 1) { mHasText = true;/*from w w w . ja v a 2 s . co m*/ } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); mRingColors = context.getResources().getIntArray(R.array.ring_colors); super.setImageDrawable(mProgressDrawable); mHandler = new Handler(); }
From source file:com.pixellostudio.qqdroid.BaseQuote.java
/** Called when the activity is first created. */ @Override/*from www . ja va 2 s. co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarContentView(R.layout.show); getActionBar().setTitle(title); getActionBar().addItem(getActionBar().newActionBarItem(NormalActionBarItem.class) .setDrawable(R.drawable.seemore).setContentDescription("List"), R.id.actionbar_seemore); view = (ListView) findViewById(R.id.ListView); view.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(0, 1, 0, R.string.sharequote); } }); adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1); adapter2 = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1) { @Override public View getView(int position, View convertView, ViewGroup parent) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(BaseQuote.this); TextView txt = new TextView(this.getContext()); txt.setTextSize(Float.parseFloat(pref.getString("policesize", "20"))); txt.setText(Html.fromHtml(this.getItem(position))); if (pref.getString("design", "blackonwhite").equals("blackonwhite")) { txt.setTextColor(Color.BLACK); txt.setBackgroundColor(Color.WHITE); txt.setBackgroundDrawable( this.getContext().getResources().getDrawable(R.drawable.quote_gradient_white)); } else if (pref.getString("design", "blackonwhite").equals("whiteonblack")) { txt.setTextColor(Color.WHITE); txt.setBackgroundColor(Color.BLACK); txt.setBackgroundDrawable( this.getContext().getResources().getDrawable(R.drawable.quote_gradient_black)); } return txt; } }; String[] liste = (String[]) getLastNonConfigurationInstance(); if (liste != null && liste.length != 0) { for (int i = 0; i < liste.length; i++) { adapter.add(liste[i]); adapter2.add(liste[i]); } this.setTitle(name); } else { new LoadQuotes().execute(); } view.setAdapter(adapter2); }
From source file:com.donsen.svg.ui.common.AnimatedSvgView.java
@SuppressWarnings("NewApi") private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);// w w w . ja v a2 s. c o m mFillPaint.setStyle(Paint.Style.FILL); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MARKER_LENGTH_DIP, getResources().getDisplayMetrics()); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = Color.argb(50, 0, 0, 0); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeX, 433); mRatioSizingInfo.aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeX, 433); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeY, 433); mRatioSizingInfo.aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeY, 433); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_svgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_svgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_svgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_svgFillTime, 1000); a.recycle(); mViewport = new PointF(mViewportWidth, mViewportHeight); } // See https://github.com/romainguy/road-trip/blob/master/application/src/main/java/org/curiouscreature/android/roadtrip/IntroView.java // Note: using a software layer here is an optimization. This view works with // hardware accelerated rendering but every time a path is modified (when the // dash path effect is modified), the graphics pipeline will rasterize the path // again in a new texture. Since we are dealing with dozens of paths, it is much // more efficient to rasterize the entire view into a single re-usable texture // instead. Ideally this should be toggled using a heuristic based on the number // and or dimensions of paths to render. // Note that PathDashPathEffects can lead to clipping issues with hardware rendering. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); } }
From source file:com.daitu_liang.study.mytest.svg.AnimatedSvgView.java
private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);//from w w w . j a v a2s.c o m mFillPaint.setStyle(Paint.Style.FILL); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MARKER_LENGTH_DIP, getResources().getDisplayMetrics()); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = Color.argb(50, 0, 0, 0); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); Log.i(TAG, "mViewportWidth=" + mViewportWidth); mRatioSizingInfo.aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mRatioSizingInfo.aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillTime, 1000); a.recycle(); mViewport = new PointF(mViewportWidth, mViewportHeight); } }
From source file:com.axinom.drm.quickstart.activity.SampleChooserActivity.java
private void makeMoviesRequest() { JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, API_CATALOG, null, new Response.Listener<JSONArray>() { @Override/*w ww . j av a 2s.com*/ public void onResponse(JSONArray response) { // Adding video URLs and names to lists from json array response. for (int i = 0; i < response.length(); i++) { try { JSONObject jsonObject = response.getJSONObject(i); mVideoUrls.add(jsonObject.getString("url")); mVideoNames.add(jsonObject.getString("name")); } catch (JSONException e) { e.printStackTrace(); } } ArrayAdapter adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, mVideoNames) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setTextColor(Color.BLACK); return view; } }; mListView.setAdapter(adapter); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.d(TAG, "Movies json was not loaded with error: " + error.getMessage()); } }); BaseApp.requestQueue.add(request); }
From source file:org.lol.reddit.activities.ImageViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences); if (solidblack) getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK)); final Intent intent = getIntent(); mUrl = General.uriFromString(intent.getDataString()); final RedditPost src_post = intent.getParcelableExtra("post"); if (mUrl == null) { General.quickToast(this, "Invalid URL. Trying web browser."); revertToWeb();/*from w w w . ja v a2s .com*/ return; } Log.i("ImageViewActivity", "Loading URL " + mUrl.toString()); final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(progressBar); CacheManager.getInstance(this) .makeRequest(new CacheRequest(mUrl, RedditAccountManager.getAnon(), null, Constants.Priority.IMAGE_VIEW, 0, CacheRequest.DownloadType.IF_NECESSARY, Constants.FileType.IMAGE, false, false, false, this) { private void setContentView(View v) { layout.removeAllViews(); layout.addView(v); v.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; v.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(context.getApplicationContext(), new RRError(null, null, t)); } @Override protected void onDownloadNecessary() { General.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { progressBar.setVisibility(View.VISIBLE); progressBar.setIndeterminate(true); } }); } @Override protected void onDownloadStarted() { } @Override protected void onFailure(final RequestFailureType type, Throwable t, StatusLine status, final String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status, url.toString()); General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { // TODO handle properly progressBar.setVisibility(View.GONE); layout.addView(new ErrorView(ImageViewActivity.this, error)); } }); } @Override protected void onProgress(final long bytesRead, final long totalBytes) { General.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { progressBar.setVisibility(View.VISIBLE); progressBar.setIndeterminate(false); progressBar.setProgress((int) ((100 * bytesRead) / totalBytes)); } }); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, final String mimetype) { if (mimetype == null || !Constants.Mime.isImage(mimetype)) { revertToWeb(); return; } final InputStream cacheFileInputStream; try { cacheFileInputStream = cacheFile.getInputStream(); } catch (IOException e) { notifyFailure(RequestFailureType.PARSE, e, null, "Could not read existing cached image."); return; } if (cacheFileInputStream == null) { notifyFailure(RequestFailureType.CACHE_MISS, null, null, "Could not find cached image"); return; } if (Constants.Mime.isImageGif(mimetype)) { if (AndroidApi.isIceCreamSandwichOrLater()) { General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { try { final GIFView gifView = new GIFView(ImageViewActivity.this, cacheFileInputStream); setContentView(gifView); gifView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); } catch (OutOfMemoryError e) { General.quickToast(context, R.string.imageview_oom); revertToWeb(); } catch (Throwable e) { General.quickToast(context, R.string.imageview_invalid_gif); revertToWeb(); } } }); } else { gifThread = new GifDecoderThread(cacheFileInputStream, new GifDecoderThread.OnGifLoadedListener() { public void onGifLoaded() { General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); setContentView(imageView); gifThread.setView(imageView); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); } }); } public void onOutOfMemory() { General.quickToast(context, R.string.imageview_oom); revertToWeb(); } public void onGifInvalid() { General.quickToast(context, R.string.imageview_invalid_gif); revertToWeb(); } }); gifThread.start(); } } else { final long bytes = cacheFile.getSize(); final byte[] buf = new byte[(int) bytes]; try { new DataInputStream(cacheFileInputStream).readFully(buf); } catch (IOException e) { throw new RuntimeException(e); } final ImageTileSource imageTileSource; try { imageTileSource = new ImageTileSourceWholeBitmap(buf); } catch (OutOfMemoryError e) { General.quickToast(context, R.string.imageview_oom); revertToWeb(); return; } catch (Throwable t) { Log.e("ImageViewActivity", "Exception when creating ImageTileSource", t); General.quickToast(context, R.string.imageview_decode_failed); revertToWeb(); return; } General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { surfaceView = new RRGLSurfaceView(ImageViewActivity.this, new ImageViewDisplayListManager(imageTileSource, ImageViewActivity.this)); setContentView(surfaceView); surfaceView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); if (mIsPaused) { surfaceView.onPause(); } else { surfaceView.onResume(); } } }); } } }); final RedditPreparedPost post = src_post == null ? null : new RedditPreparedPost(this, CacheManager.getInstance(this), 0, src_post, -1, false, false, false, false, RedditAccountManager.getInstance(this).getDefaultAccount(), false); final FrameLayout outerFrame = new FrameLayout(this); outerFrame.addView(layout); if (post != null) { final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(this); final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(this, new BezelSwipeOverlay.BezelSwipeListener() { public boolean onSwipe(BezelSwipeOverlay.SwipeEdge edge) { toolbarOverlay.setContents( post.generateToolbar(ImageViewActivity.this, false, toolbarOverlay)); toolbarOverlay.show(edge == BezelSwipeOverlay.SwipeEdge.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT : SideToolbarOverlay.SideToolbarPosition.RIGHT); return true; } public boolean onTap() { if (toolbarOverlay.isShown()) { toolbarOverlay.hide(); return true; } return false; } }); outerFrame.addView(bezelOverlay); outerFrame.addView(toolbarOverlay); bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; } setContentView(outerFrame); }
From source file:com.ixco.troncalnet.Tabulacion.SlidingTabsColorsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (populate_tabs) /**/*from w w w.j a va 2 s. co m*/ * Populate our tab list with tabs. Each item contains a title, indicator color and divider * color, which are used by {@link SlidingTabLayout}. */ mTabs.add(new SamplePagerItem(getString(R.string.title_activity_maps), // Title Color.BLUE, // Indicator color Color.BLACK// Divider color )); mTabs.add(new SamplePagerItem(getString(R.string.title_activity_vehicles), // Title Color.GREEN, // Indicator color Color.BLACK // Divider color )); mTabs.add(new SamplePagerItem(getString(R.string.title_activity_notifications), // Title Color.RED, // Indicator color Color.BLACK // Divider color )); /* mTabs.add(new SamplePagerItem( getString(R.string.tab_photos), // Title Color.YELLOW, // Indicator color Color.GRAY // Divider color )); mTabs.add(new SamplePagerItem( getString(R.string.tab_notifications), // Title Color.GREEN, // Indicator color Color.GRAY // Divider color ));*/ // END_INCLUDE (populate_tabs) }
From source file:com.github.ajasmin.telususageandroidwidget.ReportAccountErrorActivity.java
private void looksBetterOnIceCream() { if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 11) { findViewById(R.id.bottom_pane).setBackgroundColor(Color.BLACK); }/*from w ww. ja v a2s .com*/ }