List of usage examples for android.widget ImageView setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:com.example.util.ImageUtils.java
/** * /*from ww w. j a v a2s. c om*/ */ public static void downloadHomeTopDrawable(Context context, String url, ImageView imageView) { CacheManager cache = CacheManager.getInstance(); if (cache.existsDrawable(url)) { BitmapDrawable background = new BitmapDrawable(cache.getDrawableFromCache(url)); StateListDrawable foreground = getMaskDrawable(context); imageView.setImageDrawable(foreground); imageView.setBackgroundDrawable(background); return; } Drawable defaultDrawable = context.getResources().getDrawable(R.drawable.banner_loading); if (cancelPotentialBitmapDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); DownloadedDrawable1 downloadedDrawable = new DownloadedDrawable1(defaultDrawable, task); imageView.setImageDrawable(downloadedDrawable); task.execute(context, url, TYPE_TOP); } }
From source file:com.example.util.ImageUtils.java
/** * // w w w . j av a 2 s. c o m */ public static void downloadScreenShot(Context context, String url, ImageView imageView) { AnimationDrawable loadingDrawable = new LoadingDrawable(context); if (cancelPotentialImageDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); DownloadedDrawable2 downloadedDrawable = new DownloadedDrawable2(loadingDrawable, task); // clear the old image imageView.setImageDrawable(null); imageView.setBackgroundDrawable(downloadedDrawable); downloadedDrawable.start(); task.execute(context, url, TYPE_IMAGE); } }
From source file:org.disrupted.rumble.userinterface.activity.ContactDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_contact_detail); Bundle args = getIntent().getExtras(); String contactName = args.getString("ContactName"); String contactUID = args.getString("ContactID"); /* set the toolbar */ CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(contactName); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w ww . j a v a 2 s.c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setTitle(contactName); /* set the background header */ ImageView header = (ImageView) findViewById(R.id.header_background); ColorGenerator generator = ColorGenerator.DEFAULT; header.setBackgroundDrawable(builder.build(contactName.substring(0, 1), generator.getColor(contactUID))); /* setting up the view pager and the tablayout */ TabLayout tabLayout = (TabLayout) findViewById(R.id.contact_tab_layout); ViewPager viewPager = (ViewPager) findViewById(R.id.contact_viewpager); ContactDetailPagerAdapter pagerAdapter = new ContactDetailPagerAdapter(getSupportFragmentManager(), args); viewPager.setAdapter(pagerAdapter); tabLayout.setupWithViewPager(viewPager); tabLayout.setSelectedTabIndicatorHeight(10); }
From source file:eu.geopaparazzi.library.forms.views.GPictureView.java
public void refresh(final Context context) throws Exception { log("Entering refresh...."); if (_value != null && _value.length() > 0) { String[] imageSplit = _value.split(IMAGE_ID_SEPARATOR); log("Handling images: " + _value); IImagesDbHelper imagesDbHelper = DefaultHelperClasses.getDefaulfImageHelper(); for (String imageId : imageSplit) { log("img: " + imageId); if (imageId.length() == 0) { continue; }//ww w. j a v a 2 s . c om long imageIdLong; try { imageIdLong = Long.parseLong(imageId); } catch (Exception e) { continue; } if (addedImages.contains(imageId.trim())) { continue; } byte[] imageThumbnail = imagesDbHelper.getImageThumbnail(imageIdLong); Bitmap thumbnail = ImageUtilities.getImageFromImageData(imageThumbnail); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(102, 102)); imageView.setPadding(5, 5, 5, 5); imageView.setImageBitmap(thumbnail); imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px)); // imageView.setOnClickListener(new View.OnClickListener() { // public void onClick(View v) { // /* // * open in markers to edit it // */ // // FIXME // MarkersUtilities.launchOnImage(context, image); // // Intent intent = new Intent(); // // intent.setAction(android.content.Intent.ACTION_VIEW); // // intent.setDataAndType(Uri.fromFile(image), "image/*"); //$NON-NLS-1$ // // context.startActivity(intent); // } // }); log("Creating thumb and adding it: " + imageId); imageLayout.addView(imageView); imageLayout.invalidate(); addedImages.add(imageId); } if (addedImages.size() > 0) { StringBuilder sb = new StringBuilder(); for (String imagePath : addedImages) { sb.append(IMAGE_ID_SEPARATOR).append(imagePath); } _value = sb.substring(1); log("New img ids: " + _value); } log("Exiting refresh...."); } }
From source file:eu.geopaparazzi.library.forms.views.GSketchView.java
public void refresh(final Context context) throws Exception { log("Entering refresh...."); if (_value != null && _value.length() > 0) { String[] imageSplit = _value.split(";"); log("Handling images: " + _value); IImagesDbHelper imagesDbHelper = DefaultHelperClasses.getDefaulfImageHelper(); for (String imageId : imageSplit) { log("img: " + imageId); if (imageId.length() == 0) { continue; }/*from w ww. java 2s . co m*/ long imageIdLong; try { imageIdLong = Long.parseLong(imageId); } catch (Exception e) { continue; } if (addedImages.contains(imageId.trim())) { continue; } byte[] imageThumbnail = imagesDbHelper.getImageThumbnail(imageIdLong); Bitmap thumbnail = ImageUtilities.getImageFromImageData(imageThumbnail); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(102, 102)); imageView.setPadding(5, 5, 5, 5); imageView.setImageBitmap(thumbnail); imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px)); // imageView.setOnClickListener(new View.OnClickListener() { // public void onClick(View v) { // /* // * open in markers to edit it // */ // MarkersUtilities.launchOnImage(context, image); // } // }); log("Creating thumb and adding it: " + imageId); imageLayout.addView(imageView); imageLayout.invalidate(); addedImages.add(imageId); } if (addedImages.size() > 0) { StringBuilder sb = new StringBuilder(); for (String imagePath : addedImages) { sb.append(";").append(imagePath); } _value = sb.substring(1); log("New img paths: " + _value); } log("Exiting refresh...."); } }
From source file:es.voghdev.prjdagger2.ui.renderer.UserRenderer.java
private void transformImageWithPorterDuff(ImageView imageView) { Drawable background = ContextCompat.getDrawable(mContext, R.drawable.rounded_edges); background.setColorFilter(ContextCompat.getColor(mContext, R.color.light_gray), PorterDuff.Mode.SRC_OVER); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(background); // setBackground requires minSdkVersion >= 16!! } else {/* w w w. jav a 2s.co m*/ imageView.setBackgroundDrawable(background); // setBackground requires minSdkVersion >= 16!! } }
From source file:com.runkun.lbsq.fragment.StickyHeaderFragment2.java
public void add2Shopcart(View triggerView, GoodsCategoryCombineView2Test gccv) { String memberId = ConfigUtil.readString(getActivity(), MyConstant.KEY_MEMBERID, ""); if (Tools.isEmpty(memberId)) { Tools.dialog(getActivity(), Tools.getStr(getActivity(), R.string.REQUESTLOGIN), true, new onButtonClick() { @Override/*from w w w. j av a 2 s. c om*/ public void buttonClick() { getActivity().startActivity(new Intent(getActivity(), LoginActivity.class)); AnimUtil.animToSlide(getActivity()); } }); } else { RequestParams requestParams = new RequestParams(); requestParams.addQueryStringParameter("goods_id", gccv.getGoodId()); requestParams.addQueryStringParameter("quantity", gccv.getOrderCountTV().getText().toString().trim()); requestParams.addQueryStringParameter("member_id", memberId); ImageView aniImg = new ImageView(getActivity()); aniImg.setBackgroundDrawable(gccv.getGoodImgIV().getDrawable()); Tools.addShopCard((BaseAcitivity) getActivity(), "addshopcar", triggerView, mainActivity.getShopcardLayout(), aniImg, requestParams, true); } }
From source file:inc.bait.jubilee.model.helper.util.ImgLoader.java
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(android.R.color.transparent)), new BitmapDrawable(mResources, bitmap) }); imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td);//from w w w . j ava2 s.co m td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:net.naonedbus.fragment.impl.ItineraireFragment.java
private void setIcon(final ImageView imageView, final int icoRes, final int color) { imageView.setImageResource(icoRes);//w ww. jav a 2s.c o m if (color == Color.TRANSPARENT) { imageView.setBackgroundDrawable(null); imageView.setPadding(0, 0, 0, 0); } else { imageView.setBackgroundDrawable(ColorUtils.getCircle(color)); imageView.setPadding(mIconPadding, mIconPadding, mIconPadding, mIconPadding); } }
From source file:android.com.example.contactslist.util.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./*ww w. j av a 2 s. c om*/ */ 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) }); imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }