本文整理汇总了Java中com.google.firebase.remoteconfig.FirebaseRemoteConfigValue类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseRemoteConfigValue类的具体用法?Java FirebaseRemoteConfigValue怎么用?Java FirebaseRemoteConfigValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseRemoteConfigValue类属于com.google.firebase.remoteconfig包,在下文中一共展示了FirebaseRemoteConfigValue类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
public void getValue(final CallbackContext callbackContext, final String key, final String namespace) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Getting value " + key);
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigValue value = (namespace == null)
? remoteConfig.getValue(key)
: remoteConfig.getValue(key, namespace);
callbackContext.success(value.asString());
} catch (Exception e) {
Log.e(TAG, "Error getting value " + key, e);
callbackContext.error(e.getMessage());
}
}
});
}
示例2: parseValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
public <T> Observable<T> parseValue(final ValueParser<T> valueParser) {
return getValue().map(new Func1<FirebaseRemoteConfigValue, T>() {
@Override public T call(FirebaseRemoteConfigValue remoteConfigValue) {
return valueParser.parse(remoteConfigValue.asString());
}
});
}
示例3: stringValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
public Observable<String> stringValue() {
return getValue().map(new Func1<FirebaseRemoteConfigValue, String>() {
@Override public String call(FirebaseRemoteConfigValue remoteConfigValue) {
return remoteConfigValue.asString();
}
});
}
示例4: booleanValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
public Observable<Boolean> booleanValue() {
return getValue().map(new Func1<FirebaseRemoteConfigValue, Boolean>() {
@Override public Boolean call(FirebaseRemoteConfigValue remoteConfigValue) {
return remoteConfigValue.asBoolean();
}
});
}
示例5: getValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
private Observable<FirebaseRemoteConfigValue> getValue() {
return Observable.fromEmitter(new Action1<AsyncEmitter<FirebaseRemoteConfigValue>>() {
@Override public void call(final AsyncEmitter<FirebaseRemoteConfigValue> asyncEmitter) {
final Activity activity = activityWeakReference.get();
remoteConfig.fetch(cacheExpiration).addOnFailureListener(
activity, new OnFailureListener() {
@Override public void onFailure(@NonNull Exception e) {
asyncEmitter.onError(e);
}
}).addOnSuccessListener(activity, new OnSuccessListener<Void>() {
@Override public void onSuccess(Void aVoid) {
remoteConfig.activateFetched();
asyncEmitter.onNext(remoteConfig.getValue(key));
}
}).addOnCompleteListener(
activity, new OnCompleteListener<Void>() {
@Override public void onComplete(@NonNull Task<Void> task) {
asyncEmitter.onCompleted();
}
});
asyncEmitter.setCancellation(new AsyncEmitter.Cancellable() {
@Override public void cancel() throws Exception {
activityWeakReference.clear();
}
});
}
}, AsyncEmitter.BackpressureMode.BUFFER)
.timeout(timeout, TimeUnit.MILLISECONDS)
.onErrorResumeNext(new Func1<Throwable, Observable<? extends FirebaseRemoteConfigValue>>() {
@Override
public Observable<? extends FirebaseRemoteConfigValue> call(Throwable throwable) {
return Observable.just(remoteConfig.getValue(key));
}
});
}
示例6: getValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; //导入依赖的package包/类
public static Single<FirebaseRemoteConfigValue> getValue(@NonNull String key) {
return Single.fromCallable(() -> FirebaseRemoteConfig.getInstance().getValue(key))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}