Example usage for android.graphics Color argb

List of usage examples for android.graphics Color argb

Introduction

In this page you can find the example usage for android.graphics Color argb.

Prototype

@ColorInt
public static int argb(float alpha, float red, float green, float blue) 

Source Link

Document

Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).

Usage

From source file:com.example.mapsample.view.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/*from  ww  w.j a  v  a2s  .  c  om*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:net.nkzn.android.sample.maps.c84_techbooster.MainActivity.java

/**
 * ????/*w w  w .j a v a 2  s . co  m*/
 */
private void drawField(Field field) {
    // 
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.title(field.getName()); // ???
    markerOptions.snippet(field.getMemo()); // 
    markerOptions.position(calcCenter(field.getVertexes())); // ??
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(field.getColorHue())); // 

    // ?
    mGoogleMap.addMarker(markerOptions);

    // ??
    final LatLng[] vertexes = field.getVertexes();
    if (vertexes != null && vertexes.length > 3) {
        // ?
        PolygonOptions polygonOptions = new PolygonOptions();

        // RGB?????
        final int[] colorRgb = field.getColorRgb();
        int colorRed = colorRgb[0];
        int colorGreen = colorRgb[1];
        int colorBlue = colorRgb[2];

        // ?????
        polygonOptions.strokeColor(Color.argb(0x255, colorRed, colorGreen, colorBlue));
        polygonOptions.strokeWidth(5);

        // ????????
        polygonOptions.fillColor(Color.argb(0x40, colorRed, colorGreen, colorBlue));

        // ??
        polygonOptions.add(vertexes); // LatLng?LatLng[]?OK

        // ??
        mGoogleMap.addPolygon(polygonOptions);
    }
}

From source file:moose.com.ac.ArticleViewActivity.java

@Override
protected void onInitView(Bundle savedInstanceState) {
    setContentView(R.layout.activity_article_view);
    article = (Article) getIntent().getSerializableExtra(Config.ARTICLE);
    /*//  ww  w  .  ja va 2  s.  c om
    * Uri data = getIntent().getData();
    if(Intent.ACTION_VIEW.equalsIgnoreCase(getIntent().getAction()) && data!=null){
    String scheme = data.getScheme();
    if(scheme.equals("ac")){
        // ac://ac000000
        aid = Integer.parseInt(getIntent().getDataString().substring(7));
    }else if(scheme.equals("http")){
        // http://www.acfun.tv/v/ac123456
        Matcher matcher;
        String path = data.getPath();
        if(path==null){
            finish();
            return;
        }
        if((matcher = sVreg.matcher(path)).find()
                || (matcher = sAreg.matcher(path)).find()){
            aid = Integer.parseInt(matcher.group(1));
        }
    }
    if(aid != 0) title = "ac"+aid;
    isWebMode = getIntent().getBooleanExtra("webmode", false) && aid == 0;
    }else{
    aid = getIntent().getIntExtra("aid", 0);
    title = getIntent().getStringExtra("title");
    }*/
    isFav = dbHelper.isExits(TAB_NAME, article.isfav);
    articleId = Integer.valueOf(article.contentId);
    toolbarHeight = DisplayUtil.dip2px(this, 56f);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setDisplayHomeAsUpEnabled(true);
    }
    contend = "ac" + articleId;
    getSupportActionBar().setTitle(contend);

    fab = (FloatingActionButton) findViewById(R.id.view_fab);
    fab.setOnClickListener(v -> {
        Intent intent = new Intent(this, BigNewsActivity.class);
        intent.putExtra(Config.CONTENTID, String.valueOf(articleId));
        intent.putExtra(Config.TITLE, title);
        startActivity(intent);
    });

    mSwipeRefreshLayout = (MultiSwipeRefreshLayout) findViewById(R.id.web_swipe);
    mSwipeRefreshLayout.setSwipeableChildren(R.id.view_fab);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.md_white);
    mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.colorPrimary);

    mWeb = (ObservableWebView) findViewById(R.id.view_webview);
    mContentView = (CoordinatorLayout) findViewById(R.id.view_content);
    settings = mWeb.getSettings();
    settings.setJavaScriptEnabled(true);
    //settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    settings.setUserAgentString(RxUtils.UA);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName(Config.TEXT_ENCODING);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mWeb.getSettings().setDisplayZoomControls(false);
    }
    mWeb.setWebViewClient(new Client());
    mWeb.addJavascriptInterface(new JsBridge(), "JsBridge");
    if (Build.VERSION.SDK_INT >= 11)
        mWeb.setBackgroundColor(Color.argb(1, 0, 0, 0));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
    }

    mWeb.setOnScrollChangedCallback(this);
    level = CommonUtil.getTextSize();
    setText();
    mSwipeRefreshLayout.post(() -> mSwipeRefreshLayout.setRefreshing(true));
    initData();
}

