Java Code Examples for android.widget.ImageView.getTag()

The following are Jave code examples for showing how to use getTag() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ArtOfAndroid   File: MainActivity.java   View Source Code Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = mLayoutInflater.inflate(R.layout.item_grid, parent, false);
        viewHolder = new ViewHolder();
        viewHolder.mImageView = (ImageView) convertView.findViewById(R.id.image_view);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    ImageView imageView = viewHolder.mImageView;
    String tag = (String) imageView.getTag();
    String uri = getItem(position);

    if (!uri.equals(tag)) {
        imageView.setImageDrawable(new ColorDrawable(getResources().getColor(R.color.colorAccent)));
    }

    if (mIsGridViewIdle && mCanGetBitmapFromNetWork) {
        imageView.setTag(uri);
        mImageLoadUtil.bindBitmap(mUrls.get(position), imageView, mImageWidth, mImageWidth);
    }
    return convertView;
}
 
Example 2
Project: ArtOfAndroid   File: ImageLoadUtil.java   View Source Code Vote up 7 votes
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_LOAD_RESULT:
            LoaderResult loaderResult = (LoaderResult) msg.obj;
            ImageView imageView = loaderResult.mImageView;
            String url = (String) imageView.getTag(TAG_KEY_URL);
            if (!TextUtils.isEmpty(url) && url.equals(loaderResult.mUrl)) {
                imageView.setImageBitmap(loaderResult.mBitmap);
            } else {
                Log.w(TAG, "set image bitmap, but url has changed.");
            }
            break;
        default:
            super.handleMessage(msg);
            break;
    }
}
 
Example 3
Project: BBSSDK-for-Android   File: ImageGetter.java   View Source Code Vote up 7 votes
public static Request loadPic(ImageView imageview, ImageGotListener listener, String url, Bitmap defaultbitmap, boolean forceupdate) {
	Request request = null;
	if (imageview != null) {
		Object object = imageview.getTag();
		if (object != null && object instanceof Request) {
			//reuse the request.
			request = (Request) object;
			//ignore this request.
			request.endRequest();
		}
	}
	request = getInstance().buildRequest(imageview, listener, url, defaultbitmap, forceupdate);
	if (imageview != null) {
		imageview.setTag(request);
	}
	request.getPic();
	return request;
}
 
Example 4
Project: letv   File: ImageDownloader.java   View Source Code Vote up 7 votes
static void setBitmapForView(View view, Bitmap bitmap, String url, boolean doAnim) {
    if (view != null && bitmap != null && !TextUtils.isEmpty(url) && !bitmap.isRecycled() && view.getTag(R.id.view_tag) != null && view.getTag(R.id.view_tag).toString().equals(url)) {
        view.setTag(R.id.view_result, Boolean.valueOf(true));
        if (view instanceof ImageView) {
            ImageView imageView = (ImageView) view;
            if (imageView.getTag(R.id.imageview_atts) == null || !imageView.getTag(R.id.imageview_atts).toString().contains("background")) {
                if (imageView.getTag(R.id.scale_type) instanceof ScaleType) {
                    imageView.setScaleType((ScaleType) imageView.getTag(R.id.scale_type));
                } else {
                    imageView.setScaleType(ScaleType.FIT_XY);
                }
                imageView.setImageBitmap(bitmap);
            } else {
                view.setBackgroundDrawable(new BitmapDrawable(bitmap));
            }
        } else {
            view.setBackgroundDrawable(new BitmapDrawable(bitmap));
        }
        if (doAnim) {
            view.startAnimation(AnimationUtils.loadAnimation(BaseApplication.getInstance(), R.anim.fade_in));
        }
    }
}
 
Example 5
Project: exciting-app   File: StickerManager2.java   View Source Code Vote up 7 votes
public void setImage() {
    if (bm != null) {
        if(wr_image == null)
            return;
        ImageView iv = wr_image.get();
        if(iv != null)
        {
            String tag = (String) iv.getTag();
            if(TextUtils.isEmpty(tag)) {
                iv.setImageBitmap(bm);
            } else if(this.url.equals(tag)) {
                iv.setImageBitmap(bm);
            }
        }
    }
    this.onLoadFinish();
}
 
