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.ytd.SubmitActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.submit);

    this.authorizer = new GlsAuthorizer.GlsAuthorizerFactory().getAuthorizer(this,
            GlsAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE);

    dbHelper = new DbHelper(this);
    dbHelper = dbHelper.open();/*from w  w w  .j  a va2s . c o m*/

    Intent intent = this.getIntent();
    this.videoUri = intent.getData();
    this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN);
    this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID);
    this.title = intent.getExtras().getString(DbHelper.DESCRIPTION);
    this.instructions = intent.getExtras().getString(DbHelper.INSTRUCTIONS);

    this.domainHeader = (TextView) this.findViewById(R.id.domainHeader);
    domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain));

    this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE);
    this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null);

    final Button submitButton = (Button) findViewById(R.id.submitButton);
    submitButton.setEnabled(false);

    submitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_LEGAL);
        }
    });

    Button cancelButton = (Button) findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    EditText titleEdit = (EditText) findViewById(R.id.submitTitle);
    titleEdit.setText(title);
    titleEdit.setEnabled(false);
    enableSubmitIfReady();

    EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription);
    descriptionEdit.setText(instructions);
    descriptionEdit.setEnabled(false);

    Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null);

    if (cursor.getCount() == 0) {
        Log.d(LOG_TAG, "not a valid video uri");
        Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show();
    } else {
        getVideoLocation();

        if (cursor.moveToFirst()) {

            long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID));
            this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN)));

            SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa");
            Configuration userConfig = new Configuration();
            Settings.System.getConfiguration(getContentResolver(), userConfig);
            Calendar cal = Calendar.getInstance(userConfig.locale);
            TimeZone tz = cal.getTimeZone();

            dateFormat.setTimeZone(tz);

            TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured);
            dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken));

            ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail);
            ContentResolver crThumb = getContentResolver();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 1;
            Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id,
                    MediaStore.Video.Thumbnails.MICRO_KIND, options);
            thumbnail.setImageBitmap(curThumb);
        }
    }
}

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

@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState.containsKey("cropping")) {
        state[CROP_IMAGE] = savedInstanceState.getBoolean("cropping");
    }/*from w ww.ja v a 2s .  c om*/
    if (savedInstanceState.containsKey("treated")) {
        state[TREAT_IMAGE] = savedInstanceState.getBoolean("treated");
    }

    if (savedInstanceState.containsKey("image_uri")) {
        image_uri = Uri.parse(savedInstanceState.getString("image_uri"));
    }

    if (savedInstanceState.getBoolean("image")) {
        String fileName = "temp_image.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            image = Util.decodeScaledBitmapFromFile(file.getPath(), MAX_SIZE, MAX_SIZE);
            //  image = BitmapFactory.decodeStream(imageStream);

        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        }
    }

    if (state[CROP_IMAGE]) {
        String fileName = "temp_cropped.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            croppedimage = BitmapFactory.decodeStream(imageStream);
            imageStream.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }
    }
    if (state[TREAT_IMAGE]) {
        String fileName = "temp_treated.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            ImageView imv = (ImageView) findViewById(R.id.image_intro);
            imv.setImageBitmap(BitmapFactory.decodeStream(imageStream));
            imageStream.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }
    }
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    colours = savedInstanceState.getIntArray("colours");
    if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE])
        imv.setImageBitmap(croppedimage);
    else {

        imv.setImageBitmap(image);
    }
    TextView imc = (TextView) findViewById(R.id.textView);
    imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B]));
}

From source file:com.likou.util.NImageLoader.java

/**
 * Sets a {@link android.graphics.Bitmap} to an
 * {@link android.widget.ImageView} using a fade-in animation. If there is a
 * {@link android.graphics.drawable.Drawable} already set on the ImageView
 * then use that as the image to fade from. Otherwise fade in from a
 * transparent Drawable./*  ww  w. j  av a2 s .  c o m*/
 */
