Java 类android.graphics.PorterDuff 实例源码

项目:Phoenix-for-VK    文件:LogsAdapter.java   
Holder(View itemView) {
    super(itemView);
    this.tag = (TextView) itemView.findViewById(R.id.log_tag);
    this.datetime = (TextView) itemView.findViewById(R.id.log_datetime);
    this.body = (TextView) itemView.findViewById(R.id.log_body);

    this.buttonShare = itemView.findViewById(R.id.log_button_share);

    this.bodyRoot = itemView.findViewById(R.id.log_body_root);
    this.buttonExpand = itemView.findViewById(R.id.log_button_expand);

    Context context = itemView.getContext();

    ImageView icon = (ImageView) itemView.findViewById(R.id.log_icon);
    icon.getBackground().setColorFilter(CurrentTheme.getColorPrimary(context), PorterDuff.Mode.MULTIPLY);
    icon.setColorFilter(CurrentTheme.getIconColorOnColoredBackgroundCode(context));
}
项目:QuranAndroid    文件:AboutActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    getSupportActionBar().setTitle(getString(R.string.about));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    progressBar = (ProgressBar) findViewById(R.id.progress);
    progressBar.getIndeterminateDrawable()
            .setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
    info_web = (WebView) findViewById(R.id.webview_company_info);
    info_web.setBackgroundColor(Color.TRANSPARENT);
    info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    info_web.setWebViewClient(new myWebClient());
    info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    info_web.getSettings().setJavaScriptEnabled(true);
    String infoText = getString(R.string.company_info_web);
    info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);

}
项目:Blogg    文件:Tools.java   
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    // canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    //Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
    //return _bmp;
    return output;
}
项目:PlusGram    文件:BotHelpCell.java   
@Override
protected void onDraw(Canvas canvas) {
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    Theme.backgroundMediaDrawableIn.setColorFilter(themePrefs.getInt("chatLBubbleColor", 0xfffafafa), PorterDuff.Mode.SRC_IN);
    int x = (canvas.getWidth() - width) / 2;
    int y = AndroidUtilities.dp(4);
    Theme.backgroundMediaDrawableIn.setBounds(x, y, width + x, height + y);
    Theme.backgroundMediaDrawableIn.draw(canvas);
    canvas.save();
    canvas.translate(textX = AndroidUtilities.dp(2 + 9) + x, textY = AndroidUtilities.dp(2 + 9) + y);
    if (pressedLink != null) {
        canvas.drawPath(urlPath, urlPaint);
    }
    if (textLayout != null) {
        textLayout.draw(canvas);
    }
    canvas.restore();
}
项目:Cable-Android    文件:CircleColorImageView.java   
public CircleColorImageView(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  int circleColor = Color.WHITE;

  if (attrs != null) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CircleColorImageView, 0, 0);
    circleColor = typedArray.getColor(R.styleable.CircleColorImageView_circleColor, Color.WHITE);
    typedArray.recycle();
  }

  Drawable circle = context.getResources().getDrawable(R.drawable.circle_tintable);
  circle.setColorFilter(circleColor, PorterDuff.Mode.SRC_IN);

  setBackgroundDrawable(circle);
}
项目:PlusGram    文件:ProfileActivity.java   
private void updateTheme(){
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
    try{

        Drawable floatingDrawableWhite = getParentActivity().getResources().getDrawable(R.drawable.floating_white);
        if(floatingDrawableWhite != null)floatingDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingBGColor", def), PorterDuff.Mode.MULTIPLY);
        floatingButton.setBackgroundDrawable(floatingDrawableWhite);
        Drawable pencilDrawableWhite = getParentActivity().getResources().getDrawable(R.drawable.ic_float_sms);
        if(pencilDrawableWhite != null)pencilDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingPencilColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
        floatingButton.setImageDrawable(pencilDrawableWhite);
    } catch (NullPointerException e) {
        FileLog.e("tmessages", e);
    }

}
项目:RLibrary    文件:RDownloadView.java   
private void initView(Context context) {
        normalDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_download);
        finishDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_yixiazai);
        if (isInEditMode()) {
            SkinHelper.init(context);
        } else {
            finishDrawable.mutate().setColorFilter(SkinHelper.getSkin().getThemeSubColor(), PorterDuff.Mode.MULTIPLY);
        }

        normalDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());
        finishDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mStrokeWidth = 2 * getResources().getDisplayMetrics().density;
        mPaint.setStrokeWidth(mStrokeWidth);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);//设置笔触的模式
