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:org.pixmob.droidlink.ui.EventCursorAdapter.java

@Override
public void bindView(View v, Context context, Cursor cursor) {
    final int state = cursor.getInt(cursor.getColumnIndexOrThrow(STATE));
    final String name = cursor.getString(cursor.getColumnIndexOrThrow(NAME));
    String number = cursor.getString(cursor.getColumnIndexOrThrow(NUMBER));
    final long date = cursor.getLong(cursor.getColumnIndexOrThrow(CREATED));

    if (number != null) {
        number = PhoneNumberUtils.formatNumber(number);
    }/*w  ww. j av a 2s . c om*/

    final int type = cursor.getInt(cursor.getColumnIndexOrThrow(TYPE));
    final Integer typeResourceId = EVENT_ICONS.get(type);

    final CharSequence eventDate = DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(),
            DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE);

    final String message = cursor.getString(cursor.getColumnIndexOrThrow(MESSAGE));

    final String eventName;
    final String eventNumber;
    if (number == null) {
        eventName = context.getString(R.string.unknown_number);
        eventNumber = EMPTY;
    } else if (name == null) {
        eventName = number;
        eventNumber = EMPTY;
    } else {
        eventName = name;
        eventNumber = number;
    }

    TextView tv = (TextView) v.findViewById(R.id.event_name);
    tv.setText(eventName);

    tv = (TextView) v.findViewById(R.id.event_number);
    tv.setText(eventNumber);

    tv = (TextView) v.findViewById(R.id.event_date);
    tv.setText(eventDate);

    tv = (TextView) v.findViewById(R.id.event_message);
    tv.setText(message);

    ImageView iv = (ImageView) v.findViewById(R.id.event_icon);
    if (typeResourceId != null) {
        iv.setImageResource(typeResourceId);
        iv.setVisibility(View.VISIBLE);
    } else {
        iv.setVisibility(View.INVISIBLE);
    }

    iv = (ImageView) v.findViewById(R.id.event_state);
    if (state == EventsContract.PENDING_DELETE_STATE) {
        iv.setImageResource(R.drawable.pending_delete);
        iv.setVisibility(View.VISIBLE);
    } else if (state == EventsContract.PENDING_UPLOAD_STATE) {
        iv.setImageResource(R.drawable.pending_upload);
        iv.setVisibility(View.VISIBLE);
    } else {
        iv.setVisibility(View.GONE);
    }

    v.setTag(TAG_ID, cursor.getString(cursor.getColumnIndex(_ID)));
}

From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java

public void onUpdateAvailable() {
    View navViewHeader = navView.getHeaderView(0);
    ImageView updateButton = navViewHeader.findViewById(R.id.nav_view_header_main_update);
    updateButton.setVisibility(View.VISIBLE);
}

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingCursorAdapter.java

/**
 * Show the imageView and start its animation drawable.
 *//*  w w w  .ja  v a 2  s .co m*/
private void startAnimation(final ImageView imageView) {
    if (imageView.getVisibility() != View.VISIBLE) {
        Log.v(TAG, "startAnimation");
        imageView.setVisibility(View.VISIBLE);
        final AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
        // On some devices, directly calling start() on the animation does not work.
        // We have to wait until the ImageView is visible before starting the animation.
        imageView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @SuppressWarnings("deprecation")
            @Override
            public void onGlobalLayout() {
                if (!animationDrawable.isRunning()) {
                    imageView.post(() -> {
                        animationDrawable.setVisible(true, false);
                        animationDrawable.start();
                    });
                }
                imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        });
    }
}

