Example usage for android.view View isShown

List of usage examples for android.view View isShown

Introduction

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

Prototype

public boolean isShown() 

Source Link

Document

Returns the visibility of this view and all of its ancestors

Usage

From source file:com.actionbarsherlock.internal.view.menu.MenuPopupHelper.java

@Override
public void onGlobalLayout() {
    if (isShowing()) {
        final View anchor = mAnchorView;
        if (anchor == null || !anchor.isShown()) {
            dismiss();//  w w  w . ja  va  2 s  .  co m
        } else if (isShowing()) {
            // Recompute window size and position
            mPopup.show();
        }
    }
}

From source file:de.grobox.liberario.locations.LocationView.java

protected void onFocusChange(View v, boolean hasFocus) {
    if (hasFocus && v.isShown() && v instanceof AutoCompleteTextView) {
        ((AutoCompleteTextView) v).showDropDown();
    }/*w  ww . j a  va  2  s . c o  m*/
}

From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java

protected int getNumberOfNotVisibleTools() {
    LinearLayout toolsLayout = (LinearLayout) mSolo.getView(R.id.tools_layout);
    int toolCount = toolsLayout.getChildCount();
    int numberOfNotVisibleTools = 0;
    for (int i = 0; i < toolCount; i++) {
        View toolButton = toolsLayout.getChildAt(i);
        if (!toolButton.isShown())
            numberOfNotVisibleTools++;/*from w  w w. ja va2s .  c  o  m*/
    }
    return numberOfNotVisibleTools;
}

From source file:org.solovyev.android.widget.menu.CustomPopupMenuHelper.java

@Override
public void onGlobalLayout() {
    if (!isShowing()) {
        return;//  w  ww  . j a  va2 s  . c  o m
    }
    final View anchor = mAnchorView;
    if (anchor == null || !anchor.isShown()) {
        dismiss();
    } else {
        // Recompute window size and position
        mPopup.show();
    }
}

From source file:com.nile.kmooc.view.custom.popup.menu.MenuPopupHelper.java

@Override
public void onGlobalLayout() {
    if (isShowing()) {
        final View anchor = mAnchorView;
        if (anchor == null || !anchor.isShown()) {
            dismiss();//from w w  w  . j  a  v  a2 s  .c  om
        } else {
            // Recompute window size and position
            mPopup.show();
        }
    }
}

From source file:org.mozilla.gecko.tests.components.AboutHomeComponent.java

public AboutHomeComponent assertBannerNotVisible() {
    View banner = getHomeBannerView();
    if (Build.VERSION.SDK_INT >= 11) {
        fAssertTrue("The HomeBanner is not visible",
                getHomePagerContainer().getVisibility() != View.VISIBLE || banner == null
                        || banner.getVisibility() != View.VISIBLE
                        || banner.getTranslationY() == banner.getHeight());
    } else {/*  www.j a v a  2  s.c  o m*/
        // getTranslationY is not available before api 11.
        // This check is a little less specific.
        fAssertTrue("The HomeBanner is not visible", getHomePagerContainer().getVisibility() != View.VISIBLE
                || banner == null || banner.isShown() == false);
    }
    return this;
}

From source file:com.android.mail.browse.ConversationViewAdapter.java

public boolean focusFirstMessageHeader() {
    if (mItems.size() > 1) {
        final View v = mItems.get(1).getFocusableView();
        if (v != null && v.isShown() && v.isFocusable()) {
            v.requestFocus();/*  w  w  w  . java 2 s .  c o m*/
            return true;
        }
    }
    return false;
}

From source file:org.app.enjoy.musicplayer.FileExplorerActivity.java

protected void initPopupWindow(final List<MusicData> list) {
    // TODO: 15/10/9
    //?activity_pop_left.xml 
    final View popipWindow_view = getLayoutInflater().inflate(R.layout.music_list, null, false);
    //Popupwindow 200LayoutParams.MATCH_PARENT 
    popupWindow = new PopupWindow(popipWindow_view, ViewGroup.LayoutParams.MATCH_PARENT - 150,
            ViewGroup.LayoutParams.MATCH_PARENT - 150, true);
    ///*from w  w w . jav a  2s.com*/
    //        popupWindow.setAnimationStyle(R.style.AnimationFade);
    //
    popipWindow_view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (popipWindow_view != null && popipWindow_view.isShown()) {

                popupWindow.dismiss();
                popupWindow = null;
            }
            return false;
        }
    });
    popupWindow.setBackgroundDrawable(new ColorDrawable(0));
    ListView listView = (ListView) popipWindow_view.findViewById(R.id.local_music_list);
    MusicListAdapter musicListAdapter = new MusicListAdapter(FileExplorerActivity.this, listView);
    musicListAdapter.setDatas(list);
    listView.setAdapter(musicListAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putSerializable(Contsant.MUSIC_LIST_KEY, (Serializable) list);
            bundle.putInt(Contsant.POSITION_KEY, position);
            intent.putExtras(bundle);
            intent.setAction("com.app.media.MUSIC_SERVICE");
            intent.putExtra("op", Contsant.PlayStatus.PLAY);// ???
            intent.setPackage(getPackageName());
            startService(intent);
        }
    });
}

