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:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java

private void addFirstScreenPresents() {
    // First 4 slots have no nothing.
    for (int i = 0; i < Math.min(4, SLOTS_PER_SCREEN); i++) {
        View view = new View(this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mSlotWidth, mScreenHeight);
        mObstacleLayout.addView(view, lp);
    }/*from  w  ww  .ja v a 2s . c o  m*/

    // Generate a SIN like pattern;
    float center = (float) ((mScreenHeight - mGiftBoxes[0].getHeight()) / 2);
    float presentHeight = (float) mGiftBoxes[0].getHeight();
    float[] heights = new float[] { center, center - presentHeight, center - (1.5f * presentHeight),
            center - presentHeight, center, center + presentHeight, center + (1.5f * presentHeight),
            center + presentHeight, center };
    // Add presents to the end
    if (SLOTS_PER_SCREEN > 4) {
        for (int i = 0; i < (SLOTS_PER_SCREEN - 4); i++) {
            // Which one?
            Bitmap bmp = mGiftBoxes[mRandom.nextInt(mGiftBoxes.length)];
            ImageView iv = new ImageView(this);
            iv.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            iv.setImageBitmap(bmp);

            // Position the present
            float left = (mSlotWidth - bmp.getWidth()) / 2;
            float top = heights[(i % heights.length)];

            FrameLayout frame = new FrameLayout(this);
            LayoutParams flp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            frame.addView(iv, flp);
            iv.setTranslationX(left);
            iv.setTranslationY(top);

            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mSlotWidth,
                    LinearLayout.LayoutParams.MATCH_PARENT);
            mObstacleLayout.addView(frame, lp);
        }
    }

    // Account for rounding errors in mSlotWidth
    int extra = (mScreenWidth - (SLOTS_PER_SCREEN * mSlotWidth));
    if (extra > 0) {
        // Add filler to ensure sync with background/foreground scrolls!
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(extra,
                LinearLayout.LayoutParams.MATCH_PARENT);
        View view = new View(this);
        mObstacleLayout.addView(view, lp);
    }

    mLastObstacle = 0;
}

From source file:com.easemob.chatui.adapter.MessageAdapter.java

/**
 * load image into image view/* www .ja  v  a2  s  .co m*/
 *
 * @param thumbernailPath
 * @param iv
 * @param
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath,
        String remoteDir, final EMMessage message) {
    // String imagename =
    // localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
    // localFullSizePath.length());
    // final String remote = remoteDir != null ? remoteDir+imagename :
    // imagename;
    final String remote = remoteDir;
    EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);
        iv.setClickable(true);
        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                EMLog.d(TAG, "image view on click");
                Intent intent = new Intent(activity, ShowBigImage.class);
                File file = new File(localFullSizePath);
                if (file.exists()) {
                    Uri uri = Uri.fromFile(file);
                    intent.putExtra("uri", uri);
                    EMLog.d(TAG, "here need to check why download everytime");
                } else {
                    // The local full size pic does not exist yet.
                    // ShowBigImage needs to download it from the server
                    // first
                    // intent.putExtra("", message.get);
                    ImageMessageBody body = (ImageMessageBody) message.getBody();
                    intent.putExtra("secret", body.getSecret());
                    intent.putExtra("remotepath", remote);
                }
                if (message != null && message.direct == Direct.RECEIVE && !message.isAcked
                        && message.getChatType() != ChatType.GroupChat
                        && message.getChatType() != ChatType.ChatRoom) {
                    try {
                        EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
                        message.isAcked = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                activity.startActivity(intent);
            }
        });
        return true;
    } else {

        new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv,
                activity, message);
        return true;
    }

}

