android.view.View#getImportantForAccessibility ( )源码实例Demo

下面列出了android.view.View#getImportantForAccessibility ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: AdapterViewAnimator.java
void refreshChildren() {
    if (mAdapter == null) return;
    for (int i = mCurrentWindowStart; i <= mCurrentWindowEnd; i++) {
        int index = modulo(i, getWindowSize());

        int adapterCount = getCount();
        // get the fresh child from the adapter
        final View updatedChild = mAdapter.getView(modulo(i, adapterCount), null, this);

        if (updatedChild.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
            updatedChild.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
        }

        if (mViewsMap.containsKey(index)) {
            final FrameLayout fl = (FrameLayout) mViewsMap.get(index).view;
            // add the new child to the frame, if it exists
            if (updatedChild != null) {
                // flush out the old child
                fl.removeAllViewsInLayout();
                fl.addView(updatedChild);
            }
        }
    }
}
 
源代码2 项目: delion   文件: Tab.java
/**
 * Update whether or not the current native tab and/or web contents are
 * currently visible (from an accessibility perspective), or whether
 * they're obscured by another view.
 */
public void updateAccessibilityVisibility() {
    View view = getView();
    if (view != null) {
        int importantForAccessibility = isObscuredByAnotherViewForAccessibility()
                ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : View.IMPORTANT_FOR_ACCESSIBILITY_YES;
        if (view.getImportantForAccessibility() != importantForAccessibility) {
            view.setImportantForAccessibility(importantForAccessibility);
            view.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        }
    }

    ContentViewCore cvc = getContentViewCore();
    if (cvc != null) {
        boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility()
                || isShowingSadTab();
        cvc.setObscuredByAnotherView(isWebContentObscured);
    }
}
 
源代码3 项目: AndroidChromium   文件: Tab.java
/**
 * Update whether or not the current native tab and/or web contents are
 * currently visible (from an accessibility perspective), or whether
 * they're obscured by another view.
 */
public void updateAccessibilityVisibility() {
    View view = getView();
    if (view != null) {
        int importantForAccessibility = isObscuredByAnotherViewForAccessibility()
                ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : View.IMPORTANT_FOR_ACCESSIBILITY_YES;
        if (view.getImportantForAccessibility() != importantForAccessibility) {
            view.setImportantForAccessibility(importantForAccessibility);
            view.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        }
    }

    ContentViewCore cvc = getContentViewCore();
    if (cvc != null) {
        boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility()
                || isShowingSadTab();
        cvc.setObscuredByAnotherView(isWebContentObscured);
    }
}
 
源代码4 项目: 365browser   文件: Tab.java
/**
 * Update whether or not the current native tab and/or web contents are
 * currently visible (from an accessibility perspective), or whether
 * they're obscured by another view.
 */
public void updateAccessibilityVisibility() {
    View view = getView();
    if (view != null) {
        int importantForAccessibility = isObscuredByAnotherViewForAccessibility()
                ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : View.IMPORTANT_FOR_ACCESSIBILITY_YES;
        if (view.getImportantForAccessibility() != importantForAccessibility) {
            view.setImportantForAccessibility(importantForAccessibility);
            view.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        }
    }

    ContentViewCore cvc = getContentViewCore();
    if (cvc != null) {
        boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility()
                || isShowingSadTab();
        cvc.setObscuredByAnotherView(isWebContentObscured);
    }
}
 
源代码5 项目: android_9.0.0_r45   文件: AdapterView.java
/**
 * Sets the view to show if the adapter is empty
 */
