Example usage for android.widget ImageView setImageBitmap

List of usage examples for android.widget ImageView setImageBitmap

Introduction

In this page you can find the example usage for android.widget ImageView setImageBitmap.

Prototype

@android.view.RemotableViewMethod
public void setImageBitmap(Bitmap bm) 

Source Link

Document

Sets a Bitmap as the content of this ImageView.

Usage

From source file:fm.smart.r1.ItemActivity.java

static void setSound(ImageView sound_icon, final String sound_url, final Context context, final int type_id,
        final String artifact_id, final String to_record) {
    if (!TextUtils.isEmpty(sound_url)) {
        OnClickListener sound_listener = new OnClickListener() {
            public void onClick(View v) {// TODO removed temporarily
                MediaUtility.playSound(sound_url, ItemListActivity.mMediaPlayer, context);
            }//  ww  w.  j a v a2s.c o m
        };
        sound_icon.setOnClickListener(sound_listener);
        sound_icon
                .setImageBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.active_sound));
    } else {
        if (type_id == R.id.response_sound || type_id == R.id.translation_sound) {
            sound_icon.setVisibility(View.INVISIBLE);
        } else {
            sound_icon.setImageBitmap(
                    BitmapFactory.decodeResource(context.getResources(), R.drawable.inactive_sound_add));

            OnClickListener listener = new OnClickListener() {
                public void onClick(View v) {
                    // TODO removed temporarily
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setClassName(context, CreateSoundActivity.class.getName());
                    AndroidUtils.putExtra(intent, "item_id", (String) item.getId());
                    AndroidUtils.putExtra(intent, "to_record", to_record);
                    AndroidUtils.putExtra(intent, "id", artifact_id);
                    AndroidUtils.putExtra(intent, "sound_type", Integer.toString(type_id));
                    context.startActivity(intent);

                }
            };
            sound_icon.setOnClickListener(listener);
        }
    }
}

From source file:eu.loopit.f2011.library.BitmapManager.java

public void fetchBitmapOnThread(final String urlString, final ImageView imageView, final Bitmap defaultImage) {
    if (bitmapMap.containsKey(urlString)) {
        imageView.setImageBitmap(bitmapMap.get(urlString));
    }// ww w . j  a  va  2 s.c  om

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.obj != null) {
                imageView.setImageBitmap((Bitmap) message.obj);
            }
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            Bitmap bitmap = fetchBitmap(urlString, defaultImage);
            Message message = handler.obtainMessage(1, bitmap);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.facebook.samples.socialcafe.OrderDrinkFragmentActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.order_drink, parent, false);
    getActivity().setTitle(R.string.place_order);

    TextView userName = (TextView) v.findViewById(R.id.story_order_message);
    userName.setText(getString(R.string.og_message,
            ((SocialCafeApplication) getActivity().getApplication()).userName, drink.getTitle()));

    ImageView userPic = (ImageView) v.findViewById(R.id.user_order_pic);
    userPic.setImageBitmap(((SocialCafeApplication) getActivity().getApplication()).userPic);

    TextView drinkTitle = (TextView) v.findViewById(R.id.drink_order_title);
    drinkTitle.setText(drink.getTitle());

    TextView drinkInfo = (TextView) v.findViewById(R.id.drink_order_info);
    drinkInfo.setText(drink.getInfo());//from   ww w .j  a v a 2s . c om

    final TextView userMessage = (TextView) v.findViewById(R.id.user_message);

    ImageView drinkImage = (ImageView) v.findViewById(R.id.drink_order_image);
    drinkImage.setImageResource(drink.getImageID());

    ImageButton orderButton = (ImageButton) v.findViewById(R.id.order_drink_button);
    orderButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog = ProgressDialog.show(getActivity(), "", getString(R.string.please_wait), true, true);
            Bundle params = new Bundle();
            params.putString("beverage", drink.getURL());
            if (userMessage.getText() != null && userMessage.getText().length() > 0) {
                params.putString("message", userMessage.getText().toString());
            }
            ((SocialCafeApplication) getActivity().getApplication()).asyncRunner.request("me/social-cafe:order",
                    params, "POST", new OrderDrinkPostListener(), ORDER_STATE);

        }
    });

    ImageButton tagFriendButton = (ImageButton) v.findViewById(R.id.tag_friends);
    tagFriendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(getActivity()).setMessage(R.string.tag_friends_not_supported)
                    .setPositiveButton(R.string.ok, null).show();
        }
    });

    ImageButton tagLocationButton = (ImageButton) v.findViewById(R.id.tag_location);
    tagLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(getActivity()).setMessage(R.string.tag_location_not_supported)
                    .setPositiveButton(R.string.ok, null).show();
        }
    });

    ImageButton addPhotoButton = (ImageButton) v.findViewById(R.id.add_photo);
    addPhotoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(getActivity()).setMessage(R.string.add_photo_not_supported)
                    .setPositiveButton(R.string.ok, null).show();
        }
    });

    return v;
}

From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java

public BaseViewHolder setImageBitmap(int viewId, Bitmap imgBitmap) {
    ImageView view = getView(viewId);
    view.setImageBitmap(imgBitmap);
    return this;
}

From source file:gov.in.bloomington.georeporter.fragments.SavedReportViewFragment.java

