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:baselyous.com.copticsmedia.mediaTasks.tasks.ebsalmodiaTask.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from  w w  w.j a  v  a 2 s .  c  o  m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(mResources.getColor(android.R.color.transparent)), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:air.com.snagfilms.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from  w  w  w. j a  va2  s.c  o m
 * 
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final
        // drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.baseproject.image.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView.//from w  w w  .j  av  a2s  .  c  om
 * 
 * @param imageView
 * @param bitmap
 */
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        if (imageView.getTag() instanceof String && "no_animation".equals(String.valueOf(imageView.getTag()))) {
            imageView.setImageBitmap(bitmap);
        } else {
            // Transition drawable with a transparent drwabale and the final
            // bitmap
            TransitionDrawable td = new TransitionDrawable(
                    new Drawable[] { new ColorDrawable(android.R.color.transparent),
                            new BitmapDrawable(mContext.getResources(), bitmap) });
            final WeakReference<TransitionDrawable> tdReference = new WeakReference<TransitionDrawable>(td);
            td = null;
            // Set background to loading bitmap
            final BitmapDrawable bd = new BitmapDrawable(mContext.getResources(), mLoadingBitmap);
            if (Build.VERSION.SDK_INT >= 16) {
                imageView.setBackground(bd);
            } else {
                imageView.setBackgroundDrawable(bd);

            }
            if (null != tdReference.get()) {
                imageView.setImageDrawable(tdReference.get());
                tdReference.get().startTransition(FADE_IN_TIME);
            }
        }
    } else {
        imageView.setImageBitmap(bitmap);
    }

}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Set a drawable to draw in the insets area for the status bar.
 * Note that this will only be activated if this DrawerLayout fitsSystemWindows.
 *
 * @param color Color to use as a background drawable to draw behind the status bar
 *              in 0xAARRGGBB format./*from  www. j ava  2 s  .c  o m*/
 */
public void setStatusBarBackgroundColor(@ColorInt int color) {
    setStatusBarBackground(new ColorDrawable(color));
}

From source file:com.example.mohmurtu.registration.imagesUtil.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from w  w w .ja  va2 s  .co  m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        System.out.println("Doing some thing here");
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        System.out.println("Bitmap is getting drawable");
        imageView.setImageDrawable(drawable);
    }
}

From source file:angel.zhuoxiu.picker.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*  w  w w.  ja v a  2  s  .com*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.cw.litenote.note_add.Note_addCameraImage.java

protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
    System.out.println("Note_addCameraImage / onActivityResult");
    if (requestCode == TAKE_IMAGE_ACT) {
        if (resultCode == Activity.RESULT_OK) {
            // disable Rotate to avoid leak window
            //            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

            // Note: 
            // 1 .for Google Camera App, imageReturnedIntent is null
            //    its default path is 
            //    a. open App by cell phone menu: /sdcard/DCIM/Camera
            //    b. open App by intent: intent appoints
            // 2. for Camera360 App, get data from imageReturnedIntent is null
            //    and its default path is /sdcard/DCIM/Camera (??? has duplication, how to solve?)

            // check returned intent
            if (imageReturnedIntent == null) {
                System.out.println("returned intent is null"); // Google Camera case
            } else {
                Uri imageUri = imageReturnedIntent.getData();

                if (imageUri == null)
                    System.out.println("-- imageUri = " + null); // Camera360 case
                else
                    System.out.println("-- imageUri = " + imageUri.toString());
            }/*from  www. j  a v a2  s . c o m*/

            // The following source code can be used 
            // if we know the file name is got from returned intent
            // note: unfortunately, this is not working for Google Camera,
            //       so using this way will get null after taking image
            /*            
                        // get Uri from returned intent, scheme is content
                        // example: content://media/external/images/media/43983
                        Uri picUri = imageReturnedIntent.getData();
                                
                        if(picUri == null)
                           System.out.println("-- picUri = " + null);
                        else
                           System.out.println("-- picUri = " + picUri.toString());
                                   
                        // get file path and add prefix (file://)
                        String realPath = Util.getRealPathByUri(this, picUri);
                        System.out.println("--- realPath = " + realPath);
                        if("content".equalsIgnoreCase(picUri.getScheme()))
                        {
                           // example: file:///storage/ext_sd/DCIM/100MEDIA/IMAG0146.jpg
                           // path of default camera App: 100MEDIA for hTC , 100ANDRO for Sony
                           pictureUriInDB = "file://".concat(realPath);
                           System.out.println("---- pictureUriInDB = " + pictureUriInDB);
                        }
                                
                                
                        // get picture name
                        File pic = new File(pictureUriInDB);
                        String picName = pic.getName();
            //            System.out.println("picName = " + picName);
                                
                        // get directory by removing picture name
                        String picDir = realPath.replace(picName, "");
            //            System.out.println("picDir = " + picDir);
                                
            //            // get current picture directory
            //            SharedPreferences pref_takePicture;
            //              pref_takePicture = getSharedPreferences("takePicutre", 0);   
            //              String currentPictureDir = pref_takePicture.getString("KEY_SET_PICTURE_DIR","unknown");
            //              
            //              // update picture directory if needed
            //              if(   !picDir.equalsIgnoreCase(currentPictureDir))         
            //                    pref_takePicture.edit().putString("KEY_SET_PICTURE_DIR",picDir).apply();
            */

            SharedPreferences pref_takeImage;
            pref_takeImage = getSharedPreferences("takeImage", 0);

            if (!UtilImage.bShowExpandedImage)
                noteId = savePictureStateInDB(noteId, imageUriInDB);

            // set for Rotate any times
            if (noteId != null) {
                cameraImageUri = dB_page.getNotePictureUri_byId(noteId);
            }

            if (getIntent().getExtras().getString("extra_ADD_NEW_TO_TOP", "false").equalsIgnoreCase("true")
                    && (dB_page.getNotesCount(true) > 0))
                Page_recycler.swap(Page_recycler.mDb_page);

            Toast.makeText(this, R.string.toast_saved, Toast.LENGTH_SHORT).show();

            // check and delete duplicated image file in 100ANDRO (Sony) / 100MEDIA (hTC)
            //            int lastContentId = getLastCapturedImageId(this);
            handleDuplicatedImage(this);

            // show confirm Continue dialog
            if (pref_takeImage.getString("KEY_SHOW_CONFIRMATION_DIALOG", "no").equalsIgnoreCase("yes")) {
                bUseCameraImage = true;
                // set Continue Taking Picture dialog
                showContinueConfirmationDialog();
            } else
            // not show confirm Continue dialog
            {
                bUseCameraImage = false;

                // take image without confirmation dialog 
                noteId = null; // set null for Insert
                takeImageWithName();
            }

            // enable Rotate 
            //               setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        } else if (resultCode == RESULT_CANCELED) {
            // hide action bar
            if (getActionBar() != null)
                getActionBar().hide();

            // set action bar to transparent
            //            getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            //            getActionBar().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
            //            setTitle("");

            // disable content view
            //            findViewById(android.R.id.content).setVisibility(View.INVISIBLE);

            // set background to transparent
            getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

            Toast.makeText(this, R.string.note_cancel_add_new, Toast.LENGTH_LONG).show();

            // delete the temporary note in DB
            if (noteId != null)
                dB_page.deleteNote(noteId, true);

            // When auto time out of taking picture App happens, 
            // Note_addCameraImage activity will start from onCreate,
            // at this case, imageUri is null
            if (imageUri != null) {
                File tempFile = new File(imageUri.getPath());
                if (tempFile.isFile()) {
                    // delete 0 bit temporary file
                    tempFile.delete();
                    System.out.println("temp 0 bit file is deleted");
                }
            }
            finish();
            return; // must add this
        }

    }
}

From source file:com.corebase.android.bitmap.util.ImageWorker.java

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

        imageView.setImageDrawable(td);
        imageView.setBackgroundDrawable(null);
        td.startTransition(FADE_IN_TIME);

    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.bitmaphandler.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//  w ww .jav a  2s .  c  o m
 *
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        if (useLoadingImage && mLoadingBitmap != null) {
            // Set background to loading bitmap
            if (imageView instanceof CircleImageView) {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(new BitmapDrawable(mResources,
                            CircleImageView.getCroppedBitmap(mLoadingBitmap, mLoadingBitmap.getWidth())));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources,
                            CircleImageView.getCroppedBitmap(mLoadingBitmap, mLoadingBitmap.getWidth())));
                }
            } else if (imageView instanceof RoundedBitmapDisplayer) {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(
                            new BitmapDrawable(mResources, RoundedBitmapDisplayer.roundCorners(mLoadingBitmap,
                                    imageView, ((RoundedBitmapDisplayer) imageView).getRoundPixle())));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources, RoundedBitmapDisplayer.roundCorners(
                            mLoadingBitmap, imageView, ((RoundedBitmapDisplayer) imageView).getRoundPixle())));
                }
            } else {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));
                }
            }
        }

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

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

private void loadXML() {
    setContentView(R.layout.filtershow_activity);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.filtershow_actionbar);
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.background_screen)));

    mSaveButton = actionBar.getCustomView();
    mSaveButton.setOnClickListener(new OnClickListener() {
        @Override/*from   w w  w  .  ja v a2 s  .  c o  m*/
        public void onClick(View view) {
            saveImage();
        }
    });

    mImageShow = (ImageShow) findViewById(R.id.imageShow);
    mImageViews.add(mImageShow);

    setupEditors();

    mEditorPlaceHolder.hide();
    mImageShow.attach();

    setupStatePanel();
}