List of usage examples for android.widget ImageView setTag
public void setTag(final Object tag)
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
/** * Private convenience methods used by this class. *//*from ww w . j av a 2 s . co m*/ private void setActiveIndicator(int position) { if (mIndicatorContainer.findViewWithTag(TAG_CIRCLE) == null) { // No indicators yet, let's make some. Only run once per configuration. for (int i = 0; i < getCount(); i++) { ImageView indicator = (ImageView) View.inflate(mContext, R.layout.swipeselector_circle_item, null); if (i == position) { indicator.setImageDrawable(mActiveCircleDrawable); } else { indicator.setImageDrawable(mInActiveCircleDrawable); } indicator.setLayoutParams(mCircleParams); indicator.setTag(TAG_CIRCLE); mIndicatorContainer.addView(indicator); } return; } ImageView previousActiveIndicator = (ImageView) mIndicatorContainer.getChildAt(mCurrentPosition); ImageView nextActiveIndicator = (ImageView) mIndicatorContainer.getChildAt(position); previousActiveIndicator.setImageDrawable(mInActiveCircleDrawable); nextActiveIndicator.setImageDrawable(mActiveCircleDrawable); mCurrentPosition = position; if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(getSelectedItem()); } }
From source file:com.glabs.homegenie.adapters.MediaRendererWidgetAdapter.java
@Override public void updateViewModel() { if (_module.View == null) return;/*from w w w. j a va 2 s . co m*/ _updateRendererDisplayData(); TextView title = (TextView) _module.View.findViewById(R.id.titleText); TextView subtitle = (TextView) _module.View.findViewById(R.id.subtitleText); TextView infotext = (TextView) _module.View.findViewById(R.id.infoText); title.setText(_module.getDisplayName()); infotext.setVisibility(View.GONE); subtitle.setText(Control.getUpnpDisplayName(_module)); // if (_module.getParameter("UPnP.StandardDeviceType") != null && !_module.getParameter("UPnP.StandardDeviceType").Value.trim().equals("")) { infotext.setText(_module.getParameter("UPnP.StandardDeviceType").Value); infotext.setVisibility(View.VISIBLE); } // final ImageView image = (ImageView) _module.View.findViewById(R.id.iconImage); if (image.getTag() == null && !(image.getDrawable() instanceof AsyncImageDownloadTask.DownloadedDrawable)) { AsyncImageDownloadTask asyncDownloadTask = new AsyncImageDownloadTask(image, true, new AsyncImageDownloadTask.ImageDownloadListener() { @Override public void imageDownloadFailed(String imageUrl) { } @Override public void imageDownloaded(String imageUrl, Bitmap downloadedImage) { image.setTag("CACHED"); } }); asyncDownloadTask.download(Control.getHgBaseHttpAddress() + getModuleIcon(_module), image); } }
From source file:com.frostwire.android.gui.adapters.SearchResultListAdapter.java
private void populateThumbnail(View view, SearchResult sr) { ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon); if (sr.getThumbnailUrl() != null) { thumbLoader.load(Uri.parse(sr.getThumbnailUrl()), fileTypeIcon, 96, 96, getFileTypeIconId()); }//from w w w . ja va 2s . c o m MediaPlaybackStatusOverlayView overlayView = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon_media_playback_overlay_view); fileTypeIcon.setOnClickListener(previewClickListener); if (isAudio(sr) || sr instanceof YouTubePackageSearchResult) { fileTypeIcon.setTag(sr); overlayView.setTag(sr); overlayView.setVisibility(View.VISIBLE); overlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.PREVIEW); overlayView.setOnClickListener(previewClickListener); } else { fileTypeIcon.setTag(null); overlayView.setTag(null); overlayView.setVisibility(View.GONE); overlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.NONE); } }
From source file:com.frostwire.android.gui.adapters.FileListAdapter.java
private View getListItemView(int position, View view, ViewGroup parent) { view = super.getView(position, view, parent); final FileDescriptorItem item = getItem(position); if (item.fd.fileType == Constants.FILE_TYPE_AUDIO || item.fd.fileType == Constants.FILE_TYPE_RINGTONES) { initPlaybackStatusOverlayTouchFeedback(view, item); }// ww w . j a va2 s.c o m ImageView thumbnailView = findView(view, R.id.view_my_files_thumbnail_list_item_browse_thumbnail_image_button); if (thumbnailView != null) { thumbnailView.setTag(item); thumbnailView.setOnClickListener(v -> { if (!selectAllMode) { if (getShowMenuOnClick()) { if (showMenu(v)) { return; } } LOG.info("AbstractListAdapter.ViewOnClickListener.onClick()"); onItemClicked(v); } else { onItemClicked(v); } }); } return view; }
From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { if (cursorLoader == mGeneralInfoLoader) { if (cursor != null && cursor.moveToFirst()) { int columnIndexPosterPath = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_POSTER_PATH); String posterPath = MovieAdapter.POSTER_BASE_URL_W185 + cursor.getString(columnIndexPosterPath); Picasso picasso = Picasso.with(getActivity()); picasso.load(posterPath).into(mPosterImageView); int columnIndexTitle = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_TITLE); String title = cursor.getString(columnIndexTitle); mTitleTextView.setText(title); int columnIndexIsFavorite = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED); int isFavorite = cursor.getInt(columnIndexIsFavorite); mHeartImageView/*ww w . jav a 2 s. c o m*/ .setImageResource(isFavorite == 1 ? R.drawable.heart_active : R.drawable.heart_inactive); mHeartImageView.setOnClickListener(this); int columnIndexReleaseDate = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_RELEASE_DATE); String releaseDateText = cursor.getString(columnIndexReleaseDate); String releaseYearText = releaseDateText.substring(0, Math.min(releaseDateText.length(), 4)); mReleaseYearTextView.setText(releaseYearText); int columnIndexVoteAverage = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_VOTE_AVERAGE); float vote_average = cursor.getFloat(columnIndexVoteAverage); mRatingBar.setRating(vote_average); int columnIndexSynopsis = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_SYNOPSIS); mSynopsisTextView.setText(cursor.getString(columnIndexSynopsis)); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareText = title; mShareActionProvider.setShareIntent(createShareIntent()); } } else { Log.e(LOG_TAG, "Cursor to populate general info was empty or null!"); } } else if (cursorLoader == mTrailerLoader) { if (cursor == null || !cursor.moveToFirst()) { mTrailerListTitle.setVisibility(View.INVISIBLE); } else { mTrailerListTitle.setVisibility(View.VISIBLE); for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) { int columnIndexName = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_NAME); String trailerName = cursor.getString(columnIndexName); int columnIndexLanguageCode = cursor .getColumnIndex(MovieContract.TrailersTable.COLUMN_LANGUAGE_CODE); String trailerLanguageCode = cursor.getString(columnIndexLanguageCode); String trailer_summary = String.format("%s (%s)", trailerName, trailerLanguageCode.toUpperCase()); int columnIndexSite = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_SITE); String site = cursor.getString(columnIndexSite); int columnIndexKey = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_KEY); String key = cursor.getString(columnIndexKey); String link = null; if (site.compareTo("YouTube") == 0) { link = "https://www.youtube.com/watch?v=" + key; } else { Log.e(LOG_TAG, "Unsupported site: " + site); } ImageView trailerThumbnail = (ImageView) mActivity.getLayoutInflater() .inflate(R.layout.detail_fragment_trailer_item, null, false); if (site.compareTo("YouTube") == 0) { Picasso picasso = Picasso.with(mActivity); String youtubeThumbnailPath = String.format("http://img.youtube.com/vi/%s/mqdefault.jpg", key); picasso.load(youtubeThumbnailPath).into(trailerThumbnail); trailerThumbnail.setTag(link); trailerThumbnail.setOnClickListener(this); } mTrailerList.addView(trailerThumbnail); } } } else if (cursorLoader == mReviewLoader) { if (cursor == null || !cursor.moveToFirst()) { mReviewListTitle.setVisibility(View.INVISIBLE); } else { mReviewListTitle.setVisibility(View.VISIBLE); String colors[] = { "#00BFFF", "#00CED1", "#FF8C00", "#00FA9A", "#9400D3" }; for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) { int columnIndexAuthor = cursor.getColumnIndex(MovieContract.ReviewsTable.COLUMN_AUTHOR); String author = cursor.getString(columnIndexAuthor); String authorAbbreviation = author != null && author.length() >= 1 ? author.substring(0, 1) : "?"; int columnIndexReviewText = cursor .getColumnIndex(MovieContract.ReviewsTable.COLUMN_REVIEW_TEXT); String reviewText = cursor.getString(columnIndexReviewText); RelativeLayout review = (RelativeLayout) mActivity.getLayoutInflater() .inflate(R.layout.detail_fragment_review_item, null, false); review.setOnClickListener(this); review.setTag(TAG_REVIEW_COLLAPSED); TextView authorIcon = (TextView) review.findViewById(R.id.author_icon); authorIcon.setText(authorAbbreviation); int color = Color.parseColor(colors[cursor.getPosition() % colors.length]); authorIcon.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); TextView authorFullName = (TextView) review.findViewById(R.id.author_full_name); authorFullName.setText(author); TextView reviewTextView = (TextView) review.findViewById(R.id.review_text); reviewTextView.setText(reviewText); mReviewList.addView(review); } } } }
From source file:com.todoroo.astrid.adapter.TaskAdapter.java
/** Helper method to set the contents and visibility of each field */ public synchronized void setFieldContentsAndVisibility(View view) { ViewHolder viewHolder = (ViewHolder) view.getTag(); Task task = viewHolder.task;/*from w w w . j ava 2 s .c o m*/ if (fontSize < 16) { viewHolder.rowBody.setMinimumHeight(0); viewHolder.completeBox.setMinimumHeight(0); } else { viewHolder.rowBody.setMinimumHeight(minRowHeight); viewHolder.completeBox.setMinimumHeight(minRowHeight); } // name final TextView nameView = viewHolder.nameView; { String nameValue = task.getTitle(); long hiddenUntil = task.getHideUntil(); if (task.getDeletionDate() > 0) { nameValue = resources.getString(R.string.TAd_deletedFormat, nameValue); } if (hiddenUntil > DateUtilities.now()) { nameValue = resources.getString(R.string.TAd_hiddenFormat, nameValue); } nameView.setText(nameValue); } setupDueDateAndTags(viewHolder, task); // Task action ImageView taskAction = viewHolder.taskActionIcon; if (taskAction != null) { TaskAction action = getTaskAction(task, viewHolder.hasFiles, viewHolder.hasNotes); if (action != null) { viewHolder.taskActionContainer.setVisibility(View.VISIBLE); taskAction.setImageResource(action.icon); taskAction.setTag(action); } else { viewHolder.taskActionContainer.setVisibility(View.GONE); taskAction.setTag(null); } } }
From source file:com.android.calendar.event.EventLocationAdapter.java
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { View view = convertView;// w ww .j a va 2s . co m if (view == null) { view = mInflater.inflate(R.layout.location_dropdown_item, parent, false); } final Result result = getItem(position); if (result == null) { return view; } // Update the display name in the item in auto-complete list. TextView nameView = (TextView) view.findViewById(R.id.location_name); if (nameView != null) { if (result.mName == null) { nameView.setVisibility(View.GONE); } else { nameView.setVisibility(View.VISIBLE); nameView.setText(result.mName); } } // Update the address line. TextView addressView = (TextView) view.findViewById(R.id.location_address); if (addressView != null) { addressView.setText(result.mAddress); } // Update the icon. final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (imageView != null) { if (result.mDefaultIcon == null) { imageView.setVisibility(View.INVISIBLE); } else { imageView.setVisibility(View.VISIBLE); imageView.setImageResource(result.mDefaultIcon); // Save the URI on the view, so we can check against it later when updating // the image. Otherwise the async image update with using 'convertView' above // resulted in the wrong list items being updated. imageView.setTag(result.mContactPhotoUri); if (result.mContactPhotoUri != null) { Bitmap cachedPhoto = mPhotoCache.get(result.mContactPhotoUri); if (cachedPhoto != null) { // Use photo in cache. imageView.setImageBitmap(cachedPhoto); } else { // Asynchronously load photo and update. asyncLoadPhotoAndUpdateView(result.mContactPhotoUri, imageView); } } } } return view; }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Drop money from the top of the layout to the bottom simulating that a * coin or bill is inserted in the moneybox. * //from www . j ava 2 s .c o m * @param leftMargin * Left side of the coin/bill * @param width * Width of the image to slide down * @param m * Movement with the value of the money to drop */ protected void dropMoney(int leftMargin, int width, Movement m) { ImageView money; AnimationSet moneyDrop; RelativeLayout layout; RelativeLayout.LayoutParams lpParams; Rect r; Activity parent; CurrencyValueDef curr; parent = getActivity(); curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); r = curr.getDrawable().getBounds(); money = new ImageView(parent); money.setVisibility(View.INVISIBLE); money.setImageDrawable(curr.getDrawable().getConstantState().newDrawable()); money.setTag(curr); money.setId((int) m.getIdMovement()); layout = findLayout(); lpParams = new RelativeLayout.LayoutParams(r.width(), r.height()); lpParams.leftMargin = leftMargin; lpParams.rightMargin = layout.getWidth() - (leftMargin + width); lpParams.topMargin = 0; lpParams.bottomMargin = r.height(); layout.addView(money, lpParams); moneyDrop = createDropAnimation(money, layout, curr); money.setVisibility(View.VISIBLE); SoundsManager.playMoneySound(curr.getType()); VibratorManager.vibrateMoneyDrop(curr.getType()); money.startAnimation(moneyDrop); }
From source file:com.skyousuke.ivtool.windows.MainWindow.java
private void updateImageResource(ImageView view, int resId) { Integer tag = (Integer) view.getTag(); if (tag == null || tag != resId) { view.setImageResource(resId);//from w w w . j av a 2 s. c o m view.setTag(resId); } }
From source file:com.android.volley.cache.plus.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 ww w.jav a2s . 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, bitmap); // Store request in ImageView tag imageView.setTag(imageContainer); } else { if (!(imageView instanceof PhotoView)) { imageView.setImageDrawable(placeHolder); } imageView.setTag(null); } return imageContainer; }