From source file:com.dwdesign.tweetings.adapter.UserAutoCompleteAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    if (mCursorClosed)
        return;//  w  w w . j ava2 s  . c  o  m
    super.bindView(view, context, cursor);
    if (mLookupText != null) {

        String statusText = cursor.getString(mStatusText);
        String finalUrl = statusText;
        SpannableString spannable = new SpannableString(statusText);
        final Matcher matcher = Regex.VALID_HASHTAG.matcher(spannable);
        while (matcher.find()) {
            final String url = matcherGroup(matcher, Regex.VALID_HASHTAG_GROUP_HASHTAG_FULL);
            if (url.toLowerCase().startsWith(mLookupText.toLowerCase())) {
                finalUrl = url;
                //break;
            }
        }

        final ImageView image_view = (ImageView) view.findViewById(android.R.id.icon);
        image_view.setVisibility(View.GONE);
        TextView text_view1 = (TextView) view.findViewById(android.R.id.text1);
        text_view1.setText(finalUrl);
        TextView text_view2 = (TextView) view.findViewById(android.R.id.text2);
        text_view2.setVisibility(View.GONE);
        //text_view2.setText(cursor.getString(mStatusText));

    } else {
        final ImageView image_view = (ImageView) view.findViewById(android.R.id.icon);
        image_view.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
        if (mDisplayProfileImage && mProfileImageLoader != null) {
            final String profile_image_url_string = cursor.getString(mProfileImageUrlIdx);
            mProfileImageLoader.displayProfileImage(image_view, cursor.getString(mProfileImageUrlIdx));
            if (mDisplayHiResProfileImage) {
                mProfileImageLoader.displayProfileImage(image_view,
                        getBiggerTwitterProfileImage(profile_image_url_string));
            } else {
                mProfileImageLoader.displayProfileImage(image_view, profile_image_url_string);
            }
        }
        TextView text_view1 = (TextView) view.findViewById(android.R.id.text1);
        text_view1.setText(cursor.getString(mScreenNameIdx));
        TextView text_view2 = (TextView) view.findViewById(android.R.id.text2);
        text_view2.setText(cursor.getString(mScreenNameIdx));

    }

}

From source file:org.runbuddy.tomahawk.views.PageIndicator.java

private void populate() {
    removeAllViews();/* w  ww.j  av  a2s .com*/
    mItems.clear();
    for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View item = inflater.inflate(R.layout.page_indicator_item, this, false);
        final TextView textView = (TextView) item.findViewById(R.id.textview);
        textView.setText(mViewPager.getAdapter().getPageTitle(i));
        final int j = i;
        if (mFragmentInfosList.get(i).size() > 1) {
            final ImageView arrow = (ImageView) item.findViewById(R.id.arrow);
            arrow.setVisibility(VISIBLE);
            item.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!mSelector.isListShowing()) {
                        rotateArrow(arrow, false);

                        mViewPager.setCurrentItem(j);

                        final List<FragmentInfo> fragmentInfos = mFragmentInfosList.get(j).getFragmentInfos();
                        Selector.SelectorListener selectorListener = new Selector.SelectorListener() {
                            @Override
                            public void onSelectorItemSelected(int position) {
                                rotateArrow(arrow, true);

                                FragmentInfo selectedItem = fragmentInfos.get(position);
                                ((TomahawkPagerAdapter) mViewPager.getAdapter()).changeFragment(j,
                                        selectedItem);
                                TextView textView = (TextView) mItems.get(j).findViewById(R.id.textview);
                                textView.setText(selectedItem.mTitle);
                                ImageView imageView = (ImageView) item.findViewById(R.id.imageview);
                                imageView.setImageResource(selectedItem.mIconResId);
                            }

                            @Override
                            public void onCancel() {
                                rotateArrow(arrow, true);
                            }
                        };
                        mSelector.setup(fragmentInfos, selectorListener, mRootview, mSelectorPosStorageKey);
                        mSelector.showSelectorList();
                    } else {
                        rotateArrow(arrow, true);

                        mSelector.hideSelectorList();
                    }
                }
            });
        } else {
            item.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mSelector.hideSelectorList();
                    mViewPager.setCurrentItem(j);
                }
            });
        }
        if (mFragmentInfosList.get(i).getCurrentFragmentInfo().mIconResId > 0) {
            ImageView imageView = (ImageView) item.findViewById(R.id.imageview);
            imageView.setVisibility(VISIBLE);
            imageView.setImageResource(mFragmentInfosList.get(i).getCurrentFragmentInfo().mIconResId);
        }
        if (i != 0) {
            View spacer = inflater.inflate(R.layout.page_indicator_spacer, this, false);
            addView(spacer);
        }
        addView(item);
        mItems.add(item);
        updateColors(mViewPager.getCurrentItem());
    }
}

