Example usage for android.view View getVisibility

List of usage examples for android.view View getVisibility

Introduction

In this page you can find the example usage for android.view View getVisibility.

Prototype

@ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
        @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
        @ViewDebug.IntToString(from = GONE, to = "GONE") })
@Visibility
public int getVisibility() 

Source Link

Document

Returns the visibility status for this view.

Usage

From source file:com.github.nestscrolldemo.behavior.DefineBehavior.java

@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dxConsumed,
        int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    //        if (dyConsumed > 0 && dyUnconsumed == 0) {
    //            System.out.println("");
    //        }/*  ww w.ja  v  a2  s  . c  o  m*/
    //        if (dyConsumed == 0 && dyUnconsumed > 0) {
    //            System.out.println("");
    //        }
    //        if (dyConsumed < 0 && dyUnconsumed == 0) {
    //            System.out.println("");
    //        }
    //        if (dyConsumed == 0 && dyUnconsumed < 0) {
    //            System.out.println("");
    //        }

    // ???
    if ((dyConsumed > 0 || dyUnconsumed > 0) && listenerAnimatorEndBuild.isFinish()
            && child.getVisibility() == View.VISIBLE) {//
        scaleHide(child, listenerAnimatorEndBuild.build());
    } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) {
        scaleShow(child, null);
    }
}

From source file:com.csipsimple.ui.SipHome.java

private ArrayList<View> getVisibleLeafs(View v) {
    ArrayList<View> res = new ArrayList<View>();
    if (v.getVisibility() != View.VISIBLE) {
        return res;
    }//from   w ww .ja v a  2  s. c  o  m
    if (v instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) v).getChildCount(); i++) {
            ArrayList<View> subLeafs = getVisibleLeafs(((ViewGroup) v).getChildAt(i));
            res.addAll(subLeafs);
        }
        return res;
    }
    res.add(v);
    return res;
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChooseActivityTypeDialogFragment.java

public static Dialog getDialog(final Activity activity, final String category,
        final ChooseActivityTypeCaller caller) {
    View view = activity.getLayoutInflater().inflate(R.layout.choose_activity_type, null);
    GridView gridView = (GridView) view.findViewById(R.id.choose_activity_type_grid_view);
    final View weightContainer = view.findViewById(R.id.choose_activity_type_weight_container);

    TextView weightLabel = (TextView) view.findViewById(R.id.choose_activity_type_weight_label);
    weightLabel.setText(PreferencesUtils.isMetricUnits(activity) ? R.string.description_weight_metric
            : R.string.description_weight_imperial);

    final TextView weight = (TextView) view.findViewById(R.id.choose_activity_type_weight);

    List<Integer> imageIds = new ArrayList<Integer>();
    for (String iconValue : TrackIconUtils.getAllIconValues()) {
        imageIds.add(TrackIconUtils.getIconDrawable(iconValue));
    }//from  w ww  .ja  v a2s  .  c  o  m

    Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_track_airplane, options);
    int padding = 32;
    int width = options.outWidth + 2 * padding;
    int height = options.outHeight + 2 * padding;
    gridView.setColumnWidth(width);

    final ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(activity, imageIds,
            width, height, padding);
    gridView.setAdapter(imageAdapter);

    final String weightValue = StringUtils.formatWeight(PreferencesUtils.getWeightDisplayValue(activity));
    final AlertDialog alertDialog = new AlertDialog.Builder(activity)
            .setNegativeButton(R.string.generic_cancel, null)
            .setPositiveButton(R.string.generic_ok, new Dialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    boolean newWeight = false;
                    if (weightContainer.getVisibility() == View.VISIBLE) {
                        String newValue = weight.getText().toString();
                        if (!newValue.equals(weightValue)) {
                            newWeight = true;
                            PreferencesUtils.storeWeightValue(activity, newValue);
                        }
                    }
                    int selected = imageAdapter.getSelected();
                    caller.onChooseActivityTypeDone(TrackIconUtils.getAllIconValues().get(selected), newWeight);
                }
            }).setTitle(R.string.track_edit_activity_type_hint).setView(view).create();
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            int position = getPosition(activity, category);
            alertDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(position != -1);
            if (position != -1) {
                imageAdapter.setSelected(position);
                imageAdapter.notifyDataSetChanged();
            }
            updateWeightContainer(weightContainer, position);
            weight.setText(weightValue);
            DialogUtils.setDialogTitleDivider(activity, alertDialog);
        }
    });

    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            alertDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(true);
            imageAdapter.setSelected(position);
            imageAdapter.notifyDataSetChanged();
            updateWeightContainer(weightContainer, position);
        }
    });
    return alertDialog;
}