From source file:com.example.android.drawabletinting.DrawableTintingFragment.java

/**
 * Computes the {@link Color} value from selection on ARGB sliders.
 *
 * @return color computed from selected ARGB values
 *///from  w w  w . j  a  v  a 2 s  . co m
public int getColor() {
    final int alpha = mAlphaBar.getProgress();
    final int red = mRedBar.getProgress();
    final int green = mGreenBar.getProgress();
    final int blue = mBlueBar.getProgress();

    return Color.argb(alpha, red, green, blue);
}

From source file:com.nextgis.mobile.MapFragment.java

protected void addMapButtons(RelativeLayout rl) {
    mivZoomIn = new ImageView(getActivity());
    mivZoomIn.setImageResource(R.drawable.ic_plus);
    //mivZoomIn.setId(R.drawable.ic_plus);

    mivZoomOut = new ImageView(getActivity());
    mivZoomOut.setImageResource(R.drawable.ic_minus);
    //mivZoomOut.setId(R.drawable.ic_minus);

    final ImageView ivMark = new ImageView(getActivity());
    ivMark.setImageResource(R.drawable.ic_mark);
    //ivMark.setId(R.drawable.ic_mark);

    //show zoom level between plus and minus
    mivZoomLevel = new TextView(getActivity());
    //ivZoomLevel.setAlpha(150);
    mivZoomLevel.setId(R.drawable.ic_zoomlevel);

    final float scale = getResources().getDisplayMetrics().density;
    int pixels = (int) (48 * scale + 0.5f);

    mivZoomLevel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    //ivZoomLevel.setTextAppearance(this, android.R.attr.textAppearanceLarge);

    mivZoomLevel.setWidth(pixels);// w w w.  jav  a  2 s.c  o m
    mivZoomLevel.setHeight(pixels);
    mivZoomLevel.setTextColor(Color.DKGRAY);
    mivZoomLevel.setBackgroundColor(Color.argb(50, 128, 128, 128)); //Color.LTGRAY R.drawable.ic_zoomlevel);
    mivZoomLevel.setGravity(Gravity.CENTER);
    mivZoomLevel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mivZoomLevel.setText("" + (int) Math.floor(mMap.getZoomLevel()));

    mivZoomIn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mMap.zoomIn();
        }
    });

    mivZoomOut.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mMap.zoomOut();
        }
    });

    ivMark.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            //TODO: onMark();
        }
    });

    final RelativeLayout.LayoutParams RightParams1 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams1.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams1.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP
    rl.addView(mivZoomLevel, RightParams1);

    final RelativeLayout.LayoutParams RightParams4 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams4.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams4.addRule(RelativeLayout.ABOVE, R.drawable.ic_zoomlevel);//ALIGN_PARENT_TOP
    rl.addView(mivZoomIn, RightParams4);

    final RelativeLayout.LayoutParams RightParams3 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams3.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams3.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    RightParams3.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP
    rl.addView(ivMark, RightParams3);

    final RelativeLayout.LayoutParams RightParams2 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams2.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams2.addRule(RelativeLayout.BELOW, R.drawable.ic_zoomlevel);//R.drawable.ic_plus);
    rl.addView(mivZoomOut, RightParams2);

    setZoomInEnabled(mMap.canZoomIn());
    setZoomOutEnabled(mMap.canZoomOut());
}

From source file:es.eucm.eadandroid.utils.ViewPagerIndicator.java

/**
 * Create all views, build the layout//from  www.j  a  va 2  s . c o  m
 */
