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.euphor.paperpad.activities.main.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    View rootView = inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    if (illustration == null)
        return rootView;

    /// construct the view
    final ImageView imag = (TouchImageView) rootView.findViewById(R.id.Image);

    String path = "";
    boolean isFile = true;
    if (!illustration.getFullPath().isEmpty()) {
        //           path = "file:///"+illustration.getFullPath();
        path = illustration.getFullPath();
    } else if (!illustration.getPath().isEmpty()) {
        //         path = "file:///"+illustration.getPath();
        path = illustration.getPath();/*w w  w  .j a  v  a 2s .  c  om*/
    } else if (!illustration.getLink().isEmpty()) {
        path = illustration.getLink();
        isFile = false;
    } else if (!illustration.getFullLink().isEmpty()) {
        path = illustration.getFullLink();
        isFile = false;
    }
    /*if(!Glide.isSetup()){
       GlideBuilder builder =  new GlideBuilder(getActivity());
       builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
       Glide.setup(builder);
    }*/
    if (isFile) {

        Glide.with(getActivity()).load(new File(path)).asBitmap().diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource,
                            GlideAnimation<? super Bitmap> glideAnimation) {
                        imag.setImageBitmap(resource);
                    }
                });
    } else {
        Glide.with(getActivity()).load(path).asBitmap().diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource,
                            GlideAnimation<? super Bitmap> glideAnimation) {
                        imag.setImageBitmap(resource);
                    }
                });
    }

    return rootView;
}

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

/***************************************************************/
@Override//from www . j ava2s  . c o  m
protected void onActivityResult(int requestCode, int resultCode, Intent returnedIntent) {
    super.onActivityResult(requestCode, resultCode, returnedIntent);

    switch (requestCode) {
    case PICK_IMAGE:
        if (resultCode == RESULT_OK) {

            resetVisibility(PICK_IMAGE);
            try {

                state[PICK_IMAGE] = true;
                state[CROP_IMAGE] = false;
                state[TREAT_IMAGE] = false;
                captura = String.valueOf(System.currentTimeMillis() / 1000L);
                ImageView imv = (ImageView) findViewById(R.id.image_intro);
                image_uri = returnedIntent.getData();
                InputStream is = getContentResolver().openInputStream(returnedIntent.getData());
                imv.setImageBitmap(BitmapFactory.decodeStream(is));
                is.close();
                RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
                seekBar.setVisibility(View.GONE);

            } catch (IOException e) {
                Log.e(TAG, "Error reading from gallery" + e.getMessage());
            } catch (Exception e) {
                Log.e(TAG, "Error reading from gallery" + e.getMessage());
            }
        }
        break;
    case CAPTURE_IMAGE:
        try {
            if (resultCode == RESULT_OK) {
                resetVisibility(CAPTURE_IMAGE);
                captura = String.valueOf(System.currentTimeMillis() / 1000L);
                state[PICK_IMAGE] = false;
                state[CROP_IMAGE] = false;
                state[TREAT_IMAGE] = false;
                TextView imc = (TextView) findViewById(R.id.textView);
                imc.setBackgroundColor(Color.rgb(255, 255, 255));
                RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
                seekBar.setVisibility(View.GONE);
                if (returnedIntent != null) {
                    setPic();
                    Bundle extras = returnedIntent.getExtras();
                    setSelectedImage(returnedIntent.getData());
                } else {

                    ImageView imv = (ImageView) findViewById(R.id.image_intro);
                    image = Util.decodeSampledBitmapFromUri(image_uri, MAX_SIZE, MAX_SIZE, this);
                    imv.setImageBitmap(image);

                    gpstracker = new GPSTracking(this);
                    if (gpstracker.canGetLocation()) {
                        latitude = String.valueOf(gpstracker.getLatitude());
                        longitude = String.valueOf(gpstracker.getLongitude());
                    } else {
                        gpstracker.showSettingsAlert();
                    }
                }
            }
        } catch (Exception e) {
            Log.e(TAG, "Error " + e.getMessage());
        }

        break;
    case CROP_IMAGE:
        try {

            if (resultCode == RESULT_OK) {
                state[CROP_IMAGE] = true;
                state[TREAT_IMAGE] = false;
                RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
                seekBar.setVisibility(View.VISIBLE);
                ImageTreatment imt = null;
                Bundle extras = returnedIntent.getExtras();
                if (extras != null) {
                    croppedimage_uri = Uri.parse(extras.getString(RETURN_DATA));
                    // croppedimage=extras.getParcelable(RETURN_DATA_AS_BITMAP);
                    if (croppedimage_uri != null) {
                        InputStream is = getContentResolver().openInputStream(croppedimage_uri);
                        croppedimage = BitmapFactory.decodeStream(is);
                        is.close();
                    } else {
                        image = BitmapFactory.decodeResource(getResources(), R.drawable.platanus_hispanica);
                    }
                    ImageView imv = (ImageView) findViewById(R.id.image_intro);
                    imv.setImageBitmap(croppedimage);
                    colours[COLOUR_R] = (int) imt.getRedColor();
                    colours[COLOUR_B] = (int) imt.getBlueColor();
                    colours[COLOUR_G] = (int) imt.getGreenColor();

                }
            }
        } catch (OutOfMemoryError e) {
            Log.e(TAG, "Error " + e.getMessage());

        } catch (IOException e) {
            Log.e(TAG, "Error " + e.getMessage());
        } catch (Exception e) {
            Log.e(TAG, "Error " + e.getMessage());
        }
    }

}