From source file:com.ibuildapp.romanblack.CouponPlugin.CouponAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    try {//ErrorLogging 

        View row;//from w w w.  j a v a2s .co  m

        if (null == convertView) {
        } else {
            row = convertView;
        }

        if (items.get(position).hasImage()) {
            row = layoutInflater.inflate(R.layout.romanblack_coupon_feed_item_image, null);
            ImageView imageView = (ImageView) row.findViewById(R.id.romanblack_coupon_image);
            imageView.setImageResource(R.drawable.romanblack_coupon_no_image);
        } else {
            row = layoutInflater.inflate(R.layout.romanblack_coupon_feed_item, null);
        }

        // change arrow color depending of background color
        ImageView arrow = (ImageView) row.findViewById(R.id.romanblack_coupon_feed_item_arrow);
        if (Utils.isChemeDark(Statics.color1)) {
            arrow.setImageResource(R.drawable.romanblack_coupon_arrow_light);
        } else {
            arrow.setImageResource(R.drawable.romanblack_coupon_arrow);
        }

        TextView title = (TextView) row.findViewById(R.id.romanblack_coupon_title);
        title.setTextColor(Statics.color3);

        TextView description = (TextView) row.findViewById(R.id.romanblack_coupon_description);
        description.setTextColor(Statics.color4);

        title.setText(items.get(position).getTitle());
        description.setText(items.get(position).getAnounce(75));

        if (items.get(position).hasImage()) {
            ImageView imageView = (ImageView) row.findViewById(R.id.romanblack_coupon_image);
            if (imageView != null) {
                if (items.get(position).getImagePath().length() > 0) {
                    Bitmap bitmap = null;
                    Integer key = new Integer(position);
                    if (bitmaps.containsValue(key)) {
                        bitmap = bitmaps.get(key);
                    } else {
                        try {
                            bitmap = decodeImageFile(items.get(position).getImagePath());
                            bitmaps.put(key, bitmap);
                        } catch (Exception e) {
                            Log.w("NEWS ADAPTER", e);
                        }
                    }

                    if (bitmap != null) {
                        imageView.setImageBitmap(bitmap);
                    }
                }
            }
        }
        return row;

    } catch (Exception e) {
        return null;
    }
}

From source file:com.easemob.chatuidemo.adapter.MessageAdapter.java

public void setAvater(Context context, EMMessage message, final ImageView imge) {
    String headUrl = null;/* w w w . ja va2 s .  c o  m*/
    UserDao userDao = new UserDao(context);

    ImageDowloader dowloader = new ImageDowloader(context);
    if (message.direct == Direct.SEND) {
        headUrl = Model.PitureLoad + userDao.find(Preferences.getUserName()).getHeadImage();
        //?
    } else {
        if (userDao.find(message.getFrom()) != null) {
            headUrl = Model.PitureLoad + userDao.find(message.getFrom()).getHeadImage();
        }
    }
    if (headUrl != null) {
        dowloader.downloadImage(45, 45, headUrl, new ImageDowloader.OnImageDownloadListener() {

            @Override
            public void onImageDownload(String url, Bitmap bitmap) {
                if (bitmap != null) {
                    imge.setImageBitmap(bitmap);
                }
            }
        });
    }
}

From source file:com.akop.bach.fragment.xboxlive.AchievementsFragment.java

