Java Code Examples for io.reactivex.Observable.fromCallable()

The following are Jave code examples for showing how to use fromCallable() of the io.reactivex.Observable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CP-Tester   File: MainActivity.java   View Source Code Vote up 7 votes
private Observable<List<ProviderInfo>> getProviders(){
    return Observable.fromCallable(new Callable<List<ProviderInfo>>() {
        @Override public List<ProviderInfo> call() throws Exception {
            List<ProviderInfo> info = new ArrayList<>();
            for (PackageInfo providerInfo :getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)){
                if (providerInfo.providers != null){
                    for (ProviderInfo provider : providerInfo.providers) {
                        if (provider.authority != null) {
                            if (sp.getBoolean("need_filter",false)){
                                info.add(provider);
                            }else if(provider.readPermission!=null){
                                info.add(provider);
                            }
                        }
                    }
                }
            }
            return info;
        }
    });
}
 
Example 2
Project: GitHub   File: AppDbHelper.java   View Source Code Vote up 6 votes
@Override
public Observable<List<Question>> getAllQuestions() {
    return Observable.fromCallable(new Callable<List<Question>>() {
        @Override
        public List<Question> call() throws Exception {
            return mDaoSession.getQuestionDao().loadAll();
        }
    });
}
 
Example 3
Project: android-mvp-interactor-architecture   File: OptionRepository.java   View Source Code Vote up 5 votes
public Observable<Boolean> isOptionEmpty() {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return !(mDaoSession.getOptionDao().count() > 0);
        }
    });
}
 
Example 4
Project: android-mvp-interactor-architecture   File: UserRepository.java   View Source Code Vote up 5 votes
public Observable<List<Question>> getAllQuestions() {
    return Observable.fromCallable(new Callable<List<Question>>() {
        @Override
        public List<Question> call() throws Exception {
            return mDaoSession.getQuestionDao().loadAll();
        }
    });
}
 
Example 5
Project: GitHub   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> isOptionEmpty() {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return !(mDaoSession.getOptionDao().count() > 0);
        }
    });
}
 
Example 6
Project: GitHub   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> saveQuestion(final Question question) {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            mDaoSession.getQuestionDao().insert(question);
            return true;
        }
    });
}
 
Example 7
Project: GitHub   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> saveOption(final Option option) {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            mDaoSession.getOptionDao().insertInTx(option);
            return true;
        }
    });
}
 
Example 8
Project: android-mvvm-architecture   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> isOptionEmpty() {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return mAppDatabase.optionDao().loadAll().isEmpty();
        }
    });
}
 
Example 9
Project: android-mvvm-architecture   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> saveOptionList(final List<Option> optionList) {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            mAppDatabase.optionDao().insertAll(optionList);
            return true;
        }
    });
}
 
Example 10
Project: Paprika   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<List<LikedRecipe>> checkIfRecipeIsAlreadyLiked(final Recipe recipe) {
    return Observable.fromCallable(new Callable<List<LikedRecipe>>() {
        @Override
        public List<LikedRecipe> call() throws Exception {
            return daoSession.getLikedRecipeDao().queryBuilder().where(LikedRecipeDao.Properties.RecipeId.eq(recipe.getRecipeId())).list();
        }
    });
}
 
Example 11
Project: Paprika   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> deleteLikedRecipe(final LikedRecipe likedRecipe) {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            daoSession.getLikedRecipeDao().deleteByKey(likedRecipe.getId());
            return true;
        }
    });
}
 
Example 12
Project: android-mvvm-architecture   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Boolean> insertUser(final User user) {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            mAppDatabase.userDao().insert(user);
            return true;
        }
    });
}
 
Example 13
Project: Weather-Guru-MVP   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override public Observable<List<CityDetailsModel>> getAllCities() {
  return Observable.fromCallable(new Callable<List<CityDetailsModel>>() {
    @Override public List<CityDetailsModel> call() throws Exception {
      return daoSession.getCityDetailsModelDao()
          .queryBuilder()
          .orderDesc(CityDetailsModelDao.Properties.Id)
          .list();
    }
  });
}
 
Example 14
Project: Paprika   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<List<LikedRecipe>> getLastInsertedLikedRecipe() {
    return Observable.fromCallable(new Callable<List<LikedRecipe>>() {
        @Override
        public List<LikedRecipe> call() throws Exception {
            return daoSession.getLikedRecipeDao().queryBuilder().orderDesc(LikedRecipeDao.Properties.Id).limit(1).list();
        }
    });
}
 
Example 15
Project: eggs-android   File: OptionRepository.java   View Source Code Vote up 5 votes
public Observable<Boolean> isOptionEmpty() {
    return Observable.fromCallable(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return !(mDaoSession.getOptionDao().count() > 0);
        }
    });
}
 
Example 16
Project: eggs-android   File: UserRepository.java   View Source Code Vote up 5 votes
public Observable<List<Question>> getAllQuestions() {
    return Observable.fromCallable(new Callable<List<Question>>() {
        @Override
        public List<Question> call() throws Exception {
            return mDaoSession.getQuestionDao().loadAll();
        }
    });
}
 
Example 17
Project: DailyTech   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<Void> removeArticle(final Article article) {
    return Observable.fromCallable(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            mDaoSession.getArticleDao().delete(article);
            return null;

        }
    });
}
 
Example 18
Project: Auto.js   File: DevPluginClient.java   View Source Code Vote up 5 votes
public Observable<JsonObject> send(final JsonObject object) {
    if (mState != State.CONNECTED) {
        throw new IllegalStateException("Not connected!");
    }
    return Observable.fromCallable(() -> {
        mOutputStream.write(object.toString().getBytes());
        mOutputStream.write("\n".getBytes());
        mOutputStream.flush();
        return object;
    });
}
 
Example 19
Project: TheNounProject   File: AppDbHelper.java   View Source Code Vote up 5 votes
@Override
public Observable<List<NounCollection>> getCollectionsFromDb(final String term) {
    return Observable.fromCallable(new Callable<List<NounCollection>>() {
        @Override public List<NounCollection> call() throws Exception {
            QueryBuilder<OrmCollection> qb = daoSession.getOrmCollectionDao().queryBuilder();
            if (term != null) {
                qb.where(OrmCollectionDao.Properties.Name.like(term));
            }
            return convertOrmToNounCollections(qb.list());
        }
    });

}
 
Example 20
Project: Detoxiom   File: NewQuoteInterctorImpl.java   View Source Code Vote up 4 votes
@Override
public Observable<QuoteModel> getQuoteObservable() {
    /* Call method and run it asynchronously :) */
    Call<QuoteModel> call = MyApplication.getAppComponent().getQCService().getQuote(ClientConfig.api_token);
    return Observable.fromCallable(() -> call.execute().body());
}