List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.facebook.widget.GraphObjectAdapter.java
protected void populateGraphObjectView(View view, T graphObject) { String id = getIdOfGraphObject(graphObject); view.setTag(id);/*from www . j a va 2 s .co m*/ CharSequence title = getTitleOfGraphObject(graphObject); TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleView != null) { titleView.setText(title, TextView.BufferType.SPANNABLE); } CharSequence subtitle = getSubTitleOfGraphObject(graphObject); TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle); if (subtitleView != null) { if (subtitle != null) { subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE); subtitleView.setVisibility(View.VISIBLE); } else { subtitleView.setVisibility(View.GONE); } } if (getShowCheckbox()) { CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox); updateCheckboxState(checkBox, isGraphObjectSelected(id)); } if (getShowPicture()) { URI pictureURI = getPictureUriOfGraphObject(graphObject); if (pictureURI != null) { ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image); // See if we have already pre-fetched this; if not, download it. if (prefetchedPictureCache.containsKey(id)) { ImageResponse response = prefetchedPictureCache.get(id); profilePic.setImageBitmap(response.getBitmap()); profilePic.setTag(response.getRequest().getImageUri()); } else { downloadProfilePicture(id, pictureURI, profilePic); } } } }
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./*from w ww. j a va 2 s . com*/ * * @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.zhihuigu.sosoOffice.utils.ImageDownloaderId.java
/** * Download the specified image from the Internet and binds it to the * provided ImageView. The binding is immediate if the image is found in the * cache and will be done asynchronously otherwise. A null bitmap will be * associated to the ImageView if an error occurs. * // ww w.ja v a 2 s .c o m * @param url * The URL of the image to download. * @param imageView * The ImageView to bind the downloaded image to. */ public void download(File file, String sql, String id, String pixelswidth, String pixelsheight, String request_name, ImageView imageView, String x, String y, String width, String height) { resetPurgeTimer(); // Bitmap bitmap = getBitmapFromCache(file.getAbsolutePath()); if (id == null || id.trim().equals("") || id.trim().equals("0")) { return; } if (connection_count > connection_count_totle) { return; } if (bitmap == null) { System.out.println("1"); forceDownload(file, sql, id, pixelswidth, pixelsheight, request_name, imageView, x, y, width, height); } else { System.out.println("2"); cancelPotentialDownload(file.getAbsolutePath(), imageView); imageView.setImageBitmap(bitmap); } }
From source file:com.faayda.imageloader.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.//from w ww .j a v a 2 s . c o m */ @SuppressLint("NewApi") @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(mResources.getColor(R.color.transparent)), new BitmapDrawable(mResources, bitmap) }); if (android.os.Build.VERSION.SDK_INT >= android.os.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.andreadec.musicplayer.MainActivity.java
private void showItemInfo(PlayableItem item) { if (item == null || item.getInformation() == null) return;/*from w w w . java 2 s. co m*/ ArrayList<Information> information = item.getInformation(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.songInfo); View view = getLayoutInflater().inflate(R.layout.layout_songinfo, null, false); LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutInformation); Bitmap image = item.getImage(); if (image != null) { ImageView imageView = new ImageView(this); imageView.setImageBitmap(image); linearLayout.addView(imageView); } for (Information info : information) { TextView info1 = new TextView(this); info1.setTextAppearance(this, android.R.style.TextAppearance_Medium); info1.setText(getResources().getString(info.key)); TextView info2 = new TextView(this); info2.setText(info.value); info2.setPadding(0, 0, 0, 10); linearLayout.addView(info1); linearLayout.addView(info2); } builder.setView(view); builder.setPositiveButton(R.string.ok, null); builder.show(); }
From source file:com.inc.playground.playground.MainActivity.java
public void setPlayGroundActionBar() { String userLoginId, userFullName, userEmail, userPhoto; Bitmap imageBitmap = null;//from www . ja v a 2 s. com GlobalVariables globalVariables; final ActionBar actionBar = getActionBar(); final String MY_PREFS_NAME = "Login"; SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); globalVariables = ((GlobalVariables) this.getApplication()); if (prefs.getString("userid", null) != null) { userLoginId = prefs.getString("userid", null); userFullName = prefs.getString("fullname", null); userEmail = prefs.getString("emilid", null); userPhoto = prefs.getString("picture", null); globalVariables.GetCurrentUser().setPhotoUrl(userPhoto); actionBar.setCustomView(R.layout.actionbar_custom_view_home); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); ImageView logo_image = (ImageView) findViewById(R.id.img_profile_action_bar); logo_image.setBackgroundResource(R.drawable.pg_logo2); TextView userName = (TextView) findViewById(R.id.email); userName.setText(userFullName.replace("%20", " ")); ImageView img_profile = (ImageView) findViewById(R.id.profile_image); imageBitmap = globalVariables.GetUserPictureBitMap(); if (imageBitmap == null) { Log.i(TAG, "downloading"); try { imageBitmap = new DownloadImageBitmapTask().execute(userPhoto).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Log.i(TAG, "Image found"); } img_profile.setImageBitmap(imageBitmap); ImageView notificationBtn = (ImageView) findViewById(R.id.notification_btn); notificationBtn.setVisibility(View.VISIBLE); notificationBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent iv = new Intent(MainActivity.this, NotificationsList.class); startActivity(iv); finish(); } }); TextView notificationNumber = (TextView) findViewById(R.id.notification__numberTxt); if (globalVariables.GetNotifications() != null && globalVariables.GetNotifications().size() != 0) { notificationNumber.setText(Integer.toString(globalVariables.GetNotifications().size())); notificationNumber.setVisibility(View.VISIBLE); } else { notificationNumber.setVisibility(View.INVISIBLE); } TextView loginTxt = (TextView) findViewById(R.id.login_txt); ImageView loginImg = (ImageView) findViewById(R.id.login_img); globalVariables.SetUserPictureBitMap(imageBitmap); // Make the imageBitMap global to all activities to avoid downloading twice loginTxt.setText("Logout"); loginImg.setImageResource(R.drawable.pg_action_lock_close); // Register to notifications Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.example.web.image.ImageDownloader.java
public void download(String url, ImageView imageView, ProgressBar progressBar) { this.progressBar = progressBar; if (this.progressBar != null) { this.progressBar.setVisibility(View.VISIBLE); }/*from w w w.j a v a 2 s . c om*/ imageCache.resetPurgeTimer(); Bitmap bitmap = imageCache.getBitmapFromCache(url); if (bitmap == null) { // bitmap = fileCache.getImage(url, "" + type); if (bitmap == null) { forceDownload(url, imageView); } else { //edit bv cuiyao imageCache.addBitmapToCache(url, bitmap); cancelPotentialDownload(url, imageView); if (this.progressBar != null) { this.progressBar.setVisibility(View.GONE); } imageView.setImageBitmap(bitmap); } } else { cancelPotentialDownload(url, imageView); if (this.progressBar != null) { this.progressBar.setVisibility(View.GONE); } imageView.setImageBitmap(bitmap); } }
From source file:com.example.image.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView/*from ww w. ja v a2s . c o m*/ * @param bitmap */ private void setImageBitmap(final ImageView imageView, final Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable with a transparent drwabale and the final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { mLoadingBitmap != null ? getLoadingDrawable() : new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // Set background to loading bitmap //imageView.setBackgroundDrawable(getLoadingDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); imageView.postDelayed(new Runnable() { @Override public void run() { imageView.setImageBitmap(bitmap); } }, FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
private void configureQrScanView() { T.UI();/* www . j a v a 2s .c o m*/ final Button btn = (Button) findViewById(R.id.add_via_qr_scan_button); btn.setText(getString(R.string.scan_passport, getString(R.string.app_name))); btn.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { Intent i = new Intent(AddFriendsActivity.this, ScanTabActivity.class); i.setAction(ScanTabActivity.START_SCANNER_INTENT_ACTION); startActivity(i); } }); final ImageView imgView = (ImageView) findViewById(R.id.my_qr); imgView.setImageBitmap(mService.getIdentityStore().getIdentity().getQRBitmap()); }