Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.mallapp.utils.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set./* ww w.  jav  a2 s .  co  m*/
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        imageView.setBackground(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        bitmap = getCroppedBitmap(bitmap);
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.android.gallery3d.filtershow.FilterShowActivity.java

public void updateUIAfterServiceStarted() {
    MasterImage.setMaster(mMasterImage);
    ImageFilter.setActivityForMemoryToasts(this);
    mUserPresetsManager = new UserPresetsManager(this);
    mUserPresetsAdapter = new UserPresetsAdapter(this);

    setupMasterImage();/*from  w  ww .jav  a2  s  . c  om*/
    setupMenu();
    setDefaultValues();
    fillEditors();
    getWindow().setBackgroundDrawable(new ColorDrawable(0));
    loadXML();

    fillCategories();
    loadMainPanel();
    extractXMPData();
    processIntent();
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);//from   w  w w . java  2s .  co  m
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_CompanyApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            Log.i("Daniel", "------");
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}

From source file:com.app.chasebank.contactslist.util.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set.//  w ww  . j a va 2 s.com
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });

        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java

public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    LogUtils.d("showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();//from ww w.  ja  v  a  2  s .c  om
        return;
    }

    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;

    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    background = parent.getBackground();
    parent.setBackground(new ColorDrawable(Color.BLACK));
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);

    // Hide the content view.
    this.setVisibility(View.GONE);

    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
    if (objects != null && objects.length > 0) {
        for (Object obj : objects) {
            if (obj instanceof View) {
                ((View) obj).setVisibility(View.GONE);
            } else if (obj instanceof Fragment) {
                ((Fragment) obj).getView().setVisibility(View.GONE);
            }
        }
    }
    ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    ((Activity) mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

From source file:com.itsherpa.andg.imageloader.ContactImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView./*  ww  w. j a v a2  s . c  o  m*/
 * 
 * @param imageView
 *            The ImageView to set the bitmap to.
 * @param bitmap
 *            The new bitmap to set.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressWarnings("deprecation")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            imageView.setBackground(imageView.getDrawable());
        } else {
            imageView.setBackgroundDrawable(imageView.getDrawable());
        }
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.cypress.cysmart.BLEServiceFragments.CapsenseService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();//from   www  .j  av a2 s .  com
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(false);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.android.gallery3d.filtershow.FilterShowActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boolean onlyUsePortrait = getResources().getBoolean(R.bool.only_use_portrait);
    if (onlyUsePortrait) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*from   ww w.j  ava2s.c o m*/

    clearGalleryBitmapPool();
    doBindService();
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));
    setContentView(R.layout.filtershow_splashscreen);
}

From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*  w  w  w  . j a v a 2s  . c  o m*/
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(true);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.musenkishi.atelier.Atelier.java

private static void applyColorToView(final ImageView imageView, int color, boolean fromCache,
        boolean shouldMask) {
    if (fromCache) {
        if (shouldMask) {
            if (imageView.getDrawable() != null) {
                imageView.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            } else if (imageView.getBackground() != null) {
                imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            }//www  .  j  a  v a2 s.c  om
        } else {
            imageView.setBackgroundColor(color);
        }
    } else {
        if (shouldMask) {
            Integer colorFrom;
            ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    if (imageView.getDrawable() != null) {
                        imageView.getDrawable().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    } else if (imageView.getBackground() != null) {
                        imageView.getBackground().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    }
                }
            };
            ValueAnimator.AnimatorUpdateListener animatorUpdateListener;

            PaletteTag paletteTag = (PaletteTag) imageView.getTag(viewTagKey);
            animatorUpdateListener = imageAnimatorUpdateListener;
            colorFrom = paletteTag.getColor();
            imageView.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color));

            Integer colorTo = color;
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
            colorAnimation.addUpdateListener(animatorUpdateListener);
            colorAnimation.setDuration(300);
            colorAnimation.start();
        } else {
            Drawable preDrawable;

            if (imageView.getBackground() == null) {
                preDrawable = new ColorDrawable(Color.TRANSPARENT);
            } else {
                preDrawable = imageView.getBackground();
            }

            TransitionDrawable transitionDrawable = new TransitionDrawable(
                    new Drawable[] { preDrawable, new ColorDrawable(color) });
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                imageView.setBackground(transitionDrawable);
            } else {
                imageView.setBackgroundDrawable(transitionDrawable);
            }
            transitionDrawable.startTransition(300);
        }
    }
}