Example usage for android.widget ImageView setTag

List of usage examples for android.widget ImageView setTag

Introduction

In this page you can find the example usage for android.widget ImageView setTag.

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:com.eutectoid.dosomething.picker.GraphObjectAdapter.java

protected void populateGraphObjectView(View view, JSONObject graphObject) {
    String id = getIdOfGraphObject(graphObject);
    view.setTag(id);/*from  w w  w .jav  a2  s. c om*/

    CharSequence title = getTitleOfGraphObject(graphObject);
    TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
    if (titleView != null) {
        titleView.setText(title, TextView.BufferType.SPANNABLE);
    }

    CharSequence subtitle = getSubTitleOfGraphObject(graphObject);
    TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle);
    if (subtitleView != null) {
        if (subtitle != null) {
            subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE);
            subtitleView.setVisibility(View.VISIBLE);
        } else {
            subtitleView.setVisibility(View.GONE);
        }
    }

    if (getShowCheckbox()) {
        CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox);
        updateCheckboxState(checkBox, isGraphObjectSelected(id));
    }

    if (getShowPicture()) {
        Uri pictureURI = getPictureUriOfGraphObject(graphObject);

        if (pictureURI != null) {
            ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image);

            // See if we have already pre-fetched this; if not, download it.
            if (prefetchedPictureCache.containsKey(id)) {
                ImageResponse response = prefetchedPictureCache.get(id);
                profilePic.setImageBitmap(response.getBitmap());
                profilePic.setTag(response.getRequest().getImageUri());
            } else {
                downloadProfilePicture(id, pictureURI, profilePic);
            }
        }
    }
}

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;
            }/*from w w w .  j a  va 2  s  . c  o  m*/
            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:com.trk.aboutme.facebook.widget.GraphObjectAdapter.java

protected void populateGraphObjectView(View view, T graphObject) {
    String id = getIdOfGraphObject(graphObject);
    view.setTag(id);/* w w  w.j  a  v  a 2 s .co m*/

    CharSequence title = getTitleOfGraphObject(graphObject);
    TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
    if (titleView != null) {
        titleView.setText(title, TextView.BufferType.SPANNABLE);
    }

    CharSequence subtitle = getSubTitleOfGraphObject(graphObject);
    TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle);
    if (subtitleView != null) {
        if (subtitle != null) {
            subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE);
            subtitleView.setVisibility(View.VISIBLE);
        } else {
            subtitleView.setVisibility(View.GONE);
        }
    }

    if (getShowCheckbox()) {
        CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox);
        updateCheckboxState(checkBox, isGraphObjectSelected(id));
    }

    if (getShowPicture()) {
        URL pictureURL = getPictureUrlOfGraphObject(graphObject);

        if (pictureURL != null) {
            ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image);

            // See if we have already pre-fetched this; if not, download it.
            if (prefetchedPictureCache.containsKey(id)) {
                ImageResponse response = prefetchedPictureCache.get(id);
                profilePic.setImageBitmap(response.getBitmap());
                profilePic.setTag(response.getRequest().getImageUrl());
            } else {
                downloadProfilePicture(id, pictureURL, profilePic);
            }
        }
    }
}

From source file:com.roger.lineselectionwebview.LSWebView.java

/**
 * ?//from w w w .  j a va2s  . c  o m
 */
private void drawImage() {
    int size = rectList.size();
    Rect endRect = rectList.get(size - 1);
    Rect realEndRect = endRect;

    // ?left???,,?
    if (size > 2) {
        Rect endPreRect = rectList.get(size - 2);
        if (endRect.left == endPreRect.left) {
            if (endRect.width() > endPreRect.width()) {
                realEndRect = endPreRect;
            } else {
                realEndRect = endRect;
            }
        }
    }

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.del);
    ImageView imageView = new ImageView(mContext);
    imageView.setImageBitmap(bitmap);
    imageView.setScaleType(ScaleType.CENTER);
    imageView.setTag(selectContext);
    MyAbsoluteLayout.LayoutParams lp = new MyAbsoluteLayout.LayoutParams(
            MyAbsoluteLayout.LayoutParams.WRAP_CONTENT, MyAbsoluteLayout.LayoutParams.WRAP_CONTENT,
            realEndRect.right, realEndRect.bottom);
    imageView.setLayoutParams(lp);

    imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String tag = (String) v.getTag();
            lineView.remove(tag);
            myLayout.removeView(v);
            if (onTextSelectListener != null) {
                onTextSelectListener.cancle(tag.split(SELECT_SPLIT)[0]);
            }
        }

    });
    myLayout.addView(imageView, lp);
}