Example 6
Project: Tangram-Android   File: BannerView.java   View Source Code Vote up 7 votes
public void setCurrItem(int position) {
    if (mImageViews != null) {
        for (int i = 0; i < mImageViews.length; i++) {
            if (style == STYLE_DOT) {
                mImageViews[i].setImageDrawable(getGradientDrawable(position == i ? focusColor : norColor, radius));
            } else if (style == STYLE_IMG){
                ImageView imageView = mImageViews[i];
                if (imageView.getTag(R.id.TANGRAM_BANNER_INDICATOR_POS) == null) {
                    continue;
                } else {
                    imageView.setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, null);
                    ImageUtils.doLoadImageUrl(imageView, norUrl);
                }
            }
        }
        mImageViews[currentItemPos].setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, currentItemPos);
        ImageUtils.doLoadImageUrl(mImageViews[currentItemPos], focusUrl);
    }
}
 
Example 7
Project: Weekdays-Selector   File: WeekdaysPicker.java   View Source Code Vote up 6 votes
private void setDaySelected(ImageView dayView, boolean b) {
    dayView.setSelected(b);
    String dayText = getDayText(dayView);
    int tag = (int) dayView.getTag();
    if (b) {
        dayView.setImageDrawable(selectedBuilder.build(dayText, selectedDayBackgroundColor));
        selectedDays.add(tag);
    } else {
        dayView.setImageDrawable(unselectedBuilder.build(dayText, unSelectedDayBackgroundColor));
        selectedDays.remove(tag);
    }
}
 
Example 8
Project: android-training-2017   File: Malevich.java   View Source Code Vote up 6 votes
private void processImageResult(ImageResult imageResult) {
        if (imageResult != null) {
            ImageRequest request = imageResult.getRequest();
            ImageView imageView = request.target.get();
            if (imageView != null) {
                Object tag = imageView.getTag();
                if (tag != null && tag.equals(request.url)) {
                    TransitionDrawable drawable = new TransitionDrawable(new Drawable[]{EMPTY_DRAWABLE, new BitmapDrawable(imageResult.getBitmap())});
                    imageView.setImageDrawable(drawable);
                    drawable.startTransition(1000);
//                    imageView.setImageBitmap(imageResult.getBitmap());
                }
            }
        }
    }
 
Example 9
Project: CSipSimple   File: ContactsAsyncHelper.java   View Source Code Vote up 6 votes
private static boolean isAlreadyProcessed(ImageView imageView, Uri uri) {
    if(imageView != null) {
        PhotoViewTag vt = (PhotoViewTag) imageView.getTag(TAG_PHOTO_INFOS);
        return (vt != null && UriUtils.areEqual(uri, vt.uri));
    }
    return true;
}
 
Example 10
Project: easyfilemanager   File: IconHelper.java   View Source Code Vote up 6 votes
/**
 * Cancels any ongoing load operations associated with the given ImageView.
 * @param icon
 */
public void stopLoading(ImageView icon) {
    if(null == icon){
        return;
    }
    final LoaderTask oldTask = (LoaderTask) icon.getTag();
    if (oldTask != null) {
        oldTask.preempt();
        icon.setTag(null);
    }
}
 
Example 11
Project: simple-share-android   File: IconHelper.java   View Source Code Vote up 6 votes
/**
 * Cancels any ongoing load operations associated with the given ImageView.
 * @param icon
 */
public void stopLoading(ImageView icon) {
    if(null == icon){
        return;
    }
    final LoaderTask oldTask = (LoaderTask) icon.getTag();
    if (oldTask != null) {
        oldTask.preempt();
        icon.setTag(null);
    }
}
 
Example 12
Project: JBKWeather   File: ImageLoader.java   View Source Code Vote up 6 votes
@Override
public void handleMessage(Message msg) {
    LoaderResult result = (LoaderResult) msg.obj;
    ImageView imageView = result.imageView;
    String uri = (String) imageView.getTag(TAG_KEY_URI);
    //判断是防止错位
    if(uri.equals(result.uri)){
        imageView.setImageBitmap(result.bitmap);
    }else{
        Log.w(TAG, "set image bitmap,but url has changed,igored" );
    }
}
 
Example 13
Project: Huochexing12306   File: MyUtils.java   View Source Code Vote up 6 votes
public static boolean getToogleImageStatus(ImageView iv1){
	if (iv1 == null || iv1.getTag() == null){
		return false;
	}else{
		return (Boolean)iv1.getTag();
	}
}
 
