androidx.annotation.VisibleForTesting#PRIVATE源码实例Demo

下面列出了androidx.annotation.VisibleForTesting#PRIVATE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bitgatt   文件: GattServerCallback.java
/**
 * Will return an error to the remote client with the error code (24)GATT_ERROR with the provided offset
 * and a zero data array
 *
 * @param conn      The gatt server connection
 * @param device    The bluetooth device
 * @param requestId The request id
 * @param offset    The offset
 */

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void returnErrorToRemoteClient(GattServerConnection conn, BluetoothDevice device, int requestId, int offset) {
    handler.post(() -> {
        try {
            conn.getServer().sendResponse(device, requestId, GattStatus.GATT_ERROR.getCode(), offset, new byte[0]);
        } catch (NullPointerException e) {
            Timber.w(e, "[%s] Looks like BluetoothGattServer#sendResponse(...) can run into the unboxing bug also.  No response sent, peripheral may disconnect.", getDeviceMacFromDevice(device));
        }
    });
}
 
源代码2 项目: litho   文件: MountState.java
/** @see LithoViewTestHelper#findTestItems(LithoView, String) */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mTestItemMap == null) {
    throw new UnsupportedOperationException(
        "Trying to access TestItems while "
            + "ComponentsConfiguration.isEndToEndTestRun is false.");
  }

  final Deque<TestItem> items = mTestItemMap.get(testKey);
  return items == null ? new LinkedList<TestItem>() : items;
}
 
源代码3 项目: litho   文件: EndToEndTestingExtension.java
/** @see LithoViewTestHelper#findTestItems(LithoView, String) */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mTestItemMap == null) {
    throw new UnsupportedOperationException(
        "Trying to access TestItems while "
            + "ComponentsConfiguration.isEndToEndTestRun is false.");
  }

  final Deque<TestItem> items = mTestItemMap.get(testKey);
  return items == null ? new LinkedList<TestItem>() : items;
}
 
源代码4 项目: litho   文件: LithoView.java
@DoNotStrip
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mUseExtensions && mLithoHostListenerCoordinator != null) {
    if (mLithoHostListenerCoordinator.getEndToEndTestingExtension() == null) {
      throw new IllegalStateException(
          "Trying to access TestItems while "
              + "ComponentsConfiguration.isEndToEndTestRun is false.");
    }

    return mLithoHostListenerCoordinator.getEndToEndTestingExtension().findTestItems(testKey);
  } else {
    return mMountState.findTestItems(testKey);
  }
}
 
源代码5 项目: litho   文件: StickyHeaderControllerImpl.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
int findStickyHeaderPosition(int currentFirstVisiblePosition) {
  for (int i = currentFirstVisiblePosition; i >= 0; i--) {
    if (mHasStickyHeader.isSticky(i)) {
      return i;
    }
  }
  return RecyclerView.NO_POSITION;
}
 
源代码6 项目: litho   文件: Change.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public Change(
    @Type int ct,
    int index,
    int toIndex,
    int count,
    @Nullable RenderInfo renderInfo,
    @Nullable List<RenderInfo> renderInfos,
    @Nullable List<?> prevData,
    @Nullable List<?> nextData) {
  mType = ct;
  mIndex = index;
  mToIndex = toIndex;
  mCount = count;
  mRenderInfo = renderInfo == null ? ComponentRenderInfo.createEmpty() : renderInfo;

  if (renderInfos == null) {
    mRenderInfos = EMPTY;
  } else {
    int size = renderInfos.size();
    mRenderInfos = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
      final RenderInfo renderInfoTemp = renderInfos.get(i);
      mRenderInfos.add(
          renderInfoTemp == null ? ComponentRenderInfo.createEmpty() : renderInfoTemp);
    }
  }

  if (prevData != null) {
    mPrevData = Collections.unmodifiableList(prevData);
  }
  if (nextData != null) {
    mNextData = Collections.unmodifiableList(nextData);
  }
}
 
源代码7 项目: litho   文件: SectionTree.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public static synchronized Looper getDefaultChangeSetThreadLooper() {
  if (sDefaultChangeSetThreadLooper == null) {
    HandlerThread defaultThread =
        new HandlerThread(
            DEFAULT_CHANGESET_THREAD_NAME,
            ComponentsConfiguration.DEFAULT_CHANGE_SET_THREAD_PRIORITY);
    defaultThread.start();
    sDefaultChangeSetThreadLooper = defaultThread.getLooper();
  }

  return sDefaultChangeSetThreadLooper;
}
 
