Java 类android.support.annotation.RestrictTo 实例源码

项目:JobSchedulerCompat    文件:JobScheduler.java   
/**
 * Notify the scheduler that a job finished executing.
 *
 * Handle scheduler changes by cancelling it in the old scheduler and scheduling it in the new scheduler.
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void onJobCompleted(int jobId, boolean needsReschedule) {
    synchronized (JobStore.LOCK) {
        JobStatus jobStatus = jobStore.getJob(jobId);
        if (jobStatus != null) {
            jobStore.remove(jobId);
            if (needsReschedule) {
                jobStore.add(getRescheduleJobForFailure(jobStatus));
            } else if (jobStatus.isPeriodic()) {
                jobStore.add(getRescheduleJobForPeriodic(jobStatus));
            }
            getSchedulerForTag(context, jobStatus.getSchedulerTag()).onJobCompleted(jobId, needsReschedule);
        }
    }
}
项目:RxAndroidBle    文件:ClientOperationQueueImpl.java   
@Override
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public <T> Observable<T> queue(final Operation<T> operation) {
    return Observable.create(new Action1<Emitter<T>>() {
        @Override
        public void call(Emitter<T> tEmitter) {
            final FIFORunnableEntry entry = new FIFORunnableEntry<>(operation, tEmitter);
            tEmitter.setCancellation(new Cancellable() {
                @Override
                public void cancel() throws Exception {
                    if (queue.remove(entry)) {
                        logOperationRemoved(operation);
                    }
                }
            });
            logOperationQueued(operation);
            queue.add(entry);
        }
    }, Emitter.BackpressureMode.NONE);
}
项目:RxAndroidBle    文件:ConnectionOperationQueueImpl.java   
@Override
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public synchronized <T> Observable<T> queue(final Operation<T> operation) {
    if (!shouldRun) {
        return Observable.error(disconnectionException);
    }
    return Observable.create(new Action1<Emitter<T>>() {
        @Override
        public void call(Emitter<T> tEmitter) {
            final FIFORunnableEntry entry = new FIFORunnableEntry<>(operation, tEmitter);

            tEmitter.setCancellation(new Cancellable() {
                @Override
                public void cancel() throws Exception {
                    if (queue.remove(entry)) {
                        logOperationRemoved(operation);
                    }
                }
            });

            logOperationQueued(operation);
            queue.add(entry);
        }
    }, Emitter.BackpressureMode.NONE);
}
项目:lottie-android    文件:LottieValueCallback.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
public T getValueInternal(
    float startFrame,
    float endFrame,
    T startValue,
    T endValue,
    float linearKeyframeProgress,
    float interpolatedKeyframeProgress,
    float overallProgress
) {
  if (value != null) {
    return value;
  }
  return getValue(startFrame, endFrame, startValue, endValue, linearKeyframeProgress,
      interpolatedKeyframeProgress, overallProgress);
}
项目:lottie-android    文件:KeyPath.java   
/**
 * Returns whether they key matches at the specified depth.
 */
@SuppressWarnings("RedundantIfStatement")
@RestrictTo(RestrictTo.Scope.LIBRARY)
public boolean matches(String key, int depth) {
  if (isContainer(key)) {
    // This is an artificial layer we programatically create.
    return true;
  }
  if (depth >= keys.size()) {
    return false;
  }
  if (keys.get(depth).equals(key) ||
      keys.get(depth).equals("**") ||
      keys.get(depth).equals("*")) {
    return true;
  }
  return false;
}
项目:lottie-android    文件:KeyPath.java   
/**
 * For a given key and depth, returns how much the depth should be incremented by when
 * resolving a keypath to children.
 *
 * This can be 0 or 2 when there is a globstar and the next key either matches or doesn't match
 * the current key.
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public int incrementDepthBy(String key, int depth) {
  if (isContainer(key)) {
    // If it's a container then we added programatically and it isn't a part of the keypath.
    return 0;
  }
  if (!keys.get(depth).equals("**")) {
    // If it's not a globstar then it is part of the keypath.
    return 1;
  }
  if (depth == keys.size() - 1) {
    // The last key is a globstar.
    return 0;
  }
  if (keys.get(depth + 1).equals(key)) {
    // We are a globstar and the next key is our current key so consume both.
    return 2;
  }
  return 0;
}
项目:MaterialPreference    文件:PreferenceManager.java   
/**
 * Inflates a preference hierarchy from XML. If a preference hierarchy is
 * given, the new preference hierarchies will be merged in.
 *
 * @param context The context of the resource.
 * @param resId The resource ID of the XML to inflate.
 * @param rootPreferences Optional existing hierarchy to merge the new
 *            hierarchies into.
 * @return The root hierarchy (if one was not provided, the new hierarchy's
 *         root).
 * @hide
 */
