Java Code Examples for android.widget.ImageView.setImageURI()

The following are Jave code examples for showing how to use setImageURI() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Viajes   File: FrescoSliderView.java   Source Code and License Vote up 8 votes
protected void bindEventAndShow(final View v, ImageView targetImageView) {
    View progressBar = v.findViewById(com.daimajia.slider.library.R.id.loading_bar);
    if (progressBar != null) {
        progressBar.setVisibility(View.GONE);
    }
    Log.d("targetImageView",getUrl());

    targetImageView.setImageURI(Uri.parse(getUrl()));
    targetImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            action.onSliderClick();
        }
    });


}
 
Example 2
Project: 2017.2-codigo   File: DownloadViewActivity.java   Source Code and License Vote up 8 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_download_view);
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        File imageFile = new File(root, Uri.parse(DownloadJobService.downloadLink).getLastPathSegment());
        if (imageFile.exists()) {
            ImageView imageview = (ImageView) findViewById(R.id.imagemDownload);
            imageview.setImageURI(Uri.parse("file://" + imageFile.getAbsolutePath()));
        }
        else {
            Toast.makeText(this, "Arquivo nao existe", Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, "Armazenamento externo nao esta montado...", Toast.LENGTH_SHORT).show();
    }
}
 
Example 3
Project: shotwatch   File: MainActivity.java   Source Code and License Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mText = (TextView) findViewById(R.id.text);
    mImage = (ImageView) findViewById(R.id.image);

    mShotWatch = new ShotWatch(getContentResolver(), new ShotWatch.Listener() {
        @Override
        public void onScreenShotTaken(ScreenshotData screenshotData) {
            mText.setText(screenshotData.getFileName());
            Uri uri = Uri.parse(screenshotData.getPath());
            mImage.setImageURI(uri);
        }
    });
}
 
Example 4
Project: 2017.2-codigo   File: DownloadViewActivity.java   Source Code and License Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_download_view);
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        File imageFile = new File(root, Uri.parse(DownloadActivity.downloadLink).getLastPathSegment());
        if (imageFile.exists()) {
            ImageView imageview = (ImageView) findViewById(R.id.imagemDownload);
            imageview.setImageURI(Uri.parse("file://" + imageFile.getAbsolutePath()));
        }
        else {
            Toast.makeText(this, "Arquivo nao existe", Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, "Armazenamento externo nao esta montado...", Toast.LENGTH_SHORT).show();
    }
}
 
Example 5
Project: NotifyTools   File: FloatView.java   Source Code and License Vote up 6 votes
void showImg(){
    String strs[]=new String[]{"/sdcard/1.png","/sdcard/2.png"};

    int x=200,y=0,w=20,h=20;
    for(int i=0;i<strs.length;i++) {
        ImageView img = new ImageView(cxt);
        img.setImageURI(Uri.fromFile(new File(strs[i])));
        img.setTag(IMGTAGS[i]);
        initEvents(img);
        WindowManager.LayoutParams p = createLayoutParams(x*i+50, y, w, h);
        map.put(img, p);
        windowManager.addView(img, p);
    }
}
 
Example 6
Project: GitHub   File: FrescoImageLoader.java   Source Code and License Vote up 6 votes
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
    //用fresco加载图片
    Uri uri = Uri.parse((String) path);
    imageView.setImageURI(uri);

}
 
Example 7
Project: GitHub   File: FrescoImageLoader.java   Source Code and License Vote up 6 votes
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
    //用fresco加载图片
    Uri uri = Uri.parse((String) path);
    imageView.setImageURI(uri);

}
 
Example 8
Project: snu-artoon   File: LocalImageLoader.java   Source Code and License Vote up 6 votes
/**
 * Load the image indicated by the fileName into destination ImageView.
 * @param destination imageView to be set
 * @param fileName fileName of the image to be set. If null, no image is set.
 */
public static void load(ImageView destination, String fileName) {
    if (fileName != null) {
        Uri uri = Uri.parse("android.resource://com.snu_artoon.arwebtoonplayer/drawable/"
                + fileName);
        destination.setImageURI(uri);
    }
}
 
Example 9
Project: Geoclick   File: MyImageAdapter.java   Source Code and License Vote up 6 votes
/**
 * Create the page for the given position.
 *
 * @param container The containing View in which the page will be shown.
 * @param i The page position to be instantiated.
 *
 * @return Returns an Object representing the new page. This does not need
 *         to be a View, but can be some other container of the page.
 */
@Override
public  Object instantiateItem(ViewGroup container, int i)
{
    ImageView mImageView = new ImageView(mContext);
    mImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    mImageView.setImageURI(Uri.parse(pictureItems.get(i).get_mainImg()));
    ((ViewPager)container).addView(mImageView,0);

    return  mImageView;


}
 
Example 10
Project: Closet   File: CardPagerAdapter.java   Source Code and License Vote up 6 votes
private void bind(ProductEntity item, View view) {
    ImageView imgDressing = (ImageView) view.findViewById(R.id.img_item_dressing);
    int resId = item.getResId();
    if(resId <= 0){
        Uri uri = item.getUri();
        if(uri != null){
            imgDressing.setImageURI(uri);
        }
    }else {
        imgDressing.setImageResource(resId);
    }
}
 
