Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

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

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:es.uma.lcc.lockpic.MainActivity.java

/**
 * Overrides the back button functionality to behave in a more intuitive way.
 * When an encrypted/decrypted image is being displayed, pressing Back goes back to the menu
 * instead of closing the application.//ww  w.j  av  a 2 s.c  o  m
 */
@Override
public void onBackPressed() {
    ImageView iv = ((ImageView) findViewById(R.id.imageView));
    if (iv.getVisibility() == ImageView.VISIBLE) {
        findViewById(R.id.imageBlock).setVisibility(View.GONE);
        findViewById(R.id.encryptBlock).setVisibility(View.VISIBLE);
        findViewById(R.id.decryptBlock).setVisibility(View.VISIBLE);
        findViewById(R.id.myPicsBlock).setVisibility(View.VISIBLE);
        findViewById(R.id.accountBlock).setVisibility(View.VISIBLE);
        findViewById(R.id.filler1).setVisibility(View.VISIBLE);
        findViewById(R.id.filler2).setVisibility(View.VISIBLE);
        findViewById(R.id.filler3).setVisibility(View.VISIBLE);
        findViewById(R.id.filler4).setVisibility(View.VISIBLE);
        iv.setVisibility(ImageView.INVISIBLE);
        (findViewById(R.id.shareButton)).setVisibility(View.INVISIBLE);
    } else
        this.finish();
}

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

private void resetVisibility(int code)

{

    RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String rangepreference = (String) sharedPref.getString("rangepreference", "H");
    if (rangepreference.equals("H"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minH_preference", "60")),
                Integer.valueOf(sharedPref.getString("maxH_preference", "130")), this);
    if (rangepreference.equals("S"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minS_preference", "0")),
                Integer.valueOf(sharedPref.getString("maxS_preference", "255")), this);
    if (rangepreference.equals("V"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minV_preference", "0")),
                Integer.valueOf(sharedPref.getString("maxV_preference", "255")), this);

    seekBar.setSelectedMinValue(MIN_TH);
    seekBar.setSelectedMaxValue(MAX_TH);

    TextView imc = (TextView) findViewById(R.id.textView);
    imc.setVisibility(View.GONE);
    if ((code == CAPTURE_IMAGE) || (code == PICK_IMAGE)) {
        ImageButton cropButton = (ImageButton) findViewById(R.id.button_crop);
        cropButton.setVisibility(View.VISIBLE);
    }//  w w  w .ja  v a2 s  .c  om
    ImageButton sendButton = (ImageButton) findViewById(R.id.button_send);
    sendButton.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.GONE);
    ImageView imagePalette = (ImageView) findViewById(R.id.palette);
    imagePalette.setVisibility(View.GONE);
}

From source file:com.example.angel.parkpanda.MainActivity.java

public void initViewSetting(boolean condition) {

    ImageView iv_search = (ImageView) findViewById(R.id.toolbar_search);
    ImageView iv_control = (ImageView) findViewById(R.id.toolbar_control);
    ImageView iv_prev = (ImageView) findViewById(R.id.toolbar_prev);
    /*1:contorl,2:prev,3:search*/
    if (condition == true) {
        iv_search.setVisibility(View.VISIBLE);
        iv_control.setVisibility(View.VISIBLE);
        iv_prev.setVisibility(View.GONE);
    } else {// ww  w  .  j a  v a 2s  .  c o m
        iv_search.setVisibility(View.GONE);
        iv_control.setVisibility(View.GONE);
        iv_prev.setVisibility(View.VISIBLE);
    }

}

From source file:org.mariotaku.twidere.adapter.ComposeAutoCompleteAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);

    // Clear images in order to prevent images in recycled view shown.
    icon.setImageDrawable(null);//from ww w .ja  v  a  2s  .  c  om

    if (Suggestions.AutoComplete.TYPE_USERS.equals(cursor.getString(mTypeIdx))) {
        text1.setText(mUserColorNameManager.getUserNickname(cursor.getString(mExtraIdIdx),
                cursor.getString(mTitleIdx)));
        text2.setText(String.format("@%s", cursor.getString(mSummaryIdx)));
        if (mDisplayProfileImage) {
            final String profileImageUrl = cursor.getString(mIconIdx);
            mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
        } else {
            mProfileImageLoader.cancelDisplayTask(icon);
        }

        icon.clearColorFilter();
    } else {
        text1.setText(String.format("#%s", cursor.getString(mTitleIdx)));
        text2.setText(R.string.hashtag);

        icon.setImageResource(R.drawable.ic_action_hashtag);
        icon.setColorFilter(text1.getCurrentTextColor(), Mode.SRC_ATOP);
    }
    icon.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
    super.bindView(view, context, cursor);
}