@RestrictTo(LIBRARY_GROUP)
public PreferenceScreen inflateFromResource(Context context, int resId,
                                            PreferenceScreen rootPreferences) {
    // Block commits
    setNoCommit(true);

    final PreferenceInflater inflater = new PreferenceInflater(context, this);
    inflater.setDefaultPackages(getDefaultPackages());
    rootPreferences = (PreferenceScreen) inflater.inflate(resId, rootPreferences);
    rootPreferences.onAttachedToHierarchy(this);

    // Unblock commits
    setNoCommit(false);

    return rootPreferences;
}
项目:AndroidLife    文件:InvalidationTracker.java   
/**
 * Used by the generated code.
 *
 * @hide
 */
@SuppressWarnings("WeakerAccess")
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public InvalidationTracker(RoomDatabase database, String... tableNames) {
    mDatabase = database;
    mObservedTableTracker = new ObservedTableTracker(tableNames.length);
    mTableIdLookup = new ArrayMap<>();
    final int size = tableNames.length;
    mTableNames = new String[size];
    for (int id = 0; id < size; id++) {
        final String tableName = tableNames[id].toLowerCase(Locale.US);
        mTableIdLookup.put(tableName, id);
        mTableNames[id] = tableName;
    }
    mTableVersions = new long[tableNames.length];
    Arrays.fill(mTableVersions, 0);
}
项目:sectioned-recyclerview    文件:SectionedRecyclerViewAdapter.java   
/**
 * @hide
 * @deprecated
 */