private void refreshViewData() {
    View v = getView();/*from w  ww  .  j  a va2  s. c  om*/
    TextView textView;

    textView = (TextView) v.findViewById(R.id.service_name);
    textView.setText(mServiceRequest.service.optString(Open311.SERVICE_NAME));

    ImageView media = (ImageView) v.findViewById(R.id.media);
    media.setImageBitmap(mServiceRequest.getMediaBitmap(100, 100, getActivity()));

    textView = (TextView) v.findViewById(R.id.address);
    if (mServiceRequest.service_request.has(Open311.ADDRESS)) {
        textView.setText(mServiceRequest.service_request.optString(Open311.ADDRESS));
    } else if (mServiceRequest.post_data.has(Open311.ADDRESS_STRING)) {
        textView.setText(mServiceRequest.post_data.optString(Open311.ADDRESS_STRING));
    }

    textView = (TextView) v.findViewById(R.id.description);
    if (mServiceRequest.service_request.has(Open311.DESCRIPTION)) {
        textView.setText(mServiceRequest.service_request.optString(Open311.DESCRIPTION));
    } else if (mServiceRequest.post_data.has(Open311.DESCRIPTION)) {
        textView.setText(mServiceRequest.post_data.optString(Open311.DESCRIPTION));
    }

    textView = (TextView) v.findViewById(R.id.status);
    if (mServiceRequest.service_request.has(ServiceRequest.STATUS)) {
        textView.setText(mServiceRequest.service_request.optString(ServiceRequest.STATUS));
    }
}

From source file:edu.rowan.app.carousel.CarouselFeature.java

public void loadImage() {
    carouselView = new RelativeLayout(context);
    imageView = new ImageView(context);
    Bitmap cachedImage = aq.getCachedImage(imageURL);
    if (cachedImage != null) {
        //         System.out.println("Image was cached!");
        imageView.setImageBitmap(cachedImage);
        carouselView.addView(imageView);
        setupView();//from   w  w w  . j  a v  a2s  .c  o m
        listener.doneLoading(this);
    } else {
        // Aquery download and cache image
        aq.id(imageView).image(imageURL, true, true, 0, 0, new BitmapAjaxCallback() {
            @Override
            // set imageview to loaded bitmap and tell listener we're done loading
            public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
                iv.setImageBitmap(bm);
                carouselView.addView(iv);
                setupView();
                listener.doneLoading(CarouselFeature.this);
            }
        });
    }
}

From source file:com.microsoft.assetmanagement.adapters.DisplayCarAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    CarListViewItem item = mData.get(position);
    ImageView imageView = null;

    byte[] picture = item.getPicture();
    imageView = new ImageView(mActivity);
    try {/* w  ww .ja  v a2 s .  c om*/

        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setImageBitmap(mResizer.getBitmapFrom(picture));
        ((ViewPager) container).addView(imageView, 0);
    } catch (Exception e) {
        Log.e("Asset", e.getMessage());
    }
    return imageView;
}

From source file:com.blogspot.codigogoogle.listloadingsamples.ImageLoaderListAdapter.java

public void loadBitmap(String imageUrl, ImageView imageView) {
    final Bitmap bitmap = getBitmapFromMemCache(imageUrl);
    if (bitmap != null) {
        imageView.setImageBitmap(bitmap);
    } else {/*from  w w  w  .ja v  a2s.  c om*/
        if (cancelPotentialWork(imageUrl, imageView)) {
            final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
            final AsyncDrawable asyncDrawable = new AsyncDrawable(context.getResources(), mPlaceHolderBitmap,
                    task);
            imageView.setImageDrawable(asyncDrawable);
            task.execute(imageUrl);
        }
    }
}

From source file:com.microsoft.projectoxford.visionsample.AnalyzeInDomainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("AnalyzeInDomainActivity", "onActivityResult");
    switch (requestCode) {
    case REQUEST_SELECT_IMAGE:
        if (resultCode == RESULT_OK) {
            // If image is selected successfully, set the image URI and bitmap.
            mImageUri = data.getData();//from   w w  w  .ja va 2s . c o  m

            mBitmap = ImageHelper.loadSizeLimitedBitmapFromUri(mImageUri, getContentResolver());
            if (mBitmap != null) {
                // Show the image on screen.
                ImageView imageView = (ImageView) findViewById(R.id.selectedImage);
                imageView.setImageBitmap(mBitmap);

                // Add detection log.
                Log.d("AnalyzeInDomainActivity", "Image: " + mImageUri + " resized to " + mBitmap.getWidth()
                        + "x" + mBitmap.getHeight());

                doAnalyze();
            }
        }
        break;
    default:
        break;
    }
}

From source file:com.mappn.gfan.ui.SplashActivity.java

private void setSplashBitmap(Bitmap bmp) {

    // ????Splash?
    Bitmap scaledBitmap = ImageUtils.sacleBitmap(getApplicationContext(), bmp);
    ImageView v = ((ImageView) findViewById(R.id.iv_splashBg));
    if (scaledBitmap == null) {
        v.setImageBitmap(bmp);
    } else {//  w w w.  j a v a 2 s.  c om
        v.setImageBitmap(scaledBitmap);
    }
}