Example 14
Project: easy-animated-vector-drawable   File: EasyAnimatedVectorDrawable.java   View Source Code Vote up 6 votes
public static void setImageType(@NonNull ImageView imageView, @NonNull Enum<?> type, @ColorInt int tintColor) {
    initialize();

    if (imageView.getTag(R.id.eavd_current_type) == null || !(imageView.getTag(R.id.eavd_current_type) instanceof Enum<?>)) {
        setImageDrawable(imageView, getDefaultDrawableResId(type), type, tintColor);
        return;
    }

    final Enum<?> currentType = (Enum<?>) imageView.getTag(R.id.eavd_current_type);
    final Object currentTintColorObject = imageView.getTag(R.id.eavd_current_tint_color);
    final int currentTintColor = currentTintColorObject == null ? 0 : (int) currentTintColorObject;
    if (currentType == type && currentTintColor == tintColor) {
        // Both types are equals, do nothing.
        return;
    }

    try {
        int animatedVectorDrawable = getAnimatedVectorDrawable(currentType, type);
        if (animatedVectorDrawable != 0) {
            setImageDrawable(imageView, animatedVectorDrawable, type, tintColor);
            return;
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }

    setImageDrawable(imageView, getDefaultDrawableResId(type), type, tintColor);
}
 
Example 15
Project: DailyStudy   File: ImageLoader.java   View Source Code Vote up 6 votes
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    LoaderResult result = (LoaderResult) msg.obj;
    ImageView imageView = result.imageView;
    imageView.setImageBitmap(result.bitmap);
    String uri = (String) imageView.getTag(TAG_KEY_URL);
    if (uri.equals(result.uri)) {
        imageView.setImageBitmap(result.bitmap);
    }
}
 
Example 16
Project: microbit   File: PairingActivity.java   View Source Code Vote up 6 votes
/**
 * Sets a clicked cell on/off.
 *
 * @param image An image of a clicked cell.
 * @param pos   Position of a clicked cell.
 * @return True, if cell is on and false otherwise.
 */
private boolean toggleLED(ImageView image, int pos) {
    boolean isOn;
    //Toast.makeText(this, "Pos :" +  pos, Toast.LENGTH_SHORT).show();
    int state = (Integer) image.getTag(R.id.ledState);
    if(state != 1) {
        DEVICE_CODE_ARRAY[pos] = 1;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.red_white_led_btn));
        image.setTag(R.id.ledState, 1);
        isOn = true;

    } else {
        DEVICE_CODE_ARRAY[pos] = 0;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.white_red_led_btn));
        image.setTag(R.id.ledState, 0);
        isOn = false;
        // Update the code to consider the still ON LED below the toggled one
        if(pos < 20) {
            DEVICE_CODE_ARRAY[pos + 5] = 1;
        }
    }

    image.setSelected(false);
    int position = (Integer) image.getTag(R.id.position);
    image.setContentDescription("" + position + getLEDStatus(pos));
    return isOn;
}
 
Example 17
Project: ShortcutMenu   File: BitmapUtils.java   View Source Code Vote up 6 votes
private boolean isLoad(ImageView iv, String url) {
    Object tag = iv.getTag();
    if (tag==null || TextUtils.isEmpty(url) ||!url.equals(tag)) {
        if (TextUtils.isEmpty(url) || url.startsWith("null")) {
            iv.setTag(null);
        } else {
            iv.setTag(url);
        }
        return true;
    }
    return false;
}
 
Example 18
Project: FireFiles   File: IconHelper.java   View Source Code Vote up 6 votes
/**
 * Cancels any ongoing load operations associated with the given ImageView.
 * @param icon
 */
public void stopLoading(ImageView icon) {
    if(null == icon){
        return;
    }
    final LoaderTask oldTask = (LoaderTask) icon.getTag();
    if (oldTask != null) {
        oldTask.preempt();
        icon.setTag(null);
    }
}
 
Example 19
Project: MegviiFacepp-Android-SDK   File: FeatureInfoAdapter.java   View Source Code Vote up 6 votes
@Override
public void onClick(View v) {
    ImageView imageView = (ImageView) v;
    String check = (String) imageView.getTag();
    if (check.equals("0")){
        v.setTag("1");
        imageView.setImageResource(R.drawable.check);
        mItemSelectStatusArr[pos].isSelected = true;
    }else if (check.equals("1")){
        v.setTag("0");
        imageView.setImageResource(R.drawable.uncheck);
        mItemSelectStatusArr[pos].isSelected = false;
    }
}
 
Example 20
Project: boohee_v5.6   File: PostPicturePreviewAdapter.java   View Source Code Vote up 5 votes
private void loadImage(ImageView imageView, Uri imageUri) {
    if (imageUri != null && imageView != null && imageView.getTag() != imageUri) {
        imageView.setTag(imageUri);
        this.mImageLoader.displayImage(Uri.decode(imageUri.toString()), imageView, this.mDisplayOptions);
    }
}