@Override
@Deprecated
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final int getItemViewType(int position) {
  if (isHeader(position)) {
    return getHeaderViewType(positionManager.sectionId(position));
  } else if (isFooter(position)) {
    return getFooterViewType(positionManager.footerId(position));
  } else {
    ItemCoord sectionAndPos = getRelativePosition(position);
    return getItemViewType(
        sectionAndPos.section(),
        // offset section view positions
        sectionAndPos.relativePos(),
        position - (sectionAndPos.section() + 1));
  }
}
项目:GitHub    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override
public final void onBindViewHolder(BaseViewHolder holder, int adapterPosition,
    List<Object> payloads) {
  ItemBinder baseBinder = binders.get(holder.getItemViewType());

  int totalCount = 0;
  for (BaseDataManager dataManager : dataManagers) {
    totalCount += dataManager.getCount();
    if (adapterPosition < totalCount) {
      int itemPosition = getItemPositionInManager(adapterPosition);
      if (dataManager instanceof DataGroupManager) {
        dataManager = ((DataGroupManager) dataManager).getDataManagerForPosition(itemPosition);
      }
      //noinspection unchecked
      holder.setItem(dataManager.getItem(itemPosition));
      break;
    }
  }

  if (null == payloads || payloads.size() == 0) {
    //noinspection unchecked
    baseBinder.bindViewHolder(holder, holder.getItem());
  } else {
    //noinspection unchecked
    baseBinder.bindViewHolder(holder, holder.getItem(), payloads);
  }
}
项目:GitHub    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override public final int getItemCount() {
  int itemCount = 0;
  for (BaseDataManager dataManager : dataManagers) {
    itemCount += dataManager.size();
  }
  return itemCount;
}
项目:GitHub    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override
public final int getItemViewType(int adapterPosition) {
  ItemBinder baseBinder = getBinderForPosition(adapterPosition);
  if (null != baseBinder) {
    return binders.indexOf(baseBinder);
  }
  return super.getItemViewType(adapterPosition);
}
项目:JobSchedulerCompat    文件:PersistableBundle.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@RestrictTo(RestrictTo.Scope.LIBRARY)
public PersistableBundle(android.os.PersistableBundle bundle) {
    map = new HashMap<>(bundle.size());
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);
        if (value == null || value instanceof String || value instanceof Integer || value instanceof Long
                || value instanceof Double || value instanceof Boolean || value instanceof String[]
                || value instanceof int[] || value instanceof long[] || value instanceof double[]
                || value instanceof boolean[]) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1 && key.startsWith(PREFIX_BOOLEAN_COMPAT)) {
                key = key.substring(PREFIX_BOOLEAN_COMPAT.length());
                if (value instanceof Integer) {
                    Integer intValue = (Integer) value;
                    value = intValue != 0;
                } else if (value instanceof int[]) {
                    int[] intArrayValue = (int[]) value;
                    boolean[] boolArrayValue = new boolean[intArrayValue.length];
                    for (int i = 0; i < boolArrayValue.length; i++) {
                        boolArrayValue[i] = intArrayValue[i] != 0;
                    }
                    value = boolArrayValue;
                }
            }
            map.put(key, value);
        } else if (value instanceof android.os.PersistableBundle) {
            map.put(key, new PersistableBundle((android.os.PersistableBundle) value));
        } else {
            throw new IllegalArgumentException("Unsupported value type key=" + key + " value=" + value);
        }
    }
}
项目:JobSchedulerCompat    文件:PersistableBundle.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
@SuppressWarnings("unchecked")
public PersistableBundle(Map<String, ?> map, int depth) {
    if (depth <= 0) {
        this.map = new HashMap<>(0);
    } else {
        this.map = new HashMap<>(map);
        for (String key : this.map.keySet()) {
            Object object = this.map.get(key);
            if (object instanceof Map) {
                this.map.put(key, new PersistableBundle((Map<String, Object>) object, depth - 1));
            }
        }
    }
}
项目:JobSchedulerCompat    文件:PersistableBundle.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
public Map<String, ?> toMap(int depth) {
    if (depth <= 0) {
        return null;
    }
    Map<String, Object> map = new HashMap<>(this.map);
    for (String key : map.keySet()) {
        Object object = map.get(key);
        if (object instanceof PersistableBundle) {
            map.put(key, ((PersistableBundle) object).toMap(depth - 1));
        }
    }
    return map;
}
项目:JobSchedulerCompat    文件:JobParameters.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
public JobParameters(int jobId, PersistableBundle extras, Bundle transientExtras, boolean overrideDeadlineExpired,
                     Uri[] triggeredContentUris, String[] triggeredContentAuthorities) {
    this.jobId = jobId;
    this.extras = extras;
    this.transientExtras = transientExtras;
    this.overrideDeadlineExpired = overrideDeadlineExpired;
    this.triggeredContentUris = triggeredContentUris;
    this.triggeredContentAuthorities = triggeredContentAuthorities;
}
项目:JobSchedulerCompat    文件:JobScheduler.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
Scheduler getSchedulerForTag(Context context, String tag) {
    Scheduler scheduler = schedulers.get(tag);
    if (scheduler == null) {
        switch (tag) {
            case JobSchedulerSchedulerV26.TAG:
                scheduler = new JobSchedulerSchedulerV26(context);
                break;
            case JobSchedulerSchedulerV24.TAG:
                scheduler = new JobSchedulerSchedulerV24(context);
                break;
            case JobSchedulerSchedulerV21.TAG:
                scheduler = new JobSchedulerSchedulerV21(context);
                break;
            case GcmScheduler.TAG:
                scheduler = new GcmScheduler(context);
                break;
            case AlarmScheduler.TAG:
                scheduler = new AlarmScheduler(context);
                break;
            default:
                throw new IllegalArgumentException("Missing scheduler for tag " + tag);
        }
        schedulers.put(tag, scheduler);
    }
    return scheduler;
}
项目:ToggleButtons    文件:ToggleButton.java   
@RestrictTo(LIBRARY_GROUP)
@Override
public void setSupportButtonTintList(@Nullable ColorStateList tint) {
    if (mCompoundButtonHelper != null) {
        mCompoundButtonHelper.setSupportButtonTintList(tint);
    }
}
项目:ToggleButtons    文件:ToggleButton.java   
@RestrictTo(LIBRARY_GROUP)
@Nullable
@Override
public ColorStateList getSupportButtonTintList() {
    return mCompoundButtonHelper != null
            ? mCompoundButtonHelper.getSupportButtonTintList()
            : null;
}
项目:ToggleButtons    文件:ToggleButton.java   
@RestrictTo(LIBRARY_GROUP)
@Override
public void setSupportButtonTintMode(@Nullable PorterDuff.Mode tintMode) {
    if (mCompoundButtonHelper != null) {
        mCompoundButtonHelper.setSupportButtonTintMode(tintMode);
    }
}
项目:ToggleButtons    文件:ToggleButton.java   
@RestrictTo(LIBRARY_GROUP)
@Nullable
@Override
public PorterDuff.Mode getSupportButtonTintMode() {
    return mCompoundButtonHelper != null
            ? mCompoundButtonHelper.getSupportButtonTintMode()
            : null;
}
项目:MultiViewAdapter    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override
public final void onBindViewHolder(ItemViewHolder holder, int adapterPosition,
    List<Object> payloads) {
  ItemBinder baseBinder = binders.get(holder.getItemViewType());

  int totalCount = 0;
  for (BaseDataManager dataManager : dataManagers) {
    totalCount += dataManager.getCount();
    if (adapterPosition < totalCount) {
      int itemPosition = getItemPositionInManager(adapterPosition);
      if (dataManager instanceof DataGroupManager) {
        dataManager = ((DataGroupManager) dataManager).getDataManagerForPosition(itemPosition);
      }
      //noinspection unchecked
      holder.setItem(dataManager.getItem(itemPosition));
      break;
    }
  }

  if (null == payloads || payloads.size() == 0) {
    //noinspection unchecked
    baseBinder.bindViewHolder(holder, holder.getItem());
  } else {
    //noinspection unchecked
    baseBinder.bindViewHolder(holder, holder.getItem(), payloads);
  }
}
项目:MultiViewAdapter    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override public final int getItemCount() {
  int itemCount = 0;
  for (BaseDataManager dataManager : dataManagers) {
    itemCount += dataManager.size();
  }
  return itemCount;
}
项目:MultiViewAdapter    文件:CoreRecyclerAdapter.java   
@RestrictTo(RestrictTo.Scope.LIBRARY) @Override
public final int getItemViewType(int adapterPosition) {
  ItemBinder baseBinder = getBinderForPosition(adapterPosition);
  if (null != baseBinder) {
    return binders.indexOf(baseBinder);
  }
  return super.getItemViewType(adapterPosition);
}
项目:RxNetwork    文件:BaseInternetObservingStrategy.java   
/** Base observing implementation for all internet observing stategies. */
@Override
@RestrictTo(LIBRARY_GROUP)
public Observable<Boolean> observe() {
  return Observable.interval(delay, interval, TimeUnit.MILLISECONDS).map(toConnectionState())
      .distinctUntilChanged();
}
项目:LicenseAdapter    文件:BaseLibrary.java   
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
protected static String read(@NonNull BufferedReader in) throws IOException {
  StringBuilder builder = new StringBuilder();
  String line;
  while ((line = in.readLine()) != null) {
    builder.append(line).append("\n");
  }
  return builder.toString();
}
项目:RxAndroidBle    文件:BleCannotSetCharacteristicNotificationException.java   
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public BleCannotSetCharacteristicNotificationException(BluetoothGattCharacteristic bluetoothGattCharacteristic, @Reason int reason,
                                                       Throwable cause) {
    super(createMessage(bluetoothGattCharacteristic, reason), cause);
    this.bluetoothGattCharacteristic = bluetoothGattCharacteristic;
    this.reason = reason;
}
项目:RxAndroidBle    文件:BleIllegalOperationException.java   
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public BleIllegalOperationException(String message,
                                    UUID characteristicUUID,
                                    @BluetoothGattCharacteristicProperty int supportedProperties,
                                    @BluetoothGattCharacteristicProperty int neededProperties) {
    super(message);
    this.characteristicUUID = characteristicUUID;
    this.supportedProperties = supportedProperties;
    this.neededProperties = neededProperties;
}
项目:RxAndroidBle    文件:DisconnectOperation.java   
@SuppressWarnings("WeakerAccess")
@RestrictTo(RestrictTo.Scope.SUBCLASSES)
void considerGattDisconnected(
        final Emitter<Void> emitter,
        final QueueReleaseInterface queueReleaseInterface
) {
    connectionStateChangeListener.onConnectionStateChange(DISCONNECTED);
    queueReleaseInterface.release();
    emitter.onCompleted();
}
项目:lottie-android    文件:LottieImageAsset.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
public LottieImageAsset(int width, int height, String id, String fileName, String dirName) {
  this.width = width;
  this.height = height;
  this.id = id;
  this.fileName = fileName;
  this.dirName = dirName;
}
项目:lottie-android    文件:KeyPath.java   
/**
 * Returns a new KeyPath with the key added.
 * This is used during keypath resolution. Children normally don't know about all of their parent
 * elements so this is used to keep track of the fully qualified keypath.
 * This returns a key keypath because during resolution, the full keypath element tree is walked
 * and if this modified the original copy, it would remain after popping back up the element tree.
 */