private void loadGameDetails() {
    View view = getView();//from   w  w  w. ja v a  2  s  .com
    if (view == null)
        return;

    if (mTitleId < 0) {
        view.findViewById(R.id.unselected).setVisibility(View.VISIBLE);
        view.findViewById(R.id.achievement_contents).setVisibility(View.GONE);
    } else {
        view.findViewById(R.id.unselected).setVisibility(View.GONE);
        view.findViewById(R.id.achievement_contents).setVisibility(View.VISIBLE);
    }

    if (!mShowGameTotals)
        return;

    Context context = getActivity();
    ContentResolver cr = context.getContentResolver();
    Cursor c = cr.query(Games.CONTENT_URI, GamesFragment.PROJ, Games._ID + "=" + mTitleId, null, null);

    if (c != null) {
        try {
            if (c.moveToFirst()) {
                TextView tv;
                ImageView iv;

                XboxLiveGameListItem gameListItem = (XboxLiveGameListItem) view.findViewById(R.id.gameListItem);
                gameListItem.mBeaconSet = c.getInt(GamesFragment.GAME_BEACON_SET) != 0;
                gameListItem.mItemId = mTitleId;

                if ((tv = (TextView) view.findViewById(R.id.game_title)) != null)
                    tv.setText(c.getString(GamesFragment.GAME_TITLE));

                if ((tv = (TextView) view.findViewById(R.id.game_last_played)) != null)
                    tv.setText(Games.getLastPlayedText(context, c.getLong(GamesFragment.GAME_LAST_PLAYED)));

                if ((tv = (TextView) view.findViewById(R.id.game_achievements_unlocked)) != null)
                    tv.setText(Games.getAchievementTotalText(context, c.getInt(GamesFragment.GAME_ACH_EARNED),
                            c.getInt(GamesFragment.GAME_ACH_TOTAL)));

                if ((tv = (TextView) view.findViewById(R.id.game_gp_earned)) != null)
                    tv.setText(Games.getGamerscoreTotalText(context, c.getInt(GamesFragment.GAME_GP_EARNED),
                            c.getInt(GamesFragment.GAME_GP_TOTAL)));

                iv = (ImageView) view.findViewById(R.id.game_beacon);
                iv.setImageResource(c.getInt(GamesFragment.GAME_BEACON_SET) != 0 ? R.drawable.beacon_on
                        : R.drawable.beacon_off);

                ImageCache ic = ImageCache.getInstance();
                String iconUrl = c.getString(GamesFragment.GAME_ICON_URL);
                Bitmap bmp;

                if ((bmp = ic.getCachedBitmap(iconUrl)) != null) {
                    iv = (ImageView) view.findViewById(R.id.game_icon);
                    iv.setImageBitmap(bmp);
                } else {
                    if (iconUrl != null) {
                        ic.requestImage(iconUrl, new OnImageReadyListener() {
                            @Override
                            public void onImageReady(long id, Object param, Bitmap bmp) {
                                mHandler.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        loadGameDetails();
                                    }
                                });
                            }
                        }, 0, null, true, null);
                    }
                }
            }
        } finally {
            c.close();
        }
    }
}

From source file:com.com.easemob.chatuidemo.adapter.MessageAdapter.java

/**
 * load image into image view/*  w  ww . java2 s .  c o  m*/
 *
 * @param thumbernailPath
 * @param iv
 * @param
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath,
        String remoteDir, final EMMessage message) {
    // String imagename =
    // localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
    // localFullSizePath.length());
    // final String remote = remoteDir != null ? remoteDir+imagename :
    // imagename;
    final String remote = remoteDir;
    EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);
        iv.setClickable(true);
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EMLog.d(TAG, "image view on click");
                Intent intent = new Intent(activity, ShowBigImage.class);
                File file = new File(localFullSizePath);
                if (file.exists()) {
                    Uri uri = Uri.fromFile(file);
                    intent.putExtra("uri", uri);
                    EMLog.d(TAG, "here need to check why download everytime");
                } else {
                    // The local full size pic does not exist yet.
                    // ShowBigImage needs to download it from the server
                    // first
                    // intent.putExtra("", message.get);
                    ImageMessageBody body = (ImageMessageBody) message.getBody();
                    intent.putExtra("secret", body.getSecret());
                    intent.putExtra("remotepath", remote);
                }
                if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
                        && message.getChatType() != ChatType.GroupChat
                        && message.getChatType() != ChatType.ChatRoom) {
                    try {
                        EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
                        message.isAcked = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                activity.startActivity(intent);
            }
        });
        return true;
    } else {

        new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv,
                activity, message);
        return true;
    }

}

From source file:net.idlesoft.android.apps.github.activities.SingleActivityItem.java

