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


Java AppObservable类代码示例

本文整理汇总了Java中rx.android.app.AppObservable的典型用法代码示例。如果您正苦于以下问题:Java AppObservable类的具体用法?Java AppObservable怎么用?Java AppObservable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: loadComments

import rx.android.app.AppObservable; //导入依赖的package包/类
public void loadComments(News news) {
    if (news == null) {
        this.news = Parcels.unwrap(getActivity().getIntent().getParcelableExtra(Constants.NEWS));

        if (this.news != null) {
            comments = AppObservable.bindFragment(this, dataSource.getComments(this.news).cache());
        }
    } else {
        //Use the new news, so replace the newsDetailAdapter
        this.news = news;
        newsDetailAdapter = new NewsDetailAdapter(this, this.news);
        newsDetail.setAdapter(newsDetailAdapter);

        comments = AppObservable.bindFragment(this, dataSource.getComments(this.news).cache());
    }
}
 
开发者ID:pumpkinz,项目名称:pumpkin-reader,代码行数:17,代码来源:NewsDetailFragment.java

示例2: loadNews

import rx.android.app.AppObservable; //导入依赖的package包/类
private void loadNews(int id) {
    news = new News(id);
    Observable<List<Comment>> commentsObservable = dataSource.getNews(id)
            .flatMap(new Func1<News, Observable<List<Comment>>>() {
                @Override
                public Observable<List<Comment>> call(News loadedNews) {
                    news = loadedNews;
                    newsDetailAdapter.setNews(loadedNews);

                    if (newsListener != null) {
                        newsListener.onNewsLoaded(loadedNews);
                    }

                    return dataSource.getComments(loadedNews);
                }
            });

    comments = AppObservable.bindFragment(this, commentsObservable.cache());
}
 
开发者ID:pumpkinz,项目名称:pumpkin-reader,代码行数:20,代码来源:NewsDetailFragment.java

示例3: callOperation

import rx.android.app.AppObservable; //导入依赖的package包/类
private void callOperation() {
    if (mClient2 != null) {
        final long param1 = Long.valueOf(mParam1Text.getText().toString());
        final long param2 = Long.valueOf(mParam2Text.getText().toString());
        AppObservable.bindActivity(this, mClient2.call("com.example.add", Long.class, param1,
                param2)).subscribe(new Action1<Long>() {
            @Override
            public void call(final Long result) {
                mResultText.setText("Completed add with result " + result);
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(final Throwable error) {
                mResultText.setText("Completed add with error " + error);
            }
        });
    }
}
 
开发者ID:jrogers,项目名称:AndroidWampExample,代码行数:19,代码来源:MainActivity.java

示例4: knock

import rx.android.app.AppObservable; //导入依赖的package包/类
/**
 * Pings backend
 */
public void knock(){

    Subscription subscription = AppObservable.bindActivity(this, knockBackend())
            .subscribe(new Subscriber<String>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    Timber.e(e, e.getMessage());
                    Toast.makeText(MainActivity.this, R.string.error_message, Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onNext(final String joke) {
                    Toast.makeText(MainActivity.this, joke, Toast.LENGTH_LONG).show();
                }
            });

    mSubscriptions.add(subscription);
}
 
开发者ID:josemontiel,项目名称:FunnyDroids,代码行数:27,代码来源:MainActivity.java

示例5: knock

import rx.android.app.AppObservable; //导入依赖的package包/类
/**
 * Pings backend
 */
public void knock(){

    Subscription subscription = AppObservable.bindActivity(this, knockBackend())
            .subscribe(new Subscriber<String>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    Timber.e(e, e.getMessage());
                    Toast.makeText(MainActivity.this, R.string.error_message, Toast.LENGTH_SHORT).show();
                    showProgress(false);
                }

                @Override
                public void onNext(final String joke) {
                    showProgress(false);
                    Toast.makeText(MainActivity.this, joke, Toast.LENGTH_LONG).show();
                }
            });

    mSubscriptions.add(subscription);
}
 
开发者ID:josemontiel,项目名称:FunnyDroids,代码行数:29,代码来源:MainActivity.java

