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:com.example.android.tourguide.CategoryAdaptor.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Check if an existing view is being reused, otherwise inflate the view
    View listItemView = convertView;
    if (listItemView == null) {
        listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
    }//from ww  w.  j a v a  2  s .  c  o m

    // Get the {@link Category} object located at this position in the list
    Category currentCategory = getItem(position);

    // Find the TextView in the list_item.xml layout with the ID category_view.
    TextView categoryView = (TextView) listItemView.findViewById(R.id.catergory_view);
    // Get the Category from the currentCategry object and set this text on
    // the Category TextView.
    categoryView.setText(currentCategory.getCategory());

    // Set the theme color for the list item
    View textContainer = listItemView.findViewById(R.id.text_container);
    // Find the color that resource ID maps
    int color = ContextCompat.getColor(getContext(), mColorResourceID);
    // Set the background color of the text container view
    textContainer.setBackgroundColor(color);

    // Find the ImageView in the list_item.xml layout with the ID image.
    ImageView imageView = (ImageView) listItemView.findViewById(R.id.image);

    if (currentCategory.hasImage()) {
        // Set the image view to the image resource specified in the current word.
        imageView.setImageResource(currentCategory.getImageResourceId());
        // Find the color that resource ID maps
        imageView.setBackgroundColor(color);

        // Make sure the view is Visible
        imageView.setVisibility(View.VISIBLE);
    } else {
        imageView.setVisibility(View.GONE);
    }

    // Return the whole list item layout so that it can be shown in
    // the ListView.
    return listItemView;
}

From source file:de.questmaster.fatremote.fragments.RemoteFragment.java

