List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.example.vedantn.algaeestimator.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Processing image from camera if (requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK) { ImageView userImage = (ImageView) findViewById(R.id.userImage); Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); userImage.setImageBitmap(thumbnail); }/*from w ww . j a v a 2s .co m*/ }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private ImageView icon() { ImageView icon = new ImageView(context); LayoutParams layoutParams = new LayoutParams(UZCoreUtil.dipToPix(iconSize), UZCoreUtil.dipToPix(iconSize)); layoutParams.setMargins(UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop), UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop)); icon.setLayoutParams(layoutParams);//from w w w . j a v a 2s. co m if (getIcon() != null) { icon.setImageBitmap(getIcon()); } else { getImgShowUtil().display(icon, iconStr, getLoadCallBack()); } return icon; }
From source file:com.greendev.image.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk * cache will be used if an {@link ImageCache} has been set using * {@link ImageWorker#setImageCache(ImageCache)}. If the image is found in the memory cache, it * is set immediately, otherwise an {@link AsyncTask} will be created to asynchronously load the * bitmap./*from w w w. jav a 2 s .com*/ * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, data); } }
From source file:es.uma.lcc.tasks.DecryptionRequestTask.java
@Override public void onPostExecute(Void l) { mProgressDialog.dismiss();/* w ww. j a va 2 s .com*/ if (mConnectionSucceeded) { if (mIsAuthError) { handleAuthenticationError(); } else { mMainActivity.findViewById(R.id.imageBlock).setVisibility(View.VISIBLE); mMainActivity.findViewById(R.id.encryptBlock).setVisibility(View.GONE); mMainActivity.findViewById(R.id.decryptBlock).setVisibility(View.GONE); mMainActivity.findViewById(R.id.myPicsBlock).setVisibility(View.GONE); mMainActivity.findViewById(R.id.accountBlock).setVisibility(View.GONE); mMainActivity.findViewById(R.id.filler1).setVisibility(View.GONE); mMainActivity.findViewById(R.id.filler2).setVisibility(View.GONE); mMainActivity.findViewById(R.id.filler3).setVisibility(View.GONE); mMainActivity.findViewById(R.id.filler4).setVisibility(View.GONE); ImageView imageView = (ImageView) mMainActivity.findViewById(R.id.imageView); imageView.setVisibility(ImageView.VISIBLE); if (!mHasFoundKeys) { Toast.makeText(mMainActivity, R.string.noKeysRetrievedWarning, Toast.LENGTH_SHORT).show(); } if (mWidth >= 2048 || mHeight >= 2048) { double factor = (mWidth > mHeight ? 2048.0 / mWidth : 2048.0 / mHeight); imageView.setImageBitmap(Bitmap.createScaledBitmap(mDecodedBmp, (int) (factor * mWidth), (int) (factor * mHeight), false)); } else { imageView.setImageBitmap(mDecodedBmp); } } } else { Toast.makeText(mMainActivity, R.string.noConnectionWarning, Toast.LENGTH_SHORT).show(); } }
From source file:com.aapbd.utils.image.CacheImageDownloader.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./*w w w . j a v a 2 s. c om*/ * * @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. */ public void download(final String url, final ImageView imageView, final String cookie) { resetPurgeTimer(); final Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView, cookie); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); imageView.setVisibility(View.VISIBLE); if (isScale) { scaleImage1(imageView); } } }
From source file:com.app.hutbay.utility.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *///w w w. jav a 2 s . c o m public void download(String url, ImageView imageView, boolean filParentImageView) { this.filParentImageView = filParentImageView; resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); /* if(filParentImageView){ Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, imageView.getWidth(), imageView.getHeight(), true); imageView.setImageBitmap(scaledBitmap); } else{ imageView.setImageBitmap(bitmap); } */ } }
From source file:com.cupfish.music.cache.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk * cache will be used if an {@link ImageCache} has been set using * {@link ImageWorker#setImageCache(ImageCache)}. If the image is found in the memory cache, it * is set immediately, otherwise an {@link AsyncTask} will be created to asynchronously load the * bitmap.//from w w w . j av a2 s . c om * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(ImageInfo info, ImageView imageView) { if (info == null) { return; } String data = info.encode(); Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(data); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, info); } }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
private ImageView getImageView(final Context context, Bitmap photo, String uuid) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight)); imageView.setPadding(5, 5, 5, 5);/*from w w w. j a v a 2 s . c o m*/ imageView.setImageBitmap(photo); imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px)); imageView.setTag(uuid); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String photoId = (String) v.getTag(); FragmentActivity activity = mFragmentDetail.getActivity(); Intent intent = new Intent(activity, PictureActivity.class); if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId)); } else if (_pictures.containsKey(photoId)) {// pictures from database Map<String, String> imagePaths = _pictures.get(photoId); String imagePath = imagePaths.get("display"); intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path } if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW) || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) { intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId); activity.startActivityForResult(intent, PICTURE_VIEW_RESULT); } else Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show(); /* JSONArray form = null; try { form = mFragmentDetail.getSelectedForm(); } catch (JSONException jse) { jse.printStackTrace(); Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show(); } if (form != null) { try { String json = encodeToJson(); FormUtilities.updatePicture(form, json); } catch (JSONException e) { e.printStackTrace(); }catch (Exception e) { e.printStackTrace(); } } try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); }*/ /** * open in markers to edit it */ // MarkersUtilities.launchOnImage(context, image); /* try { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Image image = imagesDbHelper.getImage(imageIdLong); File tempDir = ResourcesManager.getInstance(context).getTempDir(); String ext = ".jpg"; if (image.getName().endsWith(".png")) ext = ".png"; File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext)); byte[] imageData = imagesDbHelper.getImageData(image.getId()); ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath()); intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$ context.startActivity(intent); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); }*/ //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show(); } }); return imageView; }
From source file:com.he5ed.lib.cloudprovider.picker.CloudPickerActivity.java
/** * @hide//from w ww . ja va 2s . c o m */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cp_activity_picker); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); // lock right drawer from been swiped open drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); navigationView.setItemIconTintList(null); // remove the auto grey tint to keep icon color Menu menu = navigationView.getMenu(); CloudProvider cloudProvider = CloudProvider.getInstance(this); // check whether individual account is assigned String accountId = getIntent().getStringExtra(EXTRA_PICK_ACCOUNT_ID); if (!TextUtils.isEmpty(accountId)) { mAccounts = new CloudAccount[1]; mAccounts[0] = cloudProvider.getAccountById(accountId); } else { mAccounts = cloudProvider.getCloudAccounts(); } // populate navigation menu for (int i = 0; i < mAccounts.length; i++) { CloudAccount account = mAccounts[i]; MenuItem item = menu.add(0, i, 0, account.getUser().email); // use cloud API class reflection try { Class clazz = Class.forName(account.api); Field iconResource = clazz.getField("ICON_RESOURCE"); item.setIcon(iconResource.getInt(null)); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); item.setIcon(R.drawable.ic_cloud_black_24dp); } catch (IllegalAccessException e) { e.printStackTrace(); } item.setCheckable(true); } mFragmentManager = getSupportFragmentManager(); mItemFragment = (ItemFragment) mFragmentManager.findFragmentById(R.id.right_drawer_view); if (mItemFragment == null) { mItemFragment = new ItemFragment(); mFragmentManager.beginTransaction().add(R.id.right_drawer_view, mItemFragment).commit(); } mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); mErrorView = (LinearLayout) findViewById(R.id.error_view); if (savedInstanceState != null) { switch (savedInstanceState.getInt("empty_view_visibility")) { case View.VISIBLE: mErrorView.setVisibility(View.VISIBLE); ImageView icon = (ImageView) mErrorView.findViewById(R.id.empty_icon_image_view); TextView title = (TextView) mErrorView.findViewById(R.id.empty_title_text_view); TextView detail = (TextView) mErrorView.findViewById(R.id.empty_detail_text_view); Bitmap bitmap = savedInstanceState.getParcelable("icon_drawable"); icon.setImageBitmap(bitmap); title.setText(savedInstanceState.getCharSequence("title_text")); detail.setText(savedInstanceState.getCharSequence("detail_text")); break; case View.INVISIBLE: mErrorView.setVisibility(View.INVISIBLE); break; case View.GONE: mErrorView.setVisibility(View.GONE); break; } } else { // open drawer on first load drawer.openDrawer(GravityCompat.START); } }
From source file:com.mobicage.rogerthat.FriendDetailActivity.java
private void initBroadcastReceiver(final IntentFilter filter) { T.UI();// w w w .j a va 2 s . co m mBroadcastReceiver = new SafeBroadcastReceiver() { @Override public String[] onSafeReceive(final Context context, final Intent intent) { T.UI(); if (mFriend == null) { L.bug("FriendDetailActivity received intent but mFriend == null"); return ALL_RECEIVING_INTENTS; } String action = intent.getAction(); if (FriendsPlugin.FRIENDS_LIST_REFRESHED.equals(action)) { Friend newFriend = showFriend(intent); if (newFriend == null) { // friend does not exist anymore, not interested in any older intent return ALL_RECEIVING_INTENTS; } mFriend = newFriend; return UPDATE_VIEW_INTENTS; } else if (BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT.equals(action) || BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT.equals(action)) { if (mFriend != null && mFriend.descriptionBranding != null && mFriend.descriptionBranding .equals(intent.getStringExtra(BrandingMgr.BRANDING_KEY))) { showBrandedDescription(mFriend); return new String[] { BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT, BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT }; } } else if (mFriend.email.equals(intent.getStringExtra(EMAIL))) { // Process friend intents if (FriendsPlugin.FRIEND_UPDATE_INTENT.equals(action) || FriendsPlugin.FRIEND_AVATAR_CHANGED_INTENT.equals(action)) { Friend newFriend = showFriend(intent); if (newFriend == null) { // friend does not exist anymore, not interested in any older intent return ALL_RECEIVING_INTENTS; } mFriend = newFriend; return UPDATE_VIEW_INTENTS; } else if (FriendsPlugin.FRIEND_REMOVED_INTENT.equals(action)) { L.d("Received intent - FRIEND_REMOVED_INTENT"); if (mFriend.existenceStatus != Friend.NOT_FOUND && !isFinishing()) { finish(); return ALL_RECEIVING_INTENTS; } } else if (FriendsPlugin.FRIEND_QR_CODE_RECEIVED_INTENT.equals(action)) { byte[] image = Base64.decode(intent.getStringExtra("qrcode")); Bitmap bm = BitmapFactory.decodeByteArray(image, 0, image.length); ImageView view = (ImageView) findViewById(R.id.qrcode); view.setImageBitmap(bm); return new String[] { action }; } } return null; } }; registerReceiver(mBroadcastReceiver, filter); }