android.content.Context.isRestricted()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中android.content.Context.isRestricted()方法的一些代码示例,展示了Context.isRestricted()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.isRestricted()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:isRestricted

Context.isRestricted介绍

暂无

代码示例

代码示例来源:origin: oasisfeng/condom

@Override public boolean isRestricted() {
  return mBase.isRestricted();
}

代码示例来源:origin: Trumeet/MiPushFramework

@Override public boolean isRestricted() {
  return mBase.isRestricted();
}

代码示例来源:origin: yuliskov/SmartYouTubeTV

while (context != null) {
  try {
    if (!context.isRestricted()) {
      final Method method = context.getClass().getMethod(mMethodName, View.class);
      if (method != null) {

代码示例来源:origin: yuliskov/SmartYouTubeTV

@NonNull
  private void resolveMethod(@Nullable Context context, @NonNull String name) {
    while (context != null) {
      try {
        if (!context.isRestricted()) {
          final Method method = context.getClass().getMethod(mMethodName, ToggleButtonBase.class, boolean.class);
          if (method != null) {
            mResolvedMethod = method;
            mResolvedContext = context;
            return;
          }
        }
      } catch (NoSuchMethodException e) {
        // Failed to find method, keep searching up the hierarchy.
      }
      if (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
      } else {
        // Can't search up the hierarchy, null out and fail.
        context = null;
      }
    }
    final int id = mHostView.getId();
    final String idText = id == NO_ID ? "" : " with id '"
        + mHostView.getContext().getResources().getResourceEntryName(id) + "'";
    throw new IllegalStateException("Could not find method " + mMethodName
        + "(ToggleButtonBase, boolean) in a parent or ancestor Context for app:onCheckedChanged "
        + "attribute defined on view " + mHostView.getClass() + idText);
  }
}

代码示例来源:origin: stackoverflow.com

....
  case R.styleable.View_onClick:
  if (context.isRestricted()) {
    throw new IllegalStateException("The android:onClick attribute cannot "
        + "be used within a restricted context");

代码示例来源:origin: zzz40500/ThemeDemo

@NonNull
  private void resolveMethod(@Nullable Context context, @NonNull String name) {
    while (context != null) {
      try {
        if (!context.isRestricted()) {
          final Method method = context.getClass().getMethod(mMethodName, View.class);
          if (method != null) {
            mResolvedMethod = method;
            mResolvedContext = context;
            return;
          }
        }
      } catch (NoSuchMethodException e) {
        // Failed to find method, keep searching up the hierarchy.
      }
      if (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
      } else {
        // Can't search up the hierarchy, null out and fail.
        context = null;
      }
    }
    final int id = mHostView.getId();
    final String idText = id == View.NO_ID ? "" : " with id '"
        + mHostView.getContext().getResources().getResourceEntryName(id) + "'";
    throw new IllegalStateException("Could not find method " + mMethodName
        + "(View) in a parent or ancestor Context for android:onClick "
        + "attribute defined on view " + mHostView.getClass() + idText);
  }
}

代码示例来源:origin: geminiwen/SkinSprite

@NonNull
  private void resolveMethod(@Nullable Context context, @NonNull String name) {
    while (context != null) {
      try {
        if (!context.isRestricted()) {
          final Method method = context.getClass().getMethod(mMethodName, View.class);
          if (method != null) {
            mResolvedMethod = method;
            mResolvedContext = context;
            return;
          }
        }
      } catch (NoSuchMethodException e) {
        // Failed to find method, keep searching up the hierarchy.
      }
      if (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
      } else {
        // Can't search up the hierarchy, null out and fail.
        context = null;
      }
    }
    final int id = mHostView.getId();
    final String idText = id == View.NO_ID ? "" : " with id '"
        + mHostView.getContext().getResources().getResourceEntryName(id) + "'";
    throw new IllegalStateException("Could not find method " + mMethodName
        + "(View) in a parent or ancestor Context for android:onClick "
        + "attribute defined on view " + mHostView.getClass() + idText);
  }
}

代码示例来源:origin: stackoverflow.com

public EditText(final Context context, final AttributeSet attrs, final int defStyle) 
 {
  super(context, attrs, defStyle);
  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EditText);
  final int N = a.getIndexCount();
  for (int i = 0; i < N; ++i)
  {
   int attr = a.getIndex(i);
   switch (attr)
   {
     case R.styleable.EditText_required: {
       if (context.isRestricted()) {
         throw new IllegalStateException("The "+getClass().getCanonicalName()+":required attribute cannot "
             + "be used within a restricted context");
       }
       boolean defaultValue = false;
       final String required = a.getBoolean(attr, defaultValue );
       //DO SOMETHING
       }
       break;
     }
     default: 
       break;
   }
  }
  a.recycle();
 }

代码示例来源:origin: wutongke/AndroidSkinAnimator

@NonNull
  private void resolveMethod(@Nullable Context context, @NonNull String name) {
    while (context != null) {
      try {
        if (!context.isRestricted()) {
          final Method method = context.getClass().getMethod(mMethodName, View.class);
          if (method != null) {
            mResolvedMethod = method;
            mResolvedContext = context;
            return;
          }
        }
      } catch (NoSuchMethodException e) {
        // Failed to find method, keep searching up the hierarchy.
      }
      if (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
      } else {
        // Can't search up the hierarchy, null out and fail.
        context = null;
      }
    }
    final int id = mHostView.getId();
    final String idText = id == View.NO_ID ? "" : " with id '"
        + mHostView.getContext().getResources().getResourceEntryName(id) + "'";
    throw new IllegalStateException("Could not find method " + mMethodName
        + "(View) in a parent or ancestor Context for android:onClick "
        + "attribute defined on view " + mHostView.getClass() + idText);
  }
}

代码示例来源:origin: stackoverflow.com

if (context.isRestricted()) {
  throw new IllegalStateException("The "+getClass().getCanonicalName()+":onKeyLongPress attribute cannot "
      + "be used within a restricted context");

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

if (mContext.isRestricted()) {
  throw new IllegalStateException("The android:onClick attribute cannot "
      + "be used within a restricted context");

代码示例来源:origin: com.willowtreeapps/oak-demos

if (mContext.isRestricted()) {
  throw new IllegalStateException("The android:onClick attribute cannot "
      + "be used within a restricted context");

相关文章

微信公众号

最新文章

更多

Context类方法