use of android.graphics.drawable.ScaleDrawable in project AndroidTraining by mixi-inc.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Handler handler = new Handler();
final Timer timer = new Timer();
// 5秒ごとにレベルを変更するタスク
final Drawable levelListDrawable = findViewById(R.id.LevelListButton).getBackground();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
final int level = levelListDrawable.getLevel();
handler.post(new Runnable() {
@Override
public void run() {
if (level == 0) {
levelListDrawable.setLevel(1);
} else {
levelListDrawable.setLevel(0);
}
}
});
}
}, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
// クロスフェードを開始する
final TransitionDrawable transition = (TransitionDrawable) findViewById(R.id.TransitionView).getBackground();
transition.startTransition(TRANSITION_DURATION);
// 5秒ごとにレベルを変更し、クリップの範囲を変化させるタスク
final ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.ClipView).getBackground();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
clipDrawable.setLevel(clipDrawable.getLevel() + 1000);
}
});
}
}, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
// スケールのレベルを変更する
ScaleDrawable scale = (ScaleDrawable) findViewById(R.id.ScaleView).getBackground();
scale.setLevel(1);
}
use of android.graphics.drawable.ScaleDrawable in project ListenerMusicPlayer by hefuyicoder.
the class QuickControlsFragment method setPalette.
@Override
public void setPalette(Palette palette) {
mSwatch = ColorUtil.getMostPopulousSwatch(palette);
int paletteColor;
if (mSwatch != null) {
paletteColor = mSwatch.getRgb();
int artistColor = mSwatch.getTitleTextColor();
mTitle.setTextColor(ColorUtil.getOpaqueColor(artistColor));
mArtist.setTextColor(artistColor);
} else {
mSwatch = palette.getMutedSwatch() == null ? palette.getVibrantSwatch() : palette.getMutedSwatch();
if (mSwatch != null) {
paletteColor = mSwatch.getRgb();
int artistColor = mSwatch.getTitleTextColor();
mTitle.setTextColor(ColorUtil.getOpaqueColor(artistColor));
mArtist.setTextColor(artistColor);
} else {
paletteColor = ATEUtil.getThemeAlbumDefaultPaletteColor(getContext());
mTitle.setTextColor(getResources().getColor(android.R.color.primary_text_light));
mArtist.setTextColor(getResources().getColor(android.R.color.secondary_text_light));
}
}
//set icon color
blackWhiteColor = ColorUtil.getBlackWhiteColor(paletteColor);
topContainer.setBackgroundColor(paletteColor);
if (bottomDialogFragment != null && mSwatch != null) {
bottomDialogFragment.setPaletteSwatch(mSwatch);
}
mLyricView.setHighLightTextColor(blackWhiteColor);
mLyricView.setDefaultColor(blackWhiteColor);
mLyricView.setTouchable(false);
mLyricView.setHintColor(blackWhiteColor);
mPlayPauseView.setDrawableColor(blackWhiteColor);
mPlayPauseView.setCircleColor(blackWhiteColor);
mPlayPauseView.setCircleAlpah(0);
mPlayPauseView.setEnabled(true);
next.setEnabled(true);
next.setColor(blackWhiteColor);
previous.setColor(blackWhiteColor);
next.setColor(blackWhiteColor);
iconPlayQueue.setColor(blackWhiteColor);
//set timely color
setTimelyColor(blackWhiteColor);
//set seekbar progressdrawable
ScaleDrawable scaleDrawable = (ScaleDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable()).findDrawableByLayerId(R.id.progress);
GradientDrawable gradientDrawable = (GradientDrawable) scaleDrawable.getDrawable();
gradientDrawable.setColors(new int[] { blackWhiteColor, blackWhiteColor, blackWhiteColor });
mIsFavorite = FavoriteSong.getInstance(getContext()).isFavorite(MusicPlayer.getCurrentAudioId());
if (mIsFavorite) {
favorite.setColor(Color.parseColor("#E97767"));
} else {
favorite.setColor(blackWhiteColor);
}
//set albumart foreground
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
mAlbumArt.setForeground(ScrimUtil.makeCubicGradientScrimDrawable(//颜色
paletteColor, //渐变层数
8, //起始方向
Gravity.CENTER_HORIZONTAL));
}
if (sListener != null) {
sListener.onPaletteColorChange(paletteColor, blackWhiteColor);
}
}
use of android.graphics.drawable.ScaleDrawable in project ListenerMusicPlayer by hefuyicoder.
the class QuickControlsFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ATE.apply(this, ATEUtil.getATEKey(getActivity()));
mSlidingUpPanelLayout = (SlidingUpPanelLayout) view.getParent().getParent();
setUpPopupMenu(popupMenu);
mLyricView.setLineSpace(15.0f);
mLyricView.setTextSize(17.0f);
mLyricView.setPlayable(false);
mLyricView.setTranslationY(DensityUtil.getScreenWidth(getActivity()) + DensityUtil.dip2px(getActivity(), 120));
mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() {
@Override
public void onPlayerClicked(long progress, String content) {
MusicPlayer.seek((long) progress);
if (!MusicPlayer.isPlaying()) {
mPresenter.onPlayPauseClick();
}
}
});
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mProgress.getLayoutParams();
mProgress.measure(0, 0);
layoutParams.setMargins(0, -(mProgress.getMeasuredHeight() / 2), 0, 0);
mProgress.setLayoutParams(layoutParams);
ScaleDrawable scaleDrawable = (ScaleDrawable) ((LayerDrawable) mProgress.getProgressDrawable()).findDrawableByLayerId(R.id.progress);
GradientDrawable gradientDrawable = (GradientDrawable) scaleDrawable.getDrawable();
int colorAccent = ATEUtil.getThemeAccentColor(getActivity());
gradientDrawable.setColors(new int[] { colorAccent, colorAccent, colorAccent });
//清除默认的左右边距
mSeekBar.setPadding(0, DensityUtil.dip2px(getContext(), 36), 0, 0);
mSeekBar.setSecondaryProgress(mSeekBar.getMax());
songElapsedTime.setY((DensityUtil.getScreenWidth(getContext()) - songElapsedTime.getHeight()) / 2);
setUpTimelyView();
setSeekBarListener();
if (mPlayPauseView != null) {
if (MusicPlayer.isPlaying())
mPlayPauseView.Play();
else
mPlayPauseView.Pause();
}
subscribeFavourateSongEvent();
subscribeMetaChangedEvent();
}
use of android.graphics.drawable.ScaleDrawable in project Shuttle by timusus.
the class SizableSeekBar method setThumb.
@Override
public void setThumb(Drawable thumb) {
if (thumb == null) {
return;
}
if (!(thumb instanceof ScaleDrawable)) {
thumb = new ScaleDrawable(thumb, Gravity.CENTER, 1.0F, 1.0F);
}
this.thumb = thumb;
int level = (int) (10000F * (1.0F / maxThumbSizeRatio));
this.thumb.setLevel(level);
super.setThumb(this.thumb);
}
use of android.graphics.drawable.ScaleDrawable in project FastHub by k0shk0sh.
the class FontTextView method setEventsIcon.
public void setEventsIcon(@DrawableRes int drawableRes) {
Drawable drawable = ContextCompat.getDrawable(getContext(), drawableRes);
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, width / 2, height / 2);
ScaleDrawable sd = new ScaleDrawable(drawable, Gravity.CENTER, 0.6f, 0.6f);
sd.setLevel(8000);
ViewHelper.tintDrawable(drawable, ViewHelper.getTertiaryTextColor(getContext()));
setCompoundDrawablesWithIntrinsicBounds(sd, null, null, null);
}
Aggregations