示例6: updateShelters

import rx.android.app.AppObservable; //导入依赖的package包/类
/**
 * 地図内の避難所情報を更新する。
 *
 * @param cameraPosition 中心位置
 */
private void updateShelters(@NonNull CameraPosition cameraPosition) {
    if (mMap != null) {
        AppObservable.bindFragment(this, mShelterManager.fetchShelters(cameraPosition.target, mMap.getProjection().getVisibleRegion().latLngBounds))
                .subscribeOn(Schedulers.newThread())
                .subscribe(new Subscriber<List<Shelter>>() {
                    @Override
                    public void onCompleted() {
                        // Nothing to do
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, ExceptionUtils.getStackTrace(e));

                        Toast.makeText(MapFragment.this.getActivity(), R.string.error_fetch_shelters, Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onNext(List<Shelter> shelters) {
                        Log.d(TAG, "updateShelters " + shelters.size());
                        mShelterMarkerManager.addShelters(shelters);
                    }
                });
    }
}
 
开发者ID:ipublishing-osp,项目名称:esnavi,代码行数:31,代码来源:MapFragment.java

示例7: registerNotification

import rx.android.app.AppObservable; //导入依赖的package包/类
/**
 * 通知を登録する。
 */
private void registerNotification() {
    AppObservable.bindActivity(this, mUserManager.registerNotificationKey(this))
            .subscribeOn(Schedulers.newThread())
            .subscribe(new Subscriber<Void>() {
                @Override
                public void onCompleted() {
                    // Nothing to do
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, ExceptionUtils.getStackTrace(e));

                    showErrorDialog(R.string.dialog_title_failed, R.string.error_register_notification, e);
                }

                @Override
                public void onNext(Void aVoid) {
                    // Nothing to do
                }
            });
}
 
开发者ID:ipublishing-osp,项目名称:esnavi,代码行数:26,代码来源:MapActivity.java

示例8: getPlacePredictions

import rx.android.app.AppObservable; //导入依赖的package包/类
private void getPlacePredictions(String searchQuery) {
    showProgress();
    Observable<List<Prediction>> observable = Observable.create((Observable
            .OnSubscribe<List<Prediction>>) subscriber -> {
        List<Prediction> predictions = googlePlacesClient.getPlacePredictions(searchQuery);
        if (predictions != null & predictions.size() != 0) {
            subscriber.onNext(predictions);
        } else {
            subscriber.onError(new Throwable());
        }
        subscriber.onCompleted();
    });
    AppObservable.bindActivity(this, observable)
            .subscribeOn(Schedulers.io())
            .flatMap(s -> Observable.from(s))
            .map(prediction -> prediction.getDescription())
            .toList()
            .subscribe(names -> showNamesInList(names),
                    throwable -> {
                        ArrayList<String> noResultsList = new ArrayList<>();
                        noResultsList.add("No results");
                        showNamesInList(noResultsList);
                        hideProgress();
                    });
}
 
开发者ID:asm-products,项目名称:nomad-android,代码行数:26,代码来源:GooglePlacesApiActivity.java

示例9: onCreate

import rx.android.app.AppObservable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    init();

    final Observable<OnTextChangeEvent> searchTermChangedObservable = WidgetObservable.text(editTextSearchTerm);
    final Observable<RepoSearchResults> searchResultsObservable = AppObservable.bindActivity(this,
            searchTermChangedObservable.debounce(MIN_SECONDS, TimeUnit.SECONDS)
                    .filter(onTextChangeEvent -> onTextChangeEvent.text().length() > MIN_CHARACTERS)
                    .flatMap(onTextChangeEvent -> callSearchWS(onTextChangeEvent.text().toString())
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())));
    searchResultsSubscription = searchResultsObservable
            .subscribe(new Subscriber<RepoSearchResults>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    Log.e(MainActivity.class.getSimpleName(), "Error", e);
                }

                @Override
                public void onNext(RepoSearchResults repoSearchResults) {
                    showData(repoSearchResults.getItems());
                }
            });
}
 
