use of android.support.annotation.CheckResult in project storio by pushtorefresh.
the class RxJavaUtils method createCompletable.
@CheckResult
@NonNull
public static <Result, Data> Completable createCompletable(@NonNull StorIOContentResolver storIOContentResolver, @NonNull PreparedCompletableOperation<Result, Data> operation) {
throwExceptionIfRxJava2IsNotAvailable("asRxCompletable()");
final Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(operation));
return subscribeOn(storIOContentResolver, completable);
}
use of android.support.annotation.CheckResult in project storio by pushtorefresh.
the class RxJavaUtils method createCompletable.
@CheckResult
@NonNull
public static <T> Completable createCompletable(@NonNull StorIOContentResolver storIOContentResolver, @NonNull PreparedOperation<T> operation) {
throwExceptionIfRxJavaIsNotAvailable("asRxCompletable()");
final Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(operation));
return subscribeOn(storIOContentResolver, completable);
}
use of android.support.annotation.CheckResult in project storio by pushtorefresh.
the class PreparedGetNumberOfResults method asRxObservable.
/**
* Creates "Hot" {@link Observable} which will be subscribed to changes of tables from query
* and will emit result each time change occurs.
* <p>
* First result will be emitted immediately after subscription,
* other emissions will occur only if changes of tables from query will occur during lifetime of
* the {@link Observable}.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>Operates on {@link StorIOSQLite#defaultScheduler()} if not {@code null}.</dd>
* </dl>
* <p>
* Please don't forget to unsubscribe from this {@link Observable} because
* it's "Hot" and endless.
*
* @return non-null {@link Observable} which will emit non-null
* number of results of the executed query and will be subscribed to changes of tables from query.
*/
@NonNull
@CheckResult
@Override
public Observable<Integer> asRxObservable() {
throwExceptionIfRxJavaIsNotAvailable("asRxObservable()");
final Set<String> tables;
if (query != null) {
tables = new HashSet<String>(1);
tables.add(query.table());
} else if (rawQuery != null) {
tables = rawQuery.observesTables();
} else {
throw new StorIOException("Please specify query");
}
final Observable<Integer> observable;
if (!tables.isEmpty()) {
observable = storIOSQLite.observeChangesInTables(// each change triggers executeAsBlocking
tables).map(MapSomethingToExecuteAsBlocking.newInstance(this)).startWith(// start stream with first query result
Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this))).onBackpressureLatest();
} else {
observable = Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this));
}
return RxJavaUtils.subscribeOn(storIOSQLite, observable);
}
use of android.support.annotation.CheckResult in project RxTools by vondear.
the class RxToast method custom.
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull String message, Drawable icon, @ColorInt int textColor, @ColorInt int tintColor, int duration, boolean withIcon, boolean shouldTint) {
if (currentToast == null) {
currentToast = new Toast(context);
}
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_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 = tint9PatchDrawableFrame(context, tintColor);
} else {
drawableFrame = getDrawable(context, R.drawable.toast_frame);
}
setBackground(toastLayout, drawableFrame);
if (withIcon) {
if (icon == null)
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
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;
}
use of android.support.annotation.CheckResult in project AndroidUtilLib by SiberiaDante.
the class SDToastUtil method showLinesToastText.
/**
* Toast 多行文本
*
* @param textSize 字体大小
* @param textColor 字体颜色
* @param contents list 形式的文本内容
*/
@CheckResult
private static Toast showLinesToastText(List<String> contents, int backgroundColor, int textSize, int textColor, int paddingStart, int paddingTop, int paddingRight, int paddingLeft) {
if (null == mToastLines) {
mToastLines = Toast.makeText(SDAndroidLib.getContext(), "", Toast.LENGTH_LONG);
}
toastList.add(mToastLines);
// 创建线性布局
LinearLayout linearLayoutTop = new LinearLayout(SDAndroidLib.getContext());
linearLayoutTop.setPadding(SDTransitionUtil.dip2px(paddingStart), SDTransitionUtil.dip2px(paddingTop), SDTransitionUtil.dip2px(paddingRight), SDTransitionUtil.dip2px(paddingLeft));
if (BACKGROUND_COLOR_NULL == backgroundColor) {
linearLayoutTop.setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
} else {
linearLayoutTop.setBackgroundColor(backgroundColor);
}
// 设置布局垂直
linearLayoutTop.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < contents.size(); i++) {
TextView textView = new TextView(SDAndroidLib.getContext());
textView.setText(contents.get(i));
textView.setTextSize(textSize);
textView.setTextColor(textColor);
linearLayoutTop.addView(textView);
}
mToastLines.setView(linearLayoutTop);
mToastLines.setDuration(Toast.LENGTH_LONG);
return mToastLines;
}
Aggregations