List of usage examples for android.widget ImageView getDrawable
public Drawable getDrawable()
From source file:eu.faircode.netguard.AccessAdapter.java
@Override public void bindView(final View view, final Context context, final Cursor cursor) { // Get values int version = cursor.getInt(colVersion); int protocol = cursor.getInt(colProtocol); String daddr = cursor.getString(colDaddr); int dport = cursor.getInt(colDPort); long time = cursor.getLong(colTime); int allowed = cursor.getInt(colAllowed); int block = cursor.getInt(colBlock); // Get views//from w ww. j a v a2 s.c o m TextView tvTime = (TextView) view.findViewById(R.id.tvTime); ImageView ivBlock = (ImageView) view.findViewById(R.id.ivBlock); final TextView tvDest = (TextView) view.findViewById(R.id.tvDest); // 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); } } tvDest.setText( Util.getProtocolName(protocol, version, true) + " " + daddr + (dport > 0 ? ":" + dport : "")); if (allowed < 0) tvDest.setTextColor(colorText); else if (allowed > 0) tvDest.setTextColor(colorOn); else tvDest.setTextColor(colorOff); }
From source file:de.vanita5.twittnuker.fragment.support.AccountsDashboardFragment.java
private void updateAccountOptionsSeparatorLabel() { final ParcelableAccount account = mAccountsAdapter.getSelectedAccount(); if (account == null) { return;/* w ww . j ava 2 s . c om*/ } mAccountProfileNameView.setText(account.name); mAccountProfileScreenNameView.setText("@" + account.screen_name); mAccountsToggle.setChecked(account.is_activated); mImageLoader.displayProfileImage(mAccountProfileImageView, account.profile_image_url); 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.concentricsky.android.khanacademy.app.TopicListActivity.java
@Override public void onStop() { Log.d(LOG_TAG, "onStop"); stopped = true;//from w w w . j av a 2s .co m if (gridView != null) { gridView.setOnItemClickListener(null); TopicGridAdapter adapter = (TopicGridAdapter) gridView.getAdapter(); if (adapter != null) { adapter.changeCursor(null); adapter.renderer.stop(); adapter.renderer.clearCache(); } gridView.setAdapter(null); gridView = null; } if (headerView != null) { final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail); // thumb.setImageResource(0); Drawable d = thumb.getDrawable(); if (d instanceof BitmapDrawable) { Bitmap bmp = ((BitmapDrawable) d).getBitmap(); if (bmp != null) { bmp.recycle(); } } } LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver); receiver = null; super.onStop(); }
From source file:com.nextgis.ngm_clink_monitoring.fragments.MapFragment.java
protected void setZoomEnabled(ImageView ivZoom, boolean isEnabled) { if (ivZoom == null) { return;//from w w w .java 2 s .c o m } if (isEnabled) { ivZoom.getDrawable().setAlpha(255); } else { ivZoom.getDrawable().setAlpha(50); } }
From source file:com.layer.messenger.makemoji.MakeMojiAtlasComposer.java
private void addAttachmentMenuItem(AttachmentSender sender) { LayoutInflater inflater = LayoutInflater.from(getContext()); LinearLayout menuLayout = (LinearLayout) mAttachmentMenu.getContentView(); View menuItem = inflater.inflate(com.layer.atlas.R.layout.atlas_message_composer_attachment_menu_item, menuLayout, false);//from w w w . ja v a 2 s.co m ((TextView) menuItem.findViewById(com.layer.atlas.R.id.title)).setText(sender.getTitle()); menuItem.setTag(sender); menuItem.setOnClickListener(new OnClickListener() { public void onClick(View v) { mAttachmentMenu.dismiss(); ((AttachmentSender) v.getTag()).requestSend(); } }); if (sender.getIcon() != null) { ImageView iconView = ((ImageView) menuItem.findViewById(com.layer.atlas.R.id.icon)); iconView.setImageResource(sender.getIcon()); iconView.setVisibility(VISIBLE); Drawable d = DrawableCompat.wrap(iconView.getDrawable()); DrawableCompat.setTint(d, getResources().getColor(com.layer.atlas.R.color.atlas_icon_enabled)); } menuLayout.addView(menuItem); }
From source file:com.doomy.decode.ScanActivity.java
private void openAboutDialog() { LayoutInflater mLayoutInflater = LayoutInflater.from(ScanActivity.this); View mView = mLayoutInflater.inflate(R.layout.view_about, null); ImageView mImageViewMrDoomy = (ImageView) mView.findViewById(R.id.imageViewMrDoomy); ImageView mImageViewStudio = (ImageView) mView.findViewById(R.id.imageViewStudio); ImageView mImageViewGitHub = (ImageView) mView.findViewById(R.id.imageViewGitHub); Drawable mMrDoomy = mImageViewMrDoomy.getDrawable(); Drawable mStudio = mImageViewStudio.getDrawable(); Drawable mGitHub = mImageViewGitHub.getDrawable(); mMrDoomy.setColorFilter(getResources().getColor(R.color.greenDark), PorterDuff.Mode.SRC_ATOP); mStudio.setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_ATOP); mGitHub.setColorFilter(getResources().getColor(R.color.greyMaterialDark), PorterDuff.Mode.SRC_ATOP); mImageViewGitHub.setOnClickListener(new View.OnClickListener() { @Override/*from w w w.j ava 2 s . c om*/ public void onClick(View v) { Intent mIntent = new Intent(); mIntent.setAction(Intent.ACTION_VIEW); mIntent.addCategory(Intent.CATEGORY_BROWSABLE); mIntent.setData(Uri.parse(getString(R.string.url))); startActivity(mIntent); } }); AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(ScanActivity.this, Utils.setThemeDialog()); mAlertDialog.setTitle(getString(R.string.about)); mAlertDialog.setView(mView); mAlertDialog.setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); mAlertDialog.show(); }
From source file:inc.bait.jubilee.model.helper.util.ImgLoader.java
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(android.R.color.transparent)), new BitmapDrawable(mResources, bitmap) }); imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td);//w w w . ja va 2 s . c om td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.he5ed.lib.cloudprovider.picker.PickerFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (getView() == null) return;// w w w .ja v a 2 s . c o m // save empty view state skip if not visible LinearLayout emptyView = (LinearLayout) getView().findViewById(android.R.id.empty); outState.putInt("empty_view_visibility", emptyView.getVisibility()); if (emptyView.getVisibility() != View.VISIBLE) return; ImageView icon = (ImageView) getView().findViewById(R.id.empty_icon_image_view); TextView title = (TextView) getView().findViewById(R.id.empty_title_text_view); TextView detail = (TextView) getView().findViewById(R.id.empty_detail_text_view); Bitmap bitmap = ((BitmapDrawable) icon.getDrawable()).getBitmap(); outState.putParcelable("icon_drawable", bitmap); outState.putCharSequence("title_text", title.getText()); outState.putCharSequence("detail_text", detail.getText()); }
From source file:com.musenkishi.wally.fragments.LatestFragment.java
private void setupAdapter() { imagesAdapter.setOnGetViewListener(new RecyclerImagesAdapter.OnGetViewListener() { @Override//from ww w . ja va 2 s . c o m public void onBindView(int position) { getMoreImagesIfNeeded(position, imagesAdapter.getItemCount()); } }); imagesAdapter.setOnItemClickListener(new RecyclerImagesAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Image image = (Image) imagesAdapter.getItem(position); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(image.imagePageURL()), view.getContext(), ImageDetailsActivity.class); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumb_image_view); Bitmap thumb = null; intent.putExtra(ImageDetailsActivity.INTENT_EXTRA_IMAGE, image); if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof GlideBitmapDrawable) { GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) thumbnailImageView .getDrawable(); thumb = glideBitmapDrawable.getBitmap(); } else if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof TransitionDrawable) { GlideBitmapDrawable squaringDrawable = (GlideBitmapDrawable) ((TransitionDrawable) thumbnailImageView .getDrawable()).getDrawable(1); thumb = squaringDrawable.getBitmap(); } WallyApplication.setBitmapThumb(thumb); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0) .toBundle(); getActivity().startActivityForResult(intent, REQUEST_CODE, bundle); } else { startActivityForResult(intent, REQUEST_CODE); } } }); }
From source file:com.bitants.wally.fragments.LatestFragment.java
private void setupAdapter() { imagesAdapter.setOnGetViewListener(new RecyclerImagesAdapter.OnGetViewListener() { @Override//from ww w .j a v a 2 s.c om public void onBindView(int position) { getMoreImagesIfNeeded(position, imagesAdapter.getItemCount()); } }); imagesAdapter.setOnItemClickListener(new RecyclerImagesAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Image image = (Image) imagesAdapter.getItem(position); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(image.imagePageURL()), view.getContext(), ImageDetailsActivity.class); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumb_image_view); Bitmap thumb = null; intent.putExtra(ImageDetailsActivity.INTENT_EXTRA_IMAGE, image); if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof GlideBitmapDrawable) { GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) thumbnailImageView .getDrawable(); thumb = glideBitmapDrawable.getBitmap(); } else if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof TransitionDrawable) { GlideBitmapDrawable squaringDrawable = (GlideBitmapDrawable) ((TransitionDrawable) thumbnailImageView .getDrawable()).getDrawable(1); thumb = squaringDrawable.getBitmap(); } WallyApplication.setBitmapThumb(thumb); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String transitionNameImage = getString(R.string.transition_image_details); ActivityOptionsCompat options = ActivityOptionsCompat .makeSceneTransitionAnimation(getActivity(), android.support.v4.util.Pair .create(view.findViewById(R.id.thumb_image_view), transitionNameImage)); ActivityCompat.startActivityForResult(getActivity(), intent, ImageDetailsActivity.REQUEST_EXTRA_TAG, options.toBundle()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0) .toBundle(); getActivity().startActivityForResult(intent, REQUEST_CODE, bundle); } else { startActivityForResult(intent, REQUEST_CODE); } } }); }