@CheckResult
@RestrictTo(RestrictTo.Scope.LIBRARY)
public KeyPath addKey(String key) {
  KeyPath newKeyPath = new KeyPath(this);
  newKeyPath.keys.add(key);
  return newKeyPath;
}
项目:lottie-android    文件:KeyPath.java   
/**
 * Return a new KeyPath with the element resolved to the specified {@link KeyPathElement}.
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public KeyPath resolve(KeyPathElement element) {
  KeyPath keyPath = new KeyPath(this);
  keyPath.resolvedElement = element;
  return keyPath;
}
项目:MaterialPreference    文件:Preference.java   
/**
 * Called from {@link PreferenceGroup} to pass in an ID for reuse
 * @hide
 */
@RestrictTo(LIBRARY_GROUP)
protected void onAttachedToHierarchy(PreferenceManager preferenceManager, long id) {
    mId = id;
    mHasId = true;
    try {
        onAttachedToHierarchy(preferenceManager);
    } finally {
        mHasId = false;
    }
}
项目:MaterialPreference    文件:TwoStatePreference.java   
/**
 * @hide
 */
@RestrictTo(LIBRARY_GROUP)
protected void syncSummaryView(View view) {
    if (!(view instanceof TextView)) {
        return;
    }
    TextView summaryView = (TextView) view;
    boolean useDefaultSummary = true;
    if (mChecked && !TextUtils.isEmpty(mSummaryOn)) {
        summaryView.setText(mSummaryOn);
        useDefaultSummary = false;
    } else if (!mChecked && !TextUtils.isEmpty(mSummaryOff)) {
        summaryView.setText(mSummaryOff);
        useDefaultSummary = false;
    }
    if (useDefaultSummary) {
        final CharSequence summary = getSummary();
        if (!TextUtils.isEmpty(summary)) {
            summaryView.setText(summary);
            useDefaultSummary = false;
        }
    }
    int newVisibility = View.GONE;
    if (!useDefaultSummary) {
        // Someone has written to it
        newVisibility = View.VISIBLE;
    }
    if (newVisibility != summaryView.getVisibility()) {
        summaryView.setVisibility(newVisibility);
    }
}
项目:MaterialPreference    文件:DropDownPreference.java   
/**
 * @hide
 */
