Java Code Examples for android.widget.ImageView#setTag()
The following examples show how to use
android.widget.ImageView#setTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuItemBuilder.java From ListView-Swipe-to-Delete with Apache License 2.0 | 6 votes |
public ImageView build(Context ctx) { String action = itemDesc.getAction(); if (action == null || action.equals("")) { throw new IllegalArgumentException("No menu action specified!"); } int iconDrawableID = itemDesc.getIcon(); if (iconDrawableID <= 0) { throw new IllegalArgumentException("No menu icon specified!"); } ImageView item = new ImageView(ctx); item.setTag(action); item.setImageResource(iconDrawableID); item.setContentDescription(ctx.getString(R.string.icon)); int padding = DimenUtils.getPixelsFromDP(ctx.getResources(), MENU_ITEM_PADDING); item.setPadding(padding, padding, padding, padding); return item; }
Example 2
Source File: RawDataDiceView.java From bither-android with Apache License 2.0 | 6 votes |
public void removeAllData() { int size = data.size(); data.clear(); for (int i = 0; i < size; i++) { final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0); if (iv.getVisibility() == View.VISIBLE) { ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setDuration(300); anim.setFillAfter(true); iv.startAnimation(anim); if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) { iv.removeCallbacks((Runnable) iv.getTag()); } HideIvRunnable r = new HideIvRunnable(iv); iv.setTag(r); iv.postDelayed(r, 300); } } }
Example 3
Source File: ArticleListAdapter.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 6 votes |
private void onBindDeviceType(ImageView clientBtn, ThreadRowInfo row) { String deviceType = row.getFromClientModel(); if (TextUtils.isEmpty(deviceType)) { clientBtn.setVisibility(View.GONE); } else { switch (deviceType) { case DEVICE_TYPE_IOS: clientBtn.setImageResource(R.drawable.ic_apple_12dp); break; case DEVICE_TYPE_WP: clientBtn.setImageResource(R.drawable.ic_windows_12dp); break; case DEVICE_TYPE_ANDROID: clientBtn.setImageResource(R.drawable.ic_android_12dp); break; default: clientBtn.setImageResource(R.drawable.ic_smartphone_12dp); break; } clientBtn.setTag(row); clientBtn.setVisibility(View.VISIBLE); } }
Example 4
Source File: MyPagerAdaper.java From ZoomPreviewPicture with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView view = (ImageView) LayoutInflater.from(mContext).inflate(R.layout.item_image2, container, false); Glide.with(mContext) .load(mThumbViewInfoList.get(position).getUrl()) .error(R.mipmap.ic_iamge_zhanwei) .into(view); view.setTag(R.id.iv, position); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRect(v); GPreviewBuilder.from((Activity) mContext) .setData(mThumbViewInfoList) .setSingleShowType(false) .setCurrentIndex((Integer) v.getTag(R.id.iv)) .setType(GPreviewBuilder.IndicatorType.Dot) .start(); } }); container.addView(view); return view; }
Example 5
Source File: CallActivity.java From Linphone4Android with GNU General Public License v3.0 | 6 votes |
private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) { boolean isCallPaused, isInConference; ImageView callState = (ImageView) callView.findViewById(R.id.call_pause); callState.setTag(call); callState.setOnClickListener(this); if (call.getState() == State.Paused || call.getState() == State.PausedByRemote || call.getState() == State.Pausing) { callState.setImageResource(R.drawable.pause); isCallPaused = true; isInConference = false; } else if (call.getState() == State.OutgoingInit || call.getState() == State.OutgoingProgress || call.getState() == State.OutgoingRinging) { isCallPaused = false; isInConference = false; } else { isInConference = isConferenceRunning && call.isInConference(); isCallPaused = false; } return isCallPaused || isInConference; }
Example 6
Source File: WheelItem.java From WheelView with Apache License 2.0 | 5 votes |
/** * 初始化 */ private void init() { LinearLayout layout = new LinearLayout(getContext()); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, WheelUtils.dip2px(getContext(), WheelConstants .WHEEL_ITEM_HEIGHT)); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING, WheelConstants .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING); layout.setGravity(Gravity.CENTER); addView(layout, layoutParams); // 图片 mImage = new ImageView(getContext()); mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG); mImage.setVisibility(View.GONE); LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN; layout.addView(mImage, imageParams); // 文本 mText = new TextView(getContext()); mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG); mText.setEllipsize(TextUtils.TruncateAt.END); mText.setSingleLine(); mText.setIncludeFontPadding(false); mText.setGravity(Gravity.CENTER); mText.setTextColor(Color.BLACK); LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layout.addView(mText, textParams); }
Example 7
Source File: SwitchImage.java From Netease with GNU General Public License v3.0 | 5 votes |
private View initView(int res, String url) { View view = LayoutInflater.from(getContext()).inflate(R.layout.item_guide, null); ImageView imageView = (ImageView) view.findViewById(R.id.iguide_img); //设置ImageView的超链接 imageView.setTag(url); imageView.setImageResource(res); //hold imageView imageViewList.add(imageView); return view; }
Example 8
Source File: AbstractTreeViewAdapter.java From satstat with GNU General Public License v3.0 | 5 votes |
public final LinearLayout populateTreeItem(final LinearLayout layout, final View childView, final TreeNodeInfo<T> nodeInfo, final boolean newChildView) { final Drawable individualRowDrawable = getBackgroundDrawable(nodeInfo); layout.setBackgroundDrawable(individualRowDrawable == null ? getDrawableOrDefaultBackground(rowBackgroundDrawable) : individualRowDrawable); final LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams( calculateIndentation(nodeInfo), LayoutParams.FILL_PARENT); final LinearLayout indicatorLayout = (LinearLayout) layout .findViewById(R.id.treeview_list_item_image_layout); indicatorLayout.setGravity(indicatorGravity); indicatorLayout.setLayoutParams(indicatorLayoutParams); final ImageView image = (ImageView) layout .findViewById(R.id.treeview_list_item_image); image.setImageDrawable(getDrawable(nodeInfo)); image.setScaleType(ScaleType.CENTER); image.setTag(nodeInfo.getId()); image.setOnClickListener(null); image.setClickable(false); layout.setTag(nodeInfo.getId()); final FrameLayout frameLayout = (FrameLayout) layout .findViewById(R.id.treeview_list_item_frame); final FrameLayout.LayoutParams childParams = new FrameLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); if (newChildView) { frameLayout.addView(childView, childParams); } frameLayout.setTag(nodeInfo.getId()); return layout; }
Example 9
Source File: GamePintuLayout.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
/** * 初始化Item */ private void initItem() { // 获得Item的宽度 int childWidth = (mWidth - mPadding * 2 - mMargin * (mColumn - 1)) / mColumn; mItemWidth = childWidth; mGamePintuItems = new ImageView[mColumn * mColumn]; // 放置Item for (int i = 0; i < mGamePintuItems.length; i++) { ImageView item = new ImageView(getContext()); item.setOnClickListener(this); item.setImageBitmap(mItemBitmaps.get(i).bitmap); mGamePintuItems[i] = item; item.setId(i + 1); item.setTag(i + "_" + mItemBitmaps.get(i).index); LayoutParams lp = new LayoutParams(mItemWidth, mItemWidth); // 设置横向边距,不是最后一列 if ((i + 1) % mColumn != 0) { lp.rightMargin = mMargin; } // 如果不是第一列 if (i % mColumn != 0) { lp.addRule(RelativeLayout.RIGHT_OF,// mGamePintuItems[i - 1].getId()); } // 如果不是第一行,//设置纵向边距,非最后一行 if ((i + 1) > mColumn) { lp.topMargin = mMargin; lp.addRule(RelativeLayout.BELOW,// mGamePintuItems[i - mColumn].getId()); } addView(item, lp); } }
Example 10
Source File: ColorPickerView.java From javaide with GNU General Public License v3.0 | 5 votes |
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) { if (colorPreview == null) return; this.colorPreview = colorPreview; if (selectedColor == null) selectedColor = 0; int children = colorPreview.getChildCount(); if (children == 0 || colorPreview.getVisibility() != View.VISIBLE) return; for (int i = 0; i < children; i++) { View childView = colorPreview.getChildAt(i); if (!(childView instanceof LinearLayout)) continue; LinearLayout childLayout = (LinearLayout) childView; if (i == selectedColor) { childLayout.setBackgroundColor(Color.WHITE); } ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview); childImage.setClickable(true); childImage.setTag(i); childImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (v == null) return; Object tag = v.getTag(); if (tag == null || !(tag instanceof Integer)) return; setSelectedColor((int) tag); } }); } }
Example 11
Source File: FirebaseStorageHelper.java From NaviBee with GNU General Public License v3.0 | 5 votes |
public static void loadImage(ImageView imageView, String filePath, boolean isThumb, Callback callback) { final String tag = filePath; imageView.setTag(tag); if (isThumb) { int where = filePath.lastIndexOf("."); filePath = filePath.substring(0, where) + "-thumb" + filePath.substring(where); } // fs- is for firebase storage caches String filename = "fs-"+ sha256(filePath); File file = new File(NaviBeeApplication.getInstance().getCacheDir(), filename); if (file.exists()) { // cache exists loadImageFromCacheFile(imageView, file, tag); if (callback != null) callback.callback(true); } else { // cache not exists FirebaseStorage storage = FirebaseStorage.getInstance(); StorageReference storageRef = storage.getReference(); storageRef = storageRef.child(filePath); storageRef.getFile(file).addOnSuccessListener(taskSnapshot -> { // Local temp file has been created loadImageFromCacheFile(imageView, file, tag); if (callback != null) callback.callback(true); }).addOnFailureListener(taskSnapshot -> { if (callback != null) callback.callback(false); }); } }
Example 12
Source File: TransactionInfoDialog.java From financisto with GNU General Public License v2.0 | 5 votes |
private void add(LinearLayout layout, int labelId, String data, String pictureFileName) { View v = inflater.new PictureBuilder(layout) .withPicture(context, pictureFileName) .withLabel(labelId) .withData(data) .create(); v.setClickable(false); v.setFocusable(false); v.setFocusableInTouchMode(false); ImageView pictureView = v.findViewById(R.id.picture); pictureView.setTag(pictureFileName); }
Example 13
Source File: LocalWorker.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private void playImageViewAnimation(final ImageView view, final Bitmap bitmap) { view.setImageBitmap(bitmap); resetProgressBarStatues(); view.setAlpha(0f); view.animate().alpha(1.0f).setDuration(500).setListener(new LayerEnablingAnimatorListener(view, null)); view.setTag(getUrl()); }
Example 14
Source File: IconHelper.java From FireFiles with Apache License 2.0 | 5 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 15
Source File: WheelItem.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 初始化 */ private void init() { LinearLayout layout = new LinearLayout(getContext()); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, WheelUtils.dip2px(getContext(), WheelConstants .WHEEL_ITEM_HEIGHT)); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING, WheelConstants .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING); layout.setGravity(Gravity.CENTER); addView(layout, layoutParams); // 图片 mImage = new ImageView(getContext()); mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG); mImage.setVisibility(View.GONE); LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN; layout.addView(mImage, imageParams); // 文本 mText = new TextView(getContext()); mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG); mText.setEllipsize(TextUtils.TruncateAt.END); mText.setSingleLine(); mText.setIncludeFontPadding(false); mText.setGravity(Gravity.CENTER); mText.setTextColor(Color.BLACK); LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layout.addView(mText, textParams); }
Example 16
Source File: IconHelper.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Load thumbnails for a directory list item. * @param uri The URI for the file being represented. * @param mimeType The mime type of the file being represented. * @param docFlags Flags for the file being represented. * @param iconThumb The itemview's thumbnail icon. * @param iconMimeBackground * @return */ public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon, ImageView iconMime, ImageView iconThumb, View iconMimeBackground) { boolean cacheHit = false; final String docAuthority = uri.getAuthority(); String docId = DocumentsContract.getDocumentId(uri); final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0; final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType); final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled; if (showThumbnail) { final Bitmap cachedResult = mCache.get(uri); if (cachedResult != null) { iconThumb.setImageBitmap(cachedResult); cacheHit = true; iconMimeBackground.setVisibility(View.GONE); } else { iconThumb.setImageDrawable(null); final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb, iconMime, iconMimeBackground); iconThumb.setTag(task); ProviderExecutor.forAuthority(docAuthority).execute(task); } } if (cacheHit) { iconMime.setImageDrawable(null); iconMime.setAlpha(0f); iconThumb.setAlpha(1f); } else { // Add a mime icon if the thumbnail is being loaded in the background. iconThumb.setImageDrawable(null); iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon)); iconMime.setAlpha(1f); iconThumb.setAlpha(0f); } }
Example 17
Source File: ColorPickerView.java From RxTools-master with Apache License 2.0 | 5 votes |
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) { if (colorPreview == null) return; this.colorPreview = colorPreview; if (selectedColor == null) selectedColor = 0; int children = colorPreview.getChildCount(); if (children == 0 || colorPreview.getVisibility() != View.VISIBLE) return; for (int i = 0; i < children; i++) { View childView = colorPreview.getChildAt(i); if (!(childView instanceof LinearLayout)) continue; LinearLayout childLayout = (LinearLayout) childView; if (i == selectedColor) { childLayout.setBackgroundColor(Color.WHITE); } ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview); childImage.setClickable(true); childImage.setTag(i); childImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (v == null) return; Object tag = v.getTag(); if (tag == null || !(tag instanceof Integer)) return; setSelectedColor((int) tag); } }); } }
Example 18
Source File: HyperTextEditor.java From YCCustomText with Apache License 2.0 | 5 votes |
/** * 生成图片View */ private FrameLayout createImageLayout() { FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.hte_edit_imageview, null); layout.setTag(viewTagIndex++); ImageView closeView = layout.findViewById(R.id.image_close); FrameLayout.LayoutParams layoutParams = (LayoutParams) closeView.getLayoutParams(); layoutParams.bottomMargin = HyperLibUtils.dip2px(layout.getContext(),10.0f); switch (delIconLocation){ //左上角 case 1: layoutParams.gravity = Gravity.TOP | Gravity.START; closeView.setLayoutParams(layoutParams); break; //右上角 case 2: layoutParams.gravity = Gravity.TOP | Gravity.END; closeView.setLayoutParams(layoutParams); break; //左下角 case 3: layoutParams.gravity = Gravity.BOTTOM | Gravity.START; closeView.setLayoutParams(layoutParams); break; //右下角 case 4: layoutParams.gravity = Gravity.BOTTOM | Gravity.END; closeView.setLayoutParams(layoutParams); break; //其他右下角 default: layoutParams.gravity = Gravity.BOTTOM | Gravity.END; closeView.setLayoutParams(layoutParams); break; } closeView.setTag(layout.getTag()); closeView.setOnClickListener(btnListener); HyperImageView imageView = layout.findViewById(R.id.edit_imageView); imageView.setOnClickListener(btnListener); return layout; }
Example 19
Source File: CTInAppNativeCoverFragment.java From clevertap-android-sdk with MIT License | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { ArrayList<Button> inAppButtons = new ArrayList<>(); View inAppView = inflater.inflate(R.layout.inapp_cover, container, false); FrameLayout fl = inAppView.findViewById(R.id.inapp_cover_frame_layout); RelativeLayout relativeLayout = fl.findViewById(R.id.cover_relative_layout); relativeLayout.setBackgroundColor(Color.parseColor(inAppNotification.getBackgroundColor())); LinearLayout linearLayout = relativeLayout.findViewById(R.id.cover_linear_layout); Button mainButton = linearLayout.findViewById(R.id.cover_button1); inAppButtons.add(mainButton); Button secondaryButton = linearLayout.findViewById(R.id.cover_button2); inAppButtons.add(secondaryButton); ImageView imageView = relativeLayout.findViewById(R.id.backgroundImage); if(inAppNotification.getInAppMediaForOrientation(currentOrientation) != null) { if (inAppNotification.getImage(inAppNotification.getInAppMediaForOrientation(currentOrientation)) != null) { imageView.setImageBitmap(inAppNotification.getImage(inAppNotification.getInAppMediaForOrientation(currentOrientation))); imageView.setTag(0); imageView.setOnClickListener(new CTInAppNativeButtonClickListener()); } } TextView textView1 = relativeLayout.findViewById(R.id.cover_title); textView1.setText(inAppNotification.getTitle()); textView1.setTextColor(Color.parseColor(inAppNotification.getTitleColor())); TextView textView2 = relativeLayout.findViewById(R.id.cover_message); textView2.setText(inAppNotification.getMessage()); textView2.setTextColor(Color.parseColor(inAppNotification.getMessageColor())); ArrayList<CTInAppNotificationButton> buttons = inAppNotification.getButtons(); if(buttons.size() ==1){ if(currentOrientation == Configuration.ORIENTATION_LANDSCAPE){ mainButton.setVisibility(View.GONE); }else if(currentOrientation == Configuration.ORIENTATION_PORTRAIT){ mainButton.setVisibility(View.INVISIBLE); } setupInAppButton(secondaryButton,buttons.get(0),0); } else if (!buttons.isEmpty()) { for(int i=0; i < buttons.size(); i++) { if (i >= 2) continue; // only show 2 buttons CTInAppNotificationButton inAppNotificationButton = buttons.get(i); Button button = inAppButtons.get(i); setupInAppButton(button,inAppNotificationButton,i); } } @SuppressLint("ResourceType") CloseImageView closeImageView = fl.findViewById(199272); closeImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { didDismiss(null); getActivity().finish(); } }); if(!inAppNotification.isHideCloseButton()) closeImageView.setVisibility(View.GONE); else closeImageView.setVisibility(View.VISIBLE); return inAppView; }
Example 20
Source File: ReadReceiptsAdapter.java From matrix-android-console with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mLayoutInflater.inflate(mLayoutResourceId, parent, false); } TextView userNameTextView = (TextView) convertView.findViewById(R.id.accountAdapter_name); ReceiptData receipt = getItem(position); RoomMember member = mRoom.getMember(receipt.userId); if (null == member) { userNameTextView.setText(receipt.userId); } else { userNameTextView.setText(member.getName()); } TextView tsTextView = (TextView) convertView.findViewById(R.id.read_receipt_ts); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); SpannableStringBuilder body = new SpannableStringBuilder(mContext.getString(org.matrix.console.R.string.read_receipt) + " : " + dateFormat.format(new Date(receipt.originServerTs))); body.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), 0, mContext.getString(org.matrix.console.R.string.read_receipt).length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tsTextView.setText(body); ImageView imageView = (ImageView) convertView.findViewById(R.id.avatar_img); imageView.setTag(null); imageView.setImageResource(R.drawable.ic_contact_picture_holo_light); String url = member.avatarUrl; if (TextUtils.isEmpty(url)) { url = ContentManager.getIdenticonURL(member.getUserId()); } if (!TextUtils.isEmpty(url)) { int size = getContext().getResources().getDimensionPixelSize(R.dimen.member_list_avatar_size); mMediasCache.loadAvatarThumbnail(mHsConfig, imageView, url, size); } // The presence ring ImageView presenceRing = (ImageView) convertView.findViewById(R.id.imageView_presenceRing); presenceRing.setColorFilter(mContext.getResources().getColor(android.R.color.transparent)); return convertView; }