//        mPaint.setStrokeJoin(Paint.Join.ROUND);//设置连接模式, 在绘制矩形各个角的时候有效果

        oval = new RectF();
    }
项目:Asteroid    文件:ImageUtils.java   
public static Bitmap gradientBitmap(Bitmap src, int color1, int color2) {
    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);

    canvas.drawBitmap(src, 0, 0, null);

    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0, 0, 0, height, color1, color2, Shader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawRect(0, 0, width, height, paint);

    return result;
}
项目:LucaHome-AndroidApplication    文件:Tools.java   
public static Bitmap GetCircleBitmap(@NonNull Bitmap bitmap) {
    final Bitmap output = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);

    final int color = Color.BLACK;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getHeight(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawOval(rectF, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    bitmap.recycle();

    return output;
}
项目:MyNotes    文件:ColorStateDrawable.java   
@Override
protected boolean onStateChange(int[] states) {
    boolean pressedOrFocused = false;
    for (int state : states) {
        if (state == android.R.attr.state_pressed || state == android.R.attr.state_focused) {
            pressedOrFocused = true;
            break;
        }
    }

    if (pressedOrFocused) {
        super.setColorFilter(getPressedColor(mColor), PorterDuff.Mode.SRC_ATOP);
    } else {
        super.setColorFilter(mColor, PorterDuff.Mode.SRC_ATOP);
    }

    return super.onStateChange(states);
}
项目:Hello-Music-droid    文件:Timber6.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(
            R.layout.fragment_timber6, container, false);

    setMusicStateListener();
    setSongDetails(rootView);

    initGestures(rootView.findViewById(R.id.album_art));

    ((SeekBar) rootView.findViewById(R.id.song_progress)).getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY));
    ((SeekBar) rootView.findViewById(R.id.song_progress)).getThumb().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP));

    nextSong = (TextView) rootView.findViewById(R.id.title_next);
    nextArt = (CircleImageView) rootView.findViewById(R.id.album_art_next);

    rootView.findViewById(R.id.nextView).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            MusicPlayer.setQueuePosition(MusicPlayer.getQueuePosition() + 1);
        }
    });

    return rootView;
}
项目:betterHotels    文件:CalendarActivity.java   
private void initializeToolbar() {

        Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);

        setSupportActionBar(mToolbar);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("");
        final Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_black_24dp);
        upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