private void hideKeyboard() {
    EditText text = (EditText) c.findViewById(R.id.enterText);
    ImageView button = (ImageView) c.findViewById(R.id.textButton);

    // clear entered Text
    text.setText("");

    // hide text field
    text.setVisibility(View.GONE);
    button.setVisibility(View.VISIBLE);

    // hide keyboard
    InputMethodManager mgr = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(text.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:net.henryco.opalette.application.StartUpActivity.java

private void initSplash() {
    findViewById(R.id.startUpAdViewBottom).setVisibility(View.GONE);
    findViewById(R.id.imageButtonGall).setVisibility(View.GONE);
    findViewById(R.id.textView).setVisibility(View.GONE);
    findViewById(R.id.firstPickLayout).setVisibility(View.GONE);
    ImageView logo = (ImageView) findViewById(R.id.logoImageVIew);
    logo.setVisibility(View.VISIBLE);

    new Thread(() -> {
        long t0 = System.currentTimeMillis();
        while (System.currentTimeMillis() < t0 + SPLASH_LOADING_TIME) {
            synchronized (this) {
                try {
                    float nt = ((float) (System.currentTimeMillis() - t0) / SPLASH_LOADING_TIME);
                    logo.setAlpha((float) Math.min(1., Math.sin(Math.PI * nt) * 1.25));
                    Thread.sleep(1);
                } catch (Exception ignored) {
                }/*from  www  .  j a  v a 2s .  c o  m*/
            }
        }
        runOnUiThread(() -> {
            logo.setVisibility(View.GONE);
            loadAfterSplash();
        });
    }).start();
}

From source file:pl.bcichecki.rms.client.android.fragments.listAdapters.OutboxMessagesListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view;//  ww w  . j a  v a 2 s.  c o m
    if (convertView == null) {
        view = getLayoutInflater().inflate(FRAGMENT_OUTBOX_MESSAGES_LIST_ITEM, parent, false);
    } else {
        view = convertView;
    }

    TextView eventSent = (TextView) view.findViewById(FRAGMENT_OUTBOX_MESSAGES_LIST_ITEM_SENT);
    TextView eventSubject = (TextView) view.findViewById(FRAGMENT_OUTBOX_MESSAGES_LIST_ITEM_SUBJECT);
    TextView eventTo = (TextView) view.findViewById(FRAGMENT_OUTBOX_MESSAGES_LIST_ITEM_TO);

    ImageView archivedIndicator = (ImageView) view
            .findViewById(FRAGMENT_OUTBOX_MESSAGES_LIST_ITEM_INDICATORS_ARCHIVED);

    Locale locale = getContext().getResources().getConfiguration().locale;

    Message event = getItem(position);

    eventSent.setText(AppUtils.getFormattedDateAsString(event.getDate(), locale));
    eventSubject.setText(event.getSubject());
    eventTo.setText(getRecipents(event));

    archivedIndicator.setVisibility(event.isArchivedBySender() ? View.VISIBLE : View.INVISIBLE);

    return view;
}

From source file:com.bonsai.btcreceive.ReceiveFragment.java

public void showAddress() {
    BTCFmt btcfmt = mBase.getBTCFmt();/*from  ww w.j ava 2  s. c o  m*/

    Address addr = mBase.getWalletService().nextReceiveAddress();
    String addrstr = addr.toString();

    TextView addrtv = (TextView) getActivity().findViewById(R.id.receive_addr);
    addrtv.setText(addrstr);
    addrtv.setVisibility(View.VISIBLE);

    String ss = mBTCAmountEditText.getText().toString();
    long bb = btcfmt.parse(ss.toString());
    BigInteger amt = bb == 0 ? null : BigInteger.valueOf(bb);

    String uri = BitcoinURI.convertToBitcoinURI(addrstr, amt, null, null);

    mLogger.info("view address uri=" + uri);

    final int size = (int) (240 * getResources().getDisplayMetrics().density);

    // Load the QR bitmap.
    Bitmap bm = createBitmap(uri, size);
    if (bm != null) {
        ImageView iv = (ImageView) getActivity().findViewById(R.id.receive_qr_view);
        iv.setImageBitmap(bm);
        iv.setVisibility(View.VISIBLE);
    }

    // Find the HDAddress object associated with this address.
    HDAddressDescription addrdesc = mBase.getWalletService().findAddress(addr);
    mHDAddress = addrdesc.hdAddress;
    mTransitioned = false;

    mFiatAmountEditText.setFocusable(false);
    mFiatAmountEditText.setFocusableInTouchMode(false);
    mBTCAmountEditText.setFocusable(false);
    mBTCAmountEditText.setFocusableInTouchMode(false);
}

From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView vKeyId = (TextView) view.findViewById(R.id.subkey_item_key_id);
    TextView vKeyDetails = (TextView) view.findViewById(R.id.subkey_item_details);
    TextView vKeyExpiry = (TextView) view.findViewById(R.id.subkey_item_expiry);
    ImageView vCertifyIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_certify);
    ImageView vSignIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_sign);
    ImageView vEncryptIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_encrypt);
    ImageView vAuthenticateIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_authenticate);
    ImageView vEditImage = (ImageView) view.findViewById(R.id.subkey_item_edit_image);
    ImageView vStatus = (ImageView) view.findViewById(R.id.subkey_item_status);

    // not used:/*w ww  .  j  a  va2 s .co m*/
    ImageView deleteImage = (ImageView) view.findViewById(R.id.subkey_item_delete_button);
    deleteImage.setVisibility(View.GONE);

    long keyId = cursor.getLong(INDEX_KEY_ID);
    vKeyId.setText(KeyFormattingUtils.beautifyKeyId(keyId));

    // may be set with additional "stripped" later on
    SpannableStringBuilder algorithmStr = new SpannableStringBuilder();
    algorithmStr.append(KeyFormattingUtils.getAlgorithmInfo(context, cursor.getInt(INDEX_ALGORITHM),
            cursor.getInt(INDEX_KEY_SIZE), cursor.getString(INDEX_KEY_CURVE_OID)));

    SubkeyChange change = mSaveKeyringParcel != null ? mSaveKeyringParcel.getSubkeyChange(keyId) : null;

    if (change != null && (change.mDummyStrip || change.mMoveKeyToSecurityToken)) {
        if (change.mDummyStrip) {
            algorithmStr.append(", ");
            final SpannableString boldStripped = new SpannableString(context.getString(R.string.key_stripped));
            boldStripped.setSpan(new StyleSpan(Typeface.BOLD), 0, boldStripped.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldStripped);
        }
        if (change.mMoveKeyToSecurityToken) {
            algorithmStr.append(", ");
            final SpannableString boldDivert = new SpannableString(context.getString(R.string.key_divert));
            boldDivert.setSpan(new StyleSpan(Typeface.BOLD), 0, boldDivert.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldDivert);
        }
    } else {
        switch (SecretKeyType.fromNum(cursor.getInt(INDEX_HAS_SECRET))) {
        case GNU_DUMMY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_stripped));
            break;
        case DIVERT_TO_CARD:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_divert));
            break;
        case PASSPHRASE_EMPTY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_no_passphrase));
            break;
        case UNAVAILABLE:
            // don't show this on pub keys
            //algorithmStr += ", " + context.getString(R.string.key_unavailable);
            break;
        }
    }
    vKeyDetails.setText(algorithmStr, TextView.BufferType.SPANNABLE);

    boolean isMasterKey = cursor.getInt(INDEX_RANK) == 0;
    if (isMasterKey) {
        vKeyId.setTypeface(null, Typeface.BOLD);
    } else {
        vKeyId.setTypeface(null, Typeface.NORMAL);
    }

    // Set icons according to properties
    vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE);
    vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE);
    vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : View.GONE);
    vAuthenticateIcon.setVisibility(cursor.getInt(INDEX_CAN_AUTHENTICATE) != 0 ? View.VISIBLE : View.GONE);

    boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;

    Date expiryDate = null;
    if (!cursor.isNull(INDEX_EXPIRY)) {
        expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000);
    }

    // for edit key
    if (mSaveKeyringParcel != null) {
        boolean revokeThisSubkey = (mSaveKeyringParcel.mRevokeSubKeys.contains(keyId));

        if (revokeThisSubkey) {
            if (!isRevoked) {
                isRevoked = true;
            }
        }

        SaveKeyringParcel.SubkeyChange subkeyChange = mSaveKeyringParcel.getSubkeyChange(keyId);
        if (subkeyChange != null) {
            if (subkeyChange.mExpiry == null || subkeyChange.mExpiry == 0L) {
                expiryDate = null;
            } else {
                expiryDate = new Date(subkeyChange.mExpiry * 1000);
            }
        }

        vEditImage.setVisibility(View.VISIBLE);
    } else {
        vEditImage.setVisibility(View.GONE);
    }

    boolean isExpired;
    if (expiryDate != null) {
        isExpired = expiryDate.before(new Date());
        Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiryCal.setTime(expiryDate);
        // convert from UTC to time zone of device
        expiryCal.setTimeZone(TimeZone.getDefault());

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": "
                + DateFormat.getDateFormat(context).format(expiryCal.getTime()));
    } else {
        isExpired = false;

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none));
    }

    // if key is expired or revoked...
    boolean isInvalid = isRevoked || isExpired;
    if (isInvalid) {
        vStatus.setVisibility(View.VISIBLE);

        vCertifyIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vSignIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vEncryptIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vAuthenticateIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);

        if (isRevoked) {
            vStatus.setImageResource(R.drawable.status_signature_revoked_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        } else if (isExpired) {
            vStatus.setImageResource(R.drawable.status_signature_expired_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        }
    } else {
        vStatus.setVisibility(View.GONE);

        vKeyId.setTextColor(mDefaultTextColor);
        vKeyDetails.setTextColor(mDefaultTextColor);
        vKeyExpiry.setTextColor(mDefaultTextColor);

        vCertifyIcon.clearColorFilter();
        vSignIcon.clearColorFilter();
        vEncryptIcon.clearColorFilter();
        vAuthenticateIcon.clearColorFilter();
    }
    vKeyId.setEnabled(!isInvalid);
    vKeyDetails.setEnabled(!isInvalid);
    vKeyExpiry.setEnabled(!isInvalid);
}

