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.cerema.cloud2.ui.fragment.ShareFileFragment.java

/**
 * {@inheritDoc}//from   w ww.j av  a2s .com
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateView");

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.share_file_layout, container, false);

    // Setup layout
    // Image
    ImageView icon = (ImageView) view.findViewById(R.id.shareFileIcon);
    icon.setImageResource(MimetypeIconUtil.getFileTypeIconId(mFile.getMimetype(), mFile.getFileName()));
    if (mFile.isImage()) {
        String remoteId = String.valueOf(mFile.getRemoteId());
        Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(remoteId);
        if (thumbnail != null) {
            icon.setImageBitmap(thumbnail);
        }
    }
    // Name
    TextView fileNameHeader = (TextView) view.findViewById(R.id.shareFileName);
    fileNameHeader.setText(getResources().getString(R.string.share_file, mFile.getFileName()));
    // Size
    TextView size = (TextView) view.findViewById(R.id.shareFileSize);
    if (mFile.isFolder()) {
        size.setVisibility(View.GONE);
    } else {
        size.setText(DisplayUtils.bytesToHumanReadable(mFile.getFileLength()));
    }

    //  Add User Button
    Button addUserGroupButton = (Button) view.findViewById(R.id.addUserButton);
    addUserGroupButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean shareWithUsersEnable = AccountUtils.hasSearchUsersSupport(mAccount);
            if (shareWithUsersEnable) {
                // Show Search Fragment
                mListener.showSearchUsersAndGroups();
            } else {
                String message = getString(R.string.share_sharee_unavailable);
                Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
            }
        }
    });

    // Set listener for user actions on switch for sharing/unsharing via link
    initShareViaLinkListener(view);

    // Set listener for user actions on expiration date
    initExpirationListener(view);

    // Set listener for user actions on password
    initPasswordListener(view);

    // Set listener for user actions on edit permission
    initEditPermissionListener(view);

    return view;
}

From source file:it.mb.whatshare.PairOutboundActivity.java

private void showPairingLayout() {
    View view = getLayoutInflater().inflate(R.layout.activity_qrcode, null);
    setContentView(view);/*from w w w .  j  av a 2s .c om*/
    String paired = getOutboundPaired();
    if (paired != null) {
        ((TextView) findViewById(R.id.qr_instructions))
                .setText(getString(R.string.new_outbound_instructions, paired));
    }
    inputCode = (EditText) findViewById(R.id.inputCode);

    inputCode.setFilters(new InputFilter[] { new InputFilter() {
        /*
         * (non- Javadoc )
         * 
         * @see android .text. InputFilter # filter( java .lang.
         * CharSequence , int, int, android .text. Spanned , int, int)
         */
        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            if (source instanceof SpannableStringBuilder) {
                SpannableStringBuilder sourceAsSpannableBuilder = (SpannableStringBuilder) source;
                for (int i = end - 1; i >= start; i--) {
                    char currentChar = source.charAt(i);
                    if (!Character.isLetterOrDigit(currentChar)) {
                        sourceAsSpannableBuilder.delete(i, i + 1);
                    }
                }
                return source;
            } else {
                StringBuilder filteredStringBuilder = new StringBuilder();
                for (int i = 0; i < end; i++) {
                    char currentChar = source.charAt(i);
                    if (Character.isLetterOrDigit(currentChar)) {
                        filteredStringBuilder.append(currentChar);
                    }
                }
                return filteredStringBuilder.toString();
            }
        }
    }, new InputFilter.LengthFilter(MAX_SHORTENED_URL_LENGTH) });

    inputCode.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                onSubmitPressed(null);
                return keepKeyboardVisible;
            }
            return false;
        }
    });

    final ImageView qrWrapper = (ImageView) findViewById(R.id.qr_code);
    qrWrapper.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        private boolean createdQRCode = false;

        @Override
        public void onGlobalLayout() {
            if (!createdQRCode) {
                try {
                    Bitmap qrCode = generateQRCode(generateRandomSeed(),
                            getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
                                    ? qrWrapper.getHeight()
                                    : qrWrapper.getWidth());
                    if (qrCode != null) {
                        qrWrapper.setImageBitmap(qrCode);
                    }
                    createdQRCode = true;
                } catch (WriterException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}

From source file:com.android.aft.AFCoreTools.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  .ja  v a2  s  .  co  m
public void download(String url, ImageView imageView, ImageDownloaderListener listener, Animation animation,
        int reqWidth, int reqHeight) {
    if (url != null) {
        resetPurgeTimer();
        Bitmap bitmap = getBitmapFromCache(url, reqWidth, reqHeight);

        if (bitmap == null) {
            forceDownload(url, imageView, reqWidth, reqHeight, listener, animation);
        } else {
            cancelPotentialDownload(url, imageView);
            // imageView.setBackgroundDrawable(null);
            imageView.setImageDrawable(null);
            // imageView.setScaleType(ScaleType.FIT_XY);
            imageView.setImageBitmap(bitmap);
            if (animation != null) {
                imageView.setAnimation(animation);
            }
            if (listener != null) {
                listener.onImageDownloaded(url, bitmap, imageView);
            }
        }
    }
}

From source file:com.abcs.sociax.gimgutil.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  ww . j av a  2s.c  o m*/
 * @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, String type) {

    if (SociaxUIUtils.getNetworkType(mContext) == ConnectivityManager.TYPE_MOBILE) {

        System.out.println("is download image setting " + SettingsActivity.isDownloadPic(mContext));

        if (!SettingsActivity.isDownloadPic(mContext)) {
            System.out.println("is download image setting " + SettingsActivity.isDownloadPic(mContext));
            return;
        }
    }

    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:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java

@SuppressLint("NewApi")
private static View createMessageDialogContentsView(Activity activity, MessageDescription messageDescription) {

    Context context = activity;/* w  ww.  jav a2s. c  o m*/

    final AlertDialog.Builder builder;

    // Workaround for dialog theme problems
    if (android.os.Build.VERSION.SDK_INT > 10) {
        builder = new AlertDialog.Builder(context);
        context = builder.getContext();
    } else {
        context = new ContextThemeWrapper(context, android.R.style.Theme_Dialog);
        builder = new AlertDialog.Builder(context);
    }

    builder.setTitle("Send feedback");

    final LayoutInflater inflater = LayoutInflater.from(context);
    final View dialogContentsView = inflater.inflate(R.layout.updater_dialog_message, null, false);
    final TextView textView = (TextView) dialogContentsView.findViewById(R.id.dialog_update_message_text);
    final ImageView imageView = (ImageView) dialogContentsView.findViewById(R.id.dialog_update_message_image);
    final ViewSwitcher switcher = (ViewSwitcher) dialogContentsView
            .findViewById(R.id.dialog_update_message_switcher);

    String messageText = null;
    String imageUrl = null;

    if (messageDescription != null) {
        messageText = messageDescription.get(MessageDescription.KEY_MESSAGE);
        imageUrl = messageDescription.get(MessageDescription.KEY_IMAGE_URL);
    }

    if (Utilities.isNullOrEmpty(messageText)) {
        textView.setVisibility(View.GONE);
    } else {
        textView.setText(messageText);
    }

    if (Utilities.isNullOrEmpty(imageUrl)) {
        switcher.setVisibility(View.GONE);
    } else {
        URI uri;
        try {
            uri = new URI(imageUrl);
        } catch (URISyntaxException e) {
            uri = null;
        }

        if (uri != null) {
            DownloadRequest request = new DownloadRequest();
            request.setUri(uri);
            request.setDownloadHandler(new DownloadHandler() {

                @Override
                public void onSuccess(byte[] result) {
                    // Load image from byte array
                    final Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length);
                    imageView.setImageBitmap(bitmap);

                    // Hide progress bar and display image
                    if (switcher != null) {
                        switcher.setDisplayedChild(1);
                    }
                }

                @Override
                public void onProgress(Integer percent) {

                }

                @Override
                public void onFail(Exception ex) {
                    Log.e("Message image couldn't be loaded", ex);
                }

                @Override
                public void onCancelled() {

                }
            });
            HttpClient client = Utilities.createClient("Turkcell Updater/1.0 ", false);
            try {
                request.executeAsync(client);
            } catch (Exception e) {
                Log.e("Message image couldn't be loaded", e);
            }

        } else {
            switcher.setVisibility(View.GONE);
        }

    }

    return dialogContentsView;
}

From source file:com.aware.ui.Plugins_Manager.java

private void drawUI() {
    //Clear previous states
    store_grid.removeAllViews();//ww  w . j a  va 2s .  c om

    //Build UI
    Cursor installed_plugins = getContentResolver().query(Aware_Plugins.CONTENT_URI, null, null, null,
            Aware_Plugins.PLUGIN_NAME + " ASC");
    if (installed_plugins != null && installed_plugins.moveToFirst()) {
        do {
            final String package_name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_PACKAGE_NAME));
            final String name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME));
            final String description = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_DESCRIPTION));
            final String developer = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_AUTHOR));
            final String version = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_VERSION));
            final int status = installed_plugins
                    .getInt(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_STATUS));

            final View pkg_view = inflater.inflate(R.layout.plugins_store_pkg_list_item, null, false);
            pkg_view.setTag(package_name); //each view has the package name as a tag for easier references

            try {
                ImageView pkg_icon = (ImageView) pkg_view.findViewById(R.id.pkg_icon);
                if (status != PLUGIN_NOT_INSTALLED) {
                    ApplicationInfo appInfo = getPackageManager().getApplicationInfo(package_name,
                            PackageManager.GET_META_DATA);
                    pkg_icon.setImageDrawable(appInfo.loadIcon(getPackageManager()));
                } else {
                    byte[] img = installed_plugins
                            .getBlob(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_ICON));
                    if (img != null)
                        pkg_icon.setImageBitmap(BitmapFactory.decodeByteArray(img, 0, img.length));
                }

                TextView pkg_title = (TextView) pkg_view.findViewById(R.id.pkg_title);
                pkg_title.setText(installed_plugins
                        .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME)));

                ImageView pkg_state = (ImageView) pkg_view.findViewById(R.id.pkg_state);

                switch (status) {
                case PLUGIN_DISABLED:
                    pkg_state.setVisibility(View.INVISIBLE);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Activate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.startPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_ACTIVE:
                    pkg_state.setImageResource(R.drawable.ic_pkg_active);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_UPDATED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_updated);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setNeutralButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, true);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_NOT_INSTALLED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_download);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                            builder.setPositiveButton("Install", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, false);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                }
                store_grid.addView(pkg_view);
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        } while (installed_plugins.moveToNext());
    }
    if (installed_plugins != null && !installed_plugins.isClosed())
        installed_plugins.close();
}

