本文整理汇总了Java中rx.android.observables.AndroidObservable类的典型用法代码示例。如果您正苦于以下问题:Java AndroidObservable类的具体用法?Java AndroidObservable怎么用?Java AndroidObservable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidObservable类属于rx.android.observables包,在下文中一共展示了AndroidObservable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
});
}
开发者ID:t28hub,项目名称:rx-weather,代码行数:25,代码来源:ForecastFragment.java
示例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);
}
});
}
开发者ID:t28hub,项目名称:rx-weather,代码行数:25,代码来源:WeatherFragment.java
示例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);
});
}
}
开发者ID:johncarpenter,项目名称:MarketAndroid,代码行数:19,代码来源:CreateSmartListFragment.java
示例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);
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:24,代码来源:RgbV1Activity.java
示例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);
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:26,代码来源:RgbV1Activity.java
示例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);
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:27,代码来源:RgbV1Activity.java
示例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);
}
开发者ID:passos,项目名称:reactive-android-demo,代码行数:21,代码来源:SearchResultAdapter.java
示例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;
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:25,代码来源:DonateManager.java
示例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);
}
开发者ID:sys1yagi,项目名称:android-roughly-java8,代码行数:10,代码来源:MainActivity.java
示例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);
}
开发者ID:florianmski,项目名称:SpongeFramework,代码行数:9,代码来源:RxFragment.java
示例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);
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:35,代码来源:OverviewActivity.java
示例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();
}
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:40,代码来源:TutorialRegisterFlowActivity.java
示例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();
}
开发者ID:passos,项目名称:reactive-android-demo,代码行数:12,代码来源:SearchResultAdapter.java
示例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);
}
}
});
}
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:31,代码来源:LauncherActivity.java
示例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);
}
});
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:12,代码来源:BroadcastObservables.java
示例16: shuffleModeChanged
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
public static Observable<Integer> shuffleModeChanged(Context appContext, final MusicServiceConnection connection) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
Observable<Intent> intentObservable = AndroidObservable
.fromBroadcast(appContext, intentFilter).observeOn(Schedulers.io());
return intentObservable.flatMap(new Func1<Intent, Observable<Integer>>() {
@Override
public Observable<Integer> call(Intent intent) {
return connection.getShuffleMode();
}
});
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:13,代码来源:BroadcastObservables.java
示例17: repeatModeChanged
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
public static Observable<Integer> repeatModeChanged(Context appContext, final MusicServiceConnection connection) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
Observable<Intent> intentObservable = AndroidObservable
.fromBroadcast(appContext, intentFilter).observeOn(Schedulers.io());
return intentObservable.flatMap(new Func1<Intent, Observable<Integer>>() {
@Override
public Observable<Integer> call(Intent intent) {
return connection.getRepeatMode();
}
});
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:13,代码来源:BroadcastObservables.java
示例18: onStart
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
@Override
public void onStart() {
super.onStart();
// Start loading
ViewUtils.setViewVisible(progressBar);
ViewUtils.setViewGone(listView);
Observable<Repository[]> observable = CustomApplication.getInstance().getGithubApi()
.getListOfRepositories("octokit");
// let's bind the observable to the fragment so It follows the Fragment lifecycle
AndroidObservable.bindFragment(MainFragment.this, observable).
// do we want to cache the response so if anyone else subscribe again to observable after it's finished will
// receive the same result?
// observable.cache()
// subscribe the observable in a scheduler
subscribeOn(Schedulers.io()).
// observe in the mainThread
observeOn(AndroidSchedulers.mainThread()).
// subscribe the observable,
subscribe(new EndObserver<Repository[]>() {
@Override
public void onCompleted() {
super.onCompleted();
// do whatever you want in the onComplete, keep in mind that if an error occurs this is never called
}
@Override
public void onNext(final Repository[] repositories) {
super.onNext(repositories);
// item emitted, use it
refreshListView(repositories);
}
@Override
public void onError(final Throwable throwable) {
super.onError(throwable);
// an error occured during the operation, implements your logic here!
}
});
}
开发者ID:fedestyla,项目名称:RetrofitWithRx,代码行数:40,代码来源:MainFragment.java
示例19: loadData
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
private void loadData() {
if (getIntent() == null || !getIntent().hasExtra(KEY_EXTRA_WIFIMODULE)) {
return;
}
this.mSelectedWifiModule = getIntent().getExtras().getParcelable(KEY_EXTRA_WIFIMODULE);
if (mSelectedWifiModule == null) {
onNavigateUp();
return;
}
final WifiInfo[] mCurrentWifiInfo = {WifiUtils.getCurrentWifiInfo(this)};
if (mCurrentWifiInfo[0] == null) {
onUnableToGetcurrentWifi();
return;
}
AndroidObservable.bindActivity(this, mGetItOn.getRegistrator().getWifiUpdates())
.flatMap(new Func1<WifiInfo, Observable<List<WifiScanResult>>>() {
@Override
public Observable<List<WifiScanResult>> call(WifiInfo wifiInfo) {
mCurrentWifiInfo[0] = wifiInfo;
return mGetItOn.getRegistrator()
.requestWifiScan(true);
}
}).subscribe(new Subscriber<List<WifiScanResult>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(List<WifiScanResult> wifiScanResults) {
for (WifiScanResult result : wifiScanResults) {
if (result.getBSSID().equals(mCurrentWifiInfo[0].getBSSID())) {
onWifiInfoLoaded(result);
break;
}
}
}
});
}
开发者ID:christophesmet,项目名称:ledsgetIton,代码行数:46,代码来源:TutorialSetupInfoActivity.java
示例20: metaChanged
import rx.android.observables.AndroidObservable; //导入依赖的package包/类
public static Observable<Intent> metaChanged(Context appContext) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MusicPlaybackService.META_CHANGED);
Observable<Intent> intentObservable = AndroidObservable.fromBroadcast(appContext, intentFilter);
return intentObservable;
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:7,代码来源:BroadcastObservables.java
注:本文中的rx.android.observables.AndroidObservable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论