源代码8 项目: brickkit-android   文件: BrickDataManager.java
/**
 * Deterimines if either the passed in param "paddingPosition" or the default value,
 * {@link #DEFAULT_BRICK_POSITION}, should be returned.
 *
 * @param paddingPosition used to compare with {@link #NO_PADDING_POSITION}
 * @return either the "paddingPosition" value or {@link #DEFAULT_BRICK_POSITION}
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
int getPaddingPositionOrDefault(int paddingPosition) {
    return NO_PADDING_POSITION == paddingPosition
            ? DEFAULT_BRICK_POSITION
            : paddingPosition;
}
 
源代码9 项目: brickkit-android   文件: BrickDataManager.java
/**
 * Safely notifies of a single item insertion.
 *
 * @param item which was just inserted.
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void safeNotifyItemInserted(@Nullable BaseBrick item) {
    int adapterIndex = adapterIndex(item);
    if (adapterIndex != NO_INDEX) {
        brickRecyclerAdapter.safeNotifyItemInserted(adapterIndex);
    }
}
 
源代码10 项目: brickkit-android   文件: BrickDataManager.java
/**
 * Safely notifies of a range insertion.
 *
 * @param item         which was just inserted.
 * @param visibleCount the item count for the range
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void safeNotifyItemRangeInserted(@Nullable BaseBrick item, int visibleCount) {
    int adapterIndex = adapterIndex(item);
    if (adapterIndex != NO_INDEX) {
        brickRecyclerAdapter.safeNotifyItemRangeInserted(adapterIndex, visibleCount);
    }
}
 
源代码11 项目: brickkit-android   文件: BrickDataManager.java
/**
 * Helper method to tell manager to update the items returned from getRecyclerViewItems().
 */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void dataHasChanged() {
    dataHasChanged = true;
    for (BrickBehavior behavior : behaviors) {
        behavior.onDataSetChanged();
    }
}
 
源代码12 项目: talkback   文件: ParseTreeResourceNode.java
/**
 * Creates CharSequence from template string by its parameters. The template string will be
 * transformed to contain "^1"-style placeholder values dynamically to match the format of
 * {@link TextUtils#expandTemplate(CharSequence, CharSequence...)} and formatted by other
 * none-string type parameters.
 *
 * @param templateString template string that may contains parameters with strings.
 * @param parameters object arrays that are supposed but not necessary to be string. If it is
 *     string, the corresponding placeholder value will be changed to "^1"-style. If not string
 *     type, the placeholder is kept and adjust the index.
 * @return CharSequence that composed by template string with "^1"-style placeholder values.
 */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected static CharSequence toExpandableTemplate(String templateString, Object[] parameters) {
  String expandTemplateString = templateString;
  List<Object> otherTypeList = new ArrayList<>();

  int spanTypeIndex = 1;
  int otherTypeIndex = 1;
  for (int i = 1; i <= parameters.length; i++) {
    Object param = parameters[i - 1];
    if (param instanceof CharSequence) {
      // replaces string type "%1$s" or "%s" to "^1" and so on.
      if (expandTemplateString.contains("%" + i + "$s")) {
        expandTemplateString =
            expandTemplateString.replace(("%" + i + "$s"), ("^" + spanTypeIndex));
      } else if (expandTemplateString.contains("%s")) {
        expandTemplateString = expandTemplateString.replaceFirst("%s", ("^" + spanTypeIndex));
      }
      spanTypeIndex++;
    } else {
      // keeps and assigns correct index to other type parameters
      expandTemplateString = expandTemplateString.replace(("%" + i), ("%" + otherTypeIndex));
      otherTypeList.add(param);
      otherTypeIndex++;
    }
  }
  return String.format(expandTemplateString, otherTypeList.toArray());
}
 
源代码13 项目: talkback   文件: AutoScrollActor.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public int createScrollInstanceId() {
  int scrollInstanceId = nextScrollInstanceId;
  nextScrollInstanceId++;
  if (nextScrollInstanceId < 0) {
    nextScrollInstanceId = 0;
  }
  return scrollInstanceId;
}
 
源代码14 项目: talkback   文件: Pipeline.java
/** Delays feedback execution. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected void startDelay(EventId eventId, Feedback.Part feedback) {
  int messageId = toMessageId(feedback.interruptGroup(), feedback.interruptLevel());
  final Message message =
      feedbackDelayer.obtainMessage(messageId, new EventIdAnd<Feedback.Part>(feedback, eventId));
  feedbackDelayer.sendMessageDelayed(message, feedback.delayMs());
  messageIdToSenderName.put(messageId, feedback.senderName());
}
 
源代码15 项目: talkback   文件: Pipeline.java
/** Cancels all delayed feedback for group, at or below level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected void cancelDelay(
    @InterruptGroup int group, @InterruptLevel int level, String senderName) {
  for (@InterruptLevel int l = 0; l <= level; l++) {
    feedbackDelayer.removeMessages(toMessageId(group, l));
    dumpInterruptLog(toMessageId(group, l), senderName);
  }
}
 
源代码16 项目: litho   文件: Component.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
InternalNode getLayoutCreatedInWillRenderForTesting() {
  return mLayoutCreatedInWillRender;
}
 
源代码17 项目: litho   文件: LithoView.java
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public void onAttachedToWindowForTest() {
  onAttachedToWindow();
}
 
源代码18 项目: talkback   文件: Pipeline.java
/** Checks whether a delay exists for a given group and level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected boolean delayExists(@InterruptGroup int group, @InterruptLevel int level) {
  return feedbackDelayer.hasMessages(toMessageId(group, level));
}
 
源代码19 项目: talkback   文件: Pipeline.java
/** Allows tests to advance the handler time. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected Looper getDelayLooper() {
  return feedbackDelayer.getLooper();
}
 
源代码20 项目: talkback   文件: Pipeline.java
/** Returns a unique result combining group and level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected static int toMessageId(@InterruptGroup int group, @InterruptLevel int level) {
  return (group * GROUP_DIGIT) + level;
}