From source file:behsaman.storytellerandroid.ScreenSlidePageFragment.java

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

    // Set the title view to show the page number.
    ((TextView) rootView.findViewById(android.R.id.text1)).setText(
            //getString(R.string.title_template_step, mPageNumber + 1));
            "Piece " + dataModel.getIndex());
    ((TextView) rootView.findViewById(R.id.textview_fragment_textviewer)).setText(this.dataModel.getText_val());

    final ImageView imgView = (ImageView) rootView.findViewById(R.id.imageViewComic);

    //Comics has picture as well
    if (storyType == STORY_TYPE.TEXT_ONLY)
        imgView.setVisibility(View.INVISIBLE);
    else {//from   w w w  .ja  va  2 s  .  com
        //Load picture
        //dataModel.get
        // Start downloading piece one and show progress bar
        ServerIO.getInstance().download(dataModel.getPicture_file_addr(), new MyBinaryHttpResponseHandler() {
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] binaryData, Throwable error) {
                Log.e(TAG, "FAILLLEEEDDD:" + error.getMessage() + "\tStatusCode:" + statusCode + "\tBinaryData:"
                        + binaryData);
                ServerIO.getInstance().connectionError(parentContext);
            }

            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] binaryData) {
                String dir = Utils.getCacheDir(parentContext).getAbsolutePath();
                File f = new File(
                        dir + "/" + dataModel.getStory_id().toString() + dataModel.getId().toString());
                try {
                    FileOutputStream writer = new FileOutputStream(f);
                    writer.write(binaryData);
                    writer.close();
                    FileInputStream inStream = new FileInputStream(f);
                    Bitmap bitmap_skip = BitmapFactory.decodeStream(inStream);
                    imgView.setImageBitmap(bitmap_skip);
                } catch (Exception e) {
                    Log.e(TAG, e.getMessage());
                }
            }
        });
    }

    return rootView;
}

From source file:it.smartcampuslab.riciclo.FeedbackFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 100) {
        if (resultCode != 0) {
            // Uri imgUri = data.getData();
            File mediaStorageDir = Environment
                    .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

            File fi = new File(mediaStorageDir + File.separator + "tmpImg.jpg");
            if (fi.exists()) {
                try {
                    Uri imgUri = Uri.parse(android.provider.MediaStore.Images.Media
                            .insertImage(getActivity().getContentResolver(), fi.getAbsolutePath(), null, null));
                    imageUri = imgUri.toString();
                    final BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inJustDecodeBounds = true;
                    BitmapFactory.decodeFile(fi.getAbsolutePath(), options);

                    options.inSampleSize = calculateInSampleSize(options, dpToPx(IMG_HEIGHT),
                            dpToPx(IMG_HEIGHT));
                    options.inJustDecodeBounds = false;
                    Bitmap myBitmap = BitmapFactory.decodeFile(fi.getAbsolutePath(), options);

                    ImageView myImage = (ImageView) getView().findViewById(R.id.feedback_img_result);
                    myImage.setVisibility(View.VISIBLE);
                    myImage.setImageBitmap(myBitmap);
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.e("CaptureHelper", "Error reading image");
                }//from  w w w  . java2 s  .  c o  m
            }
        }

    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:kr.co.generic.wifianalyzer.wifi.AccessPointsAdapter.java

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    WiFiDetail wiFiDetail = (WiFiDetail) getGroup(groupPosition);
    View view = accessPointDetail.makeView(convertView, parent, wiFiDetail, false);
    attachPopup(view, wiFiDetail);//from   ww  w .  j ava2 s .  co m

    ImageView groupIndicator = (ImageView) view.findViewById(kr.co.generic.wifianalyzer.R.id.groupIndicator);
    int childrenCount = getChildrenCount(groupPosition);
    if (childrenCount > 0) {
        groupIndicator.setVisibility(View.VISIBLE);
        groupIndicator
                .setImageResource(isExpanded ? kr.co.generic.wifianalyzer.R.drawable.ic_expand_less_black_24dp
                        : kr.co.generic.wifianalyzer.R.drawable.ic_expand_more_black_24dp);
        groupIndicator.setColorFilter(
                ContextCompat.getColor(context, kr.co.generic.wifianalyzer.R.color.icons_color));
    } else {
        groupIndicator.setVisibility(View.GONE);
    }
    return view;
}

