本文整理汇总了Java中io.reactivex.annotations.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于io.reactivex.annotations包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseStackTrace
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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]);
}
示例2: setDeck
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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);
}
}));
}
}
示例3: fromHtml
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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())));
}
}
示例4: parseStackTraceLine
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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;
}
示例5: getEnhancedStackTrace
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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;
}
示例6: execute
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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);
}
}
示例7: HtmlImageGetter
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
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;
}
示例8: getFont
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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");
}
}
示例9: State
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
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;
}
示例10: setState
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
@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();
}
示例11: waitForFinishedCampaignProcess
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
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);
}
示例12: setDeckAccess
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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));
}
});
}
}
示例13: fromSnapshot
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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;
}
示例14: getScheduledCard
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* 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;
}
示例15: transaction
import io.reactivex.annotations.Nullable; //导入依赖的package包/类
/**
* @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());
}
}
}
};
}