List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.geeker.door.imgcache.ImageDownloader.java
/** * Same as {@link #download(String, ImageView)}, with the possibility to * provide an additional cookie that will be used when the image will be * retrieved./*from ww w.j av a 2 s.co m*/ * * @param url * The URL of the image to download. * @param imageView * The ImageView to bind the downloaded image to. * @param cookie * A cookie String that will be used by the http connection. */ public void download(String url, ImageView imageView, String cookie, int defaultPicType) { // Logger.i(TAG, "download url:" + url); // ? resetPurgeTimer(); // Logger.d(TAG, ":" + System.currentTimeMillis()); Bitmap bitmap = getBitmapFromCache(url);// // Logger.d(TAG, "?:" + System.currentTimeMillis()); if (bitmap == null) { // Logger.d(TAG, "get image from SD card:" + // System.currentTimeMillis()); bitmap = loadFromSDCache(url);// SD?+ // Logger.d(TAG, "SD??:" + System.currentTimeMillis()); } // else{ // Logger.d(TAG, "get image from cache:" + System.currentTimeMillis()); // } if (bitmap == null) { // Logger.d(TAG, "get image from network:" + // System.currentTimeMillis()); forceDownload(url, imageView, cookie, defaultPicType);// // Logger.d(TAG, "?:" + System.currentTimeMillis()); } else { // Logger.d(TAG, // "got image from SD card, cancel potential download:" + // System.currentTimeMillis()); if (imageView != null) { cancelPotentialDownload(url, imageView); } // ,? // if (imageView instanceof MulitPointTouchImageView) { // ((MulitPointTouchImageView) imageView).setImageBitmap(bitmap); // } else { // imageView.setImageBitmap(bitmap);// // } if (mScaleType != null && imageView != null) { imageView.setScaleType(mScaleType); } if (imageView != null) { imageView.setImageBitmap(bitmap);// } // if (isImageViewCache) { // mImageViewCache.put(url, imageView); // } } // Log // Collection<Bitmap> hardValues = mHardBitmapCache.values(); // int hardTotalSize = 0; // for (Bitmap hartbitmap : hardValues) { // // hardTotalSize += (hartbitmap.getHeight() * hartbitmap.getWidth() * 4) // / 1024; // Logger.d(TAG, "hartbitmap Height:" + hartbitmap.getHeight() // + "hartbitmap Width:" + hartbitmap.getWidth()); // } // Collection<SoftReference<Bitmap>> softValues = mSoftBitmapCache // .values(); // int softTotalSize = 0; // for (SoftReference<Bitmap> softbitmap : softValues) { // // if (softbitmap != null && softbitmap.get() != null) { // softTotalSize += (softbitmap.get().getHeight() // * softbitmap.get().getWidth() * 4) / 1024; // Logger.d(TAG, "softbitmap Height:" // + softbitmap.get().getHeight() + "softbitmap Width:" // + softbitmap.get().getWidth()); // } // // } // Logger.d(TAG, "?==>download() bitmap ?:" + hardTotalSize // + "KB ?:" + softTotalSize + "KB"); }
From source file:com.androidquery.AQuery.java
/** * Clear a view. Applies to ImageView, WebView, and TextView. * * @return self/*from w w w .ja v a2 s. com*/ */ public AQuery clear() { if (view != null) { if (view instanceof ImageView) { ImageView iv = ((ImageView) view); iv.setImageBitmap(null); iv.setTag(AQuery.TAG_URL, null); } else if (view instanceof WebView) { WebView wv = ((WebView) view); wv.stopLoading(); wv.clearView(); wv.setTag(AQuery.TAG_URL, null); } else if (view instanceof TextView) { TextView tv = ((TextView) view); tv.setText(""); } } return self(); }
From source file:com.androidquery.AQuery.java
/** * Set the image of an ImageView.//from w w w .j a va2s.c om * * @param bm Bitmap * @return self * * @see testImage3 */ public AQuery image(Bitmap bm) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); iv.setImageBitmap(bm); } return self(); }
From source file:com.androidquery.AQuery.java
/** * Set the image of an ImageView./*ww w . j a va 2s . c om*/ * * @param resid the resource id * @return self * * @see testImage1 */ public AQuery image(int resid) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); if (resid == 0) { iv.setImageBitmap(null); } else { iv.setImageResource(resid); } } return self(); }
From source file:com.androidquery.AbstractAQuery.java
/** * Clear a view. Applies to ImageView, WebView, and TextView. * * @return self// ww w . j a va2s. c om */ public T clear() { if (view != null) { if (view instanceof ImageView) { ImageView iv = ((ImageView) view); iv.setImageBitmap(null); iv.setTag(AQuery.TAG_URL, null); } else if (view instanceof WebView) { WebView wv = ((WebView) view); wv.stopLoading(); wv.clearView(); wv.setTag(AQuery.TAG_URL, null); } else if (view instanceof TextView) { TextView tv = ((TextView) view); tv.setText(""); } } return self(); }
From source file:com.androidquery.AbstractAQuery.java
/** * Set the image of an ImageView.//from w w w . j av a 2 s.c o m * * @param bm Bitmap * @return self * * @see testImage3 */ public T image(Bitmap bm) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); iv.setImageBitmap(bm); } return self(); }
From source file:com.android.email.activity.zx.MessageView.java
private void renderAttachments(Part part, int depth) throws MessagingException { String contentType = MimeUtility.unfoldAndDecode(part.getContentType()); String name = MimeUtility.getHeaderParameter(contentType, "name"); if (name != null) { /*//from w ww .j a va 2 s . c om * We're guaranteed size because LocalStore.fetch puts it there. */ String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition()); int size = Integer.parseInt(MimeUtility.getHeaderParameter(contentDisposition, "size")); Attachment attachment = new Attachment(); attachment.size = size; attachment.contentType = part.getMimeType(); attachment.name = name; attachment.part = (LocalAttachmentBodyPart) part; LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.message_view_attachment, null); TextView attachmentName = (TextView) view.findViewById(R.id.attachment_name); TextView attachmentInfo = (TextView) view.findViewById(R.id.attachment_info); ImageView attachmentIcon = (ImageView) view.findViewById(R.id.attachment_icon); Button attachmentView = (Button) view.findViewById(R.id.view); Button attachmentDownload = (Button) view.findViewById(R.id.download); if ((!MimeUtility.mimeTypeMatches(attachment.contentType, Email.ACCEPTABLE_ATTACHMENT_VIEW_TYPES)) || (MimeUtility.mimeTypeMatches(attachment.contentType, Email.UNACCEPTABLE_ATTACHMENT_VIEW_TYPES))) { attachmentView.setVisibility(View.GONE); } if ((!MimeUtility.mimeTypeMatches(attachment.contentType, Email.ACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES)) || (MimeUtility.mimeTypeMatches(attachment.contentType, Email.UNACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES))) { attachmentDownload.setVisibility(View.GONE); } if (attachment.size > Email.MAX_ATTACHMENT_DOWNLOAD_SIZE) { attachmentView.setVisibility(View.GONE); attachmentDownload.setVisibility(View.GONE); } attachment.viewButton = attachmentView; attachment.downloadButton = attachmentDownload; attachment.iconView = attachmentIcon; view.setTag(attachment); attachmentView.setOnClickListener(this); attachmentView.setTag(attachment); attachmentDownload.setOnClickListener(this); attachmentDownload.setTag(attachment); attachmentName.setText(name); attachmentInfo.setText(formatSize(size)); Bitmap previewIcon = getPreviewIcon(attachment); if (previewIcon != null) { attachmentIcon.setImageBitmap(previewIcon); } mHandler.addAttachment(view); } if (part.getBody() instanceof Multipart) { Multipart mp = (Multipart) part.getBody(); for (int i = 0; i < mp.getCount(); i++) { renderAttachments(mp.getBodyPart(i), depth + 1); } } }
From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java
private void addNextImages(int level, boolean recycle) { if (level < BACKGROUNDS.length) { // Add the background image ImageView iv = new ImageView(this); iv.setLayerType(View.LAYER_TYPE_HARDWARE, null); // This is being background loaded. Should already be loaded, but if not, wait. while (mBackgrounds[level] == null) { synchronized (mBackgrounds) { if (mBackgrounds[level] == null) { try { mBackgrounds.wait(); } catch (InterruptedException e) { }/*from w w w .j av a 2s .co m*/ } } } iv.setImageBitmap(mBackgrounds[level]); if (recycle) { iv.setTag(new Pair<Integer, Integer>(0, level)); } LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mBackgroundLayout.addView(iv, lp); iv = new ImageView(this); iv.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (recycle) { iv.setTag(new Pair<Integer, Integer>(0, level)); } iv.setImageBitmap(mBackgrounds2[level]); mBackgroundLayout.addView(iv, lp); // Add the foreground image if (FOREGROUNDS[level] == -1) { View view = new View(this); lp = new LinearLayout.LayoutParams(mScreenWidth * 2, 10); mForegroundLayout.addView(view, lp); } else { iv = new ImageView(this); iv.setBackgroundResource(R.drawable.img_snow_ground_tiles); if (recycle) { iv.setTag(level); } lp = new LinearLayout.LayoutParams(mScreenWidth * 2, LinearLayout.LayoutParams.WRAP_CONTENT); mForegroundLayout.addView(iv, lp); iv = new ImageView(this); if (recycle) { iv.setTag(level); } iv.setBackgroundResource(R.drawable.img_snow_ground_tiles); mForegroundLayout.addView(iv, lp); } } }
From source file:com.androidquery.AbstractAQuery.java
/** * Set the image of an ImageView./*from ww w.ja v a2 s. com*/ * * @param resid the resource id * @return self * * @see testImage1 */ public T image(int resid) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); if (resid == 0) { iv.setImageBitmap(null); } else { iv.setImageResource(resid); } } return self(); }