//        mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
项目:GitHub    文件:MDTintHelper.java   
private static void setTint(@NonNull ProgressBar progressBar,
                            @ColorInt int color,
                            boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
项目:Matisse    文件:AlbumsSpinner.java   
public void setSelectedTextView(TextView textView) {
    mSelected = textView;
    // tint dropdown arrow icon
    Drawable[] drawables = mSelected.getCompoundDrawables();
    Drawable right = drawables[2];
    TypedArray ta = mSelected.getContext().getTheme().obtainStyledAttributes(
            new int[]{R.attr.album_element_color});
    int color = ta.getColor(0, 0);
    ta.recycle();
    right.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    mSelected.setVisibility(View.GONE);
    mSelected.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int itemHeight = v.getResources().getDimensionPixelSize(R.dimen.album_item_height);
            mListPopupWindow.setHeight(
                    mAdapter.getCount() > MAX_SHOWN_COUNT ? itemHeight * MAX_SHOWN_COUNT
                            : itemHeight * mAdapter.getCount());
            mListPopupWindow.show();
        }
    });
    mSelected.setOnTouchListener(mListPopupWindow.createDragToOpenListener(mSelected));
}
项目:MusicX-music-player    文件:ToolbarProcessor.java   
@SuppressWarnings("unchecked")
public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu, final @ColorInt int color) {
    try {
        final Field field = Toolbar.class.getDeclaredField("mCollapseIcon");
        field.setAccessible(true);
        Drawable collapseIcon = (Drawable) field.get(toolbar);
        if (collapseIcon != null) {
            field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, color));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // credits: https://snow.dog/blog/how-to-dynamicaly-change-android-toolbar-icons-color/
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        final View v = toolbar.getChildAt(i);
        // We can't iterate through the toolbar.getMenu() here, because we need the ActionMenuItemView. ATEActionMenuItemView is overriding the item icon tint color.
        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                    for (int k = 0; k < drawablesCount; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            ((ActionMenuItemView) innerView).getCompoundDrawables()[k].setColorFilter(colorFilter);
                        }
                    }
                }
            }
        }
    }

    if (menu == null)
        menu = toolbar.getMenu();
    if (menu != null && menu.size() > 0) {
        for (int i = 0; i < menu.size(); i++) {
            final MenuItem item = menu.getItem(i);
            // We must iterate through the toolbar.getMenu() too, to keep the tint when resuming the paused activity.
            if (item.getIcon() != null) {
                item.setIcon(TintHelper.createTintedDrawable(item.getIcon(), color));
            }
            // Search view theming
            if (item.getActionView() != null && (item.getActionView() instanceof android.widget.SearchView || item.getActionView() instanceof android.support.v7.widget.SearchView)) {
                SearchViewTintUtil.setSearchViewContentColor(item.getActionView(), color);
            }
        }
    }
}
项目:kibou-game-library    文件:SettingsActivity.java   
private void setControls() {
    iconNumber = (Spinner) findViewById(R.id.stIconNumber);

    List<String> spinnerArray = new ArrayList<>();
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_BIG));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_MEDIUM));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOW));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWER));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWEST));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWESTER));
    spinnerArray.add(String.valueOf(Const.ICONS_SIZE.ICONS_LOWESTEREST));

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            R.layout.spinner_item, spinnerArray);

    iconNumber.setAdapter(adapter);
    iconNumber.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);

    iconNumber.setSelection(selectedPosition, true);

    btnChooseWallpaper = (Button) findViewById(R.id.stWallpaperButton);
    btnChooseWallpaper.setOnClickListener(this);
    btnWallpaperDefault = (Button) findViewById(R.id.stWallpaperButtonDefault);
    btnWallpaperDefault.setOnClickListener(this);
    txtCustomTitle = (EditText) findViewById(R.id.stCustomTitleValue);
}
项目:MusicX-music-player    文件:RoundRectImageView.java   
private void init() {
    //without hardware level gpu more
    setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mColor = Color.argb(100, 200, 50, 50);
    mCirclePaint = new Paint();
    mCirclePaint.setStyle(Paint.Style.FILL);
    mCirclePaint.setColor(mColor);
    mCirclePaint.setAntiAlias(true);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(Color.BLACK);

    mMaskPaint = new Paint();
    mMaskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
}
项目:PeSanKita-android    文件:ShapeScrim.java   
public ShapeScrim(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  if (attrs != null) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShapeScrim, 0, 0);
    String     shapeName  = typedArray.getString(R.styleable.ShapeScrim_shape);

    if      ("square".equalsIgnoreCase(shapeName)) this.shape = ShapeType.SQUARE;
    else if ("circle".equalsIgnoreCase(shapeName)) this.shape = ShapeType.CIRCLE;
    else                                           this.shape = ShapeType.SQUARE;

    this.radius = typedArray.getFloat(R.styleable.ShapeScrim_radius, 0.4f);

    typedArray.recycle();
  } else {
    this.shape  = ShapeType.SQUARE;
    this.radius = 0.4f;
  }

  this.eraser = new Paint();
  this.eraser.setColor(0xFFFFFFFF);
  this.eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
}
项目:AggregationNews    文件:MainActivity.java   
private void initTab() {
    TextView firstView = (TextView) LayoutInflater.from(this).inflate(R.layout.bottom_tab_item, null);
    firstView.setText(mTabResources[0][0]);
    firstView.setTextColor(ContextCompat.getColor(MainActivity.this, R.color.colorPrimary));
    firstView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, Integer.valueOf(mTabResources[0][1]), 0, 0);
    firstView.getCompoundDrawables()[1].setColorFilter(ContextCompat.getColor(MainActivity.this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
    mTabLayout.getTabAt(0).setCustomView(firstView);

    for (int i = 1; i < 3; i++) {
        TextView textView = (TextView) LayoutInflater.from(this).inflate(R.layout.bottom_tab_item, null);
        textView.setText(mTabResources[i][0]);
        textView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, Integer.valueOf(mTabResources[i][1]), 0, 0);
        mTabLayout.getTabAt(i).setCustomView(textView);
    }

}
项目:android_ui    文件:ViewPagerWidget.java   
/**
 */
