use of android.graphics.drawable.ColorDrawable in project weiciyuan by qii.
the class GalleryAnimationActivity method showBackgroundImmediately.
public void showBackgroundImmediately() {
if (background.getBackground() == null) {
backgroundColor = new ColorDrawable(Color.BLACK);
background.setBackground(backgroundColor);
}
}
use of android.graphics.drawable.ColorDrawable in project platform_frameworks_base by android.
the class PhoneStatusBar method updateMediaMetaData.
/**
* Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper.
*/
public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) {
Trace.beginSection("PhoneStatusBar#updateMediaMetaData");
if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) {
Trace.endSection();
return;
}
if (mBackdrop == null) {
Trace.endSection();
// called too early
return;
}
if (mLaunchTransitionFadingAway) {
mBackdrop.setVisibility(View.INVISIBLE);
Trace.endSection();
return;
}
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: updating album art for notification " + mMediaNotificationKey + " metadata=" + mMediaMetadata + " metaDataChanged=" + metaDataChanged + " state=" + mState);
}
Drawable artworkDrawable = null;
if (mMediaMetadata != null) {
Bitmap artworkBitmap = null;
artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART);
if (artworkBitmap == null) {
artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);
// might still be null
}
if (artworkBitmap != null) {
artworkDrawable = new BitmapDrawable(mBackdropBack.getResources(), artworkBitmap);
}
}
boolean allowWhenShade = false;
if (ENABLE_LOCKSCREEN_WALLPAPER && artworkDrawable == null) {
Bitmap lockWallpaper = mLockscreenWallpaper.getBitmap();
if (lockWallpaper != null) {
artworkDrawable = new LockscreenWallpaper.WallpaperDrawable(mBackdropBack.getResources(), lockWallpaper);
// We're in the SHADE mode on the SIM screen - yet we still need to show
// the lockscreen wallpaper in that mode.
allowWhenShade = mStatusBarKeyguardViewManager != null && mStatusBarKeyguardViewManager.isShowing();
}
}
boolean hideBecauseOccluded = mStatusBarKeyguardViewManager != null && mStatusBarKeyguardViewManager.isOccluded();
final boolean hasArtwork = artworkDrawable != null;
if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) && (mState != StatusBarState.SHADE || allowWhenShade) && mFingerprintUnlockController.getMode() != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING && !hideBecauseOccluded) {
// time to show some art!
if (mBackdrop.getVisibility() != View.VISIBLE) {
mBackdrop.setVisibility(View.VISIBLE);
if (allowEnterAnimation) {
mBackdrop.setAlpha(SRC_MIN_ALPHA);
mBackdrop.animate().alpha(1f);
} else {
mBackdrop.animate().cancel();
mBackdrop.setAlpha(1f);
}
mStatusBarWindowManager.setBackdropShowing(true);
metaDataChanged = true;
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork");
}
}
if (metaDataChanged) {
if (mBackdropBack.getDrawable() != null) {
Drawable drawable = mBackdropBack.getDrawable().getConstantState().newDrawable(mBackdropFront.getResources()).mutate();
mBackdropFront.setImageDrawable(drawable);
if (mScrimSrcModeEnabled) {
mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
}
mBackdropFront.setAlpha(1f);
mBackdropFront.setVisibility(View.VISIBLE);
} else {
mBackdropFront.setVisibility(View.INVISIBLE);
}
if (DEBUG_MEDIA_FAKE_ARTWORK) {
final int c = 0xFF000000 | (int) (Math.random() * 0xFFFFFF);
Log.v(TAG, String.format("DEBUG_MEDIA: setting new color: 0x%08x", c));
mBackdropBack.setBackgroundColor(0xFFFFFFFF);
mBackdropBack.setImageDrawable(new ColorDrawable(c));
} else {
mBackdropBack.setImageDrawable(artworkDrawable);
}
if (mScrimSrcModeEnabled) {
mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
}
if (mBackdropFront.getVisibility() == View.VISIBLE) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Crossfading album artwork from " + mBackdropFront.getDrawable() + " to " + mBackdropBack.getDrawable());
}
mBackdropFront.animate().setDuration(250).alpha(0f).withEndAction(mHideBackdropFront);
}
}
} else {
// the metadata isn't there to support it
if (mBackdrop.getVisibility() != View.GONE) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork");
}
if (mFingerprintUnlockController.getMode() == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING || hideBecauseOccluded) {
// We are unlocking directly - no animation!
mBackdrop.setVisibility(View.GONE);
mBackdropBack.setImageDrawable(null);
mStatusBarWindowManager.setBackdropShowing(false);
} else {
mStatusBarWindowManager.setBackdropShowing(false);
mBackdrop.animate().alpha(SRC_MIN_ALPHA).setInterpolator(Interpolators.ACCELERATE_DECELERATE).setDuration(300).setStartDelay(0).withEndAction(new Runnable() {
@Override
public void run() {
mBackdrop.setVisibility(View.GONE);
mBackdropFront.animate().cancel();
mBackdropBack.setImageDrawable(null);
mHandler.post(mHideBackdropFront);
}
});
if (mKeyguardFadingAway) {
mBackdrop.animate().setDuration(mKeyguardFadingAwayDuration / 2).setStartDelay(mKeyguardFadingAwayDelay).setInterpolator(Interpolators.LINEAR).start();
}
}
}
}
Trace.endSection();
}
use of android.graphics.drawable.ColorDrawable in project platform_frameworks_base by android.
the class CompareActivity method onCreateCommon.
protected void onCreateCommon(final Runnable postDrawCallback) {
mDrawCallback = new Runnable() {
@Override
public void run() {
mRedrewFlag = true;
mHandler.post(postDrawCallback);
}
;
};
getWindow().setBackgroundDrawable(new ColorDrawable(0xffefefef));
ResourceModifiers.init(getResources());
mHardwareView = (MainView) findViewById(R.id.hardware_view);
mHardwareView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mHardwareView.setBackgroundColor(Color.WHITE);
mHardwareView.addDrawCallback(mDrawCallback);
int width = getResources().getDimensionPixelSize(R.dimen.layer_width);
int height = getResources().getDimensionPixelSize(R.dimen.layer_height);
mSoftwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mHardwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mErrorCalculator = new ErrorCalculator(getApplicationContext(), getResources());
mHandler = new Handler();
}
use of android.graphics.drawable.ColorDrawable in project platform_frameworks_base by android.
the class DatePickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DatePicker picker = new DatePicker(this);
picker.init(2012, 3, 3, true, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
}
});
setContentView(picker);
getWindow().setBackgroundDrawable(new ColorDrawable(0xffffffff));
}
use of android.graphics.drawable.ColorDrawable in project CastHelloText-android-v2 by googlecast.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
// When the user clicks on the button, use Android voice recognition to
// get text
Button voiceButton = (Button) findViewById(R.id.voiceButton);
voiceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startVoiceRecognitionActivity();
}
});
// Configure Cast device discovery
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build();
mMediaRouterCallback = new MyMediaRouterCallback();
}
Aggregations