From source file:com.itsherpa.andg.imageloader.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 added using//  ww w  .  jav  a2 s.  c o m
 * {@link ImageWorker#addImageCache(FragmentManager, ImageCache.ImageCacheParams)}
 * . 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.
 * 
 * @param data
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 */
private void loadImage(Object data, ImageView imageView, int width, int height, int gender, boolean hasCover,
        ImageListener imageListener) {

    if (data == null) {
        return;
    }
    BitmapDrawable value = null;
    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(getCacheKeyFromObject(data));
    }
    boolean isCircle = false;
    if (data instanceof CircleImageRequest) {
        isCircle = true;
    }
    Bitmap loadingBitmap = getBitmapCover(hasCover, gender, isCircle);

    if (value != null) {
        // Bitmap found in memory cache
        Bitmap bitmap = value.getBitmap();
        if (isCircle) {
            bitmap = Utils.getBitmapInCircle(bitmap);
        }
        imageView.setImageBitmap(bitmap);
        if (imageListener != null)
            imageListener.onGetImageSuccess(value.getBitmap());
    } else if (cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, width, height, gender, hasCover, isCircle,
                imageListener);

        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, loadingBitmap, 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:com.example.camera2apidemo.Camera2BasicFragment.java

private void picture_preview(ImageView iv_show) {
    try {//from w ww . j  a  v  a  2 s. c  o  m
        FileInputStream fis = new FileInputStream(mFile.getAbsolutePath());
        Bitmap bitmap = BitmapFactory.decodeStream(fis);
        Matrix matrix = new Matrix();
        matrix.setRotate(90);
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        iv_show.setImageBitmap(bitmap);

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

}

From source file:com.nd.teacherplatform.util.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  w w w  .j  a v a2 s . c  o  m*/
private void forceDownload(String url, ImageView imageView, int loadingDrawable_ID, int failDrawable_ID,
        boolean isSaveLocal, ImageDownLoaderAction action) {
    if (url == null) {
        imageView.setImageResource(failDrawable_ID);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        /* modeCORRECT */
        switch (mode) {
        case NO_ASYNC_TASK:
            Bitmap bitmap = downloadBitmap(url);
            addBitmapToCache(url, bitmap);
            imageView.setImageBitmap(bitmap);
            break;

        case NO_DOWNLOADED_DRAWABLE:
            imageView.setMinimumHeight(156);
            BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal,
                    action);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal, action);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, loadingDrawable_ID);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            try {
                task.execute(url);
            } catch (RejectedExecutionException localRejectedExecutionException) {
            }
            break;
        }
    }
}

From source file:com.android.mms.rcs.FavoriteDetailAdapter.java