//   @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
private static void setImageBitmap(final ImageView imageView, final Bitmap bitmap, Resources resources,
        boolean fadeIn) {

    //      // If we're fading in and on HC MR1+
    //      if (fadeIn && NetUtils.hasHoneycombMR1()) {
    //         // Use ViewPropertyAnimator to run a simple fade in + fade out
    //         // animation to update the
    //         // ImageView
    //         imageView
    //               .animate()
    //               .scaleY(0.95f)
    //               .scaleX(0.95f)
    //               .alpha(0f)
    //               .setDuration(
    //                     imageView.getDrawable() == null ? 0
    //                           : HALF_FADE_IN_TIME)
    //               .setListener(new AnimatorListenerAdapter() {
    //                  @Override
    //                  public void onAnimationEnd(Animator animation) {
    //                     imageView.setImageBitmap(bitmap);
    //                     imageView.animate().alpha(1f).scaleY(1f).scaleX(1f)
    //                           .setDuration(HALF_FADE_IN_TIME)
    //                           .setListener(null);
    //                  }
    //               });
    //      } else 
    if (fadeIn) {
        // Otherwise use a TransitionDrawable to fade in
        Drawable initialDrawable;
        if (imageView.getDrawable() != null) {
            initialDrawable = imageView.getDrawable();
        } else {
            initialDrawable = transparentDrawable;
        }
        BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap);
        // Use TransitionDrawable to fade in
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { initialDrawable, bitmapDrawable });
        imageView.setImageDrawable(td);
        td.startTransition(250);
    } else {
        // No fade in, just set bitmap directly
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.pongme.utils.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.
 * /*from   w  w w. j ava2 s  .  co m*/
 * @param url
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 * @param tempImage
 */
public void download(String url, ImageView imageView, BitmapDrawable image, String activityName) {
    resetPurgeTimer();

    Bitmap bitmap = getBitmapFromCache(url, imageView, image);
    // Utils.log("IMAGE "+image+","+image.getBitmap().getHeight() +
    // " imageView"+imageView.getHeight()+","+imageView.getMeasuredHeight());

    if (bitmap == null) {
        BitmapDownloaderTask task = forceDownload(url, imageView, image);
        if (task != null)
            taches.put(task, activityName);

    } else {
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.qr_scan));
    } else {/*from  www.  j  a  va  2 s.c o  m*/
        barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
    TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
    timeTextView.setText(formattedTime);

    TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
    View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            metaTextView.setText(metadataText);
            metaTextView.setVisibility(View.VISIBLE);
            metaTextViewLabel.setVisibility(View.VISIBLE);
        }
    }

    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    CharSequence displayContents = resultHandler.getDisplayContents();
    contentsTextView.setText(displayContents);
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL,
            true)) {
        SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
                historyManager, this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
        TextView button = (TextView) buttonView.getChildAt(x);
        if (x < buttonCount) {
            button.setVisibility(View.VISIBLE);
            button.setText(resultHandler.getButtonText(x));
            button.setOnClickListener(new ResultButtonListener(resultHandler, x));
        } else {
            button.setVisibility(View.GONE);
        }
    }

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        if (displayContents != null) {
            clipboard.setText(displayContents);
        }
    }
}

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

private void setParentTopic(Topic topic) {
    this.topic = topic;

    if (topic != null) {
        topicId = topic.getId();//from   w  ww  .j  av a  2  s.  c  o m

        // header
        ((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).toString());
            descView.setVisibility(View.VISIBLE);
            descView.setMovementMethod(new ScrollingMovementMethod());
        } else {
            descView.setVisibility(View.GONE);
        }

        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(VideoListActivity.this.topic.getThumb_id(),
                            Thumbnail.QUALITY_SD);
                    return bmp;
                }

                @Override
                public void onPostExecute(Bitmap bmp) {
                    thumb.setImageBitmap(bmp);
                }
            }.execute();
        }

        String countFormat;
        int param;
        if (isShowingDownloadedVideosOnly()) {
            countFormat = getString(R.string.format_downloaded_count);
            param = dataService.getOfflineVideoManager().getDownloadCountForTopic(dataService.getHelper(),
                    topicId, 1);
        } else {
            countFormat = getString(R.string.format_video_count);
            param = topic.getVideo_count();
        }
        ((TextView) headerView.findViewById(R.id.header_video_list_count))
                .setText(String.format(countFormat, param));

        listView.setAdapter(new VideoAdapter(this));
        resetListContents(topic.getId());
    }
}

