List of usage examples for android.widget ImageView setImageURI
@android.view.RemotableViewMethod(asyncImpl = "setImageURIAsync") public void setImageURI(@Nullable Uri uri)
From source file:os.ransj.adapter.SimpleJsonAdapter.java
/** * 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.//ww w. ja v a 2 s . c o m * * 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. * * This method is called instead of {@link #setViewImage(android.widget.ImageView, int)} * if the supplied data is not an int or Integer. * * @param v ImageView to receive an image * @param value the value retrieved from the data set * * @see #setViewImage(android.widget.ImageView, int) */ private void setViewImage(ImageView v, String value) { try { v.setImageResource(Integer.parseInt(value)); } catch (NumberFormatException nfe) { v.setImageURI(Uri.parse(value)); } }
From source file:com.mobeta.android.dslv.SimpleDragSortCursorAdapter.java
/** * 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.// w w w. j a v a 2s .c om * * 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(final ImageView v, final String value) { try { v.setImageResource(Integer.parseInt(value)); } catch (final NumberFormatException nfe) { v.setImageURI(Uri.parse(value)); } }
From source file:com.blandware.android.atleap.loader.ViewLoadable.java
/** * 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.//from w ww .j a va 2 s. co m * * 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 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)); } }
From source file:com.jcedar.tixee.activity.ScanTicketActivity.java
private void scanAndReturn(Context context, Uri uri, TextView scanResultss, ImageView scanTicket) { Bitmap bitmap = null;//from w w w . jav a 2s .c o m try { bitmap = decodeBitmapUri(context, uri); } catch (FileNotFoundException e) { e.printStackTrace(); } if (detector.isOperational() && bitmap != null) { scanTicket.setImageURI(uri); scanTicket.setVisibility(View.VISIBLE); Frame frame = new Frame.Builder().setBitmap(bitmap).build(); SparseArray<Barcode> barcodes = detector.detect(frame); for (int index = 0; index < barcodes.size(); index++) { Barcode code = barcodes.valueAt(index); cdScanResult.setVisibility(View.VISIBLE); // scanResultss.setText(scanResultss.getText() + code.displayValue + "\n"); // scanResultString = scanResultss.getText() + code.displayValue; scanResultString = code.rawValue; scanResultss.setText(scanResultString); // Log.e(TAG, " scanned Barcode String " + rr); //Required only if you need to extract the type of barcode int type = barcodes.valueAt(index).valueFormat; switch (type) { case Barcode.CONTACT_INFO: Log.i(TAG, code.contactInfo.title); break; case Barcode.EMAIL: Log.i(TAG, code.email.address); break; case Barcode.ISBN: Log.i(TAG, code.rawValue); break; case Barcode.PHONE: Log.i(TAG, code.phone.number); break; case Barcode.PRODUCT: Log.i(TAG, code.rawValue); break; case Barcode.SMS: Log.i(TAG, code.sms.message); break; case Barcode.TEXT: Log.i(TAG, code.rawValue); break; case Barcode.URL: Log.i(TAG, "url: " + code.url.url); break; case Barcode.WIFI: Log.i(TAG, code.wifi.ssid); break; case Barcode.GEO: Log.i(TAG, code.geoPoint.lat + ":" + code.geoPoint.lng); break; case Barcode.CALENDAR_EVENT: Log.i(TAG, code.calendarEvent.description); break; case Barcode.DRIVER_LICENSE: Log.i(TAG, code.driverLicense.licenseNumber); break; default: Log.i(TAG, code.rawValue); break; } } if (barcodes.size() == 0) { scanResultss.setText("Scan Failed: Found nothing to scan"); } } else { scanResultss.setText("Could not set up the detector!"); } }
From source file:com.example.android.droptarget.DropTargetFragment.java
@Nullable @Override//w w w. jav a2 s . co m public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_droptarget, container, false); final ImageView imageView = (ImageView) rootView.findViewById(R.id.image_target); ImageDragListener imageDragListener = new PermissionAwareImageDragListener(); imageView.setOnDragListener(imageDragListener); // Restore the application state if an image was being displayed. if (savedInstanceState != null) { final String uriString = savedInstanceState.getString(IMAGE_URI); if (uriString != null) { mImageUri = Uri.parse(uriString); imageView.setImageURI(mImageUri); } } mReleasePermissionCheckBox = (CheckBox) rootView.findViewById(R.id.release_checkbox); return rootView; }
From source file:com.linkedin.android.shaky.FormFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Toolbar toolbar = (Toolbar) view.findViewById(R.id.shaky_toolbar); EditText messageEditText = (EditText) view.findViewById(R.id.shaky_form_message); ImageView attachmentImageView = (ImageView) view.findViewById(R.id.shaky_form_attachment); Uri screenshotUri = getArguments().getParcelable(KEY_SCREENSHOT_URI); String title = getArguments().getString(KEY_TITLE); toolbar.setTitle(title);/*from w ww .jav a 2 s . c o m*/ toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(createNavigationClickListener()); toolbar.inflateMenu(R.menu.shaky_feedback_activity_actions); toolbar.setOnMenuItemClickListener(createMenuClickListener(messageEditText)); String hint = getArguments().getString(KEY_HINT); messageEditText.setHint(hint); messageEditText.requestFocus(); attachmentImageView.setImageURI(screenshotUri); attachmentImageView.setOnClickListener(createNavigationClickListener()); }
From source file:cm.confide.ex.chips.RecipientAlternatesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { int position = cursor.getPosition(); TextView display = (TextView) view.findViewById(android.R.id.title); ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); RecipientEntry entry = getRecipientEntry(position); if (position == 0) { display.setText(cursor.getString(Queries.Query.NAME)); display.setVisibility(View.VISIBLE); // TODO: see if this needs to be done outside the main thread // as it may be too slow to get immediately. imageView.setImageURI(entry.getPhotoThumbnailUri()); imageView.setVisibility(View.VISIBLE); } else {//from w ww . j a v a2s .co m display.setVisibility(View.GONE); imageView.setVisibility(View.GONE); } TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(cursor.getString(Queries.Query.DESTINATION)); TextView destinationType = (TextView) view.findViewById(android.R.id.text2); if (destinationType != null) { destinationType.setText( mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE), cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase()); } }
From source file:org.rm3l.maoni.ui.MaoniActivity.java
private void initScreenCaptureView(@NonNull final Intent intent) { final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot); final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview); if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) { touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)); }//from w w w . j ava 2 s. com final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content); if (!TextUtils.isEmpty(mScreenshotFilePath)) { final File file = new File(mScreenshotFilePath.toString()); if (file.exists()) { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.VISIBLE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.VISIBLE); } if (screenshotThumb != null) { //Thumbnail - load with smaller resolution so as to reduce memory footprint screenshotThumb.setImageBitmap( ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100)); } // Hook up clicks on the thumbnail views. if (screenshotThumb != null) { screenshotThumb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this); imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); imagePreviewDialog.getWindow() .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { //nothing; } }); imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview); final View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View v) { imagePreviewDialog.dismiss(); } }; final ImageView imageView = (ImageView) imagePreviewDialog .findViewById(R.id.maoni_screenshot_preview_image); imageView.setImageURI(Uri.fromFile(file)); final DrawableView drawableView = (DrawableView) imagePreviewDialog .findViewById(R.id.maoni_screenshot_preview_image_drawable_view); final DrawableViewConfig config = new DrawableViewConfig(); // If the view is bigger than canvas, with this the user will see the bounds config.setShowCanvasBounds(true); config.setStrokeWidth(57.0f); config.setMinZoom(1.0f); config.setMaxZoom(1.0f); config.setStrokeColor(mHighlightColor); final View decorView = getWindow().getDecorView(); config.setCanvasWidth(decorView.getWidth()); config.setCanvasHeight(decorView.getHeight()); drawableView.setConfig(config); drawableView.bringToFront(); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { config.setStrokeColor(mHighlightColor); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { config.setStrokeColor(mBlackoutColor); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close) .setOnClickListener(clickListener); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { drawableView.undo(); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ViewUtils.exportViewToFile(MaoniActivity.this, imagePreviewDialog.findViewById( R.id.maoni_screenshot_preview_image_view_updated), new File(mScreenshotFilePath.toString())); initScreenCaptureView(intent); imagePreviewDialog.dismiss(); } }); imagePreviewDialog.setCancelable(true); imagePreviewDialog.setCanceledOnTouchOutside(false); imagePreviewDialog.show(); } }); } } else { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.GONE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.GONE); } } } else { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.GONE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.GONE); } } }
From source file:im.vector.activity.SettingsActivity.java
void refreshProfileThumbnail(MXSession session, LinearLayout baseLayout) { ImageView avatarView = (ImageView) baseLayout.findViewById(R.id.imageView_avatar); Uri newAvatarUri = mTmpThumbnailUriBySession.get(session); String avatarUrl = session.getMyUser().avatarUrl; if (null != newAvatarUri) { avatarView.setImageURI(newAvatarUri); } else if (avatarUrl == null) { avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light); } else {// w w w. ja va 2 s .c o m int size = getResources().getDimensionPixelSize(R.dimen.profile_avatar_size); mMediasCache.loadAvatarThumbnail(avatarView, avatarUrl, size); } }
From source file:org.matrix.console.activity.SettingsActivity.java
void refreshProfileThumbnail(MXSession session, LinearLayout baseLayout) { ImageView avatarView = (ImageView) baseLayout.findViewById(R.id.imageView_avatar); Uri newAvatarUri = mTmpThumbnailUriByMatrixId.get(session.getCredentials().userId); String avatarUrl = session.getMyUser().getAvatarUrl(); if (null != newAvatarUri) { avatarView.setImageURI(newAvatarUri); } else if (avatarUrl == null) { avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light); } else {//from w ww . j a va 2 s .c o m int size = getResources().getDimensionPixelSize(R.dimen.profile_avatar_size); mMediasCache.loadAvatarThumbnail(session.getHomeserverConfig(), avatarView, avatarUrl, size); } }