本文整理汇总了Java中rx.android.observables.AndroidObservable类的典型用法代码示例。如果您正苦于以下问题:Java AndroidObservable类的具体用法?Java AndroidObservable怎么用?Java AndroidObservable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidObservable类属于rx.android.observables包,在下文中一共展示了AndroidObservable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWeatherService = new WeatherService("", RequestQueueRetriever.retrieve());
AndroidObservable.bindFragment(this, createForecastObservable())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Forecast>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable cause) {
onFailure(cause);
}
@Override
public void onNext(Forecast result) {
onSuccess(result);
}
});
}
示例2: onCreate
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWeatherService = new WeatherService("", RequestQueueRetriever.retrieve());
AndroidObservable.bindFragment(this, createWeatherObservable())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Weather>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable cause) {
onFailure(cause);
}
@Override
public void onNext(Weather result) {
onSuccess(result);
}
});
}
示例3: preloadSharing
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void preloadSharing(){
if(m_smartListEdit != null) {
AndroidObservable.bindFragment(this,
m_smartListService.getListOfShares(m_smartListEdit.getItemId()))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(shares -> {
this.m_shareGroupList = shares;
int shareCount = shares.size();
m_textSharingName.setText(getResources().getQuantityString(R.plurals.create_shared_with, shareCount, shareCount));
},error->{
m_smartListService.handleErrors(error);
});
}
}
示例4: loadModule
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void loadModule() {
//Initial off
showModuleOn(false, false);
AndroidObservable.bindActivity(this, mGetItOn.getModuleForId(getIntent().getStringExtra(KEY_MAC_ID)))
.subscribe(new Subscriber<LanModule>() {
@Override
public void onCompleted() {
if (mModule == null) {
onUnableToLoadModule();
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(LanModule lanModule) {
onModuleLoaded(lanModule);
}
});
}
示例5: showData
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void showData(@NonNull RGBV1Module module) {
String name = mNamedLanModulesViewModel.getNameForModuleId(module.getMac());
if (name != null) {
mTxtTitle.setText(name);
mTxtTitleEdit.setText(name);
}
AndroidObservable.bindActivity(this, checkAnimateIn()
.singleOrDefault(false))
.subscribe(new Subscriber<Boolean>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Boolean on) {
showModuleOn(on, true);
}
});
}
示例6: onSavedColorPicked
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void onSavedColorPicked(@NonNull SavedColor color) {
if (color.isAddNewColor()) {
color.setColor(mColorpicker.getColor());
addOrUpdateColor(color);
return;
}
mLastSelectedColor = color.getColor();
final int[] rgb = ColorUtils.splitColors(color.getColor());
AndroidObservable.bindActivity(this, changeModuleColorTcp(color.getColor(), mValuebar.getProgress(), true))
.subscribe(new Subscriber<Response>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Response response) {
onColorSet(rgb);
}
});
}
示例7: onCompleted
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Override
public void onCompleted() {
mAdapterDataSubscription.unsubscribe();
// initialize and launch image download process
List<String> urls = new ArrayList<String>(mData.size());
for (Result r : mData) {
String url = r.getUrl();
if (!mImages.containsKey(url)) {
urls.add(url);
mImages.put(url, null);
}
}
Observable<ListItemImage> mImageFetcherObservable = API
.getImageFetcher(urls);
mListItemImageSubscription = AndroidObservable.fromActivity(
mContext, mImageFetcherObservable).subscribe(
mListItemImageObserver);
}
示例8: onCreate
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Nullable
public Subscription onCreate(Activity activity) {
settings.incrementAppLaunchCount();
if (T || settings.shouldBother()) {
final WeakReference<Activity> wActivity = new WeakReference<>(activity);
return AndroidObservable.bindActivity(activity, provider.hasDonated())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean donated) {
Activity a = wActivity.get();
if (!donated && a != null) {
showDonateDialog(a);
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Log.w("IabManager", "query failure: cause=" + throwable);
}
}
);
}
return null;
}
示例9: initData
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void initData() {
adapter.clear();
AndroidObservable.bindActivity(this,
todoHelper
.list()
.subscribeOn(Schedulers.newThread()))
.doOnCompleted(() -> adapter.sort(todoHelper::compare))
.subscribe(adapter::add);
}
示例10: refresh
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void refresh()
{
// unsubscribe the subscription and add the new one
subscriptions.remove(subscription);
subscription = AndroidObservable.bindFragment(this, createObservable().subscribeOn(Schedulers.io()))
.subscribe(this);
subscriptions.add(subscription);
}
示例11: startSearching
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void startSearching() {
showLoading(true);
mItems.clear();
mAdapter.setCollection(new ArrayQueryable<OverViewListItem>(mItems), true);
AndroidObservable.bindActivity(this,
getNamedLanModuleScanResults()
.mergeWith(getWifiScanResults())
)
.subscribe(new Subscriber<OverViewListItem>() {
@Override
public void onCompleted() {
onSearchComplete();
}
@Override
public void onError(Throwable e) {
showloading(mPrgLoading, false);
mILoggingService.log(e);
SnackbarUtil.show(OverviewActivity.this, e, new View.OnClickListener() {
@Override
public void onClick(View v) {
mScanTries = 0;
startSearching();
}
});
}
@Override
public void onNext(OverViewListItem overViewListItem) {
mItems.add(0, overViewListItem);
mAdapter.notifyItemInserted(0);
}
});
}
示例12: startRegistration
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void startRegistration() {
mLanScanCounter = 0;
if (mConfig == null) {
return;
}
AndroidObservable.bindActivity(this,
mGetItOn.getRegistrator()
.registerModuleToNetwork(mConfig.getTargetBSSID(), mConfig.getTargetSSID(), mConfig.getWifiModule().getSSID(), mConfig.getWifiModule().getBSSID(), mConfig.getTargetPass(), "Get It On")
).subscribe(new Subscriber<RegistrationState>() {
@Override
public void onCompleted() {
showloading(mPrgLoading, false);
}
@Override
public void onError(Throwable e) {
mLoggingService.log(e);
Crashlytics.logException(e);
showloading(mPrgLoading, false);
showError();
}
@Override
public void onNext(RegistrationState registrationState) {
onUpdatedRegistrationState(registrationState);
mLoggingService.log("Flow act received registration event : " + registrationState.name());
if (registrationState == RegistrationState.REGISTRATION_STATE_LAN_SCAN_MODULE_FOUND) {
moduleFound((String) registrationState.getExtra());
this.unsubscribe();
}
if (registrationState == RegistrationState.REGISTRATION_STATE_DONE) {
lanScanCompleted();
}
if (registrationState == RegistrationState.REGISTRATION_STATE_FAILED) {
showError();
}
}
});
}
示例13: doSearch
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
public void doSearch(String keyword) {
mData.clear();
mImages.clear();
Observable<GoogleImageSearchResponse> mImageSearchObservable = API
.getImageSearchFetcher(API.SEARCH_URL);
mAdapterDataSubscription = AndroidObservable.fromActivity(mContext,
mImageSearchObservable).subscribe(mAdapterDataObserver);
// mImageSearchObservable.subscribe();
}
示例14: onStart
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
mPluginConnectionManager.onResume();
if (RxUtils.notSubscribed(chargingSubscription)) {
//check if already plugged first
IntentFilter filter2 = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent battChanged = registerReceiver(null, filter2);
int battStatus = (battChanged != null) ? battChanged.getIntExtra(BatteryManager.EXTRA_STATUS, -1) : -1;
if (battStatus == BatteryManager.BATTERY_STATUS_CHARGING
|| battStatus == BatteryManager.BATTERY_STATUS_FULL) {
keepScreenOn(true);
}
// keep apprised of future plug events
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_POWER_CONNECTED);
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
chargingSubscription = AndroidObservable.fromBroadcast(this, filter)
.subscribe(new Action1<Intent>() {
@Override
public void call(Intent intent) {
if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())) {
keepScreenOn(true);
} else if (Intent.ACTION_POWER_DISCONNECTED.equals(intent.getAction())) {
keepScreenOn(false);
}
}
});
}
}
示例15: playStateChanged
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
public static Observable<Boolean> playStateChanged(Context appContext) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
Observable<Intent> intentObservable = AndroidObservable.fromBroadcast(appContext, intentFilter);
return intentObservable.map(new Func1<Intent, Boolean>() {
@Override
public Boolean call(Intent intent) {
return intent.getBooleanExtra("playing", false);
}
});
}