List of usage examples for android.widget ImageView getDrawable
public Drawable getDrawable()
From source file:org.getlantern.firetweet.fragment.support.AccountsDashboardFragment.java
private void updateAccountOptionsSeparatorLabel(Drawable profileImageSnapshot) { final ParcelableAccount account = mAccountsAdapter.getSelectedAccount(); if (account == null) { return;/*from w w w .j a va 2 s . com*/ } mAccountProfileNameView.setText(account.name); mAccountProfileScreenNameView.setText("@" + account.screen_name); mImageLoader.displayDashboardProfileImage(mAccountProfileImageView, account.profile_image_url, profileImageSnapshot); mAccountProfileImageView.setBorderColors(account.color); final int bannerWidth = mAccountProfileBannerView.getWidth(); final Resources res = getResources(); final int defWidth = res.getDisplayMetrics().widthPixels; final int width = bannerWidth > 0 ? bannerWidth : defWidth; final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width); final ImageView bannerView = mAccountProfileBannerView; if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) { mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this); } }
From source file:com.itsherpa.andg.imageloader.ContactImageLoader.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.//from w w w .ja va 2s .c o m * * @param imageView * The ImageView to set the bitmap to. * @param bitmap * The new bitmap to set. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @SuppressWarnings("deprecation") private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable to fade from loading bitmap to final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(imageView.getDrawable()); } else { imageView.setBackgroundDrawable(imageView.getDrawable()); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditExpenseActivity.java
/** * Called when dialog appears to show current expense photo. * // w w w . j a va 2 s . c o m * Loads photo to be displayed. * ImageView is the location for the image to be displayed, height and width * are of the size the the image will be displayed in. * * @param ImageView * @param int width * @param int height */ private void loadPhoto(ImageView imageView, int width, int height) { ImageView tempImageView = imageView; AlertDialog.Builder imageDialog = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.image_adapter, (ViewGroup) findViewById(R.id.layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.fullimage); image.setImageDrawable(tempImageView.getDrawable()); imageDialog.setView(layout); String showDate = null; if (expense.getDate() != null) { showDate = sdf.format(expense.getDate()); } else { showDate = ""; } imageDialog.setPositiveButton( expense.getName() + " " + showDate + " " + expense.getScale() + " " + "Size: " + size + " Byte", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); imageDialog.create(); imageDialog.show(); }
From source file:com.ez.gallery.ucrop.UCropActivity.java
/** * Use {@link #mActiveWidgetColor} for color filter *//* w ww .j ava 2 s. c o m*/ private void setupStatesWrapper() { ImageView stateScaleImageView = (ImageView) findViewById(R.id.image_view_state_scale); ImageView stateRotateImageView = (ImageView) findViewById(R.id.image_view_state_rotate); ImageView stateAspectRatioImageView = (ImageView) findViewById(R.id.image_view_state_aspect_ratio); stateScaleImageView.setImageDrawable( new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveWidgetColor)); stateRotateImageView.setImageDrawable( new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveWidgetColor)); stateAspectRatioImageView.setImageDrawable( new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveWidgetColor)); }
From source file:com.retroteam.studio.retrostudio.EditorLandscape.java
/** * Iterate through all the measures and return a list of measure tag group objects. * The list is serialized out to the .retro project file. * @return ArrayList<MeasureTagGroup> *///from w w w. j av a 2 s . c om private ArrayList<MeasureTagGroup> getMeasureTags() { ArrayList<MeasureTagGroup> mtaglist = new ArrayList<>(); LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout); //iterate through all the measures for (int t = 0; t < track_layout.getChildCount(); t++) { //get hscrollview HorizontalScrollView hchild = (HorizontalScrollView) track_layout.getChildAt(t); for (int h = 0; h < hchild.getChildCount(); h++) { //get gridlayout GridLayout gchild = (GridLayout) hchild.getChildAt(h); for (int g = 0; g < gchild.getChildCount(); g++) { //get measure if (gchild.getChildAt(g) instanceof ImageView) { ImageView ivchild = (ImageView) gchild.getChildAt(g); Drawable measureFill = ivchild.getDrawable(); if (measureFill.getConstantState() .equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.measure_new_empty) .getConstantState())) { mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW), (int) ivchild.getTag(R.id.TAG_COLUMN), false, (int) ivchild.getTag(R.id.TAG_GUISNAP), (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES))); } else if (measureFill.getConstantState() .equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.measure_new_filled) .getConstantState())) { mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW), (int) ivchild.getTag(R.id.TAG_COLUMN), true, (int) ivchild.getTag(R.id.TAG_GUISNAP), (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES))); } } } } } return mtaglist; }
From source file:com.faayda.imageloader.ImageLoader.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView The ImageView to set the bitmap to. * @param bitmap The new bitmap to set.//from w ww .j a v a 2s . c om */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable to fade from loading bitmap to final bitmap final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(mResources.getColor(R.color.transparent)), new BitmapDrawable(mResources, bitmap) }); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(imageView.getDrawable()); } else { imageView.setBackgroundDrawable(imageView.getDrawable()); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.vstar.lib.io.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.//from w w w.j a va 2 s.c om * * @param imageView * @param bitmap */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // noinspection deprecation imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:cz.appvision.ebookreader.image.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//w w w.java 2 s . c om * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable.getClass().equals(AsyncDrawable.class)) { String placeholderKey = ((AsyncDrawable) currentDrawable).getPlaceholderKey(); imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap.get(placeholderKey))); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java
private void updateAccountOptionsSeparatorLabel(Drawable profileImageSnapshot) { final ParcelableAccount account = mAccountsAdapter.getSelectedAccount(); if (account == null) { return;//from w ww . j a v a 2s. c o m } mAccountProfileNameView.setText(account.name); mAccountProfileScreenNameView.setText("@" + account.screen_name); mImageLoader.displayDashboardProfileImage(mAccountProfileImageView, account.profile_image_url, profileImageSnapshot); mAccountProfileImageView.setBorderColors(account.color); final int bannerWidth = mAccountProfileBannerView.getWidth(); final Resources res = getResources(); final int defWidth = res.getDisplayMetrics().widthPixels; final int width = bannerWidth > 0 ? bannerWidth : defWidth; final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width); final ImageView bannerView = mAccountProfileBannerView; if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) { mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this); } else { mImageLoader.cancelDisplayTask(mAccountProfileBannerView); } }
From source file:eu.faircode.netguard.AdapterAccess.java
@Override public void bindView(final View view, final Context context, final Cursor cursor) { // Get values final int version = cursor.getInt(colVersion); final int protocol = cursor.getInt(colProtocol); final String daddr = cursor.getString(colDaddr); final int dport = cursor.getInt(colDPort); long time = cursor.getLong(colTime); int allowed = cursor.getInt(colAllowed); int block = cursor.getInt(colBlock); int count = cursor.getInt(colCount); long sent = cursor.isNull(colSent) ? -1 : cursor.getLong(colSent); long received = cursor.isNull(colReceived) ? -1 : cursor.getLong(colReceived); int connections = cursor.isNull(colConnections) ? -1 : cursor.getInt(colConnections); // Get views//from w w w . ja va2s . c o m TextView tvTime = view.findViewById(R.id.tvTime); ImageView ivBlock = view.findViewById(R.id.ivBlock); final TextView tvDest = view.findViewById(R.id.tvDest); LinearLayout llTraffic = view.findViewById(R.id.llTraffic); TextView tvConnections = view.findViewById(R.id.tvConnections); TextView tvTraffic = view.findViewById(R.id.tvTraffic); // Set values tvTime.setText(new SimpleDateFormat("dd HH:mm").format(time)); if (block < 0) ivBlock.setImageDrawable(null); else { ivBlock.setImageResource(block > 0 ? R.drawable.host_blocked : R.drawable.host_allowed); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(ivBlock.getDrawable()); DrawableCompat.setTint(wrap, block > 0 ? colorOff : colorOn); } } String dest = Util.getProtocolName(protocol, version, true) + " " + daddr + (dport > 0 ? "/" + dport : "") + (count > 1 ? " ?" + count : ""); SpannableString span = new SpannableString(dest); span.setSpan(new UnderlineSpan(), 0, dest.length(), 0); tvDest.setText(span); if (Util.isNumericAddress(daddr)) new AsyncTask<String, Object, String>() { @Override protected void onPreExecute() { ViewCompat.setHasTransientState(tvDest, true); } @Override protected String doInBackground(String... args) { try { return InetAddress.getByName(args[0]).getHostName(); } catch (UnknownHostException ignored) { return args[0]; } } @Override protected void onPostExecute(String addr) { tvDest.setText(Util.getProtocolName(protocol, version, true) + " >" + addr + (dport > 0 ? "/" + dport : "")); ViewCompat.setHasTransientState(tvDest, false); } }.execute(daddr); if (allowed < 0) tvDest.setTextColor(colorText); else if (allowed > 0) tvDest.setTextColor(colorOn); else tvDest.setTextColor(colorOff); llTraffic.setVisibility(connections > 0 || sent > 0 || received > 0 ? View.VISIBLE : View.GONE); if (connections > 0) tvConnections.setText(context.getString(R.string.msg_count, connections)); if (sent > 1024 * 1204 * 1024L || received > 1024 * 1024 * 1024L) tvTraffic.setText(context.getString(R.string.msg_gb, (sent > 0 ? sent / (1024 * 1024 * 1024f) : 0), (received > 0 ? received / (1024 * 1024 * 1024f) : 0))); else if (sent > 1204 * 1024L || received > 1024 * 1024L) tvTraffic.setText(context.getString(R.string.msg_mb, (sent > 0 ? sent / (1024 * 1024f) : 0), (received > 0 ? received / (1024 * 1024f) : 0))); else tvTraffic.setText(context.getString(R.string.msg_kb, (sent > 0 ? sent / 1024f : 0), (received > 0 ? received / 1024f : 0))); }