开发者ID:TechFreak,项目名称:RxTalk,代码行数:33,代码来源:MainActivity.java

示例10: onCreate

import rx.android.app.AppObservable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    repoAdapter = new RepoAdapter(this, new ArrayList<>());
    recyclerView.setAdapter(repoAdapter);

    showProgressBar();

    final GithubApi githubApi = new RestAdapter.Builder().setEndpoint("https://api.github.com").build().create(GithubApi.class);
    final Observable<List<Repo>> googleReposObservable = AppObservable.bindActivity(this, githubApi.getGoogleRepos())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
    googleReposSubscription = googleReposObservable.subscribe(new Subscriber<List<Repo>>() {
        @Override
        public void onCompleted() {

        }

        @Override
        public void onError(Throwable e) {
            Log.e(MainActivity.class.getSimpleName(), "Error", e);
        }

        @Override
        public void onNext(List<Repo> repos) {
            showData(repos);
        }
    });
}
 
开发者ID:TechFreak,项目名称:RxTalk,代码行数:35,代码来源:MainActivity.java

示例11: onResume

import rx.android.app.AppObservable; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    TextView searchTerm = (TextView) findViewById(R.id.searchTerm);
    Observable<String> inputs = AppObservables.inputs(searchTerm);
    compositeSubscription = new CompositeSubscription();
    // show progress bar when a new valid input is emitted from inputs
    compositeSubscription.add(AppObservable.bindActivity(this, AppObservables.doWhenSearching(inputs, showProgressBar)).subscribe());

    // TODO: this subscription will die on first error, for example missing network.
    // This should be improved e.g. by subscribing again in errorHandler
    // or using RxJava error handlers: https://github.com/ReactiveX/RxJava/wiki/Error-Handling-Operators
    compositeSubscription.add(AppObservable.bindActivity(this, AppObservables.pictures(inputs, okHttpClient, objectMapper)).subscribe(resultHandler, errorHandler));
}
 
开发者ID:blomqvie,项目名称:android-rxjava-training,代码行数:15,代码来源:MainActivity.java

示例12: onCreate

import rx.android.app.AppObservable; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    stories = AppObservable.bindFragment(this, loadNewsData(0, N_NEWS_PER_LOAD, true));
}
 
开发者ID:pumpkinz,项目名称:pumpkin-reader,代码行数:8,代码来源:NewsListFragment.java

示例13: getCharacterProfile

import rx.android.app.AppObservable; //导入依赖的package包/类
private void getCharacterProfile(boolean forceUpdate) {
    profileSubscription = AppObservable.bindActivity(
        this, LeaderboardDataService.getInstance().getCharacterProfile(realmName, name, forceUpdate))
        .observeOn(AndroidSchedulers.mainThread())
        .subscribeOn(Schedulers.newThread())
        .subscribe(this);
}
 
开发者ID:AlbertGrobas,项目名称:Leaderboards,代码行数:8,代码来源:CharacterActivity.java

示例14: setDataFromService

import rx.android.app.AppObservable; //导入依赖的package包/类
private void setDataFromService(boolean forceUpdate) {
    leaderboardSubscription = AppObservable.bindActivity(this,
            LeaderboardDataService.getInstance().getLeaderboard(Constants.BRACKET_LIST[currentBracket], forceUpdate))
            .delay(500, TimeUnit.MILLISECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.newThread())
            .subscribe(this);
}
 
开发者ID:AlbertGrobas,项目名称:Leaderboards,代码行数:9,代码来源:MainActivity.java

示例15: onViewCreated

import rx.android.app.AppObservable; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Exercise exercise = Exercises.getExerciseBySection(getArguments().getInt(SECTION_NUMBER));
    Observable<String> textObservable = Beers.beers().map(exercise::getString);
    subscription = AppObservable.bindFragment(this, textObservable).subscribe(text -> {
        setupView(view, text, exercise.getLabel());
    });
}
 
开发者ID:blomqvie,项目名称:training-totally-lazy,代码行数:9,代码来源:LazyInfoViewFragment.java


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