@Override
@SuppressWarnings("ResourceType")
void onProcessTintAttributes(Context context, TypedArray tintAttributes, int tintColor) {
    if (UiConfig.MATERIALIZED) {
        if (tintAttributes.hasValue(R.styleable.Ui_ViewPager_uiBackgroundTint)) {
            setBackgroundTintList(tintAttributes.getColorStateList(R.styleable.Ui_ViewPager_uiBackgroundTint));
        }
        if (tintAttributes.hasValue(R.styleable.Ui_ViewPager_uiBackgroundTintMode)) {
            setBackgroundTintMode(TintManager.parseTintMode(
                    tintAttributes.getInt(R.styleable.Ui_ViewPager_uiBackgroundTintMode, 0),
                    PorterDuff.Mode.SRC_IN
            ));
        }
    } else {
        if (tintAttributes.hasValue(R.styleable.Ui_ViewPager_uiBackgroundTint)) {
            mTintInfo.backgroundTintList = tintAttributes.getColorStateList(R.styleable.Ui_ViewPager_uiBackgroundTint);
        }
        mTintInfo.backgroundTintMode = TintManager.parseTintMode(
                tintAttributes.getInt(R.styleable.Ui_ViewPager_uiBackgroundTintMode, 0),
                mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null
        );
    }
}
项目:ImageLoaderProcessor    文件:PicassoLoaderProcessor.java   
@Override
public Bitmap transform(Bitmap source) {
    float roundPx = bitmapAngle;//角度
    Bitmap output = Bitmap.createBitmap(source.getWidth(),
            source.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, source.getWidth(), source.getHeight());
    final RectF rectF = new RectF(rect);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(source, rect, rect, paint);
    source.recycle();
    return output;
}
项目:materialExpansionPanel    文件:ExpandableUtils.java   
static Bitmap getCircleBitmap(Drawable drawable, int color) {
    Bitmap bitmap = drawableToBitmap(drawable);

    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
项目:TapIn    文件:employeeTimetable.java   
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view);

    cid = getIntent().getExtras().getString("cid");
    day = getIntent().getExtras().getString("day");
    month = getIntent().getExtras().getString("month");
    year = getIntent().getExtras().getString("year");

    setTitle("Schedule for Date: "+day+"/"+month+"/"+year);

    spinner = (ProgressBar)findViewById(R.id.progressBar2);
    spinner.setVisibility(View.VISIBLE);
    spinner.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);

    listView = (ListView)findViewById(R.id.employeeList);

    currentEmployees = new ArrayList<Employee>();
    getCurrentEmployees();
}
项目:NovelReader    文件:CircleTransform.java   
/**
 *
 * @param pool : 图片池,这个之后会谈到。
 * @param toTransform:需要进行处理的图片
 * @param outWidth:图片的宽
 * @param outHeight:图片的高
 * @return 返回处理完的图片
 */
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
    Paint paint = new Paint();
    //初始化画笔
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
    paint.setDither(true);

    int width = toTransform.getWidth();
    int height = toTransform.getHeight();
    int size = Math.min(width,height);
    int x = (width - size)/2;
    int y = (height - size)/2;
    Bitmap result = pool.get(size,size, Bitmap.Config.ARGB_8888);
    if (result == null){
        result = Bitmap.createBitmap(size,size,Bitmap.Config.ARGB_8888);
    }
    //
    Canvas canvas = new Canvas(result);
    int radius = size/2;
    canvas.drawCircle(radius,radius,radius,paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(toTransform,-x,-y,paint);
    return result;
}
项目:SuperRecyclerView    文件:SuperRecyclerAdapter.java   
private void applyFilterToImages(HashMap<Integer, Integer> views, ArrayList<FilterApplicator> filterApplicators) {
    for (final HashMap.Entry<Integer, Integer> entry: views.entrySet()) {
        boolean canApplyFilter = true;
        if (filterApplicators.size() > 0) {
            for (int i = 0;i < filterApplicators.size() && canApplyFilter;i++) {
                canApplyFilter = filterApplicators.get(i).canApplyFilter(getLayoutPosition());
            }
        }
        View view = itemView.findViewById(entry.getKey());
        int color = itemView.getResources().getColor(mDefaultFilter);
        if (canApplyFilter) {
            color = itemView.getResources().getColor(entry.getValue());
        }
        if (view instanceof ImageView) {
            ((ImageView) view)
                    .setColorFilter(
                            color,
                            PorterDuff.Mode.SRC_IN
                    );
        } else if (view instanceof TextView) {
            ((TextView) view)
                    .setTextColor(color);
        }
    }
}
项目:Rxjava2.0Demo    文件:BitmapUtil.java   
public static Bitmap toRoundCorner(Bitmap bitmap) {
    int height = bitmap.getHeight();
    int width = bitmap.getHeight();
    Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(output);

    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, width, height);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    //paint.setColor(0xff424242);
    paint.setColor(Color.TRANSPARENT);
    canvas.drawCircle(width / 2, height / 2, width / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
项目:phonk    文件:ProjectListFragment.java   
public View highlight(String projectName, boolean b) {
    View v = mGrid.findViewWithTag(projectName);
    v.setSelected(b);
    //TODO reenable this
    //mProjectAdapter.mData.get(mProjectAdapter.findAppIdByName(projectName)).selected = true;
    v.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);

    return v;
}
项目:Assertive-Touch    文件:ATButton.java   
public void setBackgroundColor(int color) {

        Drawable mDrawable = mApp.getResources().getDrawable(R.drawable.circle_button);
        mDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            quickActionButton.setBackgroundDrawable(mDrawable);
        } else {
            quickActionButton.setBackground(mDrawable);
        }
    }