From source file:com.likou.util.NImageLoader.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)/*from  w w w.  j a va2s  .co  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:com.facebook.widget.GraphObjectAdapter.java

protected void populateGraphObjectView(View view, T graphObject) {
    String id = getIdOfGraphObject(graphObject);
    view.setTag(id);/* w w w .j a v  a2  s .  c  om*/

    CharSequence title = getTitleOfGraphObject(graphObject);
    TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
    if (titleView != null) {
        titleView.setText(title, TextView.BufferType.SPANNABLE);
    }

    CharSequence subtitle = getSubTitleOfGraphObject(graphObject);
    TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle);
    if (subtitleView != null) {
        if (subtitle != null) {
            subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE);
            subtitleView.setVisibility(View.VISIBLE);
        } else {
            subtitleView.setVisibility(View.GONE);
        }
    }

    if (getShowCheckbox()) {
        CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox);
        updateCheckboxState(checkBox, isGraphObjectSelected(id));
    }

    if (getShowPicture()) {
        URI pictureURI = getPictureUriOfGraphObject(graphObject);

        if (pictureURI != null) {
            ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image);

            // See if we have already pre-fetched this; if not, download it.
            if (prefetchedPictureCache.containsKey(id)) {
                ImageResponse response = prefetchedPictureCache.get(id);
                profilePic.setImageBitmap(response.getBitmap());
                profilePic.setTag(response.getRequest().getImageUri());
            } else {
                downloadProfilePicture(id, pictureURI, profilePic);
            }
        }
    }
}

From source file:org.egov.android.view.activity.CreateComplaintActivity.java

/**
 * Function used to show the image added to complaint in image view. A close icon is shown at
 * the top right corner of the image to delete it
 * /*from w w w  .  j  a va 2s.co  m*/
 * @param imagePath
 */
@SuppressLint("InflateParams")
private void _addImageView(String imagePath) {
    final ImageView image_container = (ImageView) findViewById(R.id.image_container);
    LinearLayout container = (LinearLayout) findViewById(R.id.container);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.add_photo, null);

    RelativeLayout inner_container = (RelativeLayout) view.findViewById(R.id.inner_container);
    LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(100),
            _dpToPix(100));

    inner_container.setLayoutParams(inner_container_params);

    ImageView image = (ImageView) view.findViewById(R.id.image);
    image.setImageBitmap(_getBitmapImage(imagePath));
    image.setTag(imagePath);
    container.addView(inner_container);
    imageUrl.add(imagePath);

    image_container.setImageBitmap(_getBitmapImage(imagePath));

    ImageView delete_icon = (ImageView) view.findViewById(R.id.delete_photo);
    delete_icon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            file_upload_limit--;
            RelativeLayout deleteView = (RelativeLayout) v.getParent();
            ((LinearLayout) findViewById(R.id.container)).removeView(deleteView);
            ImageView image = (ImageView) deleteView.findViewById(R.id.image);
            _deleteFile(image.getTag().toString());
            _reorderFiles();
        }
    });
    inner_container.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ImageView image = (ImageView) v.findViewById(R.id.image);
            ((ImageView) findViewById(R.id.image_container))
                    .setImageBitmap(_getBitmapImage(image.getTag().toString()));
        }
    });

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.hr_scroll);
            hsv.scrollTo(hsv.getWidth() + 600, 0);
        }
    }, 500);
}

From source file:org.xbmc.kore.ui.sections.audio.AlbumSongsListFragment.java

private void displaySongs(Cursor cursor) {
    songInfoList = new ArrayList<>(cursor.getCount());
    LinearLayout listView = (LinearLayout) getView();
    do {/*  w w w. j a  va  2 s .  c  o m*/
        View songView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_song, listView, false);
        TextView songTitle = (TextView) songView.findViewById(R.id.song_title);
        TextView trackNumber = (TextView) songView.findViewById(R.id.track_number);
        TextView details = (TextView) songView.findViewById(R.id.details);
        ImageView contextMenu = (ImageView) songView.findViewById(R.id.list_context_menu);

        String artist = cursor.getString(AlbumSongsListQuery.ARTIST);

        // Add this song to the list
        FileDownloadHelper.SongInfo songInfo = new FileDownloadHelper.SongInfo(artist, albumTitle,
                cursor.getInt(AlbumSongsListQuery.SONGID), cursor.getInt(AlbumSongsListQuery.TRACK),
                cursor.getString(AlbumSongsListQuery.TITLE), cursor.getString(AlbumSongsListQuery.FILE));
        songInfoList.add(songInfo);

        songTitle.setText(songInfo.title);

        trackNumber.setText(String.valueOf(songInfo.track));

        String duration = UIUtils.formatTime(cursor.getInt(AlbumSongsListQuery.DURATION));
        String detailsText = TextUtils.isEmpty(artist) ? duration : duration + "  |  " + artist;
        details.setText(detailsText);

        contextMenu.setTag(songInfo);
        contextMenu.setOnClickListener(songItemMenuClickListener);

        songView.setTag(songInfo);
        songView.setOnClickListener(songClickListener);
        listView.addView(songView);
    } while (cursor.moveToNext());
}

From source file:com.android.volley.cache.plus.SimpleImageLoader.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)//from   ww w  . j av  a2  s. co  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(getResources(), imageView, placeHolder, mFadeInImage), maxWidth,
                    maxHeight);
            // 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.android.volley.cache.SimpleImageLoader.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 . 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 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(getResources(), imageView, placeHolder, mFadeInImage), maxWidth, maxHeight,
                    imageView.getScaleType());
            // Store request in ImageView tag
            imageView.setTag(imageContainer);
        } else {
            if (!(imageView instanceof PhotoView)) {
                imageView.setImageDrawable(placeHolder);
            }
            imageView.setTag(null);
        }
    }

    return imageContainer;
}