List of usage examples for android.graphics.drawable Drawable setBounds
public void setBounds(int left, int top, int right, int bottom)
From source file:de.azapps.mirakel.custom_views.TaskDetailDueReminder.java
@SuppressLint("NewApi") @Override//from ww w. jav a 2s. c o m protected void updateView() { final Drawable reminderImg = this.context.getResources() .getDrawable(android.R.drawable.ic_menu_recent_history); reminderImg.setBounds(0, 1, 42, 42); final Drawable dueImg = this.context.getResources().getDrawable(android.R.drawable.ic_menu_today); dueImg.setBounds(0, 1, 42, 42); final Configuration config = this.context.getResources().getConfiguration(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { this.taskReminder.setCompoundDrawables(null, null, reminderImg, null); this.taskDue.setCompoundDrawables(null, null, dueImg, null); } else { this.taskReminder.setCompoundDrawables(reminderImg, null, null, null); this.taskDue.setCompoundDrawables(dueImg, null, null, null); } setRecurringImage(this.recurrenceDue, this.task.getRecurrenceId()); setRecurringImage(this.recurrenceReminder, this.task.getRecurringReminderId()); setupRecurrenceDrawable(this.recurrenceDue, this.task.getRecurrence()); setupRecurrenceDrawable(this.recurrenceReminder, this.task.getRecurringReminder()); setDue(); setReminder(); }
From source file:com.androidformenhancer.helper.FormHelper.java
private void setDrawableIntrinsicBounds(final Drawable d) { if (d != null) { d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); }/* w ww.ja va 2s . c o m*/ }
From source file:net.bither.ui.base.AddressDetailHeader.java
public void showAddress(final Address address, int addressPosition) { this.addressPosition = addressPosition; if (address.getAddress() == null) { return;// ww w . j a va2s. com } tvAddress.setText(WalletUtils.formatHash(address.getAddress(), 4, 12)); if (this.address != address) { Qr.QrCodeTheme theme = AppSharedPreference.getInstance().getFancyQrCodeTheme(); ivQr.setContent(address.getAddress(), theme.getFgColor(), theme.getBgColor()); } llMore.setVisibility(View.VISIBLE); if (address.txCount() == 0) { tvNoTransactions.setVisibility(View.VISIBLE); } else { tvNoTransactions.setVisibility(View.GONE); } btnBalance.setAmount(address.getBalance()); if (address.hasPrivKey()) { btnSend.setCompoundDrawables(null, null, null, null); } else { Drawable d = getContext().getResources().getDrawable(R.drawable.unsigned_transaction_button_icon); int size = UIUtil.dip2pix(20); int topOffset = UIUtil.dip2pix(0.5f); d.setBounds(0, topOffset, size, size + topOffset); btnSend.setCompoundDrawables(null, null, d, null); } // } else { // llMore.setVisibility(View.GONE); // } llMonitorFailed.setVisibility(View.GONE); // } else { // llMore.setVisibility(View.GONE); // tvNoTransactions.setVisibility(View.GONE); // llMonitorFailed.setVisibility(View.VISIBLE); // } this.address = address; if (balanceDetailFuture != null) { balanceDetailFuture.cancel(true); } balanceDetailFuture = new FutureTask<DialogBalanceDetail.Info>(getBalanceInfo); new Thread(balanceDetailFuture).start(); }
From source file:org.chromium.chrome.browser.ntp.snippets.SnippetArticleViewHolder.java
private void setFaviconOnView(Drawable drawable) { drawable.setBounds(0, 0, mPublisherFaviconSizePx, mPublisherFaviconSizePx); ApiCompatibilityUtils.setCompoundDrawablesRelative(mPublisherTextView, drawable, null, null, null); mPublisherTextView.setVisibility(View.VISIBLE); }
From source file:self.philbrown.droidQuery.AsyncImageGetter.java
/** * Gets the drawable from the given URL resource, or from the local file path. * @param source the URL of the drawable, or the local file path to the image. *///from w w w . jav a2 s . c om public Drawable getDrawable(String source) { if (URLUtil.isValidUrl(source)) { //need to download image URLDrawable urlDrawable = new URLDrawable(); // 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; } else { //must be a local reference Drawable drawFromPath; int path = c.getResources().getIdentifier(source, "drawable", c.getApplicationInfo().packageName); if (path == 0) { return new TextDrawable("Could not set image"); } drawFromPath = (Drawable) c.getResources().getDrawable(path); drawFromPath.setBounds(0, 0, drawFromPath.getIntrinsicWidth(), drawFromPath.getIntrinsicHeight()); return drawFromPath; } }
From source file:fr.poucedor.poucedor.MapActivity.java
public void setMap() { MapView mapView = (MapView) findViewById(R.id.mapview); MapController mapController = new MapController(mapView); mapController.setZoom(7);//from w ww . j a v a2s . com mapView.setMinZoomLevel(4); // Center over France double lat = 51 * 1000000; double lon = -5 * 1000000; GeoPoint p = new GeoPoint((int) lat, (int) lon); mapController.animateTo(p); mapView.setTileSource(TileSourceFactory.MAPNIK); mapView.setMultiTouchControls(true); Drawable marker = getResources().getDrawable(R.drawable.ic_drawer_place); int markerWidth = marker.getIntrinsicWidth(); int markerHeight = marker.getIntrinsicHeight(); marker.setBounds(0, markerHeight, markerWidth, 0); ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getApplicationContext()); myItemizedOverlay = new MyItemizedOverlay(marker, resourceProxy); mapView.getOverlays().add(myItemizedOverlay); GeoPoint myPoint1 = new GeoPoint(0 * 1000000, 0 * 1000000); myItemizedOverlay.addItem(myPoint1, "myPoint1", "myPoint1"); GeoPoint myPoint2 = new GeoPoint((int) 48.8534100 * 1000000, (int) 2.3488000 * 1000000); myItemizedOverlay.addItem(myPoint2, "myPoint2", "myPoint2"); }
From source file:com.trellmor.berrymotes.EmoteGetter.java
@Override public Drawable getDrawable(String source) { if (mBlacklist.contains(source)) return null; Drawable d = mCache.get(source); if (d != null) return d; AnimationEmode ae = mAnimationCache.get(source); if (ae != null) { try {/*from w w w . j a v a 2 s . co m*/ d = ae.newDrawable(); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } catch (OutOfMemoryError e) { return null; } } Cursor cursor = mResolver.query(EmotesContract.Emote.CONTENT_URI, PROJECTION, EmotesContract.Emote.COLUMN_NAME + "=?", new String[] { source }, EmotesContract.Emote.COLUMN_INDEX + " ASC"); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); final int POS_IMAGE = cursor.getColumnIndex(EmotesContract.Emote.COLUMN_IMAGE); if (cursor.getCount() > 1 && cursor.getInt(cursor.getColumnIndex(EmotesContract.Emote.COLUMN_APNG)) == 1) { // Create AnimationDrawable ae = new AnimationEmode(); final int POS_DELAY = cursor.getColumnIndex(EmotesContract.Emote.COLUMN_DELAY); try { do { String path = cursor.getString(POS_IMAGE); Drawable frame = mLoader.fromPath(path); if (frame != null) { ae.addFrame(frame, cursor.getInt(POS_DELAY)); } } while (cursor.moveToNext()); d = ae.newDrawable(); mAnimationCache.put(source, ae); } catch (OutOfMemoryError e) { d = null; mBlacklist.add(source); Log.e(TAG, "Failed to load " + source, e); } } else { String path = cursor.getString(POS_IMAGE); try { d = mLoader.fromPath(path); } catch (OutOfMemoryError e) { d = null; mBlacklist.add(source); Log.e(TAG, "Failed to load " + source, e); } if (d != null) { mCache.put(source, d); } } } if (cursor != null) cursor.close(); if (d != null) { d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); } return d; }
From source file:org.onebusaway.android.ui.TripResultsFragment.java
private void setTabDrawable(TabLayout.Tab tab, @DrawableRes int res) { View view = tab.getCustomView(); TextView tv = ((TextView) view.findViewById(android.R.id.text1)); Drawable drawable = getResources().getDrawable(res); int dp = (int) getResources().getDimension(R.dimen.trip_results_icon_size); drawable.setBounds(0, 0, dp, dp); drawable.setColorFilter(getResources().getColor(R.color.trip_option_icon_tint), PorterDuff.Mode.SRC_IN); tv.setCompoundDrawables(drawable, null, null, null); }
From source file:com.justwayward.reader.ui.activity.BookDetailActivity.java
private void initCollection(boolean coll) { if (coll) {// w ww. ja v a2s.co m mBtnJoinCollection.setText(R.string.book_detail_join_collection); Drawable drawable = ContextCompat.getDrawable(this, R.drawable.book_detail_info_add_img); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); mBtnJoinCollection.setBackgroundDrawable( ContextCompat.getDrawable(this, R.drawable.shape_common_btn_solid_normal)); mBtnJoinCollection.setCompoundDrawables(drawable, null, null, null); mBtnJoinCollection.postInvalidate(); isJoinedCollections = false; } else { mBtnJoinCollection.setText(R.string.book_detail_remove_collection); Drawable drawable = ContextCompat.getDrawable(this, R.drawable.book_detail_info_del_img); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); mBtnJoinCollection .setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.btn_join_collection_pressed)); mBtnJoinCollection.setCompoundDrawables(drawable, null, null, null); mBtnJoinCollection.postInvalidate(); isJoinedCollections = true; } }
From source file:org.lytsing.android.weibo.ui.ComposeActivity.java
private void initGridView() { mGVFaceAdapter = new GridViewFaceAdapter(this); mGridView = (GridView) findViewById(R.id.tweet_pub_faces); mGridView.setAdapter(mGVFaceAdapter); mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // ?/*from w w w . j ava 2 s. c o m*/ SpannableString ss = new SpannableString(view.getTag().toString()); Drawable d = getResources().getDrawable((int) mGVFaceAdapter.getItemId(position)); d.setBounds(0, 0, 35, 35);//? ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM); ss.setSpan(span, 0, view.getTag().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // ? mEdit.getText().insert(mEdit.getSelectionStart(), ss); } }); }