From source file:cn.ucai.superwechat.ui.SettingsActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.em_fragment_conversation_settings);

    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*  w w  w  . j ava 2s. c  o  m*/
    ImageView back = (ImageView) findViewById(R.id.img_back);
    back.setVisibility(View.VISIBLE);
    back.setOnClickListener(this);
    TextView title = (TextView) findViewById(R.id.txt_title);
    title.setVisibility(View.VISIBLE);
    title.setText(getString(R.string.set));
    rl_switch_notification = (RelativeLayout) findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) findViewById(R.id.rl_switch_speaker);
    rl_switch_chatroom_leave = (RelativeLayout) findViewById(R.id.rl_switch_chatroom_owner_leave);
    rl_switch_delete_msg_when_exit_group = (RelativeLayout) findViewById(
            R.id.rl_switch_delete_msg_when_exit_group);
    rl_switch_auto_accept_group_invitation = (RelativeLayout) findViewById(
            R.id.rl_switch_auto_accept_group_invitation);
    rl_switch_adaptive_video_encode = (RelativeLayout) findViewById(R.id.rl_switch_adaptive_video_encode);
    rl_custom_server = (RelativeLayout) findViewById(R.id.rl_custom_server);

    notifiSwitch = (EaseSwitchButton) findViewById(R.id.switch_notification);
    soundSwitch = (EaseSwitchButton) findViewById(R.id.switch_sound);
    vibrateSwitch = (EaseSwitchButton) findViewById(R.id.switch_vibrate);
    speakerSwitch = (EaseSwitchButton) findViewById(R.id.switch_speaker);
    ownerLeaveSwitch = (EaseSwitchButton) findViewById(R.id.switch_owner_leave);
    switch_delete_msg_when_exit_group = (EaseSwitchButton) findViewById(R.id.switch_delete_msg_when_exit_group);
    switch_auto_accept_group_invitation = (EaseSwitchButton) findViewById(
            R.id.switch_auto_accept_group_invitation);
    switch_adaptive_video_encode = (EaseSwitchButton) findViewById(R.id.switch_adaptive_video_encode);
    logoutBtn = (Button) findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")");
    }
    customServerSwitch = (EaseSwitchButton) findViewById(R.id.switch_custom_server);

    textview1 = (TextView) findViewById(R.id.textview1);
    textview2 = (TextView) findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) findViewById(R.id.ll_black_list);
    //      userProfileContainer = (LinearLayout) findViewById(R.id.ll_user_profile);
    llDiagnose = (LinearLayout) findViewById(R.id.ll_diagnose);
    pushNick = (LinearLayout) findViewById(R.id.ll_set_push_nick);

    settingsModel = SuperWeChatHelper.getInstance().getModel();
    chatOptions = EMClient.getInstance().getOptions();

    blacklistContainer.setOnClickListener(this);
    //      userProfileContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    customServerSwitch.setOnClickListener(this);
    rl_custom_server.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    pushNick.setOnClickListener(this);
    rl_switch_chatroom_leave.setOnClickListener(this);
    rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
    rl_switch_auto_accept_group_invitation.setOnClickListener(this);
    rl_switch_adaptive_video_encode.setOnClickListener(this);

    // the vibrate and sound notification are allowed or not?
    if (settingsModel.getSettingMsgNotification()) {
        notifiSwitch.openSwitch();
    } else {
        notifiSwitch.closeSwitch();
    }

    // sound notification is switched on or not?
    if (settingsModel.getSettingMsgSound()) {
        soundSwitch.openSwitch();
    } else {
        soundSwitch.closeSwitch();
    }

    // vibrate notification is switched on or not?
    if (settingsModel.getSettingMsgVibrate()) {
        vibrateSwitch.openSwitch();
    } else {
        vibrateSwitch.closeSwitch();
    }

    // the speaker is switched on or not?
    if (settingsModel.getSettingMsgSpeaker()) {
        speakerSwitch.openSwitch();
    } else {
        speakerSwitch.closeSwitch();
    }

    // if allow owner leave
    if (settingsModel.isChatroomOwnerLeaveAllowed()) {
        ownerLeaveSwitch.openSwitch();
    } else {
        ownerLeaveSwitch.closeSwitch();
    }

    // delete messages when exit group?
    if (settingsModel.isDeleteMessagesAsExitGroup()) {
        switch_delete_msg_when_exit_group.openSwitch();
    } else {
        switch_delete_msg_when_exit_group.closeSwitch();
    }

    if (settingsModel.isAutoAcceptGroupInvitation()) {
        switch_auto_accept_group_invitation.openSwitch();
    } else {
        switch_auto_accept_group_invitation.closeSwitch();
    }

    if (settingsModel.isAdaptiveVideoEncode()) {
        switch_adaptive_video_encode.openSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true);
    } else {
        switch_adaptive_video_encode.closeSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false);
    }

    if (settingsModel.isCustomServerEnable()) {
        customServerSwitch.openSwitch();
    } else {
        customServerSwitch.closeSwitch();
    }
}