From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java

@Override
protected void onStart() {
    super.onStart();

    stopped = false;//from  ww w  . j  a  v a2 s .com

    mainMenuDelegate = new MainMenuDelegate(this);
    gridView = (GridView) findViewById(R.id.activity_topic_list_grid);
    gridView.setOnItemClickListener(clickListener);

    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("Topics");

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            TopicListActivity.this.dataService = dataService;

            try {
                thumbnailManager = dataService.getThumbnailManager();

                dao = dataService.getHelper().getTopicDao();
                if (topicId != null) {
                    topic = dao.queryForId(topicId);
                } else {
                    topic = dataService.getRootTopic();
                    topicId = topic.getId();
                }

                // DEBUG
                if (topic == null)
                    return;

                // header
                headerView = findViewById(R.id.header_topic_list);

                ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle());

                String desc = topic.getDescription();
                TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description);
                if (desc != null && desc.length() > 0) {
                    descView.setText(Html.fromHtml(desc));
                    descView.setVisibility(View.VISIBLE);
                } else {
                    descView.setVisibility(View.GONE);
                }

                // Find child count for this parent topic.
                boolean videoChildren = Topic.CHILD_KIND_VIDEO.equals(topic.getChild_kind());
                String[] idArg = { topic.getId() };
                String sql = videoChildren ? "select count() from topicvideo where topic_id=?"
                        : "select count() from topic where parentTopic_id=?";
                int count = (int) dao.queryRawValue(sql, idArg);
                String countFormat = getString(
                        videoChildren ? R.string.format_video_count : R.string.format_topic_count);

                // Set header count string.
                ((TextView) headerView.findViewById(R.id.header_video_list_count))
                        .setText(String.format(countFormat, count));

                final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail);
                if (thumb != null) {
                    new AsyncTask<Void, Void, Bitmap>() {
                        @Override
                        public Bitmap doInBackground(Void... arg) {
                            Bitmap bmp = thumbnailManager.getThumbnail(
                                    TopicListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD);
                            return bmp;
                        }

                        @Override
                        public void onPostExecute(Bitmap bmp) {
                            thumb.setImageBitmap(bmp);
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }

                // list
                if (topicCursor != null) {
                    topicCursor.close();
                }
                topicCursor = buildCursor(topicId);

                ListAdapter adapter = new TopicGridAdapter(topicCursor);
                gridView.setAdapter(adapter);

                // Request the topic and its children be updated from the api.
                List<Topic> children = dao.queryForEq("parentTopic_id", topic.getId());
                List<String> toUpdate = new ArrayList<String>();
                for (Topic child : children) {
                    toUpdate.add(child.getId());
                }
                toUpdate.add(topic.getId());
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }
    });

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_LIBRARY_UPDATE);
    filter.addAction(ACTION_BADGE_EARNED);
    filter.addAction(ACTION_TOAST);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
}