@Override
public Object instantiateItem(ViewGroup view, int position) {
    mCursor.moveToPosition(position);//from w w w .  ja  v a  2  s. co m
    View content = mInflater.inflate(R.layout.message_detail_content, view, false);

    TextView bodyText = (TextView) content.findViewById(R.id.textViewBody);
    LinearLayout mLinearLayout = (LinearLayout) content.findViewById(R.id.other_type_layout);

    mMsgType = mCursor.getInt(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE));
    if (mMsgType == RcsUtils.RCS_MSG_TYPE_TEXT) {
        initTextMsgView(bodyText);
    } else {
        bodyText.setVisibility(View.GONE);
        mLinearLayout.setVisibility(View.VISIBLE);
        ImageView imageView = (ImageView) mLinearLayout.findViewById(R.id.image_view);
        TextView textView = (TextView) mLinearLayout.findViewById(R.id.type_text_view);
        if (mMsgType != RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) {
            imageView.setOnClickListener(mOnClickListener);
        }
        if (mMsgType == RcsUtils.RCS_MSG_TYPE_IMAGE) {
            initImageMsgView(mLinearLayout);
            showContentFileSize(textView);
            mContentType = "image/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_AUDIO) {
            imageView.setImageResource(R.drawable.rcs_voice);
            showContentFileSize(textView);
            mContentType = "audio/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VIDEO) {
            String thumbPath = mCursor.getString(
                    mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL));
            Bitmap bitmap = BitmapFactory.decodeFile(thumbPath);
            imageView.setImageBitmap(bitmap);
            showContentFileSize(textView);
            mContentType = "video/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_MAP) {
            imageView.setImageResource(R.drawable.rcs_map);
            String body = mCursor
                    .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT));
            textView.setText(body);
            mContentType = "map/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VCARD) {
            textView.setVisibility(View.GONE);
            initVcardMagView(mLinearLayout);
            mContentType = "text/x-vCard";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_PAID_EMO) {
            String messageBody = mCursor
                    .getString(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.FILE_NAME));
            String[] body = messageBody.split(",");
            RcsEmojiStoreUtil.getInstance().loadImageAsynById(imageView, body[0],
                    RcsEmojiStoreUtil.EMO_STATIC_FILE);
        } else {
            bodyText.setVisibility(View.VISIBLE);
            mLinearLayout.setVisibility(View.GONE);
            initTextMsgView(bodyText);
        }
    }

    TextView detailsText = (TextView) content.findViewById(R.id.textViewDetails);
    detailsText.setText(getTextMessageDetails(mContext, mCursor, true));
    view.addView(content);

    return content;
}

From source file:com.irccloud.android.activity.UploadsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (ColorFormatter.file_uri_template != null)
        template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template);
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                cloud, 0xFFF2F7FC));//w ww  .  ja v a2 s .  c o  m
        cloud.recycle();
    }

    if (Build.VERSION.SDK_INT >= 14) {
        try {
            java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http");
            long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
            HttpResponseCache.install(httpCacheDir, httpCacheSize);
        } catch (IOException e) {
            Log.i("IRCCloud", "HTTP response cache installation failed:" + e);
        }
    }
    setContentView(R.layout.ignorelist);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
        getSupportActionBar().setElevation(0);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        to = savedInstanceState.getString("to");
        msg = savedInstanceState.getString("msg");
        page = savedInstanceState.getInt("page");
        File[] files = (File[]) savedInstanceState.getSerializable("adapter");
        for (File f : files) {
            adapter.addFile(f);
        }
        adapter.notifyDataSetChanged();
    }

    footer = getLayoutInflater().inflate(R.layout.messageview_header, null);
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(adapter);
    listView.addFooterView(footer);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) {
                canLoadMore = false;
                new FetchFilesTask().execute((Void) null);
            }
        }
    });
    listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            final File f = (File) adapter.getItem(i);

            AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this);
            builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);
            final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null);
            final EditText messageinput = (EditText) v.findViewById(R.id.message);
            messageinput.setText(msg);
            final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail);

            v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (messageinput.hasFocus()) {
                        v.post(new Runnable() {
                            @Override
                            public void run() {
                                v.scrollTo(0, v.getBottom());
                            }
                        });
                    }
                }
            });

            if (f.mime_type.startsWith("image/")) {
                try {
                    thumbnail.setImageBitmap(f.image);
                    thumbnail.setVisibility(View.VISIBLE);
                    thumbnail.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class);
                            i.setData(Uri.parse(f.url));
                            startActivity(i);
                        }
                    });
                    thumbnail.setClickable(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                thumbnail.setVisibility(View.GONE);
            }

            ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata);
            v.findViewById(R.id.filename).setVisibility(View.GONE);
            v.findViewById(R.id.filename_heading).setVisibility(View.GONE);

            builder.setTitle("Send A File To " + to);
            builder.setView(v);
            builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String message = messageinput.getText().toString();
                    if (message.length() > 0)
                        message += " ";
                    message += f.url;

                    dialog.dismiss();
                    if (getParent() == null) {
                        setResult(Activity.RESULT_OK);
                    } else {
                        getParent().setResult(Activity.RESULT_OK);
                    }
                    finish();

                    NetworkConnection.getInstance().say(cid, to, message);
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            AlertDialog d = builder.create();
            d.setOwnerActivity(UploadsActivity.this);
            d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
            d.show();
        }
    });
}

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

