List of usage examples for android.widget ImageView setImageDrawable
public void setImageDrawable(@Nullable Drawable drawable)
From source file:com.slava.android.utils.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. *//*w w w . j a va2 s .c o m*/ private void forceDownload(String url, ImageView imageView, int cornersRadius) { // State sanity: url is guaranteed to never be null in // DownloadedDrawable and cache keys. if (url == null || url.equals("")) { imageView.setImageDrawable(null); return; } if (cancelPotentialDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, cornersRadius); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(imageView.getResources(), mLoadingIndicator, task); imageView.setImageDrawable(downloadedDrawable); imageView.setMinimumHeight(156); task.execute(url); } }
From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java
private void initReceiptView() { Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/roboto-regular.ttf"); TextView merchantName = (TextView) findViewById(R.id.merchant_name); merchantName.setTypeface(tf, Typeface.BOLD); merchantName.setText(getMerchantName()); TextView transactionDateView = (TextView) findViewById(R.id.date); java.text.DateFormat df = DateFormat.getDateFormat(this); transactionDateView.setTypeface(tf); transactionDateView.setText(" " + df.format(mResult.getDateTime())); TextView transactionResult = (TextView) findViewById(R.id.transaction_result); transactionResult.setTypeface(tf, Typeface.BOLD); transactionResult.setText(mResult.getFinancialStatus()); TextView messageView = (TextView) findViewById(R.id.message); messageView.setTypeface(tf);/*w w w. jav a2 s . c o m*/ String message = ((Application) getApplication()).formatErrorMessage(mResult.getStatusMessage(), mResult.getErrorMessage()); messageView.setText(message); ImageView cardSchemeLogo = (ImageView) findViewById(R.id.card_scheme_logo); cardSchemeLogo.setImageDrawable(getCardSchemeLogo()); TextView amountView = (TextView) findViewById(R.id.amount_text); amountView.setTypeface(tf); amountView.setText(getTotalAmount(mResult.getAuthorizedAmount(), mResult.getCurrency())); TextView descriptionView = (TextView) findViewById(R.id.item_description_text); descriptionView.setTypeface(tf); descriptionView.setText(getDescriptionText()); ImageView productImageView = (ImageView) findViewById(R.id.picture); productImageView.setImageBitmap(getImageBitmap()); }
From source file:com.aapbd.utils.image.CacheImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not * used. Kept private at the moment as its interest is not clear. *//*w w w .j a v a2s . co m*/ private void forceDownload(final String url, final ImageView imageView, final String cookie) { // State sanity: url is guaranteed to never be null in // DownloadedDrawable and cache keys. if (url == null) { imageView.setImageDrawable(null); imageView.setVisibility(View.GONE); return; } if (cancelPotentialDownload(url, imageView)) { final BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); final DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task); imageView.setImageDrawable(downloadedDrawable); task.execute(url, cookie); } }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Resets the the view to fit into a new * available width./*from w w w . j ava2 s. c o m*/ * * <p>This clears and then re-inflates the menu items * , removes all of its associated action views, and recreates * the menu and action items to fit in the new width.</p> * * @param availWidth the width available for the menu to use. If * there is room, menu items that are flagged with * android:showAsAction="ifRoom" or android:showAsAction="always" * will show as actions. */ public void reset(int availWidth) { if (mMenu == -1) return; //clean view first removeAllViews(); mActionItems.clear(); //reset menu mMenuBuilder.clearAll(); getMenuInflater().inflate(mMenu, mMenuBuilder); int holdAllItemsCount; mMenuItems = mMenuBuilder.getActionItems(); mMenuItems.addAll(mMenuBuilder.getNonActionItems()); holdAllItemsCount = mMenuItems.size(); Collections.sort(mMenuItems, new Comparator<MenuItemImpl>() { @Override public int compare(MenuItemImpl lhs, MenuItemImpl rhs) { return ((Integer) lhs.getOrder()).compareTo(rhs.getOrder()); } }); List<MenuItemImpl> menuItems = filter(mMenuItems, new MenuItemImplPredicate() { @Override public boolean apply(MenuItemImpl menuItem) { return menuItem.requiresActionButton() || menuItem.requestsActionButton(); } }); int availItemRoom = availWidth / (int) ACTION_DIMENSION_PX; boolean addOverflowAtTheEnd = false; if (((menuItems.size() < holdAllItemsCount) || availItemRoom < menuItems.size())) { addOverflowAtTheEnd = true; availItemRoom--; } ArrayList<Integer> actionMenuItems = new ArrayList<>(); if (availItemRoom > 0) for (int i = 0; i < menuItems.size(); i++) { final MenuItemImpl menuItem = menuItems.get(i); if (menuItem.getIcon() != null) { ImageView action = getActionHolder(); action.setImageDrawable(Util.setIconColor(menuItem.getIcon(), mActionIconColor)); addView(action); mActionItems.add(menuItem); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, menuItem); } }); actionMenuItems.add(menuItem.getItemId()); availItemRoom--; if (availItemRoom == 0) break; } } if (addOverflowAtTheEnd) { ImageView overflowAction = getOverflowActionHolder(); overflowAction.setImageDrawable(Util.setIconColor( getResources().getDrawable(R.drawable.ic_more_vert_black_24dp), mOverflowIconColor)); addView(overflowAction); overflowAction.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mMenuPopupHelper.show(); } }); mMenuBuilder.setCallback(mMenuCallback); mHasOverflow = true; } for (int id : actionMenuItems) mMenuBuilder.removeItem(id); actionMenuItems.clear(); if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged( ((int) ACTION_DIMENSION_PX * getChildCount()) - (mHasOverflow ? Util.dpToPx(8) : 0)); }
From source file:com.blogspot.codigogoogle.listloadingsamples.ImageLoaderListAdapter.java
public void loadBitmap(String imageUrl, ImageView imageView) { final Bitmap bitmap = getBitmapFromMemCache(imageUrl); if (bitmap != null) { imageView.setImageBitmap(bitmap); } else {//from w ww . j a va2 s . com if (cancelPotentialWork(imageUrl, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(context.getResources(), mPlaceHolderBitmap, task); imageView.setImageDrawable(asyncDrawable); task.execute(imageUrl); } } }
From source file:com.common.library.bitmap.ImageWorker.java
/** * Set image with loading or default image. * @param imageView/*from w ww . ja v a2s .c om*/ */ public void loadDefaultImage(ImageView imageView) { if (imageView != null) { imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); } }
From source file:com.example.android.lnotifications.OtherMetadataFragment.java
/** * Updates the Contact information on the screen when a contact is picked. * * @param contactUri The Uri from which the contact is retrieved. *//* w ww .j a va2 s. co m*/ private void updateContactEntryFromUri(Uri contactUri) { Cursor cursor = getActivity().getContentResolver().query(contactUri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { int idx = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); String name = cursor.getString(idx); idx = cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID); String hasPhoto = cursor.getString(idx); Uri photoUri = Uri.withAppendedPath(contactUri, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY); ImageView contactPhoto = (ImageView) getActivity().findViewById(R.id.contact_photo); if (hasPhoto != null) { contactPhoto.setImageURI(photoUri); } else { Drawable defaultContactDrawable = getActivity().getResources() .getDrawable(R.drawable.ic_contact_picture); contactPhoto.setImageDrawable(defaultContactDrawable); } TextView contactName = (TextView) getActivity().findViewById(R.id.contact_name); contactName.setText(name); getActivity().findViewById(R.id.contact_entry).setVisibility(View.VISIBLE); getActivity().findViewById(R.id.attach_person).setVisibility(View.GONE); getActivity().findViewById(R.id.click_to_change).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { findContact(); } }); Log.i(TAG, String.format("Contact updated. Name %s, PhotoUri %s", name, photoUri)); } }
From source file:com.he5ed.lib.cloudprovider.picker.PickerFragment.java
private View swapOutEmptyViewDetails(View oldView, View newView) { if (oldView == null && newView == null) { return null; } else if (oldView == null) { return newView; } else if (newView == null) { return oldView; }/*from w w w. j a va2 s. c om*/ ImageView oldIcon = (ImageView) oldView.findViewById(R.id.empty_icon_image_view); TextView oldTitle = (TextView) oldView.findViewById(R.id.empty_title_text_view); TextView oldDetail = (TextView) oldView.findViewById(R.id.empty_detail_text_view); ImageView newIcon = (ImageView) newView.findViewById(R.id.empty_icon_image_view); TextView newTitle = (TextView) newView.findViewById(R.id.empty_title_text_view); TextView newDetail = (TextView) newView.findViewById(R.id.empty_detail_text_view); newIcon.setImageDrawable(oldIcon.getDrawable()); newTitle.setText(oldTitle.getText()); newDetail.setText(oldDetail.getText()); return newView; }
From source file:com.scoreloop.client.android.ui.util.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. *//*from ww w . ja v a 2 s . c o m*/ private void forceDownload(String url, Drawable drawable, ImageView imageView) { if (cancelPotentialDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(drawable, task); imageView.setImageDrawable(downloadedDrawable); task.execute(url); } }
From source file:com.docd.purefm.adapters.BrowserBaseAdapter.java
/** * Resolves icon that should be used for the File * * @param file File to set icon for/*from w w w.ja v a 2 s.co m*/ * @param icon View to set icon */ protected final void setIcon(final GenericFile file, final ImageView icon, boolean large) { if (file.isDirectory()) { icon.setImageDrawable(getDrawableForRes(mResources, large ? R.drawable.ic_fso_folder_large : R.drawable.ic_fso_folder)); } else { final String fileExt = FilenameUtils.getExtension(file.getName()); Drawable mimeIcon = sMimeTypeIconCache.get(fileExt); if (mimeIcon == null) { final int mimeIconId = MimeTypes.getIconForExt(fileExt); if (mimeIconId != 0) { mimeIcon = mResources.getDrawable(mimeIconId); sMimeTypeIconCache.put(fileExt, mimeIcon); } } if (mimeIcon != null) { icon.setImageDrawable(mimeIcon); } else { final Permissions p = file.getPermissions(); if (!file.isSymlink() && (p.gx || p.ux || p.ox)) { final int executableIcon = R.drawable.ic_fso_type_executable; Drawable iconDrawable = sDrawableLruCache.get(executableIcon); if (iconDrawable == null) { iconDrawable = mResources.getDrawable(executableIcon); sDrawableLruCache.put(executableIcon, iconDrawable); } icon.setImageDrawable(iconDrawable); } else { icon.setImageDrawable(getDrawableForRes(mResources, R.drawable.ic_fso_default)); } } } }