From source file:net.bither.fragment.hot.AddAddressHotHDMFragment.java

private void showFlash(ImageView iv) {
    ImageView[] ivs = new ImageView[] { ivHotLight, ivColdLight, ivServerLight };
    for (ImageView v : ivs) {
        if (v != iv) {
            v.clearAnimation();/*from w  w w . j  a v  a2 s.c  o  m*/
            v.setVisibility(View.INVISIBLE);
        }
    }
    if (iv != null) {
        iv.setVisibility(View.VISIBLE);
        iv.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.hdm_keychain_add_one_part_flash));

    }
}

From source file:com.daoofdev.weatherday.MainActivity.java

private void setImageForImageViewAndShow(Bitmap bitmap, ImageView imageView) {
    if (bitmap != null) {
        imageView.setImageBitmap(bitmap);
        imageView.setVisibility(View.VISIBLE);
    } else {//from   ww w  . ja va2  s .  c  om
        imageView.setVisibility(View.GONE);
    }
}

From source file:nl.hnogames.domoticz.app.DomoticzDashboardFragment.java

public void setMessage(String message) {
    RelativeLayout errorLayout = (RelativeLayout) root.findViewById(R.id.errorLayout);
    if (errorLayout != null) {
        errorLayout.setVisibility(View.VISIBLE);

        ImageView errorImage = (ImageView) root.findViewById(R.id.errorImage);
        errorImage.setImageResource(R.drawable.empty);
        errorImage.setAlpha(0.5f);//from   w  w w .j a  v  a  2 s.c om
        errorImage.setVisibility(View.VISIBLE);

        TextView errorTextWrong = (TextView) root.findViewById(R.id.errorTextWrong);
        errorTextWrong.setVisibility(View.GONE);

        TextView errorTextMessage = (TextView) root.findViewById(R.id.errorTextMessage);
        errorTextMessage.setText(message);
    } else
        throw new RuntimeException("Layout should have a RelativeLayout defined with the ID of errorLayout");
}