List of usage examples for android.widget ImageView setTag
public void setTag(final Object tag)
From source file:com.roach.framework.http.bitmap.ImageWorker.java
public void loadImage(Object data, ImageView imageView, boolean memoryCache, boolean diskCache) { if (data == null) { return;//from w w w . j av a2 s. co m } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); task.setMemoryCache(memoryCache); task.setDiskCache(diskCache); Drawable drawable = new BitmapDrawable(mResources, mLoadingBitmap); imageView.setTag(task); imageView.setImageDrawable(drawable); // 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.THREAD_POOL_EXECUTOR, data); } }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populatePeerUpload(View view, PeerHttpUpload upload) { TextView title = findView(view, R.id.view_transfer_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress); TextView status = findView(view, R.id.view_transfer_list_item_status); TextView speed = findView(view, R.id.view_transfer_list_item_speed); TextView size = findView(view, R.id.view_transfer_list_item_size); TextView seeds = findView(view, R.id.view_transfer_list_item_seeds); TextView peers = findView(view, R.id.view_transfer_list_item_peers); ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action); seeds.setText(""); peers.setText(""); title.setText(upload.getDisplayName()); progress.setProgress(upload.getProgress()); status.setText(getStatusFromResId(upload.getStatus())); speed.setText(UIUtils.getBytesInHuman(upload.getUploadSpeed()) + "/s"); size.setText(UIUtils.getBytesInHuman(upload.getSize())); buttonAction.setTag(upload); buttonAction.setOnClickListener(viewOnClickListener); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populatePeerDownload(View view, PeerHttpDownload download) { TextView title = findView(view, R.id.view_transfer_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress); TextView status = findView(view, R.id.view_transfer_list_item_status); TextView speed = findView(view, R.id.view_transfer_list_item_speed); TextView size = findView(view, R.id.view_transfer_list_item_size); TextView seeds = findView(view, R.id.view_transfer_list_item_seeds); TextView peers = findView(view, R.id.view_transfer_list_item_peers); ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action); seeds.setText(""); peers.setText(""); title.setText(download.getDisplayName()); progress.setProgress(download.getProgress()); status.setText(getStatusFromResId(download.getStatus())); speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s"); size.setText(UIUtils.getBytesInHuman(download.getSize())); buttonAction.setTag(download); buttonAction.setOnClickListener(viewOnClickListener); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populateHttpDownload(View view, HttpDownload download) { TextView title = findView(view, R.id.view_transfer_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress); TextView status = findView(view, R.id.view_transfer_list_item_status); TextView speed = findView(view, R.id.view_transfer_list_item_speed); TextView size = findView(view, R.id.view_transfer_list_item_size); TextView seeds = findView(view, R.id.view_transfer_list_item_seeds); TextView peers = findView(view, R.id.view_transfer_list_item_peers); ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action); seeds.setText(""); peers.setText(""); title.setText(download.getDisplayName()); progress.setProgress(download.getProgress()); status.setText(getStatusFromResId(download.getStatus())); speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s"); size.setText(UIUtils.getBytesInHuman(download.getSize())); buttonAction.setTag(download); buttonAction.setOnClickListener(viewOnClickListener); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populateYouTubeDownload(View view, YouTubeDownload download) { TextView title = findView(view, R.id.view_transfer_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress); TextView status = findView(view, R.id.view_transfer_list_item_status); TextView speed = findView(view, R.id.view_transfer_list_item_speed); TextView size = findView(view, R.id.view_transfer_list_item_size); TextView seeds = findView(view, R.id.view_transfer_list_item_seeds); TextView peers = findView(view, R.id.view_transfer_list_item_peers); ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action); seeds.setText(""); peers.setText(""); title.setText(download.getDisplayName()); progress.setProgress(download.getProgress()); status.setText(getStatusFromResId(download.getStatus())); speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s"); size.setText(UIUtils.getBytesInHuman(download.getSize())); buttonAction.setTag(download); buttonAction.setOnClickListener(viewOnClickListener); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populateSoundcloudDownload(View view, SoundcloudDownload download) { TextView title = findView(view, R.id.view_transfer_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress); TextView status = findView(view, R.id.view_transfer_list_item_status); TextView speed = findView(view, R.id.view_transfer_list_item_speed); TextView size = findView(view, R.id.view_transfer_list_item_size); TextView seeds = findView(view, R.id.view_transfer_list_item_seeds); TextView peers = findView(view, R.id.view_transfer_list_item_peers); ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action); seeds.setText(""); peers.setText(""); title.setText(download.getDisplayName()); progress.setProgress(download.getProgress()); status.setText(getStatusFromResId(download.getStatus())); speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s"); size.setText(UIUtils.getBytesInHuman(download.getSize())); buttonAction.setTag(download); buttonAction.setOnClickListener(viewOnClickListener); }
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 www . j av a2 s . 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:com.conferenceengineer.android.iosched.util.ImageLoader.java
public ImageContainer get(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth, int maxHeight) { // Find any old image load request pending on this ImageView (in case this view was // recycled)//w w w .java2 s . 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 the new requestUrl is null or the new requestUrl is different to the previous // recycled requestUrl if (requestUrl == null || !requestUrl.equals(recycledImageUrl)) { if (imageContainer != null) { // Cancel previous image request imageContainer.cancelRequest(); imageView.setTag(null); } if (requestUrl != null) { // Queue new request to fetch image imageContainer = get(requestUrl, getImageListener(mResources, imageView, placeHolder, mFadeInImage), maxWidth, maxHeight); // Store request in ImageView tag imageView.setTag(imageContainer); } else { imageView.setImageDrawable(placeHolder); imageView.setTag(null); } } return imageContainer; }
From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { final TextView title = (TextView) view.findViewById(android.R.id.title); final TextView author = (TextView) view.findViewById(R.id.author); final TextView lastAlterDate = (TextView) view.findViewById(R.id.last_alter_date); registerForContextMenu(title);// w w w. ja v a2s . c om title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().openContextMenu(title); } }); (new Thread(new Runnable() { @Override public void run() { Cursor cursor = getActivity().getContentResolver().query(CatnutProvider.parse(Zhihu.MULTIPLE), PROJECTION, Zhihu.ANSWER_ID + "=" + mAnswerId, null, null); if (cursor.moveToNext()) { mQuestionId = cursor.getLong(cursor.getColumnIndex(Zhihu.QUESTION_ID)); final String _title = cursor.getString(cursor.getColumnIndex(Zhihu.TITLE)); final String _question = cursor.getString(cursor.getColumnIndex(Zhihu.DESCRIPTION)); final String _nick = cursor.getString(cursor.getColumnIndex(Zhihu.NICK)); final String _content = cursor.getString(cursor.getColumnIndex(Zhihu.ANSWER)); final long _lastAlterDate = cursor.getLong(cursor.getColumnIndex(Zhihu.LAST_ALTER_DATE)); cursor.close(); // answer Matcher matcher = HTML_IMG.matcher(_content); final List<String> contentSegment = new ArrayList<String>(); processText(_content, matcher, contentSegment); // question matcher = HTML_IMG.matcher(_question); final List<String> questionSegment = new ArrayList<String>(); processText(_question, matcher, questionSegment); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { title.setText(_title); getActivity().getActionBar().setSubtitle(_title); // ??? int l = contentSegment.size() > 1 ? contentSegment.size() >> 1 : 0; l += questionSegment.size() > 1 ? questionSegment.size() >> 1 : 0; if (l > 0) { mImageUrls = new ArrayList<Uri>(l); } // ? boolean useCachedImg = CatnutApp.getBoolean(R.string.pref_enable_cache_zhihu_images, R.bool.default_plugin_status); l = 0; // reset for reuse String text; int screenWidth = CatnutUtils.getScreenWidth(getActivity()); int max = getActivity().getResources().getDimensionPixelSize(R.dimen.max_thumb_width); if (screenWidth > max) { screenWidth = max; } LayoutInflater inflater = LayoutInflater.from(getActivity()); if (!TextUtils.isEmpty(_question)) { ViewGroup questionHolder = (ViewGroup) view.findViewById(R.id.question); for (int i = 0; i < questionSegment.size(); i++) { text = questionSegment.get(i); if (!TextUtils.isEmpty(text)) { if ((i & 1) == 0) { TextView section = (TextView) inflater.inflate(R.layout.zhihu_text, null); section.setTextSize(16); section.setTextColor( getResources().getColor(R.color.black50PercentColor)); section.setText(Html.fromHtml(text)); section.setMovementMethod(LinkMovementMethod.getInstance()); CatnutUtils.removeLinkUnderline(section); questionHolder.addView(section); } else { ImageView imageView = getImageView(); Uri uri = useCachedImg ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text)) : Uri.parse(text); Picasso.with(getActivity()).load(uri).centerCrop() .resize(screenWidth, (int) (Constants.GOLDEN_RATIO * screenWidth)) .error(R.drawable.error).into(imageView); imageView.setTag(l++); // for click imageView.setOnClickListener(ZhihuItemFragment.this); mImageUrls.add(uri); questionHolder.addView(imageView); } } } } Typeface typeface = CatnutUtils.getTypeface(CatnutApp.getTingtingApp().getPreferences(), getString(R.string.pref_customize_tweet_font), getString(R.string.default_typeface)); ViewGroup answerHolder = (ViewGroup) view.findViewById(R.id.answer); for (int i = 0; i < contentSegment.size(); i++) { text = contentSegment.get(i); if (!TextUtils.isEmpty(text)) { if ((i & 1) == 0) { TextView section = (TextView) inflater.inflate(R.layout.zhihu_text, null); section.setText(Html.fromHtml(text)); CatnutUtils.setTypeface(section, typeface); CatnutUtils.removeLinkUnderline(section); section.setMovementMethod(LinkMovementMethod.getInstance()); answerHolder.addView(section); } else { ImageView image = getImageView(); Uri uri = useCachedImg ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text)) : Uri.parse(text); Picasso.with(getActivity()).load(uri).centerCrop() .resize(screenWidth, (int) (Constants.GOLDEN_RATIO * screenWidth)) .error(R.drawable.error).into(image); image.setTag(l++); // image.setOnClickListener(ZhihuItemFragment.this); mImageUrls.add(uri); answerHolder.addView(image); } } } author.setText(_nick); lastAlterDate.setText(DateUtils.getRelativeTimeSpanString(_lastAlterDate)); if (mSwipeRefreshLayout != null) { mSwipeRefreshLayout.setRefreshing(false); } } }); } else { cursor.close(); } } })).start(); }
From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java
protected void displayAccountBanner(@NonNull ParcelableAccount account) { final int bannerWidth = mAccountProfileBannerView.getWidth(); final Resources res = getResources(); final int defWidth = res.getDisplayMetrics().widthPixels; final int width = bannerWidth > 0 ? bannerWidth : defWidth; final ImageView bannerView = (ImageView) mAccountProfileBannerView.getNextView(); if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(account, bannerView.getTag())) { mMediaLoader.displayProfileBanner(bannerView, account, width); bannerView.setTag(account); } else {/*from ww w. j av a2 s. c o m*/ mMediaLoader.cancelDisplayTask(bannerView); } }