Example 11
Project: SIIEScanner   File: ItemRow.java   Source Code and License Vote up 6 votes
private void putImage(ImageView imageView, Object data) {
    imageView.setImageBitmap( null );
    if( data == null ) {
        return;
    }
    if( data instanceof Bitmap ) imageView.setImageBitmap( ( Bitmap ) data);
    if( data instanceof Integer ) imageView.setImageResource(( Integer ) data);
    if( data instanceof Drawable ) imageView.setImageDrawable( ( Drawable ) data);
    if( data instanceof Uri ) imageView.setImageURI( ( Uri ) data);
    if( data instanceof Matrix ) imageView.setImageMatrix( ( Matrix ) data);
}
 
Example 12
Project: XSnow   File: HelperViewHolder.java   Source Code and License Vote up 6 votes
@Override
public HelperViewHolder setImageUrl(int viewId, String imgUrl) {
    ImageView imageView = getView(viewId);
    if (!TextUtils.isEmpty(imgUrl)) {
        imageView.setImageURI(Uri.parse(imgUrl));
    }
    return this;
}
 
Example 13
Project: AndroidBasicLibs   File: HelperViewHolder.java   Source Code and License Vote up 6 votes
@Override
public HelperViewHolder setImageUrl(int viewId, String imgUrl) {
    ImageView imageView = getView(viewId);
    if (!TextUtils.isEmpty(imgUrl)) {
        imageView.setImageURI(Uri.parse(imgUrl));
    }
    return this;
}
 
Example 14
Project: letv   File: SimpleCursorAdapter.java   Source Code and License Vote up 6 votes
public void setViewImage(ImageView v, String value) {
    try {
        v.setImageResource(Integer.parseInt(value));
    } catch (NumberFormatException e) {
        v.setImageURI(Uri.parse(value));
    }
}
 
Example 15
Project: smartkey   File: BindUtil.java   Source Code and License Vote up 6 votes
@BindingAdapter("imgUri")
public static void setImgUri(ImageView view, Uri uri) {
    try {
        view.setImageURI(uri);
    } catch (OutOfMemoryError error) {
        ToastUtil.toast(R.string.pic_too_large);
    }
}
 
Example 16
Project: boohee_v5.6   File: SimpleCursorAdapter.java   Source Code and License Vote up 6 votes
public void setViewImage(ImageView v, String value) {
    try {
        v.setImageResource(Integer.parseInt(value));
    } catch (NumberFormatException e) {
        v.setImageURI(Uri.parse(value));
    }
}
 
Example 17
Project: ultrasonic   File: SimpleDragSortCursorAdapter.java   Source Code and License Vote up 5 votes
/**
 * Called by bindView() to set the image for an ImageView but only if
 * there is no existing ViewBinder or if the existing ViewBinder cannot
 * handle binding to an ImageView.
 *
 * By default, the value will be treated as an image resource. If the
 * value cannot be used as an image resource, the value is used as an
 * image Uri.
 *
 * Intended to be overridden by Adapters that need to filter strings
 * retrieved from the database.
 *
 * @param v ImageView to receive an image
 * @param value the value retrieved from the cursor
 */
public void setViewImage(ImageView v, String value) {
    try {
        v.setImageResource(Integer.parseInt(value));
    } catch (NumberFormatException nfe) {
        v.setImageURI(Uri.parse(value));
    }
}
 
Example 18
Project: rental-calc   File: PropertyPicturesActivity.java   Source Code and License Vote up 5 votes
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    View view;

    if (convertView == null)
    {
        view = LayoutInflater.from(_activity).inflate(R.layout.picture_grid_item, parent, false);
    }
    else
    {
        view = convertView;
    }

    ImageView imageView = (ImageView)view.findViewById(R.id.image);

    imageView.setImageURI(null);

    final Picture picture = getItem(position);

    imageView.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            if(picture != null)
            {
                Bundle bundle = new Bundle();
                bundle.putString("file", picture.uri.getPath());
                Intent i = new Intent(_activity, PictureViewActivity.class);
                i.putExtras(bundle);
                _activity.startActivityForResult(i, REQUEST_VIEW_IMAGE_TAG);
            }
        }
    });

    if(picture != null)
    {
        Glide.with(_activity).load(picture.uri).centerCrop().into(imageView);
    }

    return imageView;
}
 
Example 19
Project: LiuAGeAndroid   File: NewsListRecyclerViewAdapter.java   Source Code and License Vote up 5 votes
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
    imageView.setImageURI(Uri.parse((String) path));
}
 
Example 20
Project: JueDiQiuSheng   File: ZKImageLoader.java   Source Code and License Vote up 5 votes
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
    //用fresco加载图片简单用法,记得要写下面的createImageView方法
    Uri uri = Uri.parse((String) path);
    imageView.setImageURI(uri);
}