private void addContent() {
    mFocusedTextColor = new int[] { 0, 0, 0 };
    mUnfocusedTextColor = new int[] { 225, 225, 225 };

    // Text views
    mPrevious = new TextView(getContext());
    mCurrent = new TextView(getContext());
    mNext = new TextView(getContext());

    RelativeLayout.LayoutParams previousParams = new RelativeLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    previousParams.addRule(RelativeLayout.ALIGN_LEFT);

    RelativeLayout.LayoutParams currentParams = new RelativeLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    currentParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

    RelativeLayout.LayoutParams nextParams = new RelativeLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    nextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    // Groups holding text and arrows
    mPreviousGroup = new LinearLayout(getContext());
    mPreviousGroup.setOrientation(LinearLayout.HORIZONTAL);
    mNextGroup = new LinearLayout(getContext());
    mNextGroup.setOrientation(LinearLayout.HORIZONTAL);

    mPreviousGroup.addView(mPrevious, new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
    mNextGroup.addView(mNext, new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

    addView(mPreviousGroup, previousParams);
    addView(mCurrent, currentParams);
    addView(mNextGroup, nextParams);

    mPrevious.setSingleLine();
    mCurrent.setSingleLine();
    mNext.setSingleLine();

    mPrevious.setText("previous");
    mCurrent.setText("current");
    mNext.setText("next");

    // Set colors
    mNext.setTextColor(Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2]));
    mPrevious.setTextColor(
            Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2]));
    updateColor(0);
}

From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java