From source file:com.tundem.aboutlibraries.ui.LibsFragment.java

private void generateAboutThisAppSection() {
    if (aboutShowIcon != null && aboutShowVersion != null) {
        View headerView = getActivity().getLayoutInflater().inflate(R.layout.listheader_opensource, null);

        //get the about this app views
        ImageView aboutIcon = (ImageView) headerView.findViewById(R.id.aboutIcon);
        TextView aboutVersion = (TextView) headerView.findViewById(R.id.aboutVersion);
        View aboutDivider = headerView.findViewById(R.id.aboutDivider);
        TextView aboutAppDescription = (TextView) headerView.findViewById(R.id.aboutDescription);

        //get the packageManager to load and read some values :D
        PackageManager pm = getActivity().getPackageManager();
        //get the packageName
        String packageName = getActivity().getPackageName();
        //Try to load the applicationInfo
        ApplicationInfo appInfo = null;//from www .ja va 2 s  . c  o  m
        PackageInfo packageInfo = null;
        try {
            appInfo = pm.getApplicationInfo(packageName, 0);
            packageInfo = pm.getPackageInfo(packageName, 0);
        } catch (Exception ex) {
        }

        //Set the Icon or hide it
        if (aboutShowIcon && appInfo != null) {
            aboutIcon.setImageDrawable(appInfo.loadIcon(pm));
        } else {
            aboutIcon.setVisibility(View.GONE);
        }

        //set the Version or hide it
        if (aboutShowVersion && packageInfo != null) {
            String versionName = packageInfo.versionName;
            int versionCode = packageInfo.versionCode;
            aboutVersion.setText(getString(R.string.version) + " " + versionName + " (" + versionCode + ")");
        } else {
            aboutVersion.setVisibility(View.GONE);
        }

        //Set the description or hide it
        if (!TextUtils.isEmpty(aboutDescription)) {
            aboutAppDescription.setText(aboutDescription);
        } else {
            aboutAppDescription.setVisibility(View.GONE);
        }

        //if there is no description or no icon and version number hide the divider
        if (!aboutShowIcon && !aboutShowVersion || TextUtils.isEmpty(aboutDescription)) {
            aboutDivider.setVisibility(View.GONE);
        }

        //add this cool thing to the headerView of our listView
        listView.addHeaderView(headerView, null, false);
    }
}

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

private void rangeSeekBarChanged(int minValue, int maxValue) {
    {/*www .  j av  a  2s.c  o  m*/

        TextView imc = (TextView) findViewById(R.id.textView);
        imc.setVisibility(View.VISIBLE);
        ImageButton cropButton = (ImageButton) findViewById(R.id.button_crop);
        cropButton.setVisibility(View.GONE);
        ImageButton sendButton = (ImageButton) findViewById(R.id.button_send);
        sendButton.setVisibility(View.VISIBLE);
        ImageButton histButton = (ImageButton) findViewById(R.id.button_histogram);
        histButton.setVisibility(View.VISIBLE);
        ImageButton revertButton = (ImageButton) findViewById(R.id.button_revert);
        revertButton.setVisibility(View.VISIBLE);
        ImageView imagePalette = (ImageView) findViewById(R.id.palette);
        imagePalette.setVisibility(View.GONE);
        ImageWrapper imw = new ImageWrapper();
        if (image_uri == null)
            image = Util.decodeSampledBitmapFromResource(getResources(), R.drawable.platanus_hispanica,
                    MAX_SIZE, MAX_SIZE);
        if (image_uri != null)
            image = Util.decodeSampledBitmapFromUri(image_uri, MAX_SIZE, MAX_SIZE, this);
        // handle changed range values
        try {
            Log.i(TAG, "User selected new range values: MIN=" + minValue + ", MAX=" + maxValue);
            ImageView imv = (ImageView) findViewById(R.id.image_intro);
            if (state[CROP_IMAGE])
                imw.setBitmap(croppedimage);
            else
                imw.setBitmap(image);
            imw.setMinV(minValue);
            imw.setMaxV(maxValue);

            ProcessImageTask pit = new ProcessImageTask();
            imw = (ImageWrapper) pit.execute(imw).get();
            treatedimage = imw.getBitmap();
            imv.setImageBitmap(treatedimage);
            histogram = imw.getHistogram();
            histograma = imw.getHist();
            mascara = imw.getMask();
            imc.setBackgroundColor(
                    Color.rgb(imw.getR().intValue(), imw.getG().intValue(), imw.getB().intValue()));
            state[TREAT_IMAGE] = true;

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

        }
    }
}

