Java Code Examples for android.widget.ImageView#getContext()
The following examples show how to use
android.widget.ImageView#getContext() .
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: PhotoViewAttacher.java From imsdk-android with MIT License | 6 votes |
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) { if(Math.abs(velocityX) > Math.abs(velocityY)){ return; } ImageView imageView = getImageView(); mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX, (int) velocityY); imageView.post(mCurrentFlingRunnable); if(velocityY > 5000){ if(mOnFlingListener != null) mOnFlingListener.onFlingExit(getImageView(), velocityX, velocityY); } }
Example 2
Source File: WXImageAdapter.java From CrazyDaily with Apache License 2.0 | 6 votes |
@Override public void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy) { if (TextUtils.isEmpty(url)) { return; } final Context context = view.getContext(); if (url.startsWith("mipmap://")) { String resIdStr = getResIdStr(url); if (TextUtils.isEmpty(resIdStr)) { return; } int imgId = context.getResources().getIdentifier(resIdStr, "mipmap", context.getPackageName()); view.setImageResource(imgId); return; } ImageLoader.load(context, url, view); }
Example 3
Source File: PhotoViewAttacher.java From Album with Apache License 2.0 | 5 votes |
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) { ImageView imageView = getImageView(); mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int)velocityX, (int)velocityY); imageView.post(mCurrentFlingRunnable); }
Example 4
Source File: PhotoViewAttacher.java From Tweetin with Apache License 2.0 | 5 votes |
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); imageView.setDrawingCacheEnabled(true); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 5
Source File: PhotoViewAttacher.java From PicturePicker with Apache License 2.0 | 5 votes |
@Override public final void onFling(float startX, float startY, float velocityX, float velocityY) { if (DEBUG) { Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY); } ImageView imageView = getImageView(); if (hasDrawable(imageView)) { mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY); imageView.post(mCurrentFlingRunnable); } }
Example 6
Source File: PhotoViewAttacher.java From android-discourse with Apache License 2.0 | 5 votes |
@Override public final void onFling(float startX, float startY, float velocityX, float velocityY) { if (DEBUG) { Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY); } ImageView imageView = getImageView(); if (hasDrawable(imageView)) { mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY); imageView.post(mCurrentFlingRunnable); } }
Example 7
Source File: PhotoViewAttacher.java From zen4android with MIT License | 5 votes |
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 8
Source File: FacebookAdapter.java From QuickReturn with Apache License 2.0 | 5 votes |
private void setUpPostImage(ImageView iv, FacebookPost post) { Context context = iv.getContext(); String postImageUrl = post.getPostImageUrl(); if (!TextUtils.isEmpty(postImageUrl)) { Picasso.with(context) .load(postImageUrl) // .placeholder(R.drawable.ic_facebook) .centerCrop() .resize(QuickReturnUtils.dp2px(context, 346), QuickReturnUtils.dp2px(context, 320)) .error(android.R.drawable.stat_notify_error) .into(iv); } }
Example 9
Source File: CropPhotoViewAttacher.java From ImageSelector with Apache License 2.0 | 5 votes |
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) { if (DEBUG) { Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY); } ImageView imageView = getImageView(); mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX, (int) velocityY); imageView.post(mCurrentFlingRunnable); }
Example 10
Source File: TwitterAdapter.java From QuickReturn with Apache License 2.0 | 5 votes |
private void setUpUserImage(ImageView iv, Tweet tweet) { Context context = iv.getContext(); String avatarUrl = tweet.getAvatarUrl(); if (!TextUtils.isEmpty(avatarUrl)) { Picasso.with(context) .load(avatarUrl) .centerCrop() .resize(QuickReturnUtils.dp2px(context, 50), QuickReturnUtils.dp2px(context, 50)) // .placeholder(R.drawable.ic_facebook) .error(android.R.drawable.stat_notify_error) .into(iv); } }
Example 11
Source File: AuthorVideosAdapter.java From Aurora with Apache License 2.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, VideoListInfo.Video item) { helper.setText(R.id.tv_title,item.getData().getTitle()) .setText(R.id.tv_type,getDetailStr(item)); ImageView img = helper.getView(R.id.iv_left); AppComponent mAppComponent = ((App)img.getContext().getApplicationContext()) .getAppComponent(); Context context = img.getContext(); mAppComponent.imageLoader().loadImage(context, ImageConfigImpl .builder() .url(item.getData().getCover().getFeed()) .imageView(img) .build()); }
Example 12
Source File: PhotoViewAttacher.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) { if (DEBUG) { LogManager.getLogger().d( LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY); } ImageView imageView = getImageView(); mCurrentFlingRunnable = new FlingRunnable(imageView.getContext()); mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX, (int) velocityY); imageView.post(mCurrentFlingRunnable); }
Example 13
Source File: ImageViewScaler.java From MultiView with Apache License 2.0 | 5 votes |
public ImageViewScaler(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(imageView); imageView.setDrawingCacheEnabled(true); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 14
Source File: PhotoViewAttacher.java From Favorite-Android-Client with Apache License 2.0 | 5 votes |
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 15
Source File: FullScreenImageGalleryAdapter.java From ImageGallery with Apache License 2.0 | 4 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { LayoutInflater inflater = (LayoutInflater) container.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.fullscreen_image, null); ImageView imageView = (ImageView) view.findViewById(R.id.iv); final LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.ll); String image = images.get(position); Context context = imageView.getContext(); int width = DisplayUtility.getScreenWidth(context); fullScreenImageLoader.loadFullScreenImage(imageView, image, width, linearLayout); container.addView(view, 0); return view; }
Example 16
Source File: PhotoViewAttacher.java From Android with MIT License | 4 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(imageView); imageView.setDrawingCacheEnabled(true); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 17
Source File: PhotoViewAttacher.java From RotatePhotoView with Apache License 2.0 | 4 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(imageView); imageView.setDrawingCacheEnabled(true); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); //modify by ChenSiLiang setRotateGestureDetector(); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 18
Source File: CacheAdapter.java From Aurora with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, VideoDownLoadInfo item) { AppComponent mAppComponent = ((App)helper.getView(R.id.iv_bg).getContext().getApplicationContext()) .getAppComponent(); ImageView imgMian = helper.getView(R.id.iv_bg); Context context = imgMian.getContext(); helper.setText(R.id.tv_title,item.getVideo().getTitle()); if (item.getVideo().getAuthor()!=null){ helper.setText(R.id.tv_author,item.getVideo().getAuthor().getName()); } helper.setText(R.id.tv_size, StringUtils.getPrintSize(item.getContentLength() == null ?0:item.getContentLength(),true)); helper.addOnClickListener(R.id.iv_more); helper.addOnClickListener(R.id.ll_detail); helper.addOnClickListener(R.id.ll_progress); helper.addOnClickListener(R.id.ctl_layout); if (!type.contains("正在")){ helper.getView(R.id.ll_detail).setVisibility(View.VISIBLE); }else { helper.getView(R.id.ll_detail).setVisibility(View.GONE); } if (item.getFinish()){ helper.getView(R.id.ll_progress).setVisibility(View.GONE); helper.getView(R.id.tv_size).setVisibility(View.VISIBLE); }else { helper.getView(R.id.tv_size).setVisibility(View.GONE); // if (downPosition == helper.getLayoutPosition()){ // helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); // helper.getView(R.id.sb_progress).setVisibility(View.VISIBLE); // ((SeekBar)helper.getView(R.id.sb_progress)).setProgress(item.getPercent()); // String size = StringUtils.getPrintSize(item.getCurrentBytes() == null ?0:item.getContentLength(),false) + "/" + StringUtils.getPrintSize(item.getContentLength() == null ?0:item.getContentLength(),true); // helper.setText(R.id.tv_pause,size); // }else { if (item.isPending()){ helper.setText(R.id.tv_pause,"正在连接中..."); ((ProgressBar)helper.getView(R.id.sb_progress)).setIndeterminate(true); helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); helper.getView(R.id.sb_progress).setVisibility(View.VISIBLE); }else { if (item.isLineUp()){ helper.setText(R.id.tv_pause,"排队中"); }else { helper.setText(R.id.tv_pause,"已暂停"); } helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); helper.getView(R.id.sb_progress).setVisibility(View.GONE); } // } } mAppComponent.imageLoader().loadImage(context, ImageConfigImpl .builder() .url(item.getVideo().getCover().getFeed()) .imageView(imgMian) .build()); }
Example 19
Source File: DataBinder.java From Learning-Resources with MIT License | 4 votes |
@BindingAdapter("imageUrl") public static void setImageUrl(ImageView imageView, String url) { Context context = imageView.getContext(); Picasso.with(context).load(url).into(imageView); }
Example 20
Source File: BindingUtils.java From android-mvvm-architecture with Apache License 2.0 | 4 votes |
@BindingAdapter("imageUrl") public static void setImageUrl(ImageView imageView, String url) { Context context = imageView.getContext(); Glide.with(context).load(url).into(imageView); }