当前位置: 首页>>代码示例>>Java>>正文


Java Resources.NotFoundException方法代码示例

本文整理汇总了Java中android.content.res.Resources.NotFoundException方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.NotFoundException方法的具体用法?Java Resources.NotFoundException怎么用?Java Resources.NotFoundException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.NotFoundException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTintedDrawable

import android.content.res.Resources; //导入方法依赖的package包/类
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
    @DrawableRes int id, @AttrRes int tintAttrId) {
  boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
  if (!attributeFound) {
    throw new Resources.NotFoundException("Required tint color attribute with name "
        + context.getResources().getResourceEntryName(tintAttrId)
        + " and attribute ID "
        + tintAttrId
        + " was not found.");
  }

  Drawable drawable = ContextCompat.getDrawable(context, id);
  drawable = DrawableCompat.wrap(drawable.mutate());
  int color = ContextCompat.getColor(context, VALUE.resourceId);
  DrawableCompat.setTint(drawable, color);
  return drawable;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Utils.java

示例2: requestRobotSetup

import android.content.res.Resources; //导入方法依赖的package包/类
private void requestRobotSetup() {
  if (controllerService == null) return;

  HardwareFactory factory;
  RobotConfigFile file = cfgFileMgr.getActiveConfigAndUpdateUI();
  HardwareFactory hardwareFactory = new HardwareFactory(context);
  try {
    hardwareFactory.setXmlPullParser(file.getXml());
  } catch (Resources.NotFoundException e) {
    file = RobotConfigFile.noConfig(cfgFileMgr);
    hardwareFactory.setXmlPullParser(file.getXml());
    cfgFileMgr.setActiveConfigAndUpdateUI(false, file);
  }
  factory = hardwareFactory;

  eventLoop = new FtcEventLoop(factory, createOpModeRegister(), callback, this, programmingModeController);
  FtcEventLoopIdle idleLoop = new FtcEventLoopIdle(factory, callback, this, programmingModeController);

  controllerService.setCallback(callback);
  controllerService.setupRobot(eventLoop, idleLoop);

  passReceivedUsbAttachmentsToEventLoop();
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:24,代码来源:FtcRobotControllerActivity.java

示例3: getLength

import android.content.res.Resources; //导入方法依赖的package包/类
private int getLength(ImageRequest imageRequest) {
  AssetFileDescriptor fd = null;
  try {
    fd = mResources.openRawResourceFd(getResourceId(imageRequest));
    return (int) fd.getLength();
  } catch (Resources.NotFoundException e) {
    return -1;
  } finally {
    try {
      if (fd != null) {
        fd.close();
      }
    } catch (IOException ignored) {
      // There's nothing we can do with the exception when closing descriptor.
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:LocalResourceFetchProducer.java

示例4: testNotMatchingPasswords

import android.content.res.Resources; //导入方法依赖的package包/类
@Test
public void testNotMatchingPasswords() throws Resources.NotFoundException {
    Editable mockEditable = mock(Editable.class);
    Editable mockEditable2 = mock(Editable.class);
    int color = 50;
    String text = "message";

    when(mPasswordInput.getText()).thenReturn(mockEditable);
    when(mockEditable.toString()).thenReturn("validPassw0rd");
    when(mockEditable2.toString()).thenReturn("validpassword");
    when(mResources.getColor(R.color.red)).thenReturn(color);
    when(mContext.getString(R.string.not_matching_passwords)).thenReturn(text);

    mPasswordMatchTextWatcher.afterTextChanged(mockEditable2);
    verify(mIcon).setImageResource(R.drawable.ic_cancel);
    verify(mText).setText(text);
    verify(mText).setTextColor(color);
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:19,代码来源:PasswordMatchTextWatcherTest.java

示例5: addChildView

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 *
 * @param parentResolver
 * @param childResolver
 * @throws Resources.NotFoundException
 */
protected void addChildView(T parentResolver, T childResolver) throws Resources.NotFoundException {
    ExpandableViewBinder<T, View> parentBinder = getBinderForResolver(parentResolver);
    if(parentBinder != null && parentBinder.isParent()){
        ExpandableViewBinder<T, View> childViewBinder = new ExpandableViewBinder<>(childResolver);
        parentBinder.getChildList().add(childViewBinder);
        if(parentBinder.isExpanded()){
            int position;
            position = getViewBinderList().indexOf(parentBinder) + parentBinder.getChildList().size();
            getViewBinderList().add(position, childViewBinder);
            childViewBinder.setParentViewBinder(parentBinder);
            childViewBinder.bindParentPosition(getParentPosition(parentBinder));
            childViewBinder.bindChildPosition(getChildPosition(parentBinder, childViewBinder));
            notifyItemInserted(position);
        }
    }
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:23,代码来源:ExpandableViewAdapter.java

示例6: getSubtypeDisplayNameInternal

import android.content.res.Resources; //导入方法依赖的package包/类
@NonNull
private static String getSubtypeDisplayNameInternal(@NonNull final InputMethodSubtype subtype,
        @NonNull final Locale displayLocale) {
    final String replacementString = getReplacementString(subtype, displayLocale);
    // TODO: rework this for multi-lingual subtypes
    final int nameResId = subtype.getNameResId();
    final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
        @Override
        protected String job(final Resources res) {
            try {
                return res.getString(nameResId, replacementString);
            } catch (Resources.NotFoundException e) {
                // TODO: Remove this catch when InputMethodManager.getCurrentInputMethodSubtype
                // is fixed.
                Log.w(TAG, "Unknown subtype: mode=" + subtype.getMode()
                        + " nameResId=" + subtype.getNameResId()
                        + " locale=" + subtype.getLocale()
                        + " extra=" + subtype.getExtraValue()
                        + "\n" + DebugLogUtils.getStackTrace());
                return "";
            }
        }
    };
    return StringUtils.capitalizeFirstCodePoint(
            getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:27,代码来源:SubtypeLocaleUtils.java

示例7: getFloat

import android.content.res.Resources; //导入方法依赖的package包/类
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static float getFloat(Context context, @DimenRes int id) {
  TypedValue value = VALUE;
  context.getResources().getValue(id, value, true);
  if (value.type == TypedValue.TYPE_FLOAT) {
    return value.getFloat();
  }
  throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id)
      + " type #0x" + Integer.toHexString(value.type) + " is not valid");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:Utils.java

示例8: onCreate

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Override the dialog's width if we're running in an eligible layout qualifier.
    try {
        getWindow().setLayout(getContext().getResources().getDimensionPixelSize(
                R.dimen.nptp_bottom_sheet_dialog_width), ViewGroup.LayoutParams.MATCH_PARENT);
    } catch (Resources.NotFoundException nfe) {
        // Do nothing.
    }
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:12,代码来源:BottomSheetNumberPadTimePickerDialog.java

示例9: getReadmeText

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Returns contents of `custom_ca.txt` file from assets as CharSequence.
 *
 * @return contents of custom_ca.txt file
 */
private CharSequence getReadmeText() {
    String rtn = "";
    try {
        InputStream stream = getResources().openRawResource(R.raw.custom_ca);
        java.util.Scanner s = new java.util.Scanner(stream)
                .useDelimiter("\\A");
        rtn = s.hasNext() ? s.next() : "";
    } catch (Resources.NotFoundException e) {
        Log.e(LOG_TAG, "License couldn't be retrieved", e);
    }
    return rtn;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:CustomCASample.java

示例10: getResourceUri

import android.content.res.Resources; //导入方法依赖的package包/类
@Nullable
private Uri getResourceUri(Integer model) {
  try {
    return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
        + resources.getResourcePackageName(model) + '/'
        + resources.getResourceTypeName(model) + '/'
        + resources.getResourceEntryName(model));
  } catch (Resources.NotFoundException e) {
    if (Log.isLoggable(TAG, Log.WARN)) {
      Log.w(TAG, "Received invalid resource id: " + model, e);
    }
    return null;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ResourceLoader.java

示例11: get

import android.content.res.Resources; //导入方法依赖的package包/类
public static int get(Context context, int res) {
    try {
        return ContextCompat.getColor(context, res);
    } catch (Resources.NotFoundException e) {
        return res;
    }
}
 
开发者ID:jrvansuita,项目名称:MaterialAbout,代码行数:8,代码来源:ColorUtil.java

示例12: replaceTargetDrawablesIfPresent

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Searches the given package for a resource to use to replace the Drawable on the
 * target with the given resource id
 * @param component of the .apk that contains the resource
 * @param name of the metadata in the .apk
 * @param existingResId the resource id of the target to search for
 * @return true if found in the given package and replaced at least one target Drawables
 */
public boolean replaceTargetDrawablesIfPresent(ComponentName component, String name,
            int existingResId) {
    if (existingResId == 0) return false;

    boolean replaced = false;
    if (component != null) {
        try {
            PackageManager packageManager = getContext().getPackageManager();
            // Look for the search icon specified in the activity meta-data
            Bundle metaData = packageManager.getActivityInfo(
                    component, PackageManager.GET_META_DATA).metaData;
            if (metaData != null) {
                int iconResId = metaData.getInt(name);
                if (iconResId != 0) {
                    Resources res = packageManager.getResourcesForActivity(component);
                    replaced = replaceTargetDrawables(res, existingResId, iconResId);
                }
            }
        } catch (NameNotFoundException e) {
            Log.w(THIS_FILE, "Failed to swap drawable; "
                    + component.flattenToShortString() + " not found", e);
        } catch (Resources.NotFoundException nfe) {
            Log.w(THIS_FILE, "Failed to swap drawable from "
                    + component.flattenToShortString(), nfe);
        }
    }
    if (!replaced) {
        // Restore the original drawable
        replaceTargetDrawables(getContext().getResources(), existingResId, existingResId);
    }
    return replaced;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:41,代码来源:GlowPadView.java

示例13: applyInvariantDeviceProfileOverrides

import android.content.res.Resources; //导入方法依赖的package包/类
public void applyInvariantDeviceProfileOverrides(InvariantDeviceProfile inv, DisplayMetrics dm) {
    int numRows = -1;
    int numColumns = -1;
    float iconSize = -1;

    try {
        int resId = getResources().getIdentifier(RES_GRID_NUM_ROWS,
                "integer", getPackageName());
        if (resId > 0) {
            numRows = getResources().getInteger(resId);
        }

        resId = getResources().getIdentifier(RES_GRID_NUM_COLUMNS,
                "integer", getPackageName());
        if (resId > 0) {
            numColumns = getResources().getInteger(resId);
        }

        resId = getResources().getIdentifier(RES_GRID_ICON_SIZE_DP,
                "dimen", getPackageName());
        if (resId > 0) {
            int px = getResources().getDimensionPixelSize(resId);
            iconSize = Utilities.dpiFromPx(px, dm);
        }
    } catch (Resources.NotFoundException ex) {
        Log.e(TAG, "Invalid Partner grid resource!", ex);
        return;
    }

    if (numRows > 0 && numColumns > 0) {
        inv.numRows = numRows;
        inv.numColumns = numColumns;
    }

    if (iconSize > 0) {
        inv.iconSize = iconSize;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:39,代码来源:Partner.java

示例14: getIcon

import android.content.res.Resources; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
Drawable getIcon(Resources res, int resId) {
    Drawable result;
    try {
        result = res.getDrawableForDensity(resId, mIconDpi);
    } catch (Resources.NotFoundException e) {
        result = null;
    }

    return result;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:12,代码来源:ResolverActivity.java

示例15: atPositionOnView

import android.content.res.Resources; //导入方法依赖的package包/类
private Matcher<View> atPositionOnView(final int position, final int targetViewId) {
    return new TypeSafeMatcher<View>() {
        Resources resources = null;
        View childView;

        public void describeTo(Description description) {
            String idDescription = Integer.toString(recyclerViewId);
            if (this.resources != null) {
                try {
                    idDescription = this.resources.getResourceName(recyclerViewId);
                } catch (Resources.NotFoundException var4) {
                    idDescription = String.format("%s (resource name not found)", recyclerViewId);
                }
            }

            description.appendText("RecyclerView with id: " + idDescription + " at position: " + position);
        }

        public boolean matchesSafely(View view) {

            this.resources = view.getResources();

            if (childView == null) {
                RecyclerView recyclerView =
                    (RecyclerView) view.getRootView().findViewById(recyclerViewId);
                if (recyclerView != null && recyclerView.getId() == recyclerViewId) {
                    RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(position);
                    if (viewHolder != null) {
                        childView = viewHolder.itemView;
                    }
                } else {
                    return false;
                }
            }

            if (targetViewId == -1) {
                return view == childView;
            } else {
                View targetView = childView.findViewById(targetViewId);
                return view == targetView;
            }
        }
    };
}
 
开发者ID:holidaycheck,项目名称:RecyclerViewInjectorAdapter,代码行数:45,代码来源:RecyclerViewMatcher.java


注:本文中的android.content.res.Resources.NotFoundException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。