From source file:com.hookedonplay.decoviewsample.SamplePeopleFragment.java

@Override
protected void setupEvents() {
    final DecoView arcView = getDecoView();
    final View view = getView();
    if (arcView == null || arcView.isEmpty() || view == null) {
        return;//from  ww w  . ja v a 2s  .  c  o m
    }
    arcView.executeReset();

    final ImageView imgView = (ImageView) view.findViewById(R.id.imageViewAvatar);
    imgView.setImageDrawable(null);
    imgView.setVisibility(View.INVISIBLE);

    addAnimation(arcView, mSeries1Index, 19, 3000, imgView, R.drawable.ic_avatar_man, COLOR_BLUE);
    addAnimation(arcView, mSeries2Index, 45, 11000, imgView, R.drawable.ic_avatar_woman, COLOR_PINK);

    arcView.addEvent(
            new DecoEvent.Builder(64).setIndex(mSeries1Index).setDelay(11000).setDuration(5000).build());

    addAnimation(arcView, mSeries3Index, 36, 19000, imgView, R.drawable.ic_avatar_child, COLOR_YELLOW);

    arcView.addEvent(
            new DecoEvent.Builder(79).setIndex(mSeries2Index).setDelay(19000).setDuration(5000).build());

    arcView.addEvent(
            new DecoEvent.Builder(100).setIndex(mSeries1Index).setDelay(19000).setDuration(5000).build());

    arcView.addEvent(new DecoEvent.Builder(EventType.EVENT_COLOR_CHANGE, COLOR_BACK).setIndex(mBack1Index)
            .setDelay(27000).setDuration(2000).setListener(new DecoEvent.ExecuteEventListener() {
                @Override
                public void onEventStart(DecoEvent event) {
                    imgView.setImageDrawable(
                            ContextCompat.getDrawable(getActivity(), R.drawable.ic_avatar_group));
                    showAvatar(true, imgView);
                }

                @Override
                public void onEventEnd(DecoEvent event) {

                }
            }).build());

    addFinishAnimation(arcView, mSeries3Index, 1250, 30000, imgView);
    addFinishAnimation(arcView, mSeries2Index, 1500, 30000, null);
    addFinishAnimation(arcView, mSeries1Index, 1750, 30000, null);
}

From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetail.java

public void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean child, boolean frequencyRange) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    TextView textIPAddress = (TextView) view.findViewById(R.id.ipAddress);
    TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed);
    String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress();
    if (StringUtils.isBlank(ipAddress)) {
        textIPAddress.setVisibility(View.GONE);
        textLinkSpeed.setVisibility(View.GONE);
    } else {/*from w w w . j a  va 2 s .  co  m*/
        textIPAddress.setVisibility(View.VISIBLE);
        textIPAddress.setText(ipAddress);

        int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed();
        if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) {
            textLinkSpeed.setVisibility(View.GONE);
        } else {
            textLinkSpeed.setVisibility(View.VISIBLE);
            textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS));
        }
    }

    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    if (wiFiDetail.getWiFiAdditional().isConfiguredNetwork()) {
        configuredImage.setVisibility(View.VISIBLE);
        configuredImage.setColorFilter(resources.getColor(R.color.connected));
    } else {
        configuredImage.setVisibility(View.GONE);
    }

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();
    ImageView imageView = (ImageView) view.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.imageResource());
    imageView.setColorFilter(resources.getColor(strength.colorResource()));

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(resources.getColor(R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(resources.getColor(strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel))
            .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel()));
    ((TextView) view.findViewById(R.id.frequency))
            .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance()));
    ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities());

    TextView textVendor = ((TextView) view.findViewById(R.id.vendor));
    String vendor = wiFiDetail.getWiFiAdditional().getVendorName();
    if (StringUtils.isBlank(vendor)) {
        textVendor.setVisibility(View.GONE);
    } else {
        textVendor.setVisibility(View.VISIBLE);
        textVendor.setText(vendor);
    }

    if (child) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }

    if (frequencyRange) {
        view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.VISIBLE);
        ((TextView) view.findViewById(R.id.channel_frequency_range)).setText(String.format("%d - %d %s",
                wiFiSignal.getFrequencyStart(), wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS));
    } else {
        view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.GONE);
    }
}