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 Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #2
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 Project: XKnife-Android   Author: SkySeraph-XKnife   File: LogParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 #4
Source Project: XKnife-Android   Author: SkySeraph-XKnife   File: LogParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 #5
Source Project: XKnife-Android   Author: SkySeraph-XKnife   File: LogParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 #6
Source Project: MiPushFramework   Author: MiPushFramework   File: CondomCore.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source Project: MiPushFramework   Author: MiPushFramework   File: CondomCore.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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 #8
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #9
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
@CheckResult
private static @AdState int[] copyStatesWithSpaceForAdCount(@AdState int[] states, int count) {
  int oldStateCount = states.length;
  int newStateCount = Math.max(count, oldStateCount);
  states = Arrays.copyOf(states, newStateCount);
  Arrays.fill(states, oldStateCount, newStateCount, AD_STATE_UNAVAILABLE);
  return states;
}
 
Example #10
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
@CheckResult
private static long[] copyDurationsUsWithSpaceForAdCount(long[] durationsUs, int count) {
  int oldDurationsUsCount = durationsUs.length;
  int newDurationsUsCount = Math.max(count, oldDurationsUsCount);
  durationsUs = Arrays.copyOf(durationsUs, newDurationsUsCount);
  Arrays.fill(durationsUs, oldDurationsUsCount, newDurationsUsCount, C.TIME_UNSET);
  return durationsUs;
}
 
Example #11
Source Project: Bus-Tracking-Parent   Author: Rjtsahu   File: Toasty.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static
@CheckResult
Toast custom(@NonNull Context context, @NonNull CharSequence message, @DrawableRes int iconRes,
             @ColorInt int textColor, @ColorInt int tintColor, int duration,
             boolean withIcon, boolean shouldTint) {
    return custom(context, message, ToastyUtils.getDrawable(context, iconRes), textColor,
            tintColor, duration, withIcon, shouldTint);
}
 
Example #12
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #13
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #14
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #15
Source Project: Protein   Author: gejiaheng   File: ColorUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 #16
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #17
Source Project: Bus-Tracking-Parent   Author: Rjtsahu   File: Toasty.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static
@CheckResult
Toast custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
             @ColorInt int textColor, @ColorInt int tintColor, int duration,
             boolean withIcon, boolean shouldTint) {
    final Toast currentToast = new Toast(context);
    final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.toasty_layout, null);
    final ImageView toastIcon = (ImageView) toastLayout.findViewById(R.id.toast_icon);
    final TextView toastTextView = (TextView) toastLayout.findViewById(R.id.toast_text);
    Drawable drawableFrame;

    if (shouldTint)
        drawableFrame = ToastyUtils.tint9PatchDrawableFrame(context, tintColor);
    else
        drawableFrame = ToastyUtils.getDrawable(context, R.drawable.toast_frame);
    ToastyUtils.setBackground(toastLayout, drawableFrame);

    if (withIcon) {
        if (icon == null)
            throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
        ToastyUtils.setBackground(toastIcon, icon);
    } else
        toastIcon.setVisibility(View.GONE);

    toastTextView.setTextColor(textColor);
    toastTextView.setText(message);
    toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL));

    currentToast.setView(toastLayout);
    currentToast.setDuration(duration);
    return currentToast;
}
 
Example #18
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #19
Source Project: TelePlus-Android   Author: TelePlusDev   File: MediaCodecRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@CheckResult
private DecoderInitializationException copyWithFallbackException(
    DecoderInitializationException fallbackException) {
  return new DecoderInitializationException(
      getMessage(),
      getCause(),
      mimeType,
      secureDecoderRequired,
      decoderName,
      diagnosticInfo,
      fallbackException);
}
 
Example #20
Source Project: ucar-weex-core   Author: weexext   File: WXComponent.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 #21
Source Project: RetroMusicPlayer   Author: deepshooter   File: Util.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #22
Source Project: Synapse   Author: huazhouwang   File: ActivateFunction.java    License: Apache License 2.0 5 votes vote down vote up
@CheckResult
static Matrix sigmoid(@NonNull Matrix matrix) {
    Precondition.checkNotNull(matrix);

    final Matrix copy = matrix.copy();
    final double[] doubles = copy.getArray();

    for (int i = 0, len = doubles.length; i < len; ++i) {
            final double cur = -doubles[i];
            doubles[i] = 1D / (1D + Math.exp(cur));
    }

    return copy;
}
 
Example #23
Source Project: Protein   Author: gejiaheng   File: ColorUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 #24
Source Project: neatle   Author: inovait   File: OperationBuilder.java    License: MIT License 5 votes vote down vote up
/**
 * 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 #25
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #26
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #27
Source Project: RetroMusicPlayer   Author: deepshooter   File: Util.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #28
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #29
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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 #30
Source Project: TelePlus-Android   Author: TelePlusDev   File: AdPlaybackState.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** 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);
}