Java 类io.reactivex.annotations.Nullable 实例源码
项目:RxJava2Debug
文件:StackTraceUtils.java
/**
* Extract StackTrace and filter to show an app-specific entry at its top
*
* @param exception RxJavaAssemblyException to be parsed
* @return StackTrace, filtered so a app-specific line is at the top of it
*/
@NonNull
static StackTraceElement[] parseStackTrace(@NonNull RxJavaAssemblyException exception, @Nullable String[] basePackages) {
String[] lines = exception.stacktrace()
.split(NEW_LINE_REGEX);
List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>();
boolean filterIn = false;
for (String line : lines) {
filterIn = filterIn
|| basePackages == null
|| basePackages.length == 0
|| startsWithAny(line, basePackages);
if (filterIn) {
StackTraceElement element = parseStackTraceLine(line);
if (element != null) {
stackTrace.add(element);
}
}
}
return stackTrace.toArray(new StackTraceElement[0]);
}
项目:delern
文件:DeckViewHolder.java
/**
* Set deck object currently associated with this ViewHolder.
*
* @param deck Deck or null if ViewHolder is being recycled.
*/
public void setDeck(@Nullable final Deck deck) {
if (deck == null) {
mResources.clear();
} else {
mDeckTextView.setText(deck.getName());
mResources.add(deck.fetchDeckAccessOfUser().subscribe(v -> mDeckAccess = v));
mResources.add(Deck.fetchCount(
deck.fetchCardsToRepeatWithLimitQuery(CARDS_COUNTER_LIMIT + 1))
.subscribe((final Long cardsCount) -> {
if (cardsCount <= CARDS_COUNTER_LIMIT) {
mCountToLearnTextView.setText(String.valueOf(cardsCount));
} else {
String tooManyCards = CARDS_COUNTER_LIMIT + "+";
mCountToLearnTextView.setText(tooManyCards);
}
}));
}
}
项目:delern
文件:CardViewHolder.java
/**
* Set Card object currently associated with this ViewHolder.
*
* @param card Card or null if ViewHolder is being recycled.
*/
@SuppressWarnings("deprecation" /* fromHtml(String, int) not available before API 24 */)
public void setCard(@Nullable final Card card) {
mCard = card;
if (card != null) {
if (card.getDeck().isMarkdown()) {
mFrontTextView.setText(Html.fromHtml(card.getFront()));
mBackTextView.setText(Html.fromHtml(card.getBack()));
} else {
mFrontTextView.setText(card.getFront());
mBackTextView.setText(card.getBack());
}
mCardView.setCardBackgroundColor(ContextCompat.getColor(itemView.getContext(),
CardColor.getColor(card.specifyContentGender())));
}
}
项目:RxJava2Debug
文件:StackTraceUtils.java
/**
* Parse string containing a <i>single line</i> of a StackTrace
*
* @param stackTraceLine string containing single line of a StackTrace
* @return parsed StackTraceElement
*/
@Nullable
private static StackTraceElement parseStackTraceLine(@NonNull String stackTraceLine) {
StackTraceElement retVal = null;
Matcher matcher = STACK_TRACE_ELEMENT_PATTERN.matcher(stackTraceLine);
if (matcher.matches()) {
String clazz = matcher.group(1);
String method = matcher.group(2);
String filename = matcher.group(3);
int line = Integer.valueOf(matcher.group(4));
retVal = new StackTraceElement(clazz, method, filename, line);
}
return retVal;
}
项目:RxJava2Debug
文件:RxJava2Debug.java
/**
* Obtain a copy of the original Throwable with an extended StackTrace
* @param original Original Throwable
* @return new Throwable with enhanced StackTrace if information was found. <i>null</i> otherwise
*/
public static @Nullable Throwable getEnhancedStackTrace(Throwable original) {
Throwable enhanced = original;
RxJavaAssemblyException assembledException = RxJavaAssemblyException.find(original);
if (assembledException != null) {
StackTraceElement[] clearStack = parseStackTrace(assembledException, basePackages);
Throwable clearException = new Throwable();
clearException.setStackTrace(clearStack);
enhanced = setRootCause(original, clearException);
}
return enhanced;
}
项目:RxCommand
文件:RxCommand.java
/**
* If the receiver is enabled, this method will:
* <p>
* 1. Invoke the `func` given at the time of creation.
* 2. Multicast the returned observable.
* 3. Send the multicasted observable on {@link #executionObservables()}.
* 4. Subscribe (connect) to the original observable on the main thread.
*
* @param input The input value to pass to the receiver's `func`. This may be null.
* @return the multicasted observable, after subscription. If the receiver is not
* enabled, returns a observable that will send an error.
*/
@MainThread
public final Observable<T> execute(@Nullable Object input) {
boolean enabled = mImmediateEnabled.blockingFirst();
if (!enabled) {
return Observable.error(new IllegalStateException("The command is disabled and cannot be executed"));
}
try {
Observable<T> observable = mFunc.apply(input);
if (observable == null) {
throw new RuntimeException(String.format("null Observable returned from observable func for value %s", input));
}
// This means that `executing` and `enabled` will send updated values before
// the observable actually starts performing work.
final ConnectableObservable<T> connection = observable
.subscribeOn(AndroidSchedulers.mainThread())
.replay();
mAddedExecutionObservableSubject.onNext(connection);
connection.connect();
return connection;
} catch (Exception e) {
e.printStackTrace();
return Observable.error(e);
}
}
项目:PSNine
文件:HtmlImageGetter.java
public HtmlImageGetter(Context context, @Nullable TextView tv) {
this.context = context;
this.tv = tv;
DisplayMetrics dm = context.getResources().getDisplayMetrics();
w_screen = dm.widthPixels;
h_screen = dm.heightPixels;
}
项目:smart-lens
文件:BaseButton.java
/**
* Get the font based on the text style.
*
* @return font file name.
*/
String getFont(@Nullable Typeface typeface) {
switch (typeface != null ? typeface.getStyle() : Typeface.NORMAL) {
case Typeface.BOLD_ITALIC:
return String.format(Locale.US, "fonts/%s", "OpenSans-BoldItalic.ttf");
case Typeface.ITALIC:
return String.format(Locale.US, "fonts/%s", "OpenSans-Italic.ttf");
case Typeface.BOLD:
return String.format(Locale.US, "fonts/%s", "OpenSans-Bold.ttf");
default:
case Typeface.NORMAL:
return String.format(Locale.US, "fonts/%s", "OpenSans-Regular.ttf");
}
}
项目:ActivityRx
文件:State.java
public State(
@NonNull final String id,
@NonNull final On on,
@Nullable final A ui,
@Nullable final Bundle arg) {
this.id = id;
this.on = on;
this.ui = ui;
this.arg = arg;
}
项目:ActivityRx
文件:Activities.java
@SuppressWarnings("unchecked")
private static void setState(
@NonNull String id,
@NonNull On on,
@Nullable Activity activity,
@Nullable Bundle bundle) {
State<? extends Activity> newState = new State<>(id, on, activity, bundle);
EVENTS.onNext(newState);
Iterator<State<? extends Activity>> iterator = STATES.iterator();
while (iterator.hasNext()) {
if (iterator.next().id.equals(id)) {
iterator.remove();
break;
}
}
if (newState.on != On.DESTROY) {
STATES.add(newState);
}
for (Map.Entry<String, LinkedHashSet<ObservableEmitter>> subscription : EMITTERS.entrySet()) {
if (subscription.getKey().equals(id)) {
BUFFER.addAll(subscription.getValue());
}
}
for (ObservableEmitter emitter : BUFFER) {
emitter.onNext(newState);
}
BUFFER.clear();
}
项目:webtrekk-android-sdk
文件:WebtrekkBaseSDKTest.java
protected void waitForFinishedCampaignProcess(@Nullable final Runnable callback){
Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(@NonNull CompletableEmitter completableEmitter) throws Exception {
while (!isCampaignProcessFinished()){
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
if (callback != null) {
callback.run();
}
completableEmitter.onComplete();
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.blockingAwait(130, TimeUnit.SECONDS);
}
项目:delern
文件:UserDeckAccessViewHolder.java
/**
* Set DeckAccess for this item.
*
* @param deckAccess DeckAccess or null if the view is being recycled.
*/
public void setDeckAccess(@Nullable final DeckAccess deckAccess) {
if (deckAccess == null) {
mUserDisposable.dispose();
} else {
mUserDisposable = deckAccess.fetchChild(
deckAccess.getChildReference(User.class), User.class)
.subscribe((final User user) -> {
mNameTextView.setText(user.getName());
Context context = itemView.getContext();
Picasso.with(context)
.load(user.getPhotoUrl())
.error(android.R.color.holo_green_dark)
.placeholder(R.drawable.splash_screen)
.into(mProfilePhoto);
if ("owner".equals(deckAccess.getAccess())) {
mSharingPermissionsSpinner
.setType(R.array.owner_access_spinner_text,
R.array.owner_access_spinner_img);
} else {
mSharingPermissionsSpinner
.setType(R.array.user_permissions_spinner_text,
R.array.share_permissions_spinner_img);
mSharingPermissionsSpinner
.setSelection(mPresenter
.setUserAccessPositionForSpinner(deckAccess));
mSharingPermissionsSpinner
.setOnItemSelectedListener(access ->
mPresenter.changeUserPermission(access, deckAccess));
}
});
}
}
项目:delern
文件:Model.java
/**
* Parse model from a database snapshot using getValue().
*
* @param snapshot a snapshot pointing to model data (not the list of models).
* @param cls a model class, e.g. Card.class or card.getClass().
* @param parent a parent model. See Model constructor for limitations.
* @param <T> an Model subclass.
* @return an instance of T with key and parent set, or null.
*/
@Nullable
public static <T extends Model> T fromSnapshot(final DataSnapshot snapshot,
final Class<T> cls,
final Model parent) {
T model = snapshot.getValue(cls);
if (model != null) {
model.setKey(snapshot.getKey());
model.setParent(parent);
model.setReference(snapshot.getRef());
}
return model;
}
项目:delern
文件:Card.java
/**
* Get the ScheduledCard this Card is associated with.
*
* @return Model parent casted to ScheduledCard (if set).
*/
@Exclude
@Nullable
public ScheduledCard getScheduledCard() {
Model parent = getParent();
if (parent instanceof ScheduledCard) {
return (ScheduledCard) parent;
}
return null;
}
项目:rxfirebase
文件:RxValue.java
/**
* @param emitter
* @param function
* @return
*/
@NonNull
@CheckReturnValue
public static Transaction.Handler transaction(
@NonNull final SingleEmitter<DataSnapshot> emitter,
@NonNull final Function<MutableData, Transaction.Result> function) {
return new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData mutableData) {
try {
return function.apply(mutableData);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void onComplete(@Nullable DatabaseError databaseError,
boolean committed,
@NonNull DataSnapshot dataSnapshot) {
if (!emitter.isDisposed()) {
if (null == databaseError) {
emitter.onSuccess(dataSnapshot);
} else {
emitter.onError(databaseError.toException());
}
}
}
};
}
项目:rxfirebase
文件:RxFirebaseStorage.java
/**
* @see StorageReference#putFile(Uri, StorageMetadata, Uri)
*/
@CheckReturnValue
@NonNull
public static Single<UploadTask.TaskSnapshot> putFile(
@NonNull final StorageReference ref,
@NonNull final Uri uri,
@Nullable final StorageMetadata storageMetadata,
@Nullable final Uri existingUploadUri) {
return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() {
@Override
public Task<UploadTask.TaskSnapshot> call() throws Exception {
return ref.putFile(uri, storageMetadata, existingUploadUri);
}
});
}
项目:RxDownloader
文件:RxDownloader.java
private DownloadManager.Request createRequest(@NonNull String url,
@NonNull String filename,
@Nullable String destinationPath,
@NonNull String mimeType,
boolean inPublicDir,
boolean showCompletedNotification) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription(filename);
request.setMimeType(mimeType);
if (destinationPath == null) {
destinationPath = Environment.DIRECTORY_DOWNLOADS;
}
File destinationFolder = inPublicDir
? Environment.getExternalStoragePublicDirectory(destinationPath)
: new File(context.getFilesDir(), destinationPath);
createFolderIfNeeded(destinationFolder);
removeDuplicateFileIfExist(destinationFolder, filename);
if (inPublicDir) {
request.setDestinationInExternalPublicDir(destinationPath, filename);
} else {
request.setDestinationInExternalFilesDir(context, destinationPath, filename);
}
request.setNotificationVisibility(showCompletedNotification
? DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
: DownloadManager.Request.VISIBILITY_VISIBLE);
return request;
}
项目:commcare-core
文件:FormController.java
/**
* Retrieves the index of the Group which hosts child index and is marked with given appearanceTag, null otherwise
*/
@Nullable
private FormIndex getHostWithAppearance(FormIndex child, String appearanceTag) {
int event = mFormEntryController.getModel().getEvent(child);
if (event == FormEntryController.EVENT_QUESTION || event == FormEntryController.EVENT_GROUP || event == FormEntryController.EVENT_REPEAT) {
// caption[0..len-1]
// caption[len-1] == the event itself
// caption[len-2] == the groups containing this group
FormEntryCaption[] captions = mFormEntryController.getModel().getCaptionHierarchy(child);
//This starts at the beginning of the heirarchy, so it'll catch the top-level
//host index.
for (FormEntryCaption caption : captions) {
FormIndex parentIndex = caption.getIndex();
if (mFormEntryController.isHostWithAppearance(parentIndex, appearanceTag)) {
return parentIndex;
}
}
//none of this node's parents are marked with appearanceTag
return null;
} else {
// Non-host elements can't have hosts marked as appearanceTag .
return null;
}
}
项目:commcare-core
文件:XPathAccumulatingAnalyzer.java
@Nullable
public Set<T> accumulate(XPathAnalyzable rootExpression) {
try {
rootExpression.applyAndPropagateAnalyzer(this);
Set<T> set = new HashSet<>();
for (T item : aggregateResults(new ArrayList<T>())) {
set.add(item);
}
return set;
} catch (AnalysisInvalidException e) {
return null;
}
}
项目:commcare-core
文件:XPathAccumulatingAnalyzer.java
@Nullable
public List<T> accumulateAsList(XPathAnalyzable rootExpression) {
try {
rootExpression.applyAndPropagateAnalyzer(this);
return aggregateResults(new ArrayList<T>());
} catch (AnalysisInvalidException e) {
return null;
}
}
项目:Blackboard
文件:Blackboard.java
/**
* @return the current url prefix, or null if none has been set
*/
@Nullable
public String getUrl() {
return prefs.getString(PREF_URL, null);
}
项目:RxRedux
文件:Result.java
@Nullable
static <B> Result<B> loadingResult() {
return new Result<>(true, null, false, Pair.<String, B>create("", null));
}
项目:RxRedux
文件:Result.java
@Nullable
static <B> Result<B> throwableResult(Throwable error) {
return new Result<>(false, error, false, Pair.<String, B>create("", null));
}
项目:KotlinKomparisons
文件:LoginDetails.java
public LoginDetails(@Nullable final String email, @Nullable final String username) {
this.email = email;
this.username = username;
}
项目:KotlinKomparisons
文件:LoginDetails.java
public @Nullable String getEmail() {
return email;
}
项目:KotlinKomparisons
文件:LoginDetails.java
public @Nullable String getUsername() {
return username;
}
项目:rxtools
文件:Optional.java
@SuppressWarnings("unchecked")
public static <T> Optional<T> ofNullable(@Nullable T value)
{
return value == null ? (Optional<T>) empty() : of(value);
}
项目:pandroid
文件:RxLifecycleDelegate.java
@RxModel(targets = {PandroidDelegateProvider.class})
public static <T> MainObserverTransformer<T> bindLifecycleObserveOnMain(@Nullable PandroidDelegateProvider provider) {
return new MainObserverTransformer<>(provider);
}
项目:RxJava2Extensions
文件:RxJavaProtocolValidator.java
/**
* Returns the current custom violation callback handler.
* @return the current custom violation callback handler or null if not set
*/
@Nullable
public static PlainConsumer<ProtocolNonConformanceException> getOnViolationHandler() {
return onViolation;
}
项目:EasyMVP
文件:SingleUseCase.java
@Override
public Single<R> execute(@Nullable Q param) {
return interact(param).compose(getSchedulersTransformer());
}
项目:EasyMVP
文件:SingleUseCase.java
@Override
protected abstract Single<R> interact(@Nullable Q param);
项目:rx-mqtt
文件:RxMqtt.java
public static Maybe<IMqttToken> reconnect(
@NonNull final MqttAndroidClient client,
@NonNull final MqttConnectOptions options,
@Nullable final DisconnectedBufferOptions bufferOptions) {
return connect(client, options, bufferOptions);
}
项目:rx-mqtt
文件:RxMqtt.java
@Nullable
@Override
public MqttException getException() {
// nothing
return null;
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public IMqttActionListener getActionCallback() {
// nothing
return null;
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public IMqttAsyncClient getClient() {
// nothing
return null;
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public String[] getTopics() {
// nothing
return new String[0];
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public Object getUserContext() {
// nothing
return null;
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public int[] getGrantedQos() {
// nothing
return new int[0];
}
项目:rx-mqtt
文件:RxMqtt.java
@Override
@Nullable
public MqttWireMessage getResponse() {
// nothing
return null;
}
项目:rxfirebase
文件:ChildAddEvent.java
@Nullable
public String previousChildName() {
return previousChildName;
}