Java Code Examples for android.graphics.drawable.BitmapDrawable#setBounds()
The following examples show how to use
android.graphics.drawable.BitmapDrawable#setBounds() .
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: DynamicListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Creates the hover cell with the appropriate bitmap and of appropriate * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every * single time an invalidate call is made. */ private BitmapDrawable getAndAddHoverView(View v) { int w = v.getWidth(); int h = v.getHeight(); int top = v.getTop(); int left = v.getLeft(); Bitmap b = getBitmapFromView(v); BitmapDrawable drawable = new BitmapDrawable(getResources(), b); mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h); mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); drawable.setBounds(mHoverCellCurrentBounds); return drawable; }
Example 2
Source File: WebActivity.java From Android_framework with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void onHandleMessageFromFragment(Message msg) { if (msg.what == 1){ isLoading = true; refresh.setBackgroundResource(R.mipmap.ic_refresh_close); }else if (msg.what == 2){ isLoading = false; refresh.setBackgroundResource(R.mipmap.ic_refresh); }else if (msg.what == 3){ int newProgress = (int) msg.obj; if (newProgress == 100) pb_bar.setVisibility(View.GONE); else pb_bar.setVisibility(View.VISIBLE); pb_bar.setProgress(newProgress); }else if (msg.what == 4){ Bitmap icon = (Bitmap) msg.obj; BitmapDrawable drawable = new BitmapDrawable(getResources(), icon); drawable.setBounds(0, 0, CommonUtils.dp2px(20), CommonUtils.dp2px(20)); // setTitle.setCompoundDrawables(drawable, null, null, null); }else if (msg.what == 5){ String title = (String) msg.obj; titles.add(" "+title); setTitle(" " + title); } }
Example 3
Source File: UrlImageGetter.java From android-discourse with Apache License 2.0 | 6 votes |
@Override public Drawable getDrawable(String source) { source = checkUrl(source); UrlDrawable urlDrawable = new UrlDrawable(); ImageContainer ic = mImageLoader.getForImageSpan(this, source, mTextView, new ImageCallback(mCtx.getResources(), urlDrawable)); // TODO 当帖子滚动屏幕外的时候 如何和ImageView一样 取消前面没用的下载请求??? if (ic != null && ic.getBitmap() != null) { BitmapDrawable drawable = new BitmapDrawable(mCtx.getResources(), ic.getBitmap()); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); return drawable; } if (ic != null) { mImageContainers.add(ic); } // get the actual source // ImageGetterAsyncTask asyncTask = new ImageGetterAsyncTask(urlDrawable); // asyncTask.execute(source); // return reference to URLDrawable where I will change with actual image from // the src tag return urlDrawable; }
Example 4
Source File: ContactInfoListAdapter.java From coursera-android with MIT License | 6 votes |
public ContactInfoListAdapter(Context context, int layout, Cursor c, int flags) { super(context, layout, c, flags); mContentResolver = context.getContentResolver(); mApplicationContext = context.getApplicationContext(); // Default thumbnail bitmap for when contact has no thubnail mNoPictureBitmap = (BitmapDrawable) context.getResources().getDrawable( R.drawable.ic_contact_picture); mBitmapSize = (int) context.getResources().getDimension( R.dimen.textview_height); mNoPictureBitmap.setBounds(0, 0, mBitmapSize, mBitmapSize); }
Example 5
Source File: AnimatedGifDrawable.java From LiveGiftLayout with Apache License 2.0 | 6 votes |
public AnimatedGifDrawable(InputStream source, UpdateListener listener) { mListener = listener; GifDecoder decoder = new GifDecoder(); decoder.read(source); // Iterate through the gif frames, add each as animation frame for (int i = 0; i < decoder.getFrameCount(); i++) { Bitmap bitmap = decoder.getFrame(i); BitmapDrawable drawable = new BitmapDrawable(bitmap); // Explicitly set the bounds in order for the frames to display drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); addFrame(drawable, decoder.getDelay(i)); if (i == 0) { // Also set the bounds for this container drawable setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); } } }
Example 6
Source File: ImageWrapper.java From RichText with MIT License | 5 votes |
Drawable getDrawable(Resources resources) { if (gifDrawable == null) { BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); return bitmapDrawable; } else { return gifDrawable; } }
Example 7
Source File: UserSettingsFragment.java From Klyph with MIT License | 5 votes |
private void processImageResponse(String id, ImageResponse response) { if (response != null) { Bitmap bitmap = response.getBitmap(); if (bitmap != null) { BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap); drawable.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)); userProfilePic = drawable; userProfilePicID = id; connectedStateLabel.setCompoundDrawables(null, drawable, null, null); connectedStateLabel.setTag(response.getRequest().getImageUri()); } } }
Example 8
Source File: ContactInfoListAdapter.java From coursera-android with MIT License | 5 votes |
public ContactInfoListAdapter(Context context, int layout, Cursor c, int flags) { super(context, layout, c, flags); mApplicationContext = context.getApplicationContext(); // default thumbnail photo mNoPictureBitmap = (BitmapDrawable) context.getResources().getDrawable( R.drawable.ic_contact_picture); mBitmapSize = (int) context.getResources().getDimension( R.dimen.textview_height); mNoPictureBitmap.setBounds(0, 0, mBitmapSize, mBitmapSize); }
Example 9
Source File: NewMessageActivity.java From toktok-android with GNU General Public License v3.0 | 5 votes |
private void createMiniContact(@NonNull final NewMessageRecyclerAdapter adapter) { CharSequence friendsList = ""; for (final Friend friend : adapter.getSelectedFriends()) { SpannableStringBuilder sb = new SpannableStringBuilder(); LinearLayout miniContact = createContactTextView(friend.userName); BitmapDrawable bd = convertViewToDrawable(miniContact); bd.setBounds(0, 0, bd.getIntrinsicWidth() * 3, bd.getIntrinsicHeight() * 3); sb.append(friend.userName).append(" "); sb.setSpan(new ImageSpan(bd), sb.length() - (friend.userName.length() + 1), sb.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mSelectedMini.setMovementMethod(LinkMovementMethod.getInstance()); sb.setSpan(new ClickableSpan() { @Override public void onClick(View widget) { int i = 0; for (Friend item : adapter.getItems()) { if (item.id == friend.id) { adapter.selectItem(i); selectItem(i); } i += 1; } } }, sb.length() - (friend.userName.length() + 1), sb.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); friendsList = TextUtils.concat(friendsList, sb); } mSelectedMini.setText(friendsList); }
Example 10
Source File: DragSortRecycler.java From rox-android with Apache License 2.0 | 5 votes |
private BitmapDrawable createFloatingBitmap(View v) { floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(),v.getRight(), v.getBottom()); floatingItemBounds = new Rect(floatingItemStatingBounds); Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(), floatingItemStatingBounds.height(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas); BitmapDrawable retDrawable = new BitmapDrawable(v.getResources(), bitmap); retDrawable.setBounds(floatingItemBounds); return retDrawable; }
Example 11
Source File: BoardView.java From BoardView with Apache License 2.0 | 5 votes |
private BitmapDrawable getAndAddHoverView(View v, float scale){ int w = v.getWidth(); int h = v.getHeight(); int top = v.getTop(); int left = v.getLeft(); Bitmap b = getBitmapWithBorder(v,scale); BitmapDrawable drawable = new BitmapDrawable(getResources(),b); mHoverCellOriginalBounds = new Rect(left,top,left+w,top+h); mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); drawable.setBounds(mHoverCellCurrentBounds); return drawable; }
Example 12
Source File: UserSettingsFragment.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
private void processImageResponse(String id, ImageResponse response) { if (response != null) { Bitmap bitmap = response.getBitmap(); if (bitmap != null) { BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap); drawable.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)); userProfilePic = drawable; userProfilePicID = id; connectedStateLabel.setCompoundDrawables(null, drawable, null, null); connectedStateLabel.setTag(response.getRequest().getImageUri()); } } }
Example 13
Source File: UserSettingsFragment.java From Abelana-Android with Apache License 2.0 | 5 votes |
private void processImageResponse(String id, ImageResponse response) { if (response != null) { Bitmap bitmap = response.getBitmap(); if (bitmap != null) { BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap); drawable.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)); userProfilePic = drawable; userProfilePicID = id; connectedStateLabel.setCompoundDrawables(null, drawable, null, null); connectedStateLabel.setTag(response.getRequest().getImageUri()); } } }
Example 14
Source File: InputOverlayDrawableJoystick.java From citra_android with GNU General Public License v3.0 | 5 votes |
/** * Constructor * * @param res {@link Resources} instance. * @param bitmapOuter {@link Bitmap} which represents the outer non-movable part of the joystick. * @param bitmapInnerDefault {@link Bitmap} which represents the default inner movable part of the joystick. * @param bitmapInnerPressed {@link Bitmap} which represents the pressed inner movable part of the joystick. * @param rectOuter {@link Rect} which represents the outer joystick bounds. * @param rectInner {@link Rect} which represents the inner joystick bounds. * @param joystick Identifier for which joystick this is. */ public InputOverlayDrawableJoystick(Resources res, Bitmap bitmapOuter, Bitmap bitmapInnerDefault, Bitmap bitmapInnerPressed, Rect rectOuter, Rect rectInner, int joystick) { axisIDs[0] = joystick + 1; // Up axisIDs[1] = joystick + 2; // Down axisIDs[2] = joystick + 3; // Left axisIDs[3] = joystick + 4; // Right mJoystickType = joystick; mOuterBitmap = new BitmapDrawable(res, bitmapOuter); mDefaultStateInnerBitmap = new BitmapDrawable(res, bitmapInnerDefault); mPressedStateInnerBitmap = new BitmapDrawable(res, bitmapInnerPressed); mBoundsBoxBitmap = new BitmapDrawable(res, bitmapOuter); mWidth = bitmapOuter.getWidth(); mHeight = bitmapOuter.getHeight(); setBounds(rectOuter); mDefaultStateInnerBitmap.setBounds(rectInner); mPressedStateInnerBitmap.setBounds(rectInner); mVirtBounds = getBounds(); mOrigBounds = mOuterBitmap.copyBounds(); mBoundsBoxBitmap.setAlpha(0); mBoundsBoxBitmap.setBounds(getVirtBounds()); SetInnerBounds(); }
Example 15
Source File: TextPopup.java From mappwidget with Apache License 2.0 | 5 votes |
public void setIcon(BitmapDrawable theDrawable) { if (theDrawable != null) { theDrawable.setBounds(0,0, (int) (theDrawable.getBitmap().getWidth()), (int)(theDrawable.getBitmap().getHeight())); } text.setCompoundDrawables(null, null, theDrawable, null); }
Example 16
Source File: ContactInfoListAdapter.java From coursera-android with MIT License | 5 votes |
public ContactInfoListAdapter(Context context, @SuppressWarnings("SameParameterValue") int layout, Cursor c, @SuppressWarnings("SameParameterValue") int flags) { super(context, layout, c, flags); mApplicationContext = context.getApplicationContext(); // default thumbnail photo mNoPictureBitmap = (BitmapDrawable) context.getResources().getDrawable( R.drawable.ic_contact_picture, context.getTheme()); mBitmapSize = (int) context.getResources().getDimension( R.dimen.textview_height); mNoPictureBitmap.setBounds(0, 0, mBitmapSize, mBitmapSize); }
Example 17
Source File: DragSortRecycler.java From Slide with GNU General Public License v3.0 | 5 votes |
private BitmapDrawable createFloatingBitmap(View v) { floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); floatingItemBounds = new Rect(floatingItemStatingBounds); Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(), floatingItemStatingBounds.height(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas); BitmapDrawable retDrawable = new BitmapDrawable(v.getResources(), bitmap); retDrawable.setBounds(floatingItemBounds); return retDrawable; }
Example 18
Source File: DynamicGridView.java From Ninja with Apache License 2.0 | 4 votes |
/** * Creates the hover cell with the appropriate bitmap and of appropriate * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every * single time an invalidate call is made. */ private BitmapDrawable getAndAddHoverView(View v) { int w = v.getWidth(); int h = v.getHeight(); int top = v.getTop(); int left = v.getLeft(); Bitmap b = getBitmapFromView(v); BitmapDrawable drawable = new BitmapDrawable(getResources(), b); mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h); mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); drawable.setBounds(mHoverCellCurrentBounds); return drawable; }
Example 19
Source File: UrlImageGetter.java From android-discourse with Apache License 2.0 | 4 votes |
@Override public void onResponse(ImageContainer response, boolean isImmediate) { if (mTextView.getTag(R.id.poste_image_getter) == UrlImageGetter.this && response.getBitmap() != null) { BitmapDrawable drawable = new BitmapDrawable(mRes, response.getBitmap()); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); String src = response.getRequestUrl(); // redraw the image by invalidating the container // 由于下面重新设置了ImageSpan,所以这里invalidate就不必要了吧 // urlDrawable.invalidateSelf(); // UrlImageGetter.this.mTextView.invalidate(); // TODO 这种方式基本完美解决显示图片问题, blog? // 把提取到下面显示的图片在放出来? 然后点击任何图片 进入到 帖子图片浏览界面。。? TextView v = UrlImageGetter.this.mTextView; CharSequence text = v.getText(); if (!(text instanceof Spannable)) { return; } Spannable spanText = (Spannable) text; @SuppressWarnings("unchecked") ArrayList<String> imgs = (ArrayList<String>) v.getTag(R.id.poste_image_data); ImageSpan[] imageSpans = spanText.getSpans(0, spanText.length(), ImageSpan.class); L.i("%b X Recycled %b src: %s", isImmediate, response.getBitmap().isRecycled(), src); for (ImageSpan imgSpan : imageSpans) { int start = spanText.getSpanStart(imgSpan); int end = spanText.getSpanEnd(imgSpan); L.i("%d-%d :%s", start, end, imgSpan.getSource()); String url = imgSpan.getSource(); url = checkUrl(url); if (src.equals(url)) { spanText.removeSpan(imgSpan); ImageSpan is = new ImageSpan(drawable, src, ImageSpan.ALIGN_BASELINE); spanText.setSpan(is, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } if (imgs != null && imgs.contains(src)) { ImageClickableSpan ics = new ImageClickableSpan(src); spanText.setSpan(ics, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } v.setText(spanText); } }
Example 20
Source File: DynamicListView.java From ALLGO with Apache License 2.0 | 4 votes |
/** * Creates the hover cell with the appropriate bitmap and of appropriate * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every * single time an invalidate call is made. */ private BitmapDrawable getAndAddHoverView(View v) { int w = v.getWidth(); int h = v.getHeight(); int top = v.getTop(); int left = v.getLeft(); Bitmap b = getBitmapFromView(v); BitmapDrawable drawable = new BitmapDrawable(getResources(), b); mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h); mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); drawable.setBounds(mHoverCellCurrentBounds); return drawable; }