项目:RNLearn_Project1    文件:ReactSliderManager.java   
@ReactProp(name = "thumbTintColor", customType = "Color")
public void setThumbTintColor(ReactSlider view, Integer color) {
  if (color == null) {
    view.getThumb().clearColorFilter();
  } else {
    view.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
  }
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:HoverMenuAdapter.java   
public void setIcon(@Nullable Drawable icon) {
    mIconDrawable = icon;
    if (null != mForegroundColor && null != mIconDrawable) {
        mIconDrawable.setColorFilter(mForegroundColor, PorterDuff.Mode.SRC_ATOP);
    }
    updateIconBounds();

    invalidate();
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:ToolbarMenuItem.java   
public static Drawable convertDrawableToGrayScale(Drawable drawable, int color) {
    if (drawable == null || drawable.getConstantState() == null)
        return null;
    Drawable res = drawable.getConstantState().newDrawable().mutate();
    res.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    return res;
}
项目:YiZhi    文件:ClipView.java   
public ClipView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    //去锯齿
    paint.setAntiAlias(true);
    borderPaint.setStyle(Paint.Style.STROKE);
    borderPaint.setColor(Color.WHITE);
    borderPaint.setStrokeWidth(clipBorderWidth);
    borderPaint.setAntiAlias(true);
    xfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_OUT);
}
项目:OneWeather    文件:SunriseSunset.java   
private void init(AttributeSet attrs) {
    if(attrs != null){
        TypedArray typedArray = mContext.obtainStyledAttributes(attrs,R.styleable.SunriseSunset);
        lineColor = typedArray.getColor(R.styleable.SunriseSunset_lineColor, Color.WHITE);
        sunColor = typedArray.getColor(R.styleable.SunriseSunset_sunColor,Color.YELLOW);
        timeTextColor = typedArray.getColor(R.styleable.SunriseSunset_timeTextColor,Color.GRAY);
        timeTextSize = typedArray.getDimension(R.styleable.SunriseSunset_timeTextSize,40);
        typedArray.recycle();
    }
    mCenterPoint = new Point();
    mArcPaint = new Paint();
    mArcPaint.setAntiAlias(true);
    mArcPaint.setColor(lineColor);
    mArcPaint.setStyle(Paint.Style.STROKE);
    mArcPaint.setStrokeWidth(3);
    mArcPaint.setPathEffect(new DashPathEffect(new float[]{20,15},20));
    mArcPaint.setStrokeCap(Paint.Cap.ROUND);
    mRectF = new RectF();


    mSunPaint = new Paint();
    mSunPaint.setAntiAlias(true);
    mSunPaint.setColor(sunColor);
    mSunPaint.setStyle(Paint.Style.STROKE);
    mSunPaint.setStrokeWidth(3);
    mSunPaint.setPathEffect(new DashPathEffect(new float[]{20,15},20));
    mSunriseBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_sunrise);
    mSunsetBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_sunset);
    mSunPaint.setColorFilter( new PorterDuffColorFilter(sunColor, PorterDuff.Mode.SRC_ATOP)) ;//设置后bitmap才会填充颜色

    mTimePaint = new Paint();
    mTimePaint.setColor(timeTextColor);
    mTimePaint.setTextSize(timeTextSize);
    mTimePaint.setTextAlign(Paint.Align.CENTER);



}
项目:Mix    文件:ThemeUtils.java   
public static Drawable tintDrawable(Drawable drawable, @ColorInt int color, PorterDuff.Mode mode) {
    if (drawable == null) return null;
    Drawable wrapper = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTint(wrapper, color);
    DrawableCompat.setTintMode(drawable, mode);
    return wrapper;
}
项目:NoInternetDialog    文件:NoInternetDialog.java   
private void initButtonStyle() {
    wifiOn.getBackground().mutate().setColorFilter(buttonColor, PorterDuff.Mode.SRC_IN);
    mobileOn.getBackground().mutate().setColorFilter(buttonColor, PorterDuff.Mode.SRC_IN);
    airplaneOff.getBackground().mutate().setColorFilter(buttonColor, PorterDuff.Mode.SRC_IN);

    wifiOn.setTextColor(buttonTextColor);
    mobileOn.setTextColor(buttonTextColor);
    airplaneOff.setTextColor(buttonTextColor);

    Drawable wifi = ContextCompat.getDrawable(getContext(), R.drawable.ic_wifi_white);
    Drawable mobileData = ContextCompat.getDrawable(getContext(), R.drawable.ic_4g_white);
    Drawable airplane = ContextCompat.getDrawable(getContext(), R.drawable.ic_airplane_off);

    wifi.mutate().setColorFilter(buttonIconsColor, PorterDuff.Mode.SRC_ATOP);
    mobileData.mutate().setColorFilter(buttonIconsColor, PorterDuff.Mode.SRC_ATOP);
    airplane.mutate().setColorFilter(buttonIconsColor, PorterDuff.Mode.SRC_ATOP);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        wifiOn.setCompoundDrawablesRelativeWithIntrinsicBounds(wifi, null, null, null);
        mobileOn.setCompoundDrawablesRelativeWithIntrinsicBounds(mobileData, null, null, null);
        airplaneOff.setCompoundDrawablesRelativeWithIntrinsicBounds(airplane, null, null, null);
    } else {
        wifiOn.setCompoundDrawablesWithIntrinsicBounds(wifi, null, null, null);
        mobileOn.setCompoundDrawablesWithIntrinsicBounds(mobileData, null, null, null);
        airplaneOff.setCompoundDrawablesWithIntrinsicBounds(airplane, null, null, null);
    }
}
项目:PlusGram    文件:Slate.java   
public void clear() {
    if (mTiledCanvas != null) {
        commitStroke();
        mTiledCanvas.drawColor(0x00000000, PorterDuff.Mode.SRC);
        invalidate();
    } else if (mPendingPaintBitmap != null) { // FIXME for tiling
        mPendingPaintBitmap.recycle();
        mPendingPaintBitmap = null;
    }
    mEmpty = true;

    // reset the zoom when clearing
    resetZoom();
}
项目:FlickLauncher    文件:PendingAppWidgetHostView.java   
private void updateSettingColor() {
    int color = Utilities.findDominantColorByHue(mIcon, 20);
    // Make the dominant color bright.
    float[] hsv = new float[3];
    Color.colorToHSV(color, hsv);
    hsv[1] = Math.min(hsv[1], MIN_SATUNATION);
    hsv[2] = 1;
    color = Color.HSVToColor(hsv);

    mSettingIconDrawable.setColorFilter(color,  PorterDuff.Mode.SRC_IN);
}
项目:GitHub    文件:BindingUtils.java   
@BindingAdapter({"roundImageUrl"})
public static void loadRoundImg(ImageView v, String url) {
    v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
    Glide.with(v.getContext())
            .load(getFuckUrl(url))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .transform(new GlideCircleTransform(v.getContext()))
            .error(R.mipmap.ic_launcher)
            .into(v);
}
项目:zxing_qrcode_demo    文件:ViewfinderView.java   
/**
 * 绘制有四个圆角的取景框边框
 *
 * @return
 */