From source file:eu.trentorise.smartcampus.jp.PlanNewJourneyFragment.java

protected void setUpMainOperation() {
    Button searchBtn = (Button) getView().findViewById(R.id.plannew_search);
    searchBtn.setOnClickListener(new View.OnClickListener() {
        @Override/*  w w w.  j  a  v a2  s .c o m*/
        public void onClick(View v) {
            // user preferences
            View userPrefsLayout = (View) getView().findViewById(R.id.plannew_userprefs);
            if (userPrefsLayout.isShown()) {
                TableLayout tTypesTableLayout = (TableLayout) userPrefsLayout
                        .findViewById(R.id.transporttypes_table);
                RadioGroup rTypesRadioGroup = (RadioGroup) userPrefsLayout
                        .findViewById(R.id.routetypes_radioGroup);
                userPrefsHolder = PrefsHelper.userPrefsViews2Holder(tTypesTableLayout, rTypesRadioGroup,
                        userPrefs);
            } else {
                userPrefsHolder = PrefsHelper.sharedPreferences2Holder(userPrefs);
            }

            Date fromDate = (Date) dateEditText.getTag();
            Date fromTime = (Date) timeEditText.getTag();

            if (fromPosition == null) {
                // Toast.makeText(getActivity(), R.string.from_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromEditText,
                        getResources().getString(R.string.from_field_empty));
                return;
            }
            if (toPosition == null) {
                // Toast.makeText(getActivity(), R.string.to_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toEditText,
                        getResources().getString(R.string.to_field_empty));
                return;
            }

            if (!eu.trentorise.smartcampus.jp.helper.Utils.validFromDateTime(fromDate, fromTime)) {
                // Toast.makeText(getActivity(),
                // R.string.datetime_before_now, Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), timeEditText,
                        getResources().getString(R.string.datetime_before_now));
                return;
            }

            // build SingleJourney
            SingleJourney sj = new SingleJourney();

            sj.setFrom(fromPosition);
            sj.setTo(toPosition);

            // NEW! Date in getTag() support
            sj.setDate(Config.FORMAT_DATE_SMARTPLANNER.format(fromDate));
            sj.setDepartureTime(Config.FORMAT_TIME_SMARTPLANNER.format(fromTime));

            sj.setTransportTypes((TType[]) userPrefsHolder.getTransportTypes());
            sj.setRouteType(userPrefsHolder.getRouteType());

            FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager()
                    .beginTransaction();
            Fragment fragment = ItineraryChoicesFragment.newInstance(sj);
            fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            fragmentTransaction.replace(Config.mainlayout, fragment, fragment.getTag());
            fragmentTransaction.addToBackStack(fragment.getTag());
            fragmentTransaction.commit();
        }
    });
    // hide keyboard if it is still open
    InputMethodManager imm = (InputMethodManager) getSherlockActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(searchBtn.getWindowToken(), 0);
}

From source file:io.selendroid.server.model.AndroidNativeElement.java

public boolean isDisplayed() {
    View view = getView();
    boolean hasWindowFocus = view.hasWindowFocus();
    int width = view.getWidth();
    int height = view.getHeight();
    int visibility = view.getVisibility();
    boolean isVisible = (View.VISIBLE == visibility);

    // Check visibility of the view and its parents as well.
    // This is more reliable when transitions between activities are in progress.
    boolean isShown = view.isShown();

    boolean isDisplayed = hasWindowFocus && isVisible && isShown && (width > 0) && (height > 0);

    if (!isDisplayed) {
        Activity activity = instrumentation.getCurrentActivity();
        View focusedView = activity.getCurrentFocus();
        String displayCheckFailureMessage = String.format(
                "Display check failed\n" + "for view: %s\n"
                        + "isVisible: %b\nvisibility: %d\nisShown: %b\nhasWindowFocus: %b\n"
                        + "width: %d\nheight: %d\ncurrent activity: %s\nfocused view: %s",
                view, isVisible, visibility, isShown, hasWindowFocus, width, height, activity, focusedView);
        SelendroidLogger.debug(displayCheckFailureMessage);
        if (!isShown) {
            logIsShownCheckFailure(view);
        }/*  ww  w. j  ava2 s  .com*/
        // Check the view belongs to the same view hierarchy as the view with current window focus.
        // If true, this usually means a system alert dialog is rendered on top of the view
        // (typically this is an app crash dialog).
        if (!hasWindowFocus) {
            if (activity != null && focusedView != null) {
                if (view.getRootView() == focusedView.getRootView()) {
                    SelendroidLogger.debug("hasWindowFocus() check failed. "
                            + "This usually means the view is covered by a system dialog.");
                }
            }
        }
    }

    return isDisplayed;
}