List of usage examples for android.widget ImageView getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:me.egorand.contactssync.ui.adapters.ContactsAdapter.java
private void renderContactIcon(ImageView imageView, Contact contact) { String contactInitial = String.valueOf(contact.name.charAt(0)); int color = ContextCompat.getColor(imageView.getContext(), R.color.colorAccent); TextDrawable drawable = TextDrawable.builder().buildRound(contactInitial, color); imageView.setImageDrawable(drawable); }
From source file:org.amahi.anywhere.tv.presenter.MainTVPresenter.java
private void setUpImageIcon(ServerFile file, ImageView fileIconView, Uri url) { Glide.with(fileIconView.getContext()).load(url.toString()).diskCacheStrategy(DiskCacheStrategy.ALL) .centerCrop().placeholder(Mimes.getTVFileIcon(file)).into(fileIconView); }
From source file:im.neon.util.VectorUtils.java
/** * Set the default vector avatar for a member. * * @param imageView the imageView to set. * @param userId the member userId. * @param displayName the member display name. *///from w ww . j a v a 2 s.co m private static void setDefaultMemberAvatar(final ImageView imageView, final String userId, final String displayName) { // sanity checks if (null != imageView && !TextUtils.isEmpty(userId)) { final Bitmap bitmap = VectorUtils.getAvatar(imageView.getContext(), VectorUtils.getAvatarColor(userId), TextUtils.isEmpty(displayName) ? userId : displayName, true); if (Looper.getMainLooper().getThread() == Thread.currentThread()) { imageView.setImageBitmap(bitmap); } else { final String tag = userId + " - " + displayName; imageView.setTag(tag); mUIHandler.post(new Runnable() { @Override public void run() { if (TextUtils.equals(tag, (String) imageView.getTag())) { imageView.setImageBitmap(bitmap); } } }); } } }
From source file:com.yanzhenjie.album.task.ImageLocalLoader.java
/** * According to the ImageView obtains appropriate width and height of compression. * * @param imageView {@link ImageView}.// ww w. j a v a 2 s.co m * @param viewSizes ViewSize. */ private void measureSize(ImageView imageView, int[] viewSizes) { final DisplayMetrics displayMetrics = imageView.getContext().getResources().getDisplayMetrics(); final LayoutParams params = imageView.getLayoutParams(); if (params == null) { viewSizes[0] = displayMetrics.widthPixels; viewSizes[1] = displayMetrics.heightPixels; } else { viewSizes[0] = params.width == LayoutParams.WRAP_CONTENT ? 0 : imageView.getMeasuredWidth(); // Get actual image width viewSizes[1] = params.height == LayoutParams.WRAP_CONTENT ? 0 : imageView.getMeasuredWidth(); // Get actual image height if (viewSizes[0] <= 0) viewSizes[0] = displayMetrics.widthPixels; // Get layout width parameter if (viewSizes[1] <= 0) viewSizes[1] = displayMetrics.heightPixels; // Get layout height parameter } }
From source file:com.ifeng.util.imagecache.ImageWorker.java
/** * // ww w . j a va2s. c om * * @param imageView * @param drawable */ public static void setFadeInDrawable(ImageView imageView, Drawable drawable) { // Bug fix by XuWei 2013-09-09 // Drawable?bug?ViewDrawable??Drawable Drawable copyDrawable = new BitmapDrawable(imageView.getContext().getResources(), ((BitmapDrawable) drawable).getBitmap()); // Transition drawable with a transparent drawable and the final // drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), copyDrawable }); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); }
From source file:email.schaal.ocreader.OCReaderApplication.java
@Override public void onCreate() { super.onCreate(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.edit().putBoolean(Preferences.SYS_SYNC_RUNNING.getKey(), false) .putString(Preferences.SORT_FIELD.getKey(), Item.ID).apply(); Queries.init(this); AlarmUtils.init(this); OkHttp3Downloader downloader = new OkHttp3Downloader(this); Picasso picasso = new Picasso.Builder(this).downloader(downloader) .defaultBitmapConfig(Bitmap.Config.ARGB_8888).addRequestHandler(new IcoRequestHandler(downloader)) .build();//from w w w . j ava 2 s . c om Picasso.setSingletonInstance(picasso); DrawerImageLoader.init(new DrawerImageLoader.IDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder) { set(imageView, uri, placeholder, null); } @Override public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) { Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView); } @Override public void cancel(ImageView imageView) { Picasso.with(imageView.getContext()).cancelRequest(imageView); } @Override public Drawable placeholder(Context ctx) { return ContextCompat.getDrawable(ctx, R.drawable.ic_feed_icon); } @Override public Drawable placeholder(Context ctx, String tag) { final int drawableRes; if (tag != null) { switch (DrawerImageLoader.Tags.valueOf(tag)) { case PROFILE: drawableRes = R.drawable.ic_launcher; break; default: drawableRes = R.drawable.ic_feed_icon; break; } } else { drawableRes = R.drawable.ic_feed_icon; } return ContextCompat.getDrawable(ctx, drawableRes); } }); }
From source file:com.ricardotrujillo.prueba.viewmodel.adapter.StoreRecyclerViewAdapter.java
void loadImage(ImageView view, final int position, final CustomCallback callback) { Picasso.with(view.getContext()).load(storeManager.getStore().feed.entry.get(position).image[2].label) .networkPolicy(NetWorker.isConnected(activity) ? NetworkPolicy.NO_CACHE : NetworkPolicy.OFFLINE) .noFade().into(view, new Callback() { @Override// ww w. j av a 2s. com public void onSuccess() { callback.onSuccess(); } @Override public void onError() { } }); }
From source file:com.github.notizklotz.derbunddownloader.issuesgrid.DownloadedIssuesActivity.java
@AfterViews void setupIssuesGrid() { gridView.setEmptyView(emptyGridView); gridView.setOnItemClickListener(new IssuesGridOnItemClickListener()); final SimpleCursorAdapter issueListAdapter = new SimpleCursorAdapter(this, R.layout.include_issue, null, new String[] { DownloadManager.COLUMN_DESCRIPTION, DownloadManager.COLUMN_STATUS }, new int[] { R.id.dateTextView, R.id.stateTextView }, 0) { @Override//from w w w. ja v a 2 s . co m public View getView(final int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); View deleteButton = view.findViewById(R.id.issueDeleteButton); deleteButton.setOnClickListener(new IssueDeleteButtonOnClickListener(position)); // Load the thumbnail image ImageView image = (ImageView) view.findViewById(R.id.issueImageView); Uri uri = Uri.parse(getCursor().getString(getCursor().getColumnIndex(DownloadManager.COLUMN_URI))); Picasso.with(image.getContext()).load(IssueDownloadService_.getThumbnailUriForPDFUri(uri)) .placeholder(R.drawable.issue_placeholder).into(image); return view; } }; issueListAdapter.setViewBinder(new IssuesGridViewBinder(this)); gridView.setAdapter(issueListAdapter); getLoaderManager().initLoader(1, null, new IssuesGridLoaderCallbacks(this, issueListAdapter)); }
From source file:fr.eoidb.util.ImageDownloader.java
/** * Same as {@link #download(String, ImageView)}, with the possibility to provide an additional * cookie that will be used when the image will be retrieved. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. * @param cookie A cookie String that will be used by the http connection. *//* w w w . j a v a 2s . c o m*/ public void download(String url, ImageView imageView, String cookie) { Bitmap bitmap = getBitmapFromCache(url, imageView.getContext()); if (bitmap == null) { forceDownload(url, imageView, cookie); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); IconUtil.hideIconProgress(imageView); } }
From source file:com.siso.app.adapter.BannerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final View view = viewlist.get(position); final ImageView imageView = (ImageView) view.findViewById(R.id.item_banner_img); // final LinearLayout loading = (LinearLayout)view.findViewById(R.id.item_banner_loading); Log.i("tag", "imgUrl[position]==" + imgUrl[position]); if (imageView.getDrawable() == null) { Picasso picasso = Picasso.with(imageView.getContext()); picasso.load(imgUrl[position]).into(imageView); // Log.i("image", "position=="+position+""+imgUrl[position]); // AsyncHttpClient client=new AsyncHttpClient(); // client.get(imgUrl[position], new AsyncHttpResponseHandler() { // // @Override // public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { // if(statusCode==200){ // BitmapFactory factory=new BitmapFactory(); // Bitmap bitmap=factory.decodeByteArray(responseBody, 0, responseBody.length); // imageView.setImageBitmap(bitmap); // loading.setVisibility(View.GONE); // } // } // // @Override // public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // loading.setVisibility(View.GONE); // Toast.makeText(context, context.getResources().getString(R.string.timeoutError), Toast.LENGTH_SHORT); // } // }); }//from w w w . j a v a 2 s. c om ViewParent vp = view.getParent(); if (vp != null) { ViewGroup parent = (ViewGroup) vp; parent.removeView(view); } container.addView(view); return view; }