List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable
private BitmapDrawable(BitmapState state, Resources res)
From source file:fi.tuukka.weather.utils.Utils.java
public static BitmapDrawable loadBitmapDrawableFromUrl(Activity activity, String imageAddress) { Bitmap bmp = loadBitmapFromUrl(imageAddress); return new BitmapDrawable(activity.getResources(), bmp); }
From source file:aws.apps.usbDeviceEnumerator.ui.usbinfo.AndroidUsbInfoFragment.java
private void loadAsyncData(String vid, String pid, String reportedVendorName) { dataFetcher.fetchData(vid, pid, reportedVendorName, new DataFetcher.Callback() { @Override// w ww. ja v a2 s . co m public void onSuccess(final String vendorFromDb, final String productFromDb, final Bitmap bitmap) { if (isAdded() && getActivity() != null && getView() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { viewHolder.getVendorFromDb().setText(vendorFromDb); viewHolder.getProductFromDb().setText(productFromDb); if (bitmap != null) { final BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bitmap); viewHolder.getLogo().setImageDrawable(drawable); } else { viewHolder.getLogo().setImageResource(R.drawable.no_image); } } }); } } }); }
From source file:com.common.library.bitmap.ImageWorker.java
/** * Set image with loading or default image. * @param imageView// w w w . j a va 2 s . com */ public void loadDefaultImage(ImageView imageView) { if (imageView != null) { imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); } }
From source file:com.eutectoid.dosomething.usersettings.UserSettingsFragment.java
private void processImageResponse(String id, ImageResponse response) { if (response != null) { Bitmap bitmap = response.getBitmap(); if (bitmap != null) { BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap); drawable.setBounds(0, 0,/*from w w w . j a va 2 s .c o m*/ getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_height)); userProfilePic = drawable; userProfilePicID = id; connectedStateLabel.setCompoundDrawables(null, drawable, null, null); connectedStateLabel.setTag(response.getRequest().getImageUri()); } } }
From source file:com.ijiaban.yinxiang.MainActivity.java
/** * Populates the GUI elements/*w w w . j av a 2 s . c o m*/ */ private void showContactData() { Drawable generatedDrawable = new BitmapDrawable(getResources(), mGeneratedBitmap); mIconImageView.setImageDrawable(generatedDrawable); tabs.setVisibility(View.VISIBLE); pager.setVisibility(View.VISIBLE); // Change the app colour to the average colour of the generated image. setColor(ColorUtilities.getAverageColor(mGeneratedBitmap)); }
From source file:com.conferenceengineer.android.iosched.util.ImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a * fade-in animation. If there is a {@link android.graphics.drawable.Drawable} already set on * the ImageView then use that as the image to fade from. Otherwise fade in from a transparent * Drawable.// w w w .j a v a2 s. c om */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setImageBitmap(final ImageView imageView, final Bitmap bitmap, Resources resources, boolean fadeIn) { // If we're fading in and on HC MR1+ if (fadeIn && UIUtils.hasHoneycombMR1()) { // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the // ImageView imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f) .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageBitmap(bitmap); imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME) .setListener(null); } }); } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.setImageDrawable(td); td.startTransition(UIUtils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.setImageBitmap(bitmap); } }
From source file:com.esri.android.ecologicalmarineunitexplorer.map.MapFragment.java
/** * Create and add a marker to the map representing * the clicked location.//from w w w . j a v a 2s . c o m * @param point - A com.esri.arcgisruntime.geometry.Point item */ @Override public void showClickedLocation(Point point) { Bitmap icon = BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.blue_pin); BitmapDrawable drawable = new BitmapDrawable(getResources(), icon); PictureMarkerSymbol markerSymbol = new PictureMarkerSymbol(drawable); Graphic marker = new Graphic(point, markerSymbol); mGraphicOverlay.getGraphics().clear(); mGraphicOverlay.getGraphics().add(marker); }
From source file:com.likou.util.NImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an * {@link android.widget.ImageView} using a fade-in animation. If there is a * {@link android.graphics.drawable.Drawable} already set on the ImageView * then use that as the image to fade from. Otherwise fade in from a * transparent Drawable.//from w w w. j a va2s . c o m */ // @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setImageBitmap(final ImageView imageView, final Bitmap bitmap, Resources resources, boolean fadeIn) { // // If we're fading in and on HC MR1+ // if (fadeIn && NetUtils.hasHoneycombMR1()) { // // Use ViewPropertyAnimator to run a simple fade in + fade out // // animation to update the // // ImageView // imageView // .animate() // .scaleY(0.95f) // .scaleX(0.95f) // .alpha(0f) // .setDuration( // imageView.getDrawable() == null ? 0 // : HALF_FADE_IN_TIME) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // imageView.setImageBitmap(bitmap); // imageView.animate().alpha(1f).scaleY(1f).scaleX(1f) // .setDuration(HALF_FADE_IN_TIME) // .setListener(null); // } // }); // } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.setImageDrawable(td); td.startTransition(250); } else { // No fade in, just set bitmap directly imageView.setImageBitmap(bitmap); } }
From source file:com.example.kuassivi.material_avatar.feature.ChooseAvatarActivity.java
/** * This method updates the shared view we use on the material transition * * @param bitmap Bitmap//w ww. j a v a2 s. c o m */ private void updateSharedAvatarView(Bitmap bitmap) { Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, sharedAvatarSize, sharedAvatarSize, true); CircleTransform circleTransform = new CircleTransform(); mSharedAvatarView .setBackground(new BitmapDrawable(getResources(), circleTransform.transform(scaledBitmap))); }
From source file:android.support.v17.leanback.media.MediaControllerAdapter.java
/** * Get current media's drawable art./*from w w w . j a v a 2s .c o m*/ * * @return Drawable art of current media. */ public Drawable getMediaArt(Context context) { if (mController.getMetadata() == null) { return null; } Bitmap bitmap = mController.getMetadata().getDescription().getIconBitmap(); return bitmap == null ? null : new BitmapDrawable(context.getResources(), bitmap); }