List of usage examples for android.widget ImageView getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:com.android.volley.cache.SimpleImageLoader.java
public ImageContainer set(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth, int maxHeight, Bitmap bitmap) { // Find any old image load request pending on this ImageView (in case this view was // recycled)/*from w ww . j a v a 2s . c o m*/ ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer ? (ImageContainer) imageView.getTag() : null; // Find image url from prior request //String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null; if (imageContainer != null) { // Cancel previous image request imageContainer.cancelRequest(); imageView.setTag(null); } if (requestUrl != null) { // Queue new request to fetch image imageContainer = set(requestUrl, getImageListener(getResources(), imageView, placeHolder, mFadeInImage), maxWidth, maxHeight, imageView.getScaleType(), bitmap); // Store request in ImageView tag imageView.setTag(imageContainer); } else { if (!(imageView instanceof PhotoView)) { imageView.setImageDrawable(placeHolder); } imageView.setTag(null); } return imageContainer; }
From source file:es.ubiqua.atractivas.ArticlePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rss = ((ArticleActivity) getActivity()).m_parts.get(mPageNumber); // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_article_page, container, false); FontLoader.overrideFonts(rootView, "bold"); NoAutoScrollView scroll = (NoAutoScrollView) rootView.findViewById(R.id.content); if (((ArticleActivity) getActivity()).m_parts.size() <= 1) { ((ArticleActivity) getActivity()).hideButtons(); } else {//from w w w . j a v a2 s .c o m scroll.setOnEndScrollListener(new NoAutoScrollView.OnEndScrollListener() { @Override public void onEndScroll(boolean home, boolean end) { if (home || end) { ((ArticleActivity) getActivity()).showButtons(); } else { ((ArticleActivity) getActivity()).hideButtons(); } } }); } // Set the title view to show the page number. ((TextView) rootView.findViewById(R.id.DetalleCategoria)).setText(rss.getCategory()); ImageView favorito = (ImageView) rootView.findViewById(R.id.DetalleFavorito); favorito.setTag(rss); if (rss.getFavorito()) { favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected")); } else { favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos")); } ((TextView) rootView.findViewById(R.id.DetalleTitulo)).setText(rss.getTitle()); favorito.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImageView imagen = (ImageView) view; RssDataSource _rssDataSource = new RssDataSource(getActivity().getApplicationContext()); try { _rssDataSource.open(); } catch (SQLException e) { // Log.d( "action fragment_category", "Enter: handleMessage -> " + e.getMessage() ); } Rss rss = (Rss) imagen.getTag(); rss.setFavorito(!rss.getFavorito()); _rssDataSource.updateFavorito(rss.getId(), rss.getFavorito()); if (rss.getFavorito()) { imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected")); } else { imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos")); } _rssDataSource.close(); } }); // whenever you want to load an image from url // call DisplayImage function // url - image url to load // loader - loader image, will be displayed before getting image // image - ImageView imgLoader.DisplayImage(rss.getImage(), R.drawable.placeholder_detalle, (ImageView) rootView.findViewById(R.id.DetalleImagen)); ((WebView) rootView.findViewById(R.id.DestalleFulltext)).loadData(HEADER + rss.getFullText() + FOOTER, "text/html; charset=UTF-8", null); yocAdBannerViewb = (YocAdViewContainer) rootView.findViewById(R.id.baner_publicidad); if (rss.getParentCategory().equals(new String("En Forma"))) { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_ENFORMA_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } else if (rss.getParentCategory().equals(new String("Salud"))) { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_SALUD_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } else if (rss.getParentCategory().equals(new String("Moda"))) { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_MODA_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } else if (rss.getParentCategory().equals(new String("Nutricin"))) { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_NUTRI_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } else if (rss.getParentCategory().equals(new String("Belleza"))) { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_BELLEZA_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } else { _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_GENERAL_BANNER, AdSize.BANNER_SMARTPHONE_480x80, new AdBanner()); } createLigAdView(ApplicationApp.LigatusId, rootView); return rootView; }
From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == UCrop.REQUEST_CROP) { File cropFile = new File(UCrop.getOutput(data).getPath()); int index = 0; for (int id : postImageViewIds) { ImageView mImageView = (ImageView) rootView.findViewById(id); if (mImageView.getTag() == null) { rootView.findViewById(postImageViewPlusIds[index]).setVisibility(View.VISIBLE); rootView.findViewById(postImageViewRemoveIds[index]).setVisibility(View.VISIBLE); mImageView.setImageBitmap(BitmapFactory.decodeFile(cropFile.getPath())); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); mImageView.setPadding(10, 10, 10, 10); mImageView.setTag(cropFile.getPath()); mImageViewTitle.setImageDrawable(((ImageView) rootView.findViewById(id)).getDrawable()); mImageViewTitle.setTag(id); break; }// w w w. j av a 2 s . c om index++; } } else if (resultCode == Activity.RESULT_OK && requestCode == PICK_PHOTO_FOR_AVATAR) { UCrop.of(data.getData(), Uri.fromFile( new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"))) .withMaxResultSize(1920, 1920).start(getContext(), this); } else if (resultCode == Activity.RESULT_OK && requestCode == TAKE_PHOTO_FOR_AVATAR) { UCrop.of(Uri.fromFile(takeFile), Uri.fromFile( new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"))) .withMaxResultSize(1920, 1920).start(getContext(), this); } else if (resultCode == UCrop.RESULT_ERROR) { final Throwable cropError = UCrop.getError(data); Log.d("mox", "croperror" + cropError.toString()); } else if (resultCode == Activity.RESULT_OK && requestCode == SEARCH_ADDRESS) { AddressModel mAddressModel = (AddressModel) data.getSerializableExtra("data"); setAddressModel(mAddressModel); } else if (resultCode == Activity.RESULT_OK && requestCode == PICK_VIDEO_FOR_AVATAR) { String path = getPath(data.getData()); showVideoAlertDialog(path); } else if (resultCode == Activity.RESULT_OK && requestCode == TAKE_VIDEO_FOR_AVATAR) { String path = takeFile.getPath(); showVideoAlertDialog(path); } }
From source file:de.vanita5.twittnuker.fragment.support.AccountsDashboardFragment.java
private void updateAccountOptionsSeparatorLabel() { final ParcelableAccount account = mAccountsAdapter.getSelectedAccount(); if (account == null) { return;/*from w ww . j a v a2 s . c o m*/ } mAccountProfileNameView.setText(account.name); mAccountProfileScreenNameView.setText("@" + account.screen_name); mAccountsToggle.setChecked(account.is_activated); mImageLoader.displayProfileImage(mAccountProfileImageView, account.profile_image_url); final int bannerWidth = mAccountProfileBannerView.getWidth(); final Resources res = getResources(); final int defWidth = res.getDisplayMetrics().widthPixels; final int width = bannerWidth > 0 ? bannerWidth : defWidth; final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width); final ImageView bannerView = mAccountProfileBannerView; if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) { mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this); } }
From source file:org.matrix.androidsdk.db.MXMediaWorkerTask.java
@Override protected void onPostExecute(Bitmap bitmap) { if (null != mErrorAsJsonElement) { sendError(mErrorAsJsonElement);//from w w w. j a v a 2 s . c o m } sendDownloadComplete(); // update the imageView image if (bitmap != null) { for (WeakReference<ImageView> weakRef : mImageViewReferences) { final ImageView imageView = weakRef.get(); if (imageView != null && TextUtils.equals(mUrl, (String) imageView.getTag())) { imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setImageBitmap(bitmap); } } } }
From source file:com.secretlisa.lib.utils.BaseImageLoader.java
private void forceDownload(String url, ImageView imageView) { if (url == null) { imageView.setImageDrawable(null); return;// ww w .j a v a 2 s . c o m } if (cancelPotentialDownload(url, imageView)) { BitmapDownloaderTask task = null; task = new BitmapDownloaderTask(imageView, url); Object obj = imageView.getTag(); int resId = -1; Bitmap bitmapDefault = null; if (obj != null) { resId = (Integer) obj; bitmapDefault = BitmapFactory.decodeResource(imageView.getResources(), resId); } DownloadedDrawable downloadedDrawable = new DownloadedDrawable(bitmapDefault, task); imageView.setImageDrawable(downloadedDrawable); // imageView.setBackgroundColor(Color.WHITE); // imageView.setBackgroundResource(R.drawable.wallpaper_bg); imageView.setMinimumHeight(156); task.execute(); } }
From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java
private void removeImage(int index) { for (int i = index; i < postImageViewIds.length - 1; i++) { int nextIndex = i + 1; ImageView nowImage = (ImageView) rootView.findViewById(postImageViewIds[i]); ImageView nextImage = (ImageView) rootView.findViewById(postImageViewIds[nextIndex]); nowImage.setImageDrawable(nextImage.getDrawable()); nowImage.setTag(nextImage.getTag()); rootView.findViewById(postImageViewPlusIds[i]) .setVisibility(rootView.findViewById(postImageViewPlusIds[nextIndex]).getVisibility()); rootView.findViewById(postImageViewRemoveIds[i]) .setVisibility(rootView.findViewById(postImageViewRemoveIds[nextIndex]).getVisibility()); if (nowImage.getTag() == null) { nowImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); } else {/*ww w . j a v a 2 s. c o m*/ nowImage.setScaleType(ImageView.ScaleType.FIT_XY); } } int lastIndex = postImageViewIds.length - 1; ImageView lastImage = (ImageView) rootView.findViewById(postImageViewIds[lastIndex]); lastImage.setImageResource(R.drawable.ic_add_photo); lastImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); lastImage.setTag(null); rootView.findViewById(postImageViewPlusIds[lastIndex]).setVisibility(View.GONE); rootView.findViewById(postImageViewRemoveIds[lastIndex]).setVisibility(View.GONE); }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setOrAnimateIconTo(final ImageView imageView, final int imageResId, boolean animate) { if (UIUtils.hasICS() && imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();// ww w . j a v a 2 s .c o m imageView.setAlpha(1f); } } animate = animate && UIUtils.hasICS(); if (animate) { int duration = getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); inAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:com.luorrak.ouroboros.reply.ReplyCommentFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_attach_file) { if (reply.filePath.size() < 5) { if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, Util.REQUEST_STORAGE_PERMISSION); } else { selectFile();//w w w . j av a 2 s . c om } } else { Snackbar.make(getView(), "Maximum amount of attachments reached", Snackbar.LENGTH_LONG).show(); } } if (id == R.id.action_submit && !isPosting) { isPosting = true; ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.progress_bar); progressBar.setVisibility(View.VISIBLE); EditText nameText = (EditText) getActivity().findViewById(R.id.post_comment_editText_name); EditText emailText = (EditText) getActivity().findViewById(R.id.post_comment_editText_email); EditText subjectText = (EditText) getActivity().findViewById(R.id.post_comment_editText_subject); EditText commentText = (EditText) getActivity().findViewById(R.id.post_comment_editText_comment); EditText captchaText = (EditText) getActivity().findViewById(R.id.post_comment_captcha_editText); ImageView captchaImage = (ImageView) getActivity().findViewById(R.id.post_comment_captcha_image); reply.name = nameText.getText().toString(); reply.email = emailText.getText().toString(); reply.subject = subjectText.getText().toString(); reply.comment = commentText.getText().toString(); reply.captchaText = captchaText.getText().toString(); if (captchaImage.getTag() != null) { reply.captchaCookie = captchaImage.getTag().toString(); } reply.resto = resto; reply.board = boardName; reply.password = SettingsHelper.getPostPassword(getContext()); networkHelper.postReply(getActivity(), reply, sharedPreferences, new JsonParser(), new InfiniteDbHelper(getActivity()), getView()); } return super.onOptionsItemSelected(item); }
From source file:android.support.asy.image.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing * logic). A memory and disk cache will be used if an {@link ImageCache} has * been set using {@link ImageWorker#setImageCache(ImageCache)}. If the * image is found in the memory cache, it is set immediately, otherwise an * {@link AsyncTask} will be created to asynchronously load the bitmap. * /* w w w . jav a2 s . c om*/ * @param data * The URL of the image to download. * @param imageView * The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (TextUtils.isEmpty((String) data)) { return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache if ("fullscreen".equals(imageView.getTag())) { calculateImageViewHeight(String.valueOf(data), imageView); } imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { // imageview???false???imageview?true final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been // pulled from the // framework and slightly modified. Refer to the docs at the top of // the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, data); } }