Search in sources :

Example 36 with ColorDrawable

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);
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable)

Example 37 with ColorDrawable

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();
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Point(android.graphics.Point)

Example 38 with ColorDrawable

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();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Handler(android.os.Handler)

Example 39 with ColorDrawable

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));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable)

Example 40 with ColorDrawable

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();
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)530 View (android.view.View)113 Drawable (android.graphics.drawable.Drawable)103 BitmapDrawable (android.graphics.drawable.BitmapDrawable)69 ImageView (android.widget.ImageView)62 TextView (android.widget.TextView)55 Bitmap (android.graphics.Bitmap)52 AdapterView (android.widget.AdapterView)32 LinearLayout (android.widget.LinearLayout)32 Test (org.junit.Test)31 Canvas (android.graphics.Canvas)30 ListView (android.widget.ListView)27 FrameLayout (android.widget.FrameLayout)23 ViewGroup (android.view.ViewGroup)22 Handler (android.os.Handler)20 Paint (android.graphics.Paint)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 TransitionDrawable (android.graphics.drawable.TransitionDrawable)19 WindowManager (android.view.WindowManager)17 Intent (android.content.Intent)16