@android.view.RemotableViewMethod
public void setEmptyView(View emptyView) {
    mEmptyView = emptyView;

    // If not explicitly specified this view is important for accessibility.
    if (emptyView != null
            && emptyView.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        emptyView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    final T adapter = getAdapter();
    final boolean empty = ((adapter == null) || adapter.isEmpty());
    updateEmptyStatus(empty);
}
 
源代码6 项目: letv   文件: AdapterView.java
@TargetApi(16)
public void setEmptyView(View emptyView) {
    boolean empty = true;
    this.mEmptyView = emptyView;
    if (VERSION.SDK_INT >= 16 && emptyView != null && emptyView.getImportantForAccessibility() == 0) {
        emptyView.setImportantForAccessibility(1);
    }
    T adapter = getAdapter();
    if (!(adapter == null || adapter.isEmpty())) {
        empty = false;
    }
    updateEmptyStatus(empty);
}
 
源代码7 项目: Dashchan   文件: DrawerLayout.java
static boolean includeChildForAccessibility(View child) {
	// If the child is not important for accessibility we make
	// sure this hides the entire subtree rooted at it as the
	// IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDATS is not
	// supported on older platforms but we want to hide the entire
	// content and not opened drawers if a drawer is opened.
	return child.getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
			&& child.getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_NO;
}
 
源代码8 项目: Klyph   文件: AdapterView.java
/**
 * Sets the view to show if the adapter is empty
 */
public void setEmptyView( View emptyView ) {
	mEmptyView = emptyView;

	if( android.os.Build.VERSION.SDK_INT >= 16 ) {
		// If not explicitly specified this view is important for accessibility.
		if ( emptyView != null && emptyView.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO ) {
			emptyView.setImportantForAccessibility( IMPORTANT_FOR_ACCESSIBILITY_YES );
		}
	}

	final T adapter = getAdapter();
	final boolean empty = ( ( adapter == null ) || adapter.isEmpty() );
	updateEmptyStatus( empty );
}
 
源代码9 项目: android_9.0.0_r45   文件: AbsSpinner.java
/**
 * @see android.view.View#measure(int, int)
 *
 * Figure out the dimensions of this Spinner. The width comes from
 * the widthMeasureSpec as Spinnners can't have their width set to
 * UNSPECIFIED. The height is based on the height of the selected item
 * plus padding.
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize;
    int heightSize;

    mSpinnerPadding.left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft
            : mSelectionLeftPadding;
    mSpinnerPadding.top = mPaddingTop > mSelectionTopPadding ? mPaddingTop
            : mSelectionTopPadding;
    mSpinnerPadding.right = mPaddingRight > mSelectionRightPadding ? mPaddingRight
            : mSelectionRightPadding;
    mSpinnerPadding.bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom
            : mSelectionBottomPadding;

    if (mDataChanged) {
        handleDataChanged();
    }

    int preferredHeight = 0;
    int preferredWidth = 0;
    boolean needsMeasuring = true;

    int selectedPosition = getSelectedItemPosition();
    if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
        // Try looking in the recycler. (Maybe we were measured once already)
        View view = mRecycler.get(selectedPosition);
        if (view == null) {
            // Make a new one
            view = mAdapter.getView(selectedPosition, null, this);

            if (view.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
                view.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
            }
        }

        if (view != null) {
            // Put in recycler for re-measuring and/or layout
            mRecycler.put(selectedPosition, view);

            if (view.getLayoutParams() == null) {
                mBlockLayoutRequests = true;
                view.setLayoutParams(generateDefaultLayoutParams());
                mBlockLayoutRequests = false;
            }
            measureChild(view, widthMeasureSpec, heightMeasureSpec);

            preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
            preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;

            needsMeasuring = false;
        }
    }

    if (needsMeasuring) {
        // No views -- just use padding
        preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom;
        if (widthMode == MeasureSpec.UNSPECIFIED) {
            preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right;
        }
    }

    preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight());
    preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth());

    heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0);
    widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0);

    setMeasuredDimension(widthSize, heightSize);
    mHeightMeasureSpec = heightMeasureSpec;
    mWidthMeasureSpec = widthMeasureSpec;
}
 
源代码10 项目: letv   文件: ViewCompatJB.java
public static int getImportantForAccessibility(View view) {
    return view.getImportantForAccessibility();
}
 
/** See {@link View#isImportantForAccessibility()}. */
public static boolean isImportantForAccessibility(View view) {
  if (view == null) {
    return false;
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    return view.isImportantForAccessibility();
  } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
    // Prior to Jelly Bean, all Views were considered important for accessibility.
    return true;
  } else {
    // On APIs between 16 and 21, we must piece together accessibility importance from the
    // available properties. We return false incorrectly for some cases where unretrievable
    // listeners prevent us from determining importance.

    // If the developer marked the view as explicitly not important, it isn't.
    int mode = view.getImportantForAccessibility();
    if ((mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO)
        || (mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)) {
      return false;
    }

    // No parent view can be hiding us. (APIs 19 to 21)
    ViewParent parent = view.getParent();
    while (parent instanceof View) {
      if (((View) parent).getImportantForAccessibility()
          == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
        return false;
      }
      parent = parent.getParent();
    }

    // Interrogate the view's other properties to determine importance.
    return (mode == View.IMPORTANT_FOR_ACCESSIBILITY_YES)
        || isActionableForAccessibility(view)
        || hasListenersForAccessibility(view)
        || (view.getAccessibilityNodeProvider() != null)
        || (ViewCompat.getAccessibilityLiveRegion(view)
            != ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE);
  }
}
 