From source file:semanticweb.hws14.movapp.activities.MovieDetail.java

private void setData(final MovieDet movie) {
    Thread picThread = new Thread(new Runnable() {
        public void run() {
            try {
                ImageView img = (ImageView) findViewById(R.id.imageViewMovie);
                URL url = new URL(movie.getPoster());
                HttpGet httpRequest;//  w  w w  .j a v  a2 s .c  o  m

                httpRequest = new HttpGet(url.toURI());

                HttpClient httpclient = new DefaultHttpClient();
                HttpResponse response = httpclient.execute(httpRequest);

                HttpEntity entity = response.getEntity();
                BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
                InputStream input = b_entity.getContent();

                Bitmap bitmap = BitmapFactory.decodeStream(input);

                img.setImageBitmap(bitmap);

            } catch (Exception ex) {
                Log.d("MovieDetail Picture Error ", ex.toString());
            }
        }
    });
    picThread.start();

    if (!"".equals(movie.getTitle())) {
        TextView movieTitle = (TextView) findViewById(R.id.tvMovieTitle);
        movieTitle.setText(movie.getTitle());
        movieTitle.setVisibility(View.VISIBLE);
    }

    if (!"".equals(movie.getPlot())) {
        TextView moviePlot = (TextView) findViewById(R.id.tvPlot);
        moviePlot.setText(movie.getPlot());
        moviePlot.setVisibility(View.VISIBLE);
    }

    TextView ageRestriction = (TextView) findViewById(R.id.tvAgeRestriction);
    TextView arHc = (TextView) findViewById(R.id.tvAgeRestrictionHC);
    String aR = String.valueOf(movie.getRated());

    //Decode the ageRestriction
    if (!aR.equals("")) {
        ageRestriction.setVisibility(View.VISIBLE);
        arHc.setVisibility(View.VISIBLE);
        if (aR.equals("X")) {
            ageRestriction.setText("18+");
        } else if (aR.equals("R")) {
            ageRestriction.setText("16+");
        } else if (aR.equals("M")) {
            ageRestriction.setText("12+");
        } else if (aR.equals("G")) {
            ageRestriction.setText("6+");
        } else {
            ageRestriction.setVisibility(View.GONE);
            arHc.setVisibility(View.GONE);
        }
    }

    TextView ratingCount = (TextView) findViewById(R.id.tvMovieRatingCount);
    TextView ratingCountHc = (TextView) findViewById(R.id.tvMovieRatingCountHC);
    String ratingCountText = movie.getVoteCount();
    ratingCount.setText(ratingCountText);
    manageEmptyTextfields(ratingCountHc, ratingCount, ratingCountText, false);

    if (!"".equals(movie.getImdbRating())) {
        TextView movieRating = (TextView) findViewById(R.id.tvMovieRating);
        if (movie.getImdbRating().equals("0 No Rating")) {
            movieRating.setText("No Rating");
        } else if (movie.getImdbRating().equals("0 No Data")) {
            movieRating.setText("");
        } else {
            movieRating.setText(movie.getImdbRating() + "/10");
        }
        movieRating.setVisibility(View.VISIBLE);
        findViewById(R.id.tvMovieRatingHC).setVisibility(View.VISIBLE);
    }

    TextView metaScore = (TextView) findViewById(R.id.tvMetaScore);
    TextView metaScoreHc = (TextView) findViewById(R.id.tvMetaScoreHC);
    String metaSoreText = String.valueOf(movie.getMetaScore());
    metaScore.setText(metaSoreText + "/100");
    manageEmptyTextfields(metaScoreHc, metaScore, metaSoreText, false);

    TextView tvGenreHc = (TextView) findViewById(R.id.tvGenreHC);
    TextView genre = (TextView) findViewById(R.id.tvGenre);
    String genreText = String.valueOf(movie.createTvOutOfList(movie.getGenres()));
    genre.setText(genreText);
    manageEmptyTextfields(tvGenreHc, genre, genreText, true);

    TextView releaseYear = (TextView) findViewById(R.id.tvReleaseYear);
    TextView releaseYearHc = (TextView) findViewById(R.id.tvReleaseYearHC);
    String releaseYearText = String.valueOf(movie.getReleaseYear());
    releaseYear.setText(releaseYearText);
    manageEmptyTextfields(releaseYearHc, releaseYear, releaseYearText, true);

    TextView runtime = (TextView) findViewById(R.id.tvRuntime);
    TextView runTimeHc = (TextView) findViewById(R.id.tvRuntimeHC);
    String runtimeText = "";
    try {
        runtimeText = runtimeComputation(Float.parseFloat(movie.getRuntime()));
    } catch (Exception e) {
        runtimeText = movie.getRuntime();
    }
    runtime.setText(runtimeText);
    manageEmptyTextfields(runTimeHc, runtime, runtimeText, true);

    TextView budget = (TextView) findViewById(R.id.tvBudget);
    TextView budgetHc = (TextView) findViewById(R.id.tvBudgetHC);
    String budgetText = movie.getBudget();
    //Decode the budget
    if (budgetText.contains("E")) {
        BigDecimal myNumber = new BigDecimal(budgetText);
        long budgetLong = myNumber.longValue();
        NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US);
        budgetText = formatter.format(budgetLong);
        budgetText = String.valueOf(budgetText);
        budgetText = budgetComputation(budgetText);
        budget.setText(budgetText);
        manageEmptyTextfields(budgetHc, budget, budgetText, true);
    }

    TextView awards = (TextView) findViewById(R.id.tvAwards);
    TextView awardsHc = (TextView) findViewById(R.id.tvAwardsHC);
    String awardsText = movie.getAwards();
    awards.setText(awardsText);
    manageEmptyTextfields(awardsHc, awards, awardsText, true);

    TextView tvDirHc = (TextView) findViewById(R.id.tvDirectorsHC);
    TextView directors = (TextView) findViewById(R.id.tvDirectors);
    String directorText = String.valueOf(movie.createTvOutOfList(movie.getDirectors()));
    directors.setText(directorText);
    manageEmptyTextfields(tvDirHc, directors, directorText, true);

    TextView tvWriterHc = (TextView) findViewById(R.id.tvWritersHC);
    TextView writers = (TextView) findViewById(R.id.tvWriters);
    String writerText = String.valueOf(movie.createTvOutOfList(movie.getWriters()));
    writers.setText(writerText);
    manageEmptyTextfields(tvWriterHc, writers, writerText, true);

    TextView tvActorsHc = (TextView) findViewById(R.id.tvActorsHC);
    TextView actors = (TextView) findViewById(R.id.tvActors);
    String actorText = String.valueOf(movie.createTvOutOfList(movie.getActors()));
    actors.setText(actorText);
    manageEmptyTextfields(tvActorsHc, actors, actorText, true);
    colorIt(actors);

    if (movie.getActors().size() > 0) {
        btnActorList.setVisibility(View.VISIBLE);
    }

    btnRandomRelatedMovies.setVisibility(View.VISIBLE);
    btnRelatedMovies.setVisibility(View.VISIBLE);

    TextView tvRolesHc = (TextView) findViewById(R.id.tvRolesHC);
    TextView roles = (TextView) findViewById(R.id.tvRoles);
    ArrayList<String> roleList = movie.getRoles();

    if (roleList.size() > 0) {
        roles.setVisibility(View.VISIBLE);
        tvRolesHc.setVisibility(View.VISIBLE);
        roles.setText(String.valueOf(movie.createTvOutOfList(roleList)));
    }

    TextView wikiAbstract = (TextView) findViewById(R.id.tvWikiAbstract);
    wikiAbstract.setText(movie.getWikiAbstract());
    if (!"".equals(movie.getImdbId())) {
        btnImdbPage.setVisibility(View.VISIBLE);
    }
    if (!"".equals(movie.getWikiAbstract())) {
        btnSpoiler.setVisibility(View.VISIBLE);
    }
    try {
        picThread.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    setProgressBarIndeterminateVisibility(false);
}