From source file:es.upv.riromu.arbre.main.MainActivity.java

public void showHistogram(View view) throws IOException {

    state[SHOW_HISTOGRAM] = true;//w  w  w .ja  v a  2s .c  om

    // TextView imc = (TextView) findViewById(R.id.textView);
    //  imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B]));
    RangeSeekBar<Integer> rangeSeekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
    rangeSeekBar.setVisibility(View.GONE);
    ImageButton histButton = (ImageButton) findViewById(R.id.button_histogram);
    histButton.setVisibility(View.GONE);
    ImageButton revertButton = (ImageButton) findViewById(R.id.button_revert);
    revertButton.setVisibility(View.VISIBLE);
    ImageView imagePalette = (ImageView) findViewById(R.id.palette);
    imagePalette.setVisibility(View.GONE);
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    imv.setImageBitmap(histogram);

}

From source file:com.openerp.MainActivity.java

public void setDrawerHeader() {
    mDrawerTitle = OEUser.current(mContext).getUsername();
    mDrawerSubtitle = OEUser.current(mContext).getHost();

    ResPartnerDB partner = new ResPartnerDB(mContext);
    OEDataRow partnerInfo = partner.select(OEUser.current(mContext).getPartner_id());
    if (partnerInfo != null) {
        mDrawerTitle = partnerInfo.getString("name");
        Log.d("mDrawerTitle-------------" + mDrawerTitle, "-----------");
    }/*ww w . ja v a 2  s  . c o  m*/

    View v = getLayoutInflater().inflate(R.layout.drawer_header, mDrawerListView, false);
    TextView mUserName, mUserURL;
    ImageView imgUserPic = (ImageView) v.findViewById(R.id.imgUserProfilePic);
    mUserName = (TextView) v.findViewById(R.id.txvUserProfileName);
    mUserURL = (TextView) v.findViewById(R.id.txvUserServerURL);
    mUserName.setText(mDrawerTitle);
    mUserURL.setText(mDrawerSubtitle);
    if (OEUser.current(mContext) != null && !OEUser.current(mContext).getAvatar().equals("false")) {
        Bitmap profPic = Base64Helper.getBitmapImage(this, OEUser.current(mContext).getAvatar());
        if (profPic != null)
            imgUserPic.setImageBitmap(profPic);
    }
    v.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            onSettingItemSelected(SettingKeys.PROFILE);
            mDrawerLayout.closeDrawers();
        }
    });
    mDrawerListView.addHeaderView(v, null, false);
}

From source file:com.velia_systems.menuphoto.connection.ImageDownloader.java

/**
 * Same as download but the image is always downloaded and the cache is not used.
 * Kept private at the moment as its interest is not clear.
 *//*from   ww w .ja v  a2s  .  c  o m*/
private void forceDownload(String url, ImageView imageView, Bitmap bitmap, ProgressBar progress) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        switch (mode) {
        case NO_ASYNC_TASK:
            bitmap = downloadBitmap(url);
            //                    Log.d("ImageDownloader", "Sizes: " + bitmap.getWidth() + "x" + bitmap.getHeight());
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();

            int destHeight = 100 * height / width;

            Bitmap bmp1 = Bitmap.createScaledBitmap(bitmap, 100, destHeight, false);
            bitmap.recycle();

            addBitmapToCache(url, bmp1);
            imageView.setImageBitmap(bmp1);
            progress.setVisibility(View.GONE);
            break;

        case NO_DOWNLOADED_DRAWABLE:
            imageView.setMinimumHeight(50);
            BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, progress);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView, progress);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(50);
            task.execute(url);
            break;
        }
    }
}