public CommentListingFragment(final AppCompatActivity parent, final Bundle savedInstanceState,
        final ArrayList<RedditURLParser.RedditURL> urls, final UUID session, final String searchString,
        final boolean forceDownload) {

    super(parent, savedInstanceState);

    if (savedInstanceState != null) {
        mPreviousFirstVisibleItemPosition = savedInstanceState.getInt(SAVEDSTATE_FIRST_VISIBLE_POS);
    }/*w  w  w .  j  av  a2 s. co  m*/

    mCommentListingManager = new FilteredCommentListingManager(parent, searchString);
    mAllUrls = urls;

    mUrlsToDownload = new LinkedList<>(mAllUrls);

    this.mSession = session;

    if (forceDownload) {
        mDownloadStrategy = DownloadStrategyAlways.INSTANCE;

    } else {
        mDownloadStrategy = DownloadStrategyIfNotCached.INSTANCE;
    }

    mUser = RedditAccountManager.getInstance(getActivity()).getDefaultAccount();

    parent.invalidateOptionsMenu();

    final Context context = getActivity();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    mCommentFontScale = PrefsUtility.appearance_fontscale_comments(context, prefs);
    mShowLinkButtons = PrefsUtility.pref_appearance_linkbuttons(context, prefs);

    mOuterFrame = new FrameLayout(context);

    final ScrollbarRecyclerViewManager recyclerViewManager = new ScrollbarRecyclerViewManager(context, null,
            false);

    if (parent instanceof OptionsMenuUtility.OptionsMenuCommentsListener
            && PrefsUtility.pref_behaviour_enable_swipe_refresh(context, prefs)) {

        recyclerViewManager.enablePullToRefresh(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                ((OptionsMenuUtility.OptionsMenuCommentsListener) parent).onRefreshComments();
            }
        });
    }

    mRecyclerView = recyclerViewManager.getRecyclerView();
    mCommentListingManager.setLayoutManager((LinearLayoutManager) mRecyclerView.getLayoutManager());

    mRecyclerView.setAdapter(mCommentListingManager.getAdapter());
    mOuterFrame.addView(recyclerViewManager.getOuterView());

    mRecyclerView.setItemAnimator(null);

    /* TODO
    {
       final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
       itemAnimator.setRemoveDuration(80);
       itemAnimator.setChangeDuration(80);
       itemAnimator.setAddDuration(80);
       itemAnimator.setMoveDuration(80);
    }
    */

    if (!PrefsUtility.pref_appearance_comments_show_floating_toolbar(context, prefs)) {
        mFloatingToolbar = null;

    } else {
        mFloatingToolbar = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.floating_toolbar,
                mOuterFrame, false);

        // We need a container so that setVisible() doesn't mess with the Z-order
        final FrameLayout floatingToolbarContainer = new FrameLayout(context);

        floatingToolbarContainer.addView(mFloatingToolbar);
        mOuterFrame.addView(floatingToolbarContainer);

        if (PrefsUtility.isNightMode(context)) {
            mFloatingToolbar.setBackgroundColor(Color.argb(0xCC, 0x33, 0x33, 0x33));
        }

        final int buttonVPadding = General.dpToPixels(context, 12);
        final int buttonHPadding = General.dpToPixels(context, 16);

        {
            final ImageButton previousButton = (ImageButton) LayoutInflater.from(context)
                    .inflate(R.layout.flat_image_button, mFloatingToolbar, false);

            previousButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding);
            previousButton.setImageResource(R.drawable.ic_ff_up_dark);
            previousButton.setContentDescription(getString(R.string.button_prev_comment_parent));
            mFloatingToolbar.addView(previousButton);

            previousButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {

                    final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView
                            .getLayoutManager();

                    for (int pos = layoutManager.findFirstVisibleItemPosition() - 1; pos > 0; pos--) {

                        final GroupedRecyclerViewAdapter.Item item = mCommentListingManager
                                .getItemAtPosition(pos);

                        if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment()
                                && ((RedditCommentListItem) item).getIndent() == 0) {

                            layoutManager.scrollToPositionWithOffset(pos, 0);
                            return;
                        }
                    }

                    layoutManager.scrollToPositionWithOffset(0, 0);
                }
            });

            previousButton.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(final View view) {
                    General.quickToast(context, R.string.button_prev_comment_parent);
                    return true;
                }
            });
        }

        {
            final ImageButton nextButton = (ImageButton) LayoutInflater.from(context)
                    .inflate(R.layout.flat_image_button, mFloatingToolbar, false);

            nextButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding);
            nextButton.setImageResource(R.drawable.ic_ff_down_dark);
            nextButton.setContentDescription(getString(R.string.button_next_comment_parent));
            mFloatingToolbar.addView(nextButton);

            nextButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {

                    final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView
                            .getLayoutManager();

                    for (int pos = layoutManager.findFirstVisibleItemPosition() + 1; pos < layoutManager
                            .getItemCount(); pos++) {

                        final GroupedRecyclerViewAdapter.Item item = mCommentListingManager
                                .getItemAtPosition(pos);

                        if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment()
                                && ((RedditCommentListItem) item).getIndent() == 0) {

                            layoutManager.scrollToPositionWithOffset(pos, 0);
                            break;
                        }
                    }
                }
            });

            nextButton.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(final View view) {
                    General.quickToast(context, R.string.button_next_comment_parent);
                    return true;
                }
            });
        }
    }

    final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(context);

    final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(context,
            new BezelSwipeOverlay.BezelSwipeListener() {
                @Override
                public boolean onSwipe(@BezelSwipeOverlay.SwipeEdge int edge) {

                    if (mPost == null)
                        return false;

                    toolbarOverlay.setContents(mPost.generateToolbar(getActivity(), true, toolbarOverlay));
                    toolbarOverlay
                            .show(edge == BezelSwipeOverlay.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT
                                    : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                    return true;
                }

                public boolean onTap() {

                    if (toolbarOverlay.isShown()) {
                        toolbarOverlay.hide();
                        return true;
                    }

                    return false;
                }
            });

    mOuterFrame.addView(bezelOverlay);
    mOuterFrame.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;

    makeNextRequest(context);
}