From source file:com.hybris.mobile.app.commerce.adapter.ProductListAdapterBase.java

/**
 * Show image Product from URL/*www . jav a 2 s  . c  o  m*/
 *
 * @param imageUrl    image url
 * @param imageView
 * @param progressBar
 * @param productCode product code to find
 */
protected void loadProductImage(String imageUrl, final ImageView imageView, final ProgressBar progressBar,
        String productCode) {

    // Loading the product image
    if (CommerceApplication.isOnline()) {
        if (StringUtils.isNotBlank(imageUrl)) {
            CommerceApplication.getContentServiceHelper().loadImage(imageUrl,
                    "product_list_image_" + productCode, imageView, 0, 0, true, new OnRequestListener() {

                        @Override
                        public void beforeRequest() {
                            imageView.setImageResource(android.R.color.transparent);
                            imageView.setVisibility(View.GONE);
                            progressBar.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void afterRequestBeforeResponse() {

                        }

                        @Override
                        public void afterRequest(boolean isDataSynced) {
                            imageView.setVisibility(View.VISIBLE);
                        }
                    }, true);
        }
    } else {
        Log.i(TAG, "Application offline, displaying no image for product " + productCode);
        imageView.setImageDrawable(getContext().getResources().getDrawable(R.drawable.no_image_product));
        imageView.setVisibility(View.VISIBLE);
    }
}

From source file:im.vector.activity.CallViewActivity.java

/**
 * Init the buttons layer/* w  w  w  .  j a  v  a 2 s.c  o m*/
 */
private void manageSubViews() {
    // sanity check
    // the call could have been destroyed between call.
    if (null == mCall) {
        Log.d(LOG_TAG, "manageSubViews nothing to do");
        return;
    }

    // initialize buttons
    if (null == mAcceptRejectLayout) {
        mAcceptRejectLayout = findViewById(R.id.layout_accept_reject);
        mAcceptButton = (Button) findViewById(R.id.accept_button);
        mRejectButton = (Button) findViewById(R.id.reject_button);
        mCancelButton = (Button) findViewById(R.id.cancel_button);
        mStopButton = (Button) findViewById(R.id.stop_button);
        mSpeakerSelectionView = (ImageView) findViewById(R.id.call_speaker_view);

        mCallStateTextView = (TextView) findViewById(R.id.call_state_text);

        mAcceptButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mCall) {
                    mCall.answer();
                }
            }
        });

        mRejectButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onHangUp();
            }
        });

        mCancelButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onHangUp();
            }
        });

        mStopButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onHangUp();
            }
        });

        mSpeakerSelectionView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mCall) {
                    mCall.toggleSpeaker();
                    refreshSpeakerButton();
                }
            }
        });

        updateStateTextView("", false);
    }

    String callState = mCall.getCallState();

    Log.d(LOG_TAG, "manageSubViews callState : " + callState);

    // hide / show avatar
    ImageView avatarView = (ImageView) CallViewActivity.this.findViewById(R.id.call_other_member);
    if (null != avatarView) {
        avatarView.setVisibility(
                (callState.equals(IMXCall.CALL_STATE_CONNECTED) && mCall.isVideo()) ? View.GONE : View.VISIBLE);
    }

    refreshSpeakerButton();

    // display the button according to the call state
    if (callState.equals(IMXCall.CALL_STATE_ENDED)) {
        mAcceptRejectLayout.setVisibility(View.GONE);
        mCancelButton.setVisibility(View.GONE);
        mStopButton.setVisibility(View.GONE);
    } else if (callState.equals(IMXCall.CALL_STATE_CONNECTED)) {
        mAcceptRejectLayout.setVisibility(View.GONE);
        mCancelButton.setVisibility(View.GONE);
        mStopButton.setVisibility(View.VISIBLE);
    } else {
        mAcceptRejectLayout.setVisibility(mCall.isIncoming() ? View.VISIBLE : View.GONE);
        mCancelButton.setVisibility(mCall.isIncoming() ? View.GONE : View.VISIBLE);
        mStopButton.setVisibility(View.GONE);
    }

    // display the callview only when the preview is displayed
    if (mCall.isVideo() && !callState.equals(IMXCall.CALL_STATE_ENDED)) {
        int visibility;

        if (callState.equals(IMXCall.CALL_STATE_WAIT_CREATE_OFFER)
                || callState.equals(IMXCall.CALL_STATE_INVITE_SENT)
                || callState.equals(IMXCall.CALL_STATE_RINGING)
                || callState.equals(IMXCall.CALL_STATE_CREATE_ANSWER)
                || callState.equals(IMXCall.CALL_STATE_CONNECTING)
                || callState.equals(IMXCall.CALL_STATE_CONNECTED)) {
            visibility = View.VISIBLE;
        } else {
            visibility = View.GONE;
        }

        if ((null != mCall) && (visibility != mCall.getVisibility())) {
            mCall.setVisibility(visibility);
        }
    }

    // display the callstate
    if (callState.equals(IMXCall.CALL_STATE_CONNECTING) || callState.equals(IMXCall.CALL_STATE_CREATE_ANSWER)
            || callState.equals(IMXCall.CALL_STATE_WAIT_LOCAL_MEDIA)
            || callState.equals(IMXCall.CALL_STATE_WAIT_CREATE_OFFER)) {
        mAcceptButton.setAlpha(0.5f);
        mAcceptButton.setEnabled(false);
        updateStateTextView(getResources().getString(R.string.call_connecting), true);
        mCallStateTextView.setVisibility(View.VISIBLE);
        stopRinging();
    } else if (callState.equals(IMXCall.CALL_STATE_CONNECTED)) {
        stopRinging();

        CallViewActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                AudioManager audioManager = (AudioManager) CallViewActivity.this
                        .getSystemService(Context.AUDIO_SERVICE);
                audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, mCallVolume, 0);
                MXCallsManager.setSpeakerphoneOn(CallViewActivity.this, mCall.isVideo());
                refreshSpeakerButton();
            }
        });

        updateStateTextView(getResources().getString(R.string.call_connected), false);
        mCallStateTextView.setVisibility(mCall.isVideo() ? View.GONE : View.VISIBLE);
    } else if (callState.equals(IMXCall.CALL_STATE_ENDED)) {
        updateStateTextView(getResources().getString(R.string.call_ended), true);
        mCallStateTextView.setVisibility(View.VISIBLE);
    } else if (callState.equals(IMXCall.CALL_STATE_RINGING)) {
        if (mCall.isIncoming()) {
            if (mCall.isVideo()) {
                updateStateTextView(getResources().getString(R.string.incoming_video_call), true);
            } else {
                updateStateTextView(getResources().getString(R.string.incoming_voice_call), true);
            }
        } else {
            updateStateTextView(getResources().getString(R.string.call_ring), true);
        }
        mCallStateTextView.setVisibility(View.VISIBLE);

        if (mAutoAccept) {
            mAutoAccept = false;
            mAcceptButton.setAlpha(0.5f);
            mAcceptButton.setEnabled(false);
            mCallStateTextView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mCall.answer();
                }
            }, 100);
        } else {
            mAcceptButton.setAlpha(1.0f);
            mAcceptButton.setEnabled(true);

            if (mCall.isIncoming()) {
                startRinging(CallViewActivity.this);
            } else {
                startRingbackSound(CallViewActivity.this);
            }
        }
    }
}

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

