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));
}
java类android.graphics.PorterDuff的实例源码
LogsAdapter.java 文件源码
项目:Phoenix-for-VK
阅读 31
收藏 0
点赞 0
评论 0
AboutActivity.java 文件源码
项目:QuranAndroid
阅读 47
收藏 0
点赞 0
评论 0
@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);
}
Tools.java 文件源码
项目:Blogg
阅读 38
收藏 0
点赞 0
评论 0
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;
}
BotHelpCell.java 文件源码
项目:PlusGram
阅读 32
收藏 0
点赞 0
评论 0
@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();
}
CircleColorImageView.java 文件源码
项目:Cable-Android
阅读 30
收藏 0
点赞 0
评论 0
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);
}
ProfileActivity.java 文件源码
项目:PlusGram
阅读 42
收藏 0
点赞 0
评论 0
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);
}
}
RDownloadView.java 文件源码
项目:RLibrary
阅读 28
收藏 0
点赞 0
评论 0
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();
}
ImageUtils.java 文件源码
项目:Asteroid
阅读 43
收藏 0
点赞 0
评论 0
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;
}
Tools.java 文件源码
项目:LucaHome-AndroidApplication
阅读 41
收藏 0
点赞 0
评论 0
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;
}
ColorStateDrawable.java 文件源码
项目:MyNotes
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
Timber6.java 文件源码
项目:Hello-Music-droid
阅读 44
收藏 0
点赞 0
评论 0
@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;
}
CalendarActivity.java 文件源码
项目:betterHotels
阅读 36
收藏 0
点赞 0
评论 0
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();
}
});
}
MDTintHelper.java 文件源码
项目:GitHub
阅读 31
收藏 0
点赞 0
评论 0
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);
}
}
AlbumsSpinner.java 文件源码
项目:Matisse
阅读 29
收藏 0
点赞 0
评论 0
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));
}
ToolbarProcessor.java 文件源码
项目:MusicX-music-player
阅读 29
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
SettingsActivity.java 文件源码
项目:kibou-game-library
阅读 40
收藏 0
点赞 0
评论 0
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);
}
RoundRectImageView.java 文件源码
项目:MusicX-music-player
阅读 47
收藏 0
点赞 0
评论 0
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));
}
ShapeScrim.java 文件源码
项目:PeSanKita-android
阅读 33
收藏 0
点赞 0
评论 0
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));
}
MainActivity.java 文件源码
项目:AggregationNews
阅读 34
收藏 0
点赞 0
评论 0
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);
}
}
ViewPagerWidget.java 文件源码
项目:android_ui
阅读 50
收藏 0
点赞 0
评论 0
/**
*/
@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
);
}
}
PicassoLoaderProcessor.java 文件源码
项目:ImageLoaderProcessor
阅读 43
收藏 0
点赞 0
评论 0
@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;
}
ExpandableUtils.java 文件源码
项目:materialExpansionPanel
阅读 43
收藏 0
点赞 0
评论 0
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;
}
employeeTimetable.java 文件源码
项目:TapIn
阅读 24
收藏 0
点赞 0
评论 0
@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();
}
CircleTransform.java 文件源码
项目:NovelReader
阅读 38
收藏 0
点赞 0
评论 0
/**
*
* @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;
}
SuperRecyclerAdapter.java 文件源码
项目:SuperRecyclerView
阅读 38
收藏 0
点赞 0
评论 0
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);
}
}
}
BitmapUtil.java 文件源码
项目:Rxjava2.0Demo
阅读 47
收藏 0
点赞 0
评论 0
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;
}
ProjectListFragment.java 文件源码
项目:phonk
阅读 39
收藏 0
点赞 0
评论 0
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;
}
ATButton.java 文件源码
项目:Assertive-Touch
阅读 32
收藏 0
点赞 0
评论 0
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);
}
}
ReactSliderManager.java 文件源码
项目:RNLearn_Project1
阅读 37
收藏 0
点赞 0
评论 0
@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);
}
}
HoverMenuAdapter.java 文件源码
项目:https-github.com-hyb1996-NoRootScriptDroid
阅读 30
收藏 0
点赞 0
评论 0
public void setIcon(@Nullable Drawable icon) {
mIconDrawable = icon;
if (null != mForegroundColor && null != mIconDrawable) {
mIconDrawable.setColorFilter(mForegroundColor, PorterDuff.Mode.SRC_ATOP);
}
updateIconBounds();
invalidate();
}