private void loadActivityItemBox() {
    final TextView date = (TextView) findViewById(R.id.tv_activity_item_date);
    final ImageView gravatar = (ImageView) findViewById(R.id.iv_activity_item_gravatar);
    final ImageView icon = (ImageView) findViewById(R.id.iv_activity_item_icon);
    final TextView title_tv = (TextView) findViewById(R.id.tv_activity_item_title);

    try {/*  w  w  w .j  a  v a2  s .  co m*/
        final JSONObject entry = mJson;
        final JSONObject payload = entry.getJSONObject("payload");
        String end;
        final SimpleDateFormat dateFormat = new SimpleDateFormat(Hubroid.GITHUB_ISSUES_TIME_FORMAT);
        final Date item_time = dateFormat.parse(entry.getString("created_at"));
        final Date current_time = dateFormat.parse(dateFormat.format(new Date()));
        final long ms = current_time.getTime() - item_time.getTime();
        final long sec = ms / 1000;
        final long min = sec / 60;
        final long hour = min / 60;
        final long day = hour / 24;
        if (day > 0) {
            if (day == 1) {
                end = " day ago";
            } else {
                end = " days ago";
            }
            date.setText(day + end);
        } else if (hour > 0) {
            if (hour == 1) {
                end = " hour ago";
            } else {
                end = " hours ago";
            }
            date.setText(hour + end);
        } else if (min > 0) {
            if (min == 1) {
                end = " minute ago";
            } else {
                end = " minutes ago";
            }
            date.setText(min + end);
        } else {
            if (sec == 1) {
                end = " second ago";
            } else {
                end = " seconds ago";
            }
            date.setText(sec + end);
        }

        final String actor = entry.getString("actor");
        final String eventType = entry.getString("type");
        String title = actor + " did something...";
        gravatar.setImageBitmap(GravatarCache.getDipGravatar(GravatarCache.getGravatarID(actor), 30.0f,
                getResources().getDisplayMetrics().density));

        if (eventType.contains("PushEvent")) {
            icon.setImageResource(R.drawable.push);
            title = actor + " pushed to " + payload.getString("ref").split("/")[2] + " at "
                    + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("WatchEvent")) {
            final String action = payload.getString("action");
            if (action.equalsIgnoreCase("started")) {
                icon.setImageResource(R.drawable.watch_started);
            } else {
                icon.setImageResource(R.drawable.watch_stopped);
            }
            title = actor + " " + action + " watching " + entry.getJSONObject("repository").getString("owner")
                    + "/" + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("GistEvent")) {
            final String action = payload.getString("action");
            icon.setImageResource(R.drawable.gist);
            title = actor + " " + action + "d " + payload.getString("name");
        } else if (eventType.contains("ForkEvent")) {
            icon.setImageResource(R.drawable.fork);
            title = actor + " forked " + entry.getJSONObject("repository").getString("name") + "/"
                    + entry.getJSONObject("repository").getString("owner");
        } else if (eventType.contains("CommitCommentEvent")) {
            icon.setImageResource(R.drawable.comment);
            title = actor + " commented on " + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("ForkApplyEvent")) {
            icon.setImageResource(R.drawable.merge);
            title = actor + " applied fork commits to " + entry.getJSONObject("repository").getString("owner")
                    + "/" + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("FollowEvent")) {
            icon.setImageResource(R.drawable.follow);
            title = actor + " started following " + payload.getJSONObject("target").getString("login");
        } else if (eventType.contains("CreateEvent")) {
            icon.setImageResource(R.drawable.create);
            if (payload.getString("object").contains("repository")) {
                title = actor + " created repository " + payload.getString("name");
            } else if (payload.getString("object").contains("branch")) {
                title = actor + " created branch " + payload.getString("object_name") + " at "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            } else if (payload.getString("object").contains("tag")) {
                title = actor + " created tag " + payload.getString("object_name") + " at "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            }
        } else if (eventType.contains("IssuesEvent")) {
            if (payload.getString("action").equalsIgnoreCase("opened")) {
                icon.setImageResource(R.drawable.issues_open);
            } else {
                icon.setImageResource(R.drawable.issues_closed);
            }
            title = actor + " " + payload.getString("action") + " issue " + payload.getInt("number") + " on "
                    + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("DeleteEvent")) {
            icon.setImageResource(R.drawable.delete);
            if (payload.getString("object").contains("repository")) {
                title = actor + " deleted repository " + payload.getString("name");
            } else if (payload.getString("object").contains("branch")) {
                title = actor + " deleted branch " + payload.getString("object_name") + " at "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            } else if (payload.getString("object").contains("tag")) {
                title = actor + " deleted tag " + payload.getString("object_name") + " at "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            }
        } else if (eventType.contains("WikiEvent")) {
            icon.setImageResource(R.drawable.wiki);
            title = actor + " " + payload.getString("action") + " a page in the "
                    + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name") + " wiki";
        } else if (eventType.contains("DownloadEvent")) {
            icon.setImageResource(R.drawable.download);
            title = actor + " uploaded a file to " + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("PublicEvent")) {
            icon.setImageResource(R.drawable.opensource);
            title = actor + " open sourced " + entry.getJSONObject("repository").getString("name");
        } else if (eventType.contains("PullRequestEvent")) {
            final int number = (payload.get("pull_request") instanceof JSONObject)
                    ? payload.getJSONObject("pull_request").getInt("number")
                    : payload.getInt("number");
            if (payload.getString("action").equalsIgnoreCase("opened")) {
                icon.setImageResource(R.drawable.issues_open);
                title = actor + " opened pull request " + number + " on "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            } else if (payload.getString("action").equalsIgnoreCase("closed")) {
                icon.setImageResource(R.drawable.issues_closed);
                title = actor + " closed pull request " + number + " on "
                        + entry.getJSONObject("repository").getString("owner") + "/"
                        + entry.getJSONObject("repository").getString("name");
            }
        } else if (eventType.contains("MemberEvent")) {
            icon.setImageResource(R.drawable.follow);
            title = actor + " added " + payload.getString("member") + " to "
                    + entry.getJSONObject("repository").getString("owner") + "/"
                    + entry.getJSONObject("repository").getString("name");
        }

        title_tv.setText(title);

        gravatar.setOnClickListener(new OnClickListener() {
            public void onClick(final View v) {
                final Intent i = new Intent(SingleActivityItem.this, Profile.class);
                i.putExtra("username", actor);
                startActivity(i);
            }
        });

    } catch (final JSONException e) {
        e.printStackTrace();
    } catch (final ParseException e) {
        e.printStackTrace();
    }
}

