QuestionPresenter(QuestionContract.View view, RequestFactory requestFactory, TriviaSharedPreferences triviaSharedPreferences, int amount, String categoryId, String difficulty, String questionType) { this.view = view; this.requestFactory = requestFactory; this.triviaSharedPreferences = triviaSharedPreferences; this.amount = amount; this.categoryId = categoryId; this.difficulty = difficulty; this.questionType = questionType; sessionToken = triviaSharedPreferences.getSessionToken(); questionsList = new ArrayList<>(); questionPosition = 0; numberOfCorrectAnswers = 0; compositeDisposable = new CompositeDisposable(); view.setPresenter(this); }
@Override public void onBindViewHolder(ChapterViewHolder holder, int position) { CompositeDisposable compositeDisposable = new CompositeDisposable(); holder.binding.webview.loadUrl(BLANK_URL); holder.binding.webview.setUrlInterceptor(strategy.urlInterceptor); SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position); holder.binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings()); Bridge bridge = new Bridge(); holder.binding.webview.setInternalBridge(bridge); handleLocation(position, holder.binding.webview); bridge.xPath() .doOnNext(xPath -> { EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath); strategy.setCurrentLocation(location); }) .subscribeWith(new BaseDisposableObserver<>()) .addTo(compositeDisposable); }
@Test public void test() { CompletableSubject subject = CompletableSubject.create(); Completable source = subject.hide(); TestObserver testObserver = new TestObserver(); CompositeDisposable composite = new CompositeDisposable(); Disposable disposable = source .compose(DisposableAttach.<String>to(composite)) .subscribeWith(testObserver); assertTrue(composite.size() == 1); composite.dispose(); assertTrue(composite.size() == 0); assertTrue(composite.isDisposed()); assertTrue(disposable.isDisposed()); assertTrue(testObserver.isDisposed()); }
@Test public void test() { MaybeSubject<String> subject = MaybeSubject.create(); Maybe<String> maybeSource = subject.hide(); TestObserver testObserver = new TestObserver(); CompositeDisposable composite = new CompositeDisposable(); Disposable disposable = maybeSource .compose(DisposableAttach.<String>to(composite)) .subscribeWith(testObserver); subject.onSuccess("Foo"); testObserver.assertValue("Foo"); assertTrue(composite.size() == 1); composite.dispose(); assertTrue(composite.size() == 0); assertTrue(composite.isDisposed()); assertTrue(disposable.isDisposed()); assertTrue(testObserver.isDisposed()); }
private void setupLyricsView() { mDisposable = new CompositeDisposable(); //mLyricView.setLineSpace(15.0f); mLyricView.setTextSize(fontSize); //mLyricView.setTranslationY(DensityUtil.getScreenWidth(getActivity()) + DensityUtil.dip2px(getActivity(), 120)); mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() { @Override public void onPlayerClicked(long progress, String content) { MusicPlayerRemote.seekTo((int) progress); } }); rotate(); //mLyricView.setTouchable(true); //mLyricView.setPlayable(true); //mLyricView.setDefaultColor(Color.WHITE); }
@Override public void onCreate() { super.onCreate(); mCompositeDisposable = new CompositeDisposable(); mApiInterface = ApiClient.getClient().create(LastFmInterface.class); mApp = (Common) getApplicationContext(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationBuilder = new Notification.Builder(this); mNotificationBuilder.setContentTitle(getResources().getString(R.string.downloading_album_arts)) .setContentText(getResources().getString(R.string.downloading_art_for)) .setSmallIcon(R.mipmap.ic_music_file); startForeground(mNotificationId, mNotificationBuilder.build()); mCompositeDisposable.add(Observable.fromCallable(() -> downloadAndUpdateArts()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(downloadAndUpdateObserver)); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments(); mAccountInfoType = AccountInfoType.safeValueOf( args.getString( ARG_INFO_TYPE)); mCompositeDisposable = new CompositeDisposable(); View view = inflater.inflate(R.layout.dialog_input_account, container, false); ActivityComponent component = getActivityComponent(); if (component != null) { component.inject(this); } return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mLoginObservable = Observable .timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) .map(aLong -> "User id is " + UUID.randomUUID().toString()); mLoginFlowable = Flowable .timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) .map(aLong -> "User id is " + UUID.randomUUID().toString()); mCompositeDisposable = new CompositeDisposable(); findViewById(R.id.button_observable).setOnClickListener(this); findViewById(R.id.button_flowable).setOnClickListener(this); }
/** * {@link ProjectRepository} login() api call * - get accessToken after successful login (failed) */ @Test public void integrationLoginTestScenario2() throws Exception { Assert.assertEquals(projectRepository.getRepositoryState(), ProjectRepository.repositoryStates.INIT); Assert.assertNull(projectRepository.getData()); CompositeDisposable disposable = new CompositeDisposable(); disposable.add(projectRepository.login(dummyApiBadUrl, targetContext, dummyLogin, dummyPassword) .subscribeOn(Schedulers.io()) .doOnError(throwable -> Assert.fail()) .subscribe(appDataRxResponse -> { Assert.assertNotNull(appDataRxResponse); Assert.assertNull(appDataRxResponse.data); Assert.assertEquals(RxStatus.LOGIN_ERROR, appDataRxResponse.status); disposable.dispose(); })); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sp = PreferenceManager.getDefaultSharedPreferences(this); checkPermission(); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mCompositeDisposable = new CompositeDisposable(); initRecyclerView(); loadProviders(); // mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh); // mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { // @Override // public void onRefresh() { // mRefreshLayout.setRefreshing(true); // loadProviders(); // runLayoutAnimation(); // mRefreshLayout.setRefreshing(false); // } // }); }
public void InitView() { //init Composite mCompositeDisposable = new CompositeDisposable(); //init AppCompatButton btn_loading_observe=(AppCompatButton)findViewById(R.id.btn_loading_observe); btn_loadig_flowable=(AppCompatButton)findViewById(R.id.btn_loading_flowable); //btn observe btn_loading_observe.setOnClickListener(view->{ mCompositeDisposable.add(RxProgress.from(MainActivity.this) .withMessage("Logging in...") .forObservable(user_Observable) .subscribe(id -> getMessage(id), throwable -> Log.w(TAG, throwable.getMessage()))); }); //btn Flowable btn_loadig_flowable.setOnClickListener(view ->{ mCompositeDisposable.add(RxProgress.from(MainActivity.this) .forFlowable(user_Flowable, BackpressureStrategy.DROP) .subscribe(id -> getMessage(id), throwable -> Log.w(TAG, throwable.getMessage()))); } ); }
public MonthAdapter(Context context, DateTime currentMonth) { this.context = context; this.subscriptions = new CompositeDisposable(); this.calendar = AUCalendar.getInstance(); this.layoutResId = R.layout.calendar_cell; this.currentMonth = currentMonth.withDayOfMonth(1).withMillisOfDay(0); initFromCalendar(); subscribe(); }
@CallSuper @Before public void before() { initMocks(this); testScheduler = new TestScheduler(); compositeDisposableHelper = new CompositeDisposableHelper(new CompositeDisposable(), new TestSchedulerProvider(testScheduler)); view = createView(); presenter = createPresenter(); presenter.attachView(view); }
@Override protected void onCreate(Bundle savedInstanceState) { Toothpick.inject(this, Toothpick.openScopes(RxNetwork.class, this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); subscriptions = new CompositeDisposable(); }
/** * 保存订阅后的disposable * @param o * @param disposable */ public void addSubscription(Object o, Disposable disposable) { if (mSubscriptionMap == null) { mSubscriptionMap = new HashMap<>(); } String key = o.getClass().getName(); if (mSubscriptionMap.get(key) != null) { mSubscriptionMap.get(key).add(disposable); } else { //一次性容器,可以持有多个并提供 添加和移除。 CompositeDisposable disposables = new CompositeDisposable(); disposables.add(disposable); mSubscriptionMap.put(key, disposables); } }
@Before public void setUp() throws Exception { CompositeDisposable compositeDisposable = new CompositeDisposable(); mTestScheduler = new TestScheduler(); TestSchedulerProvider testSchedulerProvider = new TestSchedulerProvider(mTestScheduler); mLoginPresenter = new LoginPresenter<>( mMockDataManager, testSchedulerProvider, compositeDisposable); mLoginPresenter.onAttach(mMockLoginMvpView); }
public TaskDetailPresenter(@Nullable String taskId, @NonNull TasksRepository tasksRepository, @NonNull TaskDetailContract.View taskDetailView, @NonNull BaseSchedulerProvider schedulerProvider) { this.mTaskId = taskId; mTasksRepository = checkNotNull(tasksRepository, "tasksRepository cannot be null!"); mTaskDetailView = checkNotNull(taskDetailView, "taskDetailView cannot be null!"); mSchedulerProvider = checkNotNull(schedulerProvider, "schedulerProvider cannot be null"); mCompositeDisposable = new CompositeDisposable(); mTaskDetailView.setPresenter(this); }
public StatisticsPresenter(@NonNull TasksRepository tasksRepository, @NonNull StatisticsContract.View statisticsView, @NonNull BaseSchedulerProvider schedulerProvider) { mTasksRepository = checkNotNull(tasksRepository, "tasksRepository cannot be null"); mStatisticsView = checkNotNull(statisticsView, "statisticsView cannot be null!"); mSchedulerProvider = checkNotNull(schedulerProvider, "schedulerProvider cannot be null"); mCompositeDisposable = new CompositeDisposable(); mStatisticsView.setPresenter(this); }
@Inject public SettingStore(@NonNull Context context, @NonNull Dispatcher dispatcher) { this.compositeDisposable = new CompositeDisposable(); this.setting = Setting.get(context.getApplicationContext()); // init properties rotate.onNext(setting.getRotation()); Disposable disposable = dispatcher.stream() .filter(a -> ChangeLandscapeMode == a.id()) .map(a -> (boolean) a.param()) .subscribe(rotate::onNext); compositeDisposable.add(disposable); }
public RecentlyPlayPresenter(@NonNull RecentlyPlayContract.View view, MusicRepository repository) { mDisposables = new CompositeDisposable(); mView = view; mView.setPresenter(this); mRepository = repository; }
@Inject QuranPagePresenter(BookmarkModel bookmarkModel, CoordinatesModel coordinatesModel, QuranSettings quranSettings, QuranPageWorker quranPageWorker, Integer... pages) { this.bookmarkModel = bookmarkModel; this.quranSettings = quranSettings; this.coordinatesModel = coordinatesModel; this.quranPageWorker = quranPageWorker; this.compositeDisposable = new CompositeDisposable(); this.pages = pages; }
@Provides @FragmentScope protected SingleListPresenter providePresenter(Context context, DiscogsInteractor discogsInteractor, MySchedulerProvider mySchedulerProvider, SingleListEpxController controller, FilterHelper filterHelper) { return new SingleListPresenter(context, view, discogsInteractor, mySchedulerProvider, controller, new CompositeDisposable(), filterHelper); }
@Provides protected ArtistReleasesChildPresenter providePresenter(ArtistResultFunction artistResultFunction, ArtistReleaseBehaviorRelay relay, MySchedulerProvider mySchedulerProvider, ArtistReleasesTransformer transformer) { return new ArtistReleasesChildPresenter(new CompositeDisposable(), artistResultFunction, relay, mySchedulerProvider, transformer); }
public CompanyDetailPresenter(@NonNull CompanyDetailContract.View view, @NonNull CompaniesRepository companiesRepository, @NonNull String companyId) { this.view = view; this.companiesRepository = companiesRepository; this.companyId = companyId; this.view.setPresenter(this); compositeDisposable = new CompositeDisposable(); }
public static void populateBranchSpinner(final Context context, final Spinner spinnerBranches , final CompositeDisposable compositeDisposable) { BranchesNetworkCalls.getAllBranches().subscribe(new Observer<List<Branch>>() { @Override public void onSubscribe(Disposable d) { compositeDisposable.add(d); } @Override public void onNext(List<Branch> value) { ArrayList<String> date = new ArrayList<>(); for (Branch branch : value) { date.add(String.valueOf(branch.getCodeBr())); } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, date); spinnerBranches.setAdapter(adapter); } @Override public void onError(Throwable e) { Log.e("Get Branches" , "Error getting branches" , e); if(e instanceof SocketException || e instanceof IOException) { Toast.makeText(context , R.string.no_internet , Toast.LENGTH_SHORT).show(); } else if (e instanceof Exception) { Toast.makeText(context , e.getMessage() , Toast.LENGTH_LONG).show(); } } @Override public void onComplete() { } }); }
public static void populateBrandSpinner(final Context context, final Spinner spinnerBrands , final CompositeDisposable compositeDisposable) { BrandsNetworkCalls.getAllBrands().subscribe(new Observer<List<Brand>>() { @Override public void onSubscribe(Disposable d) { compositeDisposable.add(d); } @Override public void onNext(List<Brand> value) { ArrayList<String> date = new ArrayList<>(); for (Brand brand : value) { date.add(String.valueOf(brand.getCodeBrd())); } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, date); spinnerBrands.setAdapter(adapter); } @Override public void onError(Throwable e) { Log.e("Get Brands" , "Error getting brands" , e); if(e instanceof SocketException || e instanceof IOException) { Toast.makeText(context , R.string.no_internet , Toast.LENGTH_SHORT).show(); } else if (e instanceof Exception) { Toast.makeText(context , e.getMessage() , Toast.LENGTH_LONG).show(); } } @Override public void onComplete() { } }); }
public static void populateClientSpinner(final Context context, final Spinner spinnerClients , final CompositeDisposable compositeDisposable) { ClientsNetworkCalls.getAllClients().subscribe(new Observer<List<Client>>() { @Override public void onSubscribe(Disposable d) { compositeDisposable.add(d); } @Override public void onNext(List<Client> value) { ArrayList<String> date = new ArrayList<>(); for (Client client : value) { date.add(String.valueOf(client.getNameClt())); } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, date); spinnerClients.setAdapter(adapter); } @Override public void onError(Throwable e) { Log.e("Get Clients" , "Error getting clients" , e); if(e instanceof SocketException || e instanceof IOException) { Toast.makeText(context , R.string.no_internet , Toast.LENGTH_SHORT).show(); } else if (e instanceof Exception) { Toast.makeText(context , e.getMessage() , Toast.LENGTH_LONG).show(); } } @Override public void onComplete() { } }); }
/** * {@link ProjectRepository} getAppData() / getData() integration test scenario 1 * - check init ProjectRepository state * - get appData API response (successful) * - check ProjectRepository after successful call */ @Test public void integrationDataTestScenario1() throws Exception { Assert.assertEquals(projectRepository.getRepositoryState(), ProjectRepository.repositoryStates.INIT); Assert.assertNull(projectRepository.getData()); projectRepository.setAccessToken(dummyToken); Gson gson = new Gson(); AppData appData = gson.fromJson( readAssetFile(testContext, "api/app_data.json"), AppData.class); CompositeDisposable disposable = new CompositeDisposable(); disposable.add(projectRepository.getAppData(dummyApiUrl, targetContext) .subscribeOn(Schedulers.io()) .doOnError(throwable -> Assert.fail()) .subscribe(appDataRxResponse -> { Assert.assertNotNull(appDataRxResponse); Assert.assertNotNull(appDataRxResponse.data); Assert.assertNull(appDataRxResponse.error); Assert.assertEquals(RxStatus.SUCCESS, appDataRxResponse.status); Assert.assertEquals(appData, appDataRxResponse.data); Assert.assertEquals(appData.hashCode(), appDataRxResponse.data.hashCode()); Assert.assertEquals(projectRepository.getRepositoryState(), ProjectRepository.repositoryStates.READY); Assert.assertNotNull(projectRepository.getData()); Assert.assertEquals(projectRepository.getData().data, appData); disposable.dispose(); })); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); compositeDisposable = new CompositeDisposable(); setupViews(view); SpinnersHelper.populateBranchSpinner(getContext() , spinner_Brcode , compositeDisposable); SpinnersHelper.populateProductSpinner(getContext() , spinner_Prcode , compositeDisposable); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); clients = new ArrayList<>(); setupViews(view); compositeDisposable = new CompositeDisposable(); if (GSBApplication.isDummyData()) { clients.addAll(getDummyClients()); adapter.notifyDataSetChanged(); } else { fetchClients(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ajouter_supplier); compositeDisposable = new CompositeDisposable(); setupViews(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); compositeDisposable = new CompositeDisposable(); setContentView(R.layout.activity_ajoute_branch); setupViews(); }
private void disposeAndRemove(FragmentEvent event) { if (disposables.containsKey(event)) { CompositeDisposable disposable = disposables.get(event); disposable.dispose(); disposable.clear(); disposables.remove(event); } }
private void disposeAndRemove(ActivityEvent event) { if (disposables.containsKey(event)) { CompositeDisposable disposable = disposables.get(event); disposable.dispose(); disposable.clear(); disposables.remove(event); } }
public LoginPresenter (AuthSource authSource, LoginContract.View view, BaseSchedulerProvider schedulerProvider){ this.authSource = authSource; this.view = view; this.schedulerProvider = schedulerProvider; this.compositeDisposable = new CompositeDisposable(); view.setPresenter(this); }
protected void addDisposable(Disposable s) { if (s == null) { return; } if (this.mCompositeDisposable == null) { this.mCompositeDisposable = new CompositeDisposable(); } this.mCompositeDisposable.add(s); }
public PhotoDetailPresenter(AuthSource auth, DatabaseSource database, PhotoDetailContract.View view, BaseSchedulerProvider schedulerProvider ) { this.auth = auth; this.database = database; this.view = view; this.schedulerProvider = schedulerProvider; this.subscriptions = new CompositeDisposable(); view.setPresenter(this); }
public void attach(T view) { mBaseView = view; mComposite = new CompositeDisposable(); addSubscription(RxEvent.EVENT_TYPE_CHANGE_THEME, new Consumer() { @Override public void accept(Object o) throws Exception { mBaseView.onThemeSwitch(); } }); onAttach(); }
@Inject public BasePresenter(I mvpInteractor, SchedulerProvider schedulerProvider, CompositeDisposable compositeDisposable) { mMvpInteractor = mvpInteractor; mSchedulerProvider = schedulerProvider; mCompositeDisposable = compositeDisposable; }