private void updateVisibility()

{
    Boolean done = false;//from  w ww  . j a va  2s . com
    TextView imc = (TextView) findViewById(R.id.textView);
    //   imc.setBackgroundColor(Color.rgb(255, 255, 255));
    RangeSeekBar<Integer> rangeSeekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
    rangeSeekBar.setSelectedMinValue(MIN_TH);
    rangeSeekBar.setSelectedMaxValue(MAX_TH);

    ImageView imv = (ImageView) findViewById(R.id.image_intro);

    if (state[CROP_IMAGE]) {
        rangeSeekBar.setVisibility(View.VISIBLE);
    }
    if (!state[CROP_IMAGE]) {
        rangeSeekBar.setVisibility(View.GONE);
    }

    if (state[TREAT_IMAGE] && state[CROP_IMAGE] && (!state[SHOW_HISTOGRAM])) {
        state[TREAT_IMAGE] = false;
        imv.setImageBitmap(croppedimage);
        done = true;
    }

    if (state[TREAT_IMAGE] && (!state[CROP_IMAGE]) && (!state[SHOW_HISTOGRAM]) && (!done)) {
        state[TREAT_IMAGE] = false;

        imv.setImageBitmap(image);
        ImageButton cropButton = (ImageButton) findViewById(R.id.button_crop);
        cropButton.setVisibility(View.VISIBLE);
        imc.setVisibility(View.GONE);
        ImageButton sendButton = (ImageButton) findViewById(R.id.button_send);
        sendButton.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.GONE);
        ImageView imagePalette = (ImageView) findViewById(R.id.palette);
        imagePalette.setVisibility(View.GONE);
        done = true;
    }
    if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE] && (!state[SHOW_HISTOGRAM]) && (!done)) {
        state[CROP_IMAGE] = false;
        try {
            InputStream is = getContentResolver().openInputStream(image_uri);
            imv.setImageBitmap(BitmapFactory.decodeStream(is));
            is.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, "File not found" + e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, "File not found" + e.getMessage());
        }
        croppedimage.recycle();
        done = true;
    }
    if ((!state[TREAT_IMAGE]) && (!state[CROP_IMAGE]) && (!state[SHOW_HISTOGRAM]) && (!done)) {
        image.recycle();
        image_uri = null;
        imv.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.platanus_hispanica));
        done = true;
    }
    if ((state[SHOW_HISTOGRAM]) && (!done)) {
        state[SHOW_HISTOGRAM] = false;
        rangeSeekBar.setVisibility(View.VISIBLE);
        imv.setImageBitmap(treatedimage);
        imc.setVisibility(View.VISIBLE);
        //                imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B]));

    }
}

