android.support.annotation.CheckResult Java Examples
The following examples show how to use
android.support.annotation.CheckResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CondomCore.java From MiPushFramework with GNU General Public License v3.0 | 6 votes |
@CheckResult <T extends Throwable> List<ResolveInfo> proceedQuery( final OutboundType type, final Intent intent, final CondomCore.WrappedValueProcedureThrows<List<ResolveInfo>, T> procedure) throws T { return proceed(type, intent, Collections.<ResolveInfo>emptyList(), new CondomCore.WrappedValueProcedureThrows<List<ResolveInfo>, T>() { @Override public List<ResolveInfo> proceed() throws T { final List<ResolveInfo> candidates = procedure.proceed(); if (mOutboundJudge != null && getTargetPackage(intent) == null) { // Package-targeted intent is already filtered by OutboundJudge in proceed(). final Iterator<ResolveInfo> iterator = candidates.iterator(); while (iterator.hasNext()) { final ResolveInfo candidate = iterator.next(); final String pkg = type == OutboundType.QUERY_SERVICES ? candidate.serviceInfo.packageName : (type == OutboundType.QUERY_RECEIVERS ? candidate.activityInfo.packageName : null); if (pkg != null && shouldBlockRequestTarget(type, intent, pkg)) // Dry-run is checked inside shouldBlockRequestTarget() iterator.remove(); // TODO: Not safe to assume the list returned from PackageManager is modifiable. } } return candidates; }}); }
Example #2
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns a new instance with the specified ad set to the specified {@code state}. The ad * specified must currently either be in {@link #AD_STATE_UNAVAILABLE} or {@link * #AD_STATE_AVAILABLE}. * * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the * ad count specified later. Otherwise, {@code index} must be less than the current ad count. */ @CheckResult public AdGroup withAdState(@AdState int state, int index) { Assertions.checkArgument(count == C.LENGTH_UNSET || index < count); @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1); Assertions.checkArgument( states[index] == AD_STATE_UNAVAILABLE || states[index] == AD_STATE_AVAILABLE || states[index] == state); long[] durationsUs = this.durationsUs.length == states.length ? this.durationsUs : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length); Uri[] uris = this.uris.length == states.length ? this.uris : Arrays.copyOf(this.uris, states.length); states[index] = state; return new AdGroup(count, states, uris, durationsUs); }
Example #3
Source File: CondomCore.java From MiPushFramework with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("TypeParameterHidesVisibleType") @CheckResult <R, T extends Throwable> R proceed(final OutboundType type, final Intent intent, final @Nullable R negative_value, final CondomCore.WrappedValueProcedureThrows<R, T> procedure) throws T { final String target_pkg = getTargetPackage(intent); if (target_pkg != null) { if (mBase.getPackageName().equals(target_pkg)) return procedure.proceed(); // Self-targeting request is allowed unconditionally if (shouldBlockRequestTarget(type, intent, target_pkg)) return negative_value; } final int original_flags = adjustIntentFlags(type, intent); try { return procedure.proceed(); } finally { intent.setFlags(original_flags); } }
Example #4
Source File: LogParser.java From XKnife-Android with Apache License 2.0 | 6 votes |
/** * Parse lev log utils . level. * * @param level the level * @return the log utils . level */ @CheckResult public static Level parseLev(String level) { switch (level) { case VERBOSE: return Level.VERBOSE; case DEBUG: return Level.DEBUG; case INFO: return Level.INFO; case WARN: return Level.WARN; case ERROR: return Level.ERROR; case FATAL: return Level.FATAL; case ASSERT: return Level.ASSERT; default: return Level.ASSERT; } }
Example #5
Source File: LogParser.java From XKnife-Android with Apache License 2.0 | 6 votes |
/** * Parse string. * * @param level the level * @return the string */ @CheckResult public static String parse(Level level) { switch (level) { case VERBOSE: return VERBOSE; case DEBUG: return DEBUG; case INFO: return INFO; case WARN: return WARN; case ERROR: return ERROR; case FATAL: return FATAL; case ASSERT: return ASSERT; default: return ASSERT; } }
Example #6
Source File: LogParser.java From XKnife-Android with Apache License 2.0 | 6 votes |
/** * Parse string. * * @param options the options * @return the string */ @CheckResult public static String parse(Options options) { switch (options) { case SILENT: return SILENT; case FILE: return FILE; case BYTES: return BYTES; case COUNT: return COUNT; case FORMAT: return FORMAT; case CLEAR: return CLEAR; case DUMP: return DUMP; default: return DUMP; } }
Example #7
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns a new instance with the specified ad set to the specified {@code state}. The ad * specified must currently either be in {@link #AD_STATE_UNAVAILABLE} or {@link * #AD_STATE_AVAILABLE}. * * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the * ad count specified later. Otherwise, {@code index} must be less than the current ad count. */ @CheckResult public AdGroup withAdState(@AdState int state, int index) { Assertions.checkArgument(count == C.LENGTH_UNSET || index < count); @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1); Assertions.checkArgument( states[index] == AD_STATE_UNAVAILABLE || states[index] == AD_STATE_AVAILABLE || states[index] == state); long[] durationsUs = this.durationsUs.length == states.length ? this.durationsUs : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length); Uri[] uris = this.uris.length == states.length ? this.uris : Arrays.copyOf(this.uris, states.length); states[index] = state; return new AdGroup(count, states, uris, durationsUs); }
Example #8
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad marked as having a load error. */ @CheckResult public AdPlaybackState withAdLoadError(int adGroupIndex, int adIndexInAdGroup) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdState(AD_STATE_ERROR, adIndexInAdGroup); return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #9
Source File: Util.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@CheckResult @Nullable public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int i) { if (drawable == null) { return null; } Drawable wrap = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintMode(wrap, Mode.SRC_IN); DrawableCompat.setTint(wrap, i); return wrap; }
Example #10
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns a new instance with the specified ad durations, in microseconds. */ @CheckResult public AdGroup withAdDurationsUs(long[] durationsUs) { Assertions.checkArgument(count == C.LENGTH_UNSET || durationsUs.length <= this.uris.length); if (durationsUs.length < this.uris.length) { durationsUs = copyDurationsUsWithSpaceForAdCount(durationsUs, uris.length); } return new AdGroup(count, states, uris, durationsUs); }
Example #11
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Returns a new instance with the specified {@code uri} set for the specified ad, and the ad * marked as {@link #AD_STATE_AVAILABLE}. The specified ad must currently be in {@link * #AD_STATE_UNAVAILABLE}, which is the default state. * * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the * ad count specified later. Otherwise, {@code index} must be less than the current ad count. */ @CheckResult public AdGroup withAdUri(Uri uri, int index) { Assertions.checkArgument(count == C.LENGTH_UNSET || index < count); @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1); Assertions.checkArgument(states[index] == AD_STATE_UNAVAILABLE); long[] durationsUs = this.durationsUs.length == states.length ? this.durationsUs : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length); Uri[] uris = Arrays.copyOf(this.uris, states.length); uris[index] = uri; states[index] = AD_STATE_AVAILABLE; return new AdGroup(count, states, uris, durationsUs); }
Example #12
Source File: OperationBuilder.java From neatle with MIT License | 5 votes |
/** * Creates the operation. Note that you still need to call {@link Operation#execute()} to start * the operation. * * @param device the device on which this operation will run * @return the created operation */ @CheckResult public Operation build(BluetoothDevice device) { if (device == null) { throw new IllegalArgumentException("Device cannot be null"); } return new OperationImpl(context, device, commands, retryCount, masterObserver); }
Example #13
Source File: ColorUtils.java From Protein with Apache License 2.0 | 5 votes |
/** * Set the alpha component of {@code color} to be {@code alpha}. */ public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha) { return modifyAlpha(color, (int) (255f * alpha)); }
Example #14
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad marked as played. */ @CheckResult public AdPlaybackState withPlayedAd(int adGroupIndex, int adIndexInAdGroup) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdState(AD_STATE_PLAYED, adIndexInAdGroup); return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #15
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * Called when property has empty value * @param propName */ @CheckResult protected Object convertEmptyProperty(String propName, Object originalValue) { switch (propName) { case Constants.Name.BACKGROUND_COLOR: return "transparent"; case Constants.Name.BORDER_RADIUS: case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS: case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS: case Constants.Name.BORDER_TOP_LEFT_RADIUS: case Constants.Name.BORDER_TOP_RIGHT_RADIUS: return 0; case Constants.Name.BORDER_WIDTH: case Constants.Name.BORDER_TOP_WIDTH: case Constants.Name.BORDER_LEFT_WIDTH: case Constants.Name.BORDER_RIGHT_WIDTH: case Constants.Name.BORDER_BOTTOM_WIDTH: return 0; case Constants.Name.BORDER_COLOR: case Constants.Name.BORDER_TOP_COLOR: case Constants.Name.BORDER_LEFT_COLOR: case Constants.Name.BORDER_RIGHT_COLOR: case Constants.Name.BORDER_BOTTOM_COLOR: return "black"; } return originalValue; }
Example #16
Source File: ColorUtils.java From Protein with Apache License 2.0 | 5 votes |
/** * Set the alpha component of {@code color} to be {@code alpha}. */ public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color, @IntRange(from = 0, to = 255) int alpha) { return (color & 0x00ffffff) | (alpha << 24); }
Example #17
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad durations, in microseconds. */ @CheckResult public AdPlaybackState withAdDurationsUs(long[][] adDurationUs) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); for (int adGroupIndex = 0; adGroupIndex < adGroupCount; adGroupIndex++) { adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdDurationsUs(adDurationUs[adGroupIndex]); } return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #18
Source File: Util.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@CheckResult @Nullable public static Drawable createTintedDrawable(@Nullable Drawable drawable, @NonNull ColorStateList colorStateList) { if (drawable == null) { return null; } Drawable wrap = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintList(wrap, colorStateList); return wrap; }
Example #19
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad URI. */ @CheckResult public AdPlaybackState withAdUri(int adGroupIndex, int adIndexInAdGroup, Uri uri) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdUri(uri, adIndexInAdGroup); return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #20
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Returns a new instance with the specified {@code uri} set for the specified ad, and the ad * marked as {@link #AD_STATE_AVAILABLE}. The specified ad must currently be in {@link * #AD_STATE_UNAVAILABLE}, which is the default state. * * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the * ad count specified later. Otherwise, {@code index} must be less than the current ad count. */ @CheckResult public AdGroup withAdUri(Uri uri, int index) { Assertions.checkArgument(count == C.LENGTH_UNSET || index < count); @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1); Assertions.checkArgument(states[index] == AD_STATE_UNAVAILABLE); long[] durationsUs = this.durationsUs.length == states.length ? this.durationsUs : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length); Uri[] uris = Arrays.copyOf(this.uris, states.length); uris[index] = uri; states[index] = AD_STATE_AVAILABLE; return new AdGroup(count, states, uris, durationsUs); }
Example #21
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad marked as skipped. */ @CheckResult public AdPlaybackState withSkippedAd(int adGroupIndex, int adIndexInAdGroup) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdState(AD_STATE_SKIPPED, adIndexInAdGroup); return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #22
Source File: WXComponent.java From weex-uikit with MIT License | 5 votes |
/** * Called when property has empty value * @param propName */ @CheckResult protected Object convertEmptyProperty(String propName, Object originalValue) { if (Constants.Name.BACKGROUND_COLOR.equals(propName)) { return "transparent"; } return originalValue; }
Example #23
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Returns an instance with all ads in the specified ad group skipped (except for those already * marked as played or in the error state). */ @CheckResult public AdPlaybackState withSkippedAdGroup(int adGroupIndex) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); adGroups[adGroupIndex] = adGroups[adGroupIndex].withAllAdsSkipped(); return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #24
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad durations, in microseconds. */ @CheckResult public AdPlaybackState withAdDurationsUs(long[][] adDurationUs) { AdGroup[] adGroups = Arrays.copyOf(this.adGroups, this.adGroups.length); for (int adGroupIndex = 0; adGroupIndex < adGroupCount; adGroupIndex++) { adGroups[adGroupIndex] = adGroups[adGroupIndex].withAdDurationsUs(adDurationUs[adGroupIndex]); } return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); }
Example #25
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified ad resume position, in microseconds. */ @CheckResult public AdPlaybackState withAdResumePositionUs(long adResumePositionUs) { if (this.adResumePositionUs == adResumePositionUs) { return this; } else { return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); } }
Example #26
Source File: AdPlaybackState.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** Returns an instance with the specified content duration, in microseconds. */ @CheckResult public AdPlaybackState withContentDurationUs(long contentDurationUs) { if (this.contentDurationUs == contentDurationUs) { return this; } else { return new AdPlaybackState(adGroupTimesUs, adGroups, adResumePositionUs, contentDurationUs); } }
Example #27
Source File: Util.java From prebid-mobile-android with Apache License 2.0 | 5 votes |
@CheckResult private static JSONArray removeEntryWithoutValue(@NonNull JSONArray array) throws JSONException { for (int i = 0; i < array.length(); i++) { Object value = array.opt(i); if (value != null) { if (value instanceof JSONObject) { JSONObject mapValue = (JSONObject) value; removeEntryWithoutValue(mapValue); if (mapValue.length() == 0) { array = getJsonArrayWithoutEntryByIndex(array, i); } } else if (value instanceof JSONArray) { JSONArray arrayValue = (JSONArray) value; arrayValue = removeEntryWithoutValue(arrayValue); array.put(i, arrayValue); if (arrayValue.length() == 0) { array = getJsonArrayWithoutEntryByIndex(array, i); } } else if (value instanceof String) { String stringValue = (String) value; if (stringValue.length() == 0) { array = getJsonArrayWithoutEntryByIndex(array, i); } } } } return array; }
Example #28
Source File: MainActivity.java From Synapse with Apache License 2.0 | 5 votes |
@CheckResult @Nullable private List<TrainedModelItem> getAllTrainedModelItems() { final List<Model> models = new ArrayList<>(); try { final List<DBModel> dbModels = Global.getInstance() .getSession() .getDBModelDao() .queryBuilder() .orderDesc(DBModelDao.Properties.CreatedTime) .list(); for (int i = 0, len = dbModels.size(); i < len; ++i) { models.add(DbHelper.dbModel2Model(dbModels.get(i))); } } catch (Exception e) { ExceptionHelper.getInstance() .caught(e); } if (models.isEmpty()) { return null; } final List<TrainedModelItem> items = new ArrayList<>(models.size()); for (Model model : models) { items.add(new TrainedModelItem(model)); } return items; }
Example #29
Source File: LogCmdHelper.java From XKnife-Android with Apache License 2.0 | 5 votes |
/** * logcat Tag:I *:S * * @param tag log的tag 不输入代表仅仅通过lev做筛选 * @param lev log的级别 * @return the log cmd helper */ @CheckResult public LogCmdHelper filter(@Nullable String tag, LogParser.Level lev) { String levStr = LogParser.parse(lev); if (!TextUtils.isEmpty(tag)) { commandLine.add(tag.trim() + ":" + levStr); commandLine.add("*:S"); } else { commandLine.add("*:" + levStr); } return this; }
Example #30
Source File: Util.java From prebid-mobile-android with Apache License 2.0 | 5 votes |
@CheckResult private static JSONArray getJsonArrayWithoutEntryByIndex(JSONArray jsonArray, int pos) throws JSONException { JSONArray result = new JSONArray(); for (int i = 0; i < jsonArray.length(); i++) { if (i != pos) { result.put(jsonArray.get(i)); } } return result; }