@RestrictTo(LIBRARY_GROUP)
public int findSpinnerIndexOfValue(String value) {
    CharSequence[] entryValues = getEntryValues();
    if (value != null && entryValues != null) {
        for (int i = entryValues.length - 1; i >= 0; i--) {
            if (entryValues[i].equals(value)) {
                return i;
            }
        }
    }
    return Spinner.INVALID_POSITION;
}
项目:MaterialPreference    文件:PreferenceManager.java   
/**
 * @hide
 */
@RestrictTo(LIBRARY_GROUP)
public PreferenceManager(Context context) {
    mContext = context;

    setSharedPreferencesName(getDefaultSharedPreferencesName(context));
}
项目:Android-Orma    文件:Selector.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
@SuppressWarnings("unchecked")
public S resetLimitClause() {
    limit = -1;
    offset = -1;
    page = -1;
    return (S) this;
}
项目:Android-Orma    文件:Selector.java   
@RestrictTo(RestrictTo.Scope.LIBRARY)
public long getOffset() {
    assert hasOffset();

    if (offset != -1) {
        return offset;
    } else {
        return ((page - 1) * limit);
    }
}
项目:AndroidLife    文件:DatabaseConfiguration.java   
/**
 * Creates a database configuration with the given values.
 *
 * @param context The application context.
 * @param name Name of the database, can be null if it is in memory.
 * @param sqliteOpenHelperFactory The open helper factory to use.
 * @param migrationContainer The migration container for migrations.
 * @param allowMainThreadQueries Whether to allow main thread reads/writes or not.
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public DatabaseConfiguration(@NonNull Context context, @Nullable String name,
                             @NonNull SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory,
                             @NonNull RoomDatabase.MigrationContainer migrationContainer,
                             boolean allowMainThreadQueries) {
    this.sqliteOpenHelperFactory = sqliteOpenHelperFactory;
    this.context = context;
    this.name = name;
    this.migrationContainer = migrationContainer;
    this.allowMainThreadQueries = allowMainThreadQueries;
}
项目:AndroidLife    文件:RoomDatabase.java   
/**
 * Asserts that we are not on the main thread.
 *
 * @hide
 */
@SuppressLint("RestrictedApi")
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public void assertNotMainThread() {
    if (mAllowMainThreadQueries) {
        return;
    }
    if (AppToolkitTaskExecutor.getInstance().isMainThread()) {
        throw new IllegalStateException("Cannot access database on the main thread since"
            + " it may potentially lock the UI for a long periods of time.");
    }
}