From source file:org.gateshipone.malp.application.activities.MainActivity.java

@Override
public void setupToolbar(String title, boolean scrollingEnabled, boolean drawerIndicatorEnabled,
        boolean showImage) {
    // set drawer state
    mDrawerToggle.setDrawerIndicatorEnabled(drawerIndicatorEnabled);

    ImageView collapsingImage = (ImageView) findViewById(R.id.collapsing_image);
    View collapsingImageGradientTop = findViewById(R.id.collapsing_image_gradient_top);
    View collapsingImageGradientBottom = findViewById(R.id.collapsing_image_gradient_bottom);
    if (collapsingImage != null && collapsingImageGradientTop != null
            && collapsingImageGradientBottom != null) {
        if (showImage) {
            collapsingImage.setVisibility(View.VISIBLE);
            collapsingImageGradientTop.setVisibility(View.VISIBLE);
            collapsingImageGradientBottom.setVisibility(View.VISIBLE);
        } else {// w  w  w .  j  a  v a2 s . c om
            collapsingImage.setVisibility(View.GONE);
            collapsingImageGradientTop.setVisibility(View.GONE);
            collapsingImageGradientBottom.setVisibility(View.GONE);
        }
    }
    // set scrolling behaviour
    CollapsingToolbarLayout toolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    AppBarLayout layout = (AppBarLayout) findViewById(R.id.appbar);

    if (scrollingEnabled && !showImage) {
        toolbar.setTitleEnabled(false);
        toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
        setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
                + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED
                + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    } else if (!scrollingEnabled && showImage && collapsingImage != null) {
        toolbar.setTitleEnabled(true);
        toolbar.setPadding(0, 0, 0, 0);
        toolbar.setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
                + AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
    } else {
        toolbar.setTitleEnabled(false);
        toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
        setTitle(title);
        params.setScrollFlags(0);
    }
}