private void setPic() {
    // Get the dimensions of the View
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from w  w  w.j  av a  2  s.  c  o  m
    // Get the dimensions of the bitmap
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    int targetW = imv.getMaxWidth();
    int targetH = imv.getMaxHeight();
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    Bitmap bitmap = loadBitmap(image_uri.getPath());
    int photoW = bitmap.getWidth();
    int photoH = bitmap.getHeight();
    imv.setImageBitmap(bitmap);
    galleryAddPic();
}

From source file:com.hybris.mobile.lib.http.manager.volley.VolleyPersistenceManager.java

@Override
public void setImageFromUrl(final String url, final String requestId, final ImageView imageView,
        final OnRequestListener onRequestListener, final boolean forceImageTagToMatchRequestId) {

    if (onRequestListener != null) {
        onRequestListener.beforeRequest();
    }/*  w  w  w.j  a  va 2  s  .c  om*/

    mImageLoader.get(url, new ImageListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, "Error loading the image for url \"" + url + "\". " + error.getLocalizedMessage());

            if (onRequestListener != null) {
                onRequestListener.afterRequest(false);
            }
        }

        @Override
        public void onResponse(ImageContainer response, boolean arg1) {
            if (response.getBitmap() != null && imageView != null) {
                boolean loadImage = true;

                if (forceImageTagToMatchRequestId && imageView.getTag() != null
                        && !StringUtils.equals(requestId, imageView.getTag().toString())) {
                    loadImage = false;
                }

                if (loadImage) {
                    imageView.setImageBitmap(response.getBitmap());
                }

                if (onRequestListener != null) {
                    onRequestListener.afterRequest(true);
                }
            }
        }
    });

}

From source file:com.edible.ocr.CaptureActivity.java

/**
 * Displays information relating to the result of OCR, and requests a translation if necessary.
 * //from   w  ww. j av a2  s  .c om
 * @param ocrResult Object representing successful OCR results
 * @return True if a non-null result was received for OCR
 */
boolean handleOcrDecode(OcrResult ocrResult) {
    lastResult = ocrResult;

    // Test whether the result is null
    if (ocrResult.getText() == null || ocrResult.getText().equals("")) {
        Toast toast = Toast.makeText(this, "OCR failed. Please try again.", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        return false;
    }

    // Turn off capture-related UI elements
    shutterButton.setVisibility(View.GONE);
    statusViewBottom.setVisibility(View.GONE);
    statusViewTop.setVisibility(View.GONE);
    cameraButtonView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView bitmapImageView = (ImageView) findViewById(R.id.image_view);
    lastBitmap = ocrResult.getBitmap();
    if (lastBitmap == null) {
        bitmapImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    } else {
        bitmapImageView.setImageBitmap(lastBitmap);
    }

    // Display the recognized text
    TextView sourceLanguageTextView = (TextView) findViewById(R.id.source_language_text_view);
    sourceLanguageTextView.setText(sourceLanguageReadable);
    TextView ocrResultTextView = (TextView) findViewById(R.id.ocr_result_text_view);
    ocrResultTextView.setText(stripNoise(ocrResult.getText()));
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - ocrResult.getText().length() / 4);
    ocrResultTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView translationLanguageLabelTextView = (TextView) findViewById(
            R.id.translation_language_label_text_view);
    TextView translationLanguageTextView = (TextView) findViewById(R.id.translation_language_text_view);
    TextView translationTextView = (TextView) findViewById(R.id.translation_text_view);
    if (isTranslationActive) {
        // Handle translation text fields
        translationLanguageLabelTextView.setVisibility(View.VISIBLE);
        translationLanguageTextView.setText(targetLanguageReadable);
        translationLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL);
        translationLanguageTextView.setVisibility(View.VISIBLE);

        // Activate/re-activate the indeterminate progress indicator
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.VISIBLE);
        setProgressBarVisibility(true);

        // Get the translation asynchronously
        new TranslateAsyncTask(this, sourceLanguageCodeTranslation, targetLanguageCodeTranslation,
                stripNoise(ocrResult.getText())).execute();
    } else {
        translationLanguageLabelTextView.setVisibility(View.GONE);
        translationLanguageTextView.setVisibility(View.GONE);
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.GONE);
        setProgressBarVisibility(false);
    }
    return true;
}