From source file:com.listviewaddheader.cache.ImageDownloader.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./*from  w  ww . ja  v  a  2 s.  co  m*/
 * 
 * @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(String url, ImageView imageView, String cookie, int defaultPicType) {

    // Logger.i(TAG, "download url:" + url);

    // 
    resetPurgeTimer();

    // Logger.d(TAG, ":" + System.currentTimeMillis());
    Bitmap bitmap = getBitmapFromCache(url);// 
    // Logger.d(TAG, ":" + System.currentTimeMillis());

    if (bitmap == null) {
        // Logger.d(TAG, "get image from SD card:" +
        // System.currentTimeMillis());
        bitmap = loadFromSDCache(url);// SD+
        // Logger.d(TAG, "SD:" + System.currentTimeMillis());
    }

    // else{
    // Logger.d(TAG, "get image from cache:" + System.currentTimeMillis());
    // }
    if (bitmap == null) {
        // Logger.d(TAG, "get image from network:" +
        // System.currentTimeMillis());
        forceDownload(url, imageView, cookie, defaultPicType);// 
        // Logger.d(TAG, ":" + System.currentTimeMillis());
    } else {
        // Logger.d(TAG,
        // "got image from SD card, cancel potential download:" +
        // System.currentTimeMillis());
        if (imageView != null) {
            cancelPotentialDownload(url, imageView);
        }

        // ,
        // if (imageView instanceof MulitPointTouchImageView) {
        // ((MulitPointTouchImageView) imageView).setImageBitmap(bitmap);
        // } else {
        // imageView.setImageBitmap(bitmap);// 
        // }
        if (mScaleType != null && imageView != null) {
            imageView.setScaleType(mScaleType);
        }
        if (imageView != null) {
            imageView.setImageBitmap(bitmap);// 
        }

        // if (isImageViewCache) {
        // mImageViewCache.put(url, imageView);
        // }

    }

    // Log
    // Collection<Bitmap> hardValues = mHardBitmapCache.values();
    // int hardTotalSize = 0;
    // for (Bitmap hartbitmap : hardValues) {
    //
    // hardTotalSize += (hartbitmap.getHeight() * hartbitmap.getWidth() * 4)
    // / 1024;
    // Logger.d(TAG, "hartbitmap Height:" + hartbitmap.getHeight()
    // + "hartbitmap Width:" + hartbitmap.getWidth());
    // }

    // Collection<SoftReference<Bitmap>> softValues = mSoftBitmapCache
    // .values();
    // int softTotalSize = 0;
    // for (SoftReference<Bitmap> softbitmap : softValues) {
    //
    // if (softbitmap != null && softbitmap.get() != null) {
    // softTotalSize += (softbitmap.get().getHeight()
    // * softbitmap.get().getWidth() * 4) / 1024;
    // Logger.d(TAG, "softbitmap Height:"
    // + softbitmap.get().getHeight() + "softbitmap Width:"
    // + softbitmap.get().getWidth());
    // }
    //
    // }
    // Logger.d(TAG, "==>download() bitmap :" + hardTotalSize
    // + "KB :" + softTotalSize + "KB");
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

/**
 *  Successful Response Handler for getting the Affillitations and the provider image.
 *  This method will give the successful response of the Provider's affilitations.
 *  This response is for the Affilations Purpose.The image can be placed one below the other
 *
 *//*from   w  w w  . j  a v  a  2  s.  c o m*/
private void getProviderImageArrayResponse(JsonObject providerdetObj) {
    JsonArray ProviderImageArray = providerdetObj.get("provider_groups").getAsJsonArray();
    if (ProviderImageArray.size() != 0) {
        providerImageCollectionHolder.removeAllViews();
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                100);
        params.setMargins(5, 10, 5, 10);
        for (int i = 0; i < ProviderImageArray.size(); i++) {
            try {
                if (!ProviderImageArray.get(i).getAsJsonObject().get("logo").isJsonNull()) {
                    final ImageView imageView = new ImageView(MDLiveProviderDetails.this);
                    //imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                    imageView.setLayoutParams(params);
                    ImageRequest request = new ImageRequest(
                            ProviderImageArray.get(i).getAsJsonObject().get("logo").getAsString(),
                            new Response.Listener<Bitmap>() {
                                @Override
                                public void onResponse(Bitmap bitmap) {
                                    imageView.setImageBitmap(bitmap);
                                }
                            }, 0, 0, null, new Response.ErrorListener() {
                                public void onErrorResponse(VolleyError error) {
                                }
                            });
                    ApplicationController.getInstance().getRequestQueue(this).add(request);
                    imageView.setTag(ProviderImageArray.get(i).getAsJsonObject().get("url").getAsString());
                    imageView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(MDLiveProviderDetails.this,
                                    MDLiveProviderGroupDetailsAffiliations.class);
                            intent.putExtra("affurl",
                                    (imageView.getTag() != null) ? imageView.getTag().toString() : "");
                            startActivity(intent);
                            MdliveUtils.startActivityAnimation(MDLiveProviderDetails.this);
                        }
                    });
                    providerImageCollectionHolder.addView(imageView);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } else {
        if (!isCignaCoachUser)
            findViewById(R.id.providerGroupAffiliation).setVisibility(View.GONE);
    }
}

From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java

private void addFinalImages() {
    addNextImages(1);/*from   www .j a v  a 2 s  .  co m*/
    addNextImages(1);

    // Add presents
    addFinalPresentRun();

    // Add final screen.  This is a two screen background.
    ImageView iv = new ImageView(this);
    iv.setTag(true);
    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.bg_finish);
    if ((mScaleX != 1.0f) || (mScaleY != 1.0f)) {
        Bitmap tmp = Bitmap.createScaledBitmap(bmp, mScreenWidth * 2, mScreenHeight, false);
        if (bmp != tmp) {
            bmp.recycle();
        }
        bmp = tmp;
    }
    iv.setImageBitmap(bmp);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    mBackgroundLayout.addView(iv, lp);
    View view = new View(this);
    lp = new LinearLayout.LayoutParams(mScreenWidth * 2, 10);
    mForegroundLayout.addView(view, lp);
    addNextObstacleSpacer(2);
}