Search in sources :

Example 16 with CheckResult

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);
}
Also used : Completable(io.reactivex.Completable) CompletableOnSubscribeExecuteAsBlocking(com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 17 with CheckResult

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);
}
Also used : Completable(rx.Completable) OnSubscribeExecuteAsBlockingCompletable(com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 18 with CheckResult

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);
}
Also used : StorIOException(com.pushtorefresh.storio.StorIOException) NonNull(android.support.annotation.NonNull) CheckResult(android.support.annotation.CheckResult)

Example 19 with CheckResult

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;
}
Also used : Toast(android.widget.Toast) LayoutInflater(android.view.LayoutInflater) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) CheckResult(android.support.annotation.CheckResult)

Example 20 with CheckResult

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;
}
Also used : TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) CheckResult(android.support.annotation.CheckResult)

Aggregations

CheckResult (android.support.annotation.CheckResult)27 NonNull (android.support.annotation.NonNull)9 TextView (android.widget.TextView)5 Cursor (android.database.Cursor)4 LayoutInflater (android.view.LayoutInflater)4 View (android.view.View)4 Toast (android.widget.Toast)4 Drawable (android.graphics.drawable.Drawable)3 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)3 ImageView (android.widget.ImageView)3 Resources (android.content.res.Resources)2 ContentObserver (android.database.ContentObserver)2 LinearLayout (android.widget.LinearLayout)2 Options (com.bumptech.glide.load.Options)2 StorIOException (com.pushtorefresh.storio.StorIOException)2 OnSubscribeExecuteAsBlockingCompletable (com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable)2 CompletableOnSubscribeExecuteAsBlocking (com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking)2 Completable (io.reactivex.Completable)2 Completable (rx.Completable)2 SuppressLint (android.annotation.SuppressLint)1