当前位置: 首页>>代码示例>>Java>>正文


Java SingleEmitter.onSuccess方法代码示例

本文整理汇总了Java中io.reactivex.SingleEmitter.onSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java SingleEmitter.onSuccess方法的具体用法?Java SingleEmitter.onSuccess怎么用?Java SingleEmitter.onSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.SingleEmitter的用法示例。


在下文中一共展示了SingleEmitter.onSuccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResolutionResult

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
static void onResolutionResult(String observableId, int resultCode) {
    if (observableMap.containsKey(observableId)) {
        SettingsCheckHandleSingleOnSubscribe observable = observableMap.get(observableId).get();

        if (observable != null && observable.emitterWeakRef != null) {
            SingleEmitter<Boolean> observer = observable.emitterWeakRef.get();

            if (observer != null) {
                observer.onSuccess(resultCode == Activity.RESULT_OK);
            }
        }

        observableMap.remove(observableId);
    }

    observableMapCleanup();
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:18,代码来源:SettingsCheckHandleSingleOnSubscribe.java

示例2: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final SingleEmitter<QuerySnapshot> emitter) throws Exception {
    OnCompleteListener<QuerySnapshot> listener = new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
            if (!emitter.isDisposed()) {
                if (task.isSuccessful()) {
                    emitter.onSuccess(task.getResult());

                } else {
                    emitter.onError(task.getException());

                }
            }

        }
    };

    collectionReference.get()
            .addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:22,代码来源:GetCollectionOnSubscribe.java

示例3: listener

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
/**
 * @param emit
 * @param <R>
 * @return
 */
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final SingleEmitter<R> emit) {
    return new OnCompleteListener<R>() {
        @Override
        public void onComplete(@NonNull final Task<R> task) {
            if (!emit.isDisposed()) {
                if (task.isSuccessful()) {
                    emit.onSuccess(task.getResult());
                } else {
                    Exception e = task.getException();
                    emit.onError(e != null ? e : new RuntimeException());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxtasks,代码行数:23,代码来源:RxTask.java

示例4: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final SingleEmitter<String> emitter) {
  OnCompleteListener<GetTokenResult> listener = new OnCompleteListener<GetTokenResult>() {
    @Override public void onComplete(@NonNull Task<GetTokenResult> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult().getToken());
      }
    }
  };

  user.getToken(forceRefresh).addOnCompleteListener(listener);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:19,代码来源:UserGetTokenOnSubscribe.java

示例5: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final SingleEmitter<FirebaseUser> emitter) {
  final OnCompleteListener<AuthResult> listener = new OnCompleteListener<AuthResult>() {
    @Override public void onComplete(@NonNull Task<AuthResult> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult().getUser());
      }
    }
  };
  createAuthTask(instance).addOnCompleteListener(listener);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:18,代码来源:BaseAuthOnSubscribe.java

示例6: listener

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
public static <T> OnCompleteListener<T> listener(@NonNull final SingleEmitter<T> emitter) {
  return new OnCompleteListener<T>() {
    @Override public void onComplete(@NonNull Task<T> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult());
      }
    }
  };
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:17,代码来源:GmsTaskListeners.java

示例7: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final SingleEmitter<DataSnapshot> emitter) {
  final ValueEventListener listener = new ValueEventListener() {
    @Override public void onDataChange(DataSnapshot dataSnapshot) {
      if (!emitter.isDisposed()) {
        emitter.onSuccess(dataSnapshot);
      }
    }

    @Override public void onCancelled(DatabaseError databaseError) {
      if (!emitter.isDisposed()) {
        emitter.onError(databaseError.toException());
      }
    }
  };

  ref.addListenerForSingleValueEvent(listener);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:18,代码来源:DataOnSubscribe.java

示例8: listener

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
/**
 * @param emit
 * @return
 */
@NonNull
@CheckReturnValue
public static ValueEventListener listener(@NonNull final SingleEmitter<DataSnapshot> emit) {
    return new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (!emit.isDisposed()) {
                emit.onSuccess(dataSnapshot);
            }
        }

        @Override
        public void onCancelled(DatabaseError e) {
            if (!emit.isDisposed()) {
                emit.onError(e.toException());
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxfirebase,代码行数:24,代码来源:RxValue.java

示例9: onGoogleApiClientReady

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter<Boolean> emitter) {
    //noinspection MissingPermission
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(apiClient);

    if (locationAvailability != null) {
        emitter.onSuccess(locationAvailability.isLocationAvailable());
    } else {
        emitter.onSuccess(false);
    }
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:12,代码来源:LocationAvailabilitySingleOnSubscribe.java

示例10: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(SingleEmitter<GoogleSignInAccount> emitter) throws Exception {
  if (!result.isSuccess()) {
    emitter.onError(new GoogleSignInException(result));
    return;
  }

  emitter.onSuccess(result.getSignInAccount());
}
 
开发者ID:ashdavies,项目名称:eternity,代码行数:10,代码来源:GoogleSignInResultSingle.java

示例11: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final SingleEmitter<Cursor> emitter) throws Exception {
    if (LOG) {
        Log.d(TAG, mQuery.toString());
    }

    final Cursor c = mContentResolver.query(
            mQuery.contentUri,
            mQuery.projection,
            mQuery.selection,
            mQuery.selectionArgs,
            mQuery.sortOrder);

    emitter.onSuccess(c);
}
 
开发者ID:Doctoror,项目名称:RxCursorLoader,代码行数:16,代码来源:RxCursorLoader.java

示例12: loadStockItems

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
private SingleOnSubscribe<List<StockItem>> loadStockItems() {
    return new SingleOnSubscribe<List<StockItem>>() {
        @Override
        public void subscribe(SingleEmitter<List<StockItem>> e) throws Exception {
            List<StockItem> items = Arrays.asList(
                    new StockItem(new Image("", new Size(10, 10))),
                    new StockItem(new Image("image2", new Size(10, 10)))
            );
            e.onSuccess(items);
        }
    };
}
 
开发者ID:solkin,项目名称:drawa-android,代码行数:13,代码来源:StockActivity.java

示例13: transaction

import io.reactivex.SingleEmitter; //导入方法依赖的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());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxfirebase,代码行数:35,代码来源:RxValue.java

示例14: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(@NonNull SingleEmitter<Result> emitter) throws Exception {
    try {
        final Result value = preparedOperation.executeAsBlocking();
        emitter.onSuccess(value);
    } catch (Exception e) {
        emitter.onError(e);
    }
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:10,代码来源:SingleOnSubscribeExecuteAsBlocking.java

示例15: subscribe

import io.reactivex.SingleEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(@NonNull SingleEmitter<Optional<Result>> emitter) throws Exception {
    try {
        final Result value = preparedOperation.executeAsBlocking();
        emitter.onSuccess(Optional.of(value));
    } catch (Exception e) {
        emitter.onError(e);
    }
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:10,代码来源:SingleOnSubscribeExecuteAsBlockingOptional.java


注:本文中的io.reactivex.SingleEmitter.onSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。