private void drawRoundRectForeground(Canvas canvas, Rect frame) {
    paint.setColor(Color.TRANSPARENT);
    paint.setStyle(Paint.Style.FILL);
    paint.setAlpha(60);

    //set mode为clear
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));

    canvas.drawRoundRect(new RectF(frame.left, frame.top, frame.right, frame.bottom + scanLineHeight), radius, radius, paint);
    paint.setXfermode(null);
}
项目:airgram    文件:ResourceLoader.java   
public static void fantasyChanged(boolean fantasy){
    Context c= ApplicationLoader.applicationContext;
    loadRecources(c);

    if(fantasy){
        checkDrawableF.setColorFilter(0xff68a7ad, PorterDuff.Mode.SRC_ATOP);
        halfCheckDrawableF.setColorFilter(0xff68a7ad, PorterDuff.Mode.SRC_ATOP);
        clockDrawableF.setColorFilter(0xff68a7ad, PorterDuff.Mode.SRC_ATOP);
        viewsOutCountDrawableF.setColorFilter(0xff68a7ad, PorterDuff.Mode.SRC_ATOP);
        viewsCountDrawableF.setColorFilter(0xffb5a564, PorterDuff.Mode.SRC_ATOP);
        broadcastDrawableF.setColorFilter(0xff68a7ad, PorterDuff.Mode.SRC_ATOP);
        docMenuDrawableF[0].setColorFilter(ChatBaseColors.timeInF, PorterDuff.Mode.SRC_ATOP);
        docMenuDrawableF[1].setColorFilter(ChatBaseColors.timeOutF, PorterDuff.Mode.SRC_ATOP);
        docMenuDrawableF[2].setColorFilter(ChatBaseColors.timeInSelectedF, PorterDuff.Mode.SRC_ATOP);
    }else {
        checkDrawableF.clearColorFilter();
        halfCheckDrawableF.clearColorFilter();
        clockDrawableF.clearColorFilter();
        viewsOutCountDrawableF.clearColorFilter();
        viewsCountDrawableF.clearColorFilter();
        broadcastDrawableF.clearColorFilter();
        docMenuDrawableF[0].clearColorFilter();
        docMenuDrawableF[1].clearColorFilter();
        docMenuDrawableF[2].clearColorFilter();
    }

}