From source file:com.moki.touch.fragments.views.WebContent.java

private boolean setLogo() {
    final ImageView logoView = (ImageView) rootView.findViewById(R.id.logo);
    boolean shouldListenForLogo = false;
    if (SettingsUtil.getUploadLogo() != null && !SettingsUtil.getUploadLogo().isEmpty()) {
        final Bitmap bitmapLogo = getLogoBitmap();
        if (bitmapLogo == null) {
            shouldListenForLogo = true;/*from  w w  w.j  av  a  2s. c  o  m*/
        } else {
            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    return null;
                }

                @Override
                protected void onPostExecute(Void aVoid) {
                    super.onPostExecute(aVoid);
                    logoView.setImageBitmap(bitmapLogo);
                }
            }.execute();
        }
    } else {
        logoView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.mt_web_logo));
    }
    return shouldListenForLogo;
}

From source file:com.example.propertylist.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_project_sales_list);

    ImageView mImageView = new ImageView(this);

    DisplayMetrics metrics;//from  w w w  . j  av a 2  s .  com
    int mScreenWidth;
    int mScreenHeight;

    api_key = getResources().getString(R.string.key);

    metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mScreenWidth = metrics.widthPixels;
    mScreenHeight = metrics.heightPixels;

    if (mScreenWidth >= minScreenwidth) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (mScreenWidth >= minLandScreenwidth) {
                largeScreen = true;

            }
        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            if (mScreenHeight > minLandScreenwidth) {
                largeScreen = true;
            }
        }
    } else {
        largeScreen = false;
    }

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(getResources(), R.id.daft_logo_image, options);

    mImageView.setImageBitmap( // ensure image size is 100 x 100.
            decodeSampledBitmapFromResource(getResources(), R.id.daft_logo_image, 100, 100));

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            hideProgressDialog();
            startListActivity();
        }
    };
}

From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java

public void refreshActionBarColumns() {

    int currentPosition = pager.getCurrentItem();

    layoutBackgroundColumnsBar.removeAllViews();

    int padding = (int) getResources().getDimension(R.dimen.default_padding);
    //int sizeButton = (int) getResources().getDimension(R.dimen.actionbar_columns_height);

    for (int i = 1; i < fragmentAdapter.getFragmentList().size(); i++) {

        ImageView view = new ImageView(this);
        view.setPadding(padding, padding, padding, padding);
        view.setImageBitmap(ColumnsUtils.getButtonWithTitle(this, fragmentAdapter.getFragmentList().get(i),
                true, currentPosition == i ? Color.GREEN : Color.BLACK));
        view.setTag(i);/* w  w w . j a va2s. co  m*/
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutMainOptionsColumns.getVisibility() != View.VISIBLE) {
                    showActionBarIndicatorAndMovePager((Integer) view.getTag());
                }
            }
        });
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                int pos = (Integer) view.getTag();
                int[] loc = new int[2];
                view.getLocationOnScreen(loc);
                showOptionsColumns(loc[0], pos, true);
                return false;
            }
        });
        layoutBackgroundColumnsBar.addView(view);
    }
}