From source file:com.andryr.musicplayer.MainActivity.java

private void updateTrackInfo() {
    View trackInfoLayout = findViewById(R.id.track_info);

    if (mPlaybackService != null && mPlaybackService.hasPlaylist()) {

        if (trackInfoLayout.getVisibility() != View.VISIBLE) {
            trackInfoLayout.setVisibility(View.VISIBLE);
            trackInfoLayout//from  w  ww.j ava2 s. co m
                    .startAnimation(AnimationUtils.loadAnimation(this, R.anim.abc_grow_fade_in_from_bottom));
        }
        String title = mPlaybackService.getSongTitle();
        String artist = mPlaybackService.getArtistName();
        if (title != null) {
            ((TextView) findViewById(R.id.song_title)).setText(title);

        }
        if (artist != null) {
            ((TextView) findViewById(R.id.song_artist)).setText(artist);
        }

        long albumId = mPlaybackService.getAlbumId();
        final ImageView minArtworkView = (ImageView) findViewById(R.id.artwork_min);
        ArtworkCache.getInstance().loadBitmap(albumId, minArtworkView, mThumbSize, mThumbSize);

        int duration = mPlaybackService.getTrackDuration();
        if (duration != -1) {
            mProgressBar.setMax(duration);

            updateProgressBar();
        }

    } else {
        trackInfoLayout.setVisibility(View.GONE);
    }
}

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

/**
 * We only want the current page that is being shown to be touchable.
 *//*from w w  w  . ja v  a2s  .c  o m*/
@Override
public void addTouchables(ArrayList<View> views) {
    // Note that we don't call super.addTouchables(), which means that
    // we don't call View.addTouchables(). This is okay because a ViewPager
    // is itself not touchable.
    for (int i = 0; i < getChildCount(); i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == currentItem) {
                child.addTouchables(views);
            }
        }
    }
}

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));
    childWidthMeasureSpec = MeasureSpec/*w ww  .  j  a  v a 2  s .  co m*/
            .makeMeasureSpec(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
    childHeightMeasureSpec = MeasureSpec
            .makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);

    inLayout = true;
    populate();
    inLayout = false;

    final int size = getChildCount();
    for (int i = 0; i < size; ++i) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }
}

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // ViewPagers should only report accessibility info for the current page,
    // otherwise things get very confusing.

    // TODO: Should this note something about the paging container?

    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == currentItem && child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }/*from  w  ww . ja v  a  2s  .c  om*/
        }
    }

    return false;
}

From source file:cn.suishen.email.activity.MessageViewFragmentBase.java

private static void makeVisible(View v, boolean visible) {
    final int visibility = visible ? View.VISIBLE : View.GONE;
    if ((v != null) && (v.getVisibility() != visibility)) {
        v.setVisibility(visibility);//from w w w.j a va  2  s. c o  m
    }
}

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

/**
 * We only want the current page that is being shown to be focusable.
 *//*from  w w  w .j a va2 s  .com*/
@Override
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
    int index;
    int increment;
    int end;
    int count = getChildCount();
    if ((direction & FOCUS_FORWARD) != 0) {
        index = 0;
        increment = 1;
        end = count;
    } else {
        index = count - 1;
        increment = -1;
        end = -1;
    }
    for (int i = index; i != end; i += increment) {
        View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == currentItem) {
                if (child.requestFocus(direction, previouslyFocusedRect)) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

/**
 * We only want the current page that is being shown to be focusable.
 *///from   w ww  .j av a  2 s .c om
@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    final int focusableCount = views.size();

    final int descendantFocusability = getDescendantFocusability();

    if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) {
        for (int i = 0; i < getChildCount(); i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() == VISIBLE) {
                ItemInfo ii = infoForChild(child);
                if (ii != null && ii.position == currentItem) {
                    child.addFocusables(views, direction, focusableMode);
                }
            }
        }
    }

    // we add ourselves (if focusable) in all cases except for when we are
    // FOCUS_AFTER_DESCENDANTS and there are some descendants focusable. this is
    // to avoid the focus search finding layouts when a more precise search
    // among the focusable children would be more interesting.
    if (descendantFocusability != FOCUS_AFTER_DESCENDANTS ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // Note that we can't call the superclass here, because it will
        // add all views in. So we need to do the same thing View does.
        if (!isFocusable()) {
            return;
        }
        if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE && isInTouchMode()
                && !isFocusableInTouchMode()) {
            return;
        }
        if (views != null) {
            views.add(this);
        }
    }
}