源代码12 项目: MiBandDecompiled   文件: am.java
public static int c(View view)
{
    return view.getImportantForAccessibility();
}
 
源代码13 项目: CodenameOne   文件: ViewCompatJB.java
public static int getImportantForAccessibility(View view) {
    return view.getImportantForAccessibility();
}
 
源代码14 项目: adt-leanback-support   文件: ViewCompatJB.java
public static int getImportantForAccessibility(View view) {
    return view.getImportantForAccessibility();
}
 
源代码15 项目: Klyph   文件: AbsHListView.java
/**
 * Get a view and have it show the data associated with the specified position. This is called when we have already discovered
 * that the view is not available for reuse in the recycle bin. The only choices left are converting an old view or making a new
 * one.
 * 
 * @param position
 *           The position to display
 * @param isScrap
 *           Array of at least 1 boolean, the first entry will become true if the returned view was taken from the scrap heap,
 *           false if otherwise.
 * 
 * @return A view displaying the data associated with the specified position
 */
@SuppressLint ( "NewApi" )
protected View obtainView( int position, boolean[] isScrap ) {
	isScrap[0] = false;
	View scrapView;

	scrapView = mRecycler.getTransientStateView( position );
	if ( scrapView != null ) {
		return scrapView;
	}

	scrapView = mRecycler.getScrapView( position );

	View child;
	if ( scrapView != null ) {
		child = mAdapter.getView( position, scrapView, this );

		if ( android.os.Build.VERSION.SDK_INT >= 16 ) {
			if ( child.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO ) {
				child.setImportantForAccessibility( IMPORTANT_FOR_ACCESSIBILITY_YES );
			}
		}

		if ( child != scrapView ) {
			mRecycler.addScrapView( scrapView, position );
			if ( mCacheColorHint != 0 ) {
				child.setDrawingCacheBackgroundColor( mCacheColorHint );
			}
		} else {
			isScrap[0] = true;
			child.onFinishTemporaryDetach();
		}
	} else {
		child = mAdapter.getView( position, null, this );

		if ( android.os.Build.VERSION.SDK_INT >= 16 ) {
			if ( child.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO ) {
				child.setImportantForAccessibility( IMPORTANT_FOR_ACCESSIBILITY_YES );
			}
		}

		if ( mCacheColorHint != 0 ) {
			child.setDrawingCacheBackgroundColor( mCacheColorHint );
		}
	}

	if ( mAdapterHasStableIds ) {
		final ViewGroup.LayoutParams vlp = child.getLayoutParams();
		LayoutParams lp;
		if ( vlp == null ) {
			lp = (LayoutParams) generateDefaultLayoutParams();
		} else if ( !checkLayoutParams( vlp ) ) {
			lp = (LayoutParams) generateLayoutParams( vlp );
		} else {
			lp = (LayoutParams) vlp;
		}
		lp.itemId = mAdapter.getItemId( position );
		child.setLayoutParams( lp );
	}

	if ( mAccessibilityManager.isEnabled() ) {
		if ( mAccessibilityDelegate == null ) {
			mAccessibilityDelegate = new ListItemAccessibilityDelegate();
		}

		// TODO: implement this ( hidden by google )
		// if (child.getAccessibilityDelegate() == null) {
		// child.setAccessibilityDelegate(mAccessibilityDelegate);
		// }
	}

	return child;
}
 
源代码16 项目: V.FlyoutTest   文件: ViewCompatJB.java
public static int getImportantForAccessibility(View view) {
    return view.getImportantForAccessibility();
}
 
源代码17 项目: guideshow   文件: ViewCompatJB.java
public static int getImportantForAccessibility(View view) {
    return view.getImportantForAccessibility();
}
 
 方法所在类
 同类方法