當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。