From source file:com.maxwen.wallpaper.board.adapters.WallpapersAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder h, int position) {
    final ImageHolder holder = (ImageHolder) h;
    final Wallpaper w = mWallpapers.get(position);
    holder.name.setText(w.getName());/*from  www.jav a2s.  c  o  m*/
    holder.author.setText(w.getAuthor());
    holder.category.setText(w.getCategory());
    holder.newWallpaper.setVisibility(mNewWallpapers.contains(w) ? View.VISIBLE : View.GONE);

    String url = w.getThumbUrl();

    ImageLoader.getInstance().displayImage(url, new ImageViewAware(holder.image), mOptions.build(),
            ImageConfig.getThumbnailSize(mContext), new SimpleImageLoadingListener() {
                @Override
                public void onLoadingStarted(String imageUri, View view) {
                    super.onLoadingStarted(imageUri, view);
                    if (mIsAutoGeneratedColor) {
                        int vibrant = ColorHelper.getAttributeColor(mContext, R.attr.card_background);
                        holder.imageInfo.setBackgroundColor(vibrant);
                        int primary = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
                        holder.name.setTextColor(primary);
                        holder.author.setTextColor(primary);
                        holder.category.setTextColor(primary);
                    } else {
                        int color = mContext.getResources().getColor(R.color.image_info_text);
                        holder.imageInfo
                                .setBackgroundColor(mContext.getResources().getColor(R.color.image_info_bg));
                        holder.name.setTextColor(color);
                        holder.author.setTextColor(color);
                        holder.category.setTextColor(color);
                    }
                }

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    super.onLoadingComplete(imageUri, view, loadedImage);
                    if (mIsAutoGeneratedColor) {
                        if (loadedImage != null) {
                            Palette.from(loadedImage).generate(new Palette.PaletteAsyncListener() {
                                @Override
                                public void onGenerated(Palette palette) {
                                    int vibrant = ColorHelper.getAttributeColor(mContext,
                                            R.attr.card_background);
                                    int color = palette.getVibrantColor(vibrant);
                                    if (color == vibrant)
                                        color = palette.getMutedColor(vibrant);
                                    color = Color.argb(0x60, Color.red(color), Color.green(color),
                                            Color.blue(color));
                                    holder.imageInfo.setBackgroundColor(color);
                                    int text = ColorHelper.getTitleTextColor(color);
                                    holder.name.setTextColor(text);
                                    holder.author.setTextColor(text);
                                    holder.category.setTextColor(text);
                                    setFavorite(holder.favorite, text, holder.getAdapterPosition(), false);
                                }
                            });
                        }
                    } else {
                        int color = mContext.getResources().getColor(R.color.image_info_text);
                        holder.imageInfo
                                .setBackgroundColor(mContext.getResources().getColor(R.color.image_info_bg));
                        holder.name.setTextColor(color);
                        holder.author.setTextColor(color);
                        holder.category.setTextColor(color);
                        setFavorite(holder.favorite, color, holder.getAdapterPosition(), false);
                    }
                }
            }, null);
}

From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java

/**
 * calculate gradient color/*from  w  w  w.  ja v a2  s  . co  m*/
 * @param startColor start color
 * @param endColor   end color
 * @param percent    percent
 * @return gradient color
 */
@SuppressWarnings("unused")
private static int getGradientColor(int startColor, int endColor, float percent) {
    int startA = Color.alpha(startColor);
    int startR = Color.red(startColor);
    int startG = Color.green(startColor);
    int startB = Color.blue(startColor);

    int endA = Color.alpha(endColor);
    int endR = Color.red(endColor);
    int endG = Color.green(endColor);
    int endB = Color.blue(endColor);

    int currentA = (int) (startA * (1 - percent) + endA * percent);
    int currentR = (int) (startR * (1 - percent) + endR * percent);
    int currentG = (int) (startG * (1 - percent) + endG * percent);
    int currentB = (int) (startB * (1 - percent) + endB * percent);
    return Color.argb(currentA, currentR, currentG, currentB);
}

From source file:eu.liveandgov.ar.core.ARViewFragment.java

/** Resume metaioSDK, open Camera, and resume OpenGL surface  */
@Override/*  w ww  .j av  a 2s. com*/
public void onResume() {
    super.onResume();
    deb("ARViewFragment", "onResume ARViewFragment");
    metaioSDK.resume();

    if (mGLSurfaceView != null) {
        if (mGLSurfaceView.getParent() == null) {
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT);

            mGLSurfaceView.setBackgroundColor(Color.argb(0, 0, 0, 0));
            mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
            mGLSurfaceView.setZOrderMediaOverlay(true);
            ((ViewGroup) v).addView(mGLSurfaceView, params);
        }

        // make sure to resume the OpenGL surface
        mGLSurfaceView.onResume();
    }

    v.bringToFront();
}