Skip to content

Instantly share code, notes, and snippets.

View Diolor's full-sized avatar

Dionysis Lorentzos Diolor

View GitHub Profile
@Diolor
Diolor / gradle-mvn-push
Last active August 29, 2015 14:17
Fixing stripe dependency file
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Diolor
Diolor / README.markdown
Created October 25, 2012 02:18 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
PublishSubject<Void> viewClickedSubject = PublishSubject.create();
CompositeSubscription startStopCompositeSubscription = new CompositeSubscription();
protected void onStart() {
view.setOnClickListener(v-> viewClickedSubject.onNext(null));
Subscription subscription = viewClickedSubject
.flatMap(aVoid-> api.getAlert())
.subscribe(this::makeAlertToast, Throwable::printStackTrace);
@Diolor
Diolor / final.java
Last active June 18, 2016 05:53
Final example
private final PublishSubject<Void> viewClickedSubject = PublishSubject.create();
private final CompositeSubscription startStopCompositeSubscription = new CompositeSubscription();
@Override
protected void onStart() {
super.onStart();
view.setOnClickListener(v-> viewClickedSubject.onNext(null));
Subscription subscription = viewClickedSubject
100% — ff
99% — fc
98% — fa
97% — f7
96% — f5
95% — f2
94% — f0
93% — ed
92% — eb
91% — e8
@Diolor
Diolor / MainActivity.java
Last active January 7, 2017 19:40
Controllable observable with commit()
public class MainActivity extends AppCompatActivity {
private final PublishSubject<Object> dialogDisplaySubject = PublishSubject.create();
private final Disposable disposable = dialogDisplaySubject
.subscribe(o ->
new MyDialogFragment()
.show(getSupportFragmentManager(), "DIALOG_TAG")
);
@Override
@Diolor
Diolor / MainActivity.java
Last active January 7, 2017 19:42
Uncontrollable observable with commit()
public class MainActivity extends AppCompatActivity {
private final Disposable disposable = Observable.timer(5, TimeUnit.SECONDS)
.subscribe(o ->
new MyDialogFragment()
.show(getSupportFragmentManager(), "DIALOG_TAG")
);
@Override
protected void onPause() {
@Diolor
Diolor / Presenter.java
Last active March 18, 2017 01:36
RxJava & MVP
public interface Presenter<S, V extends StateView<S>> {
void onStart(V view);
void onStop();
}
@Diolor
Diolor / FilterButtonPresenterTest.java
Created March 18, 2017 02:02
FilterButtonPresenterTest
@RunWith(MockitoJUnitRunner.class)
class FilterButtonPresenterTest {
@Mock
AccountInteractor accountInteractor;
@Mock
StateView<FilterButtonState> view;
@InjectMocks
FilterButtonPresenter testee;
@Diolor
Diolor / FilterButtonPresenter.java
Last active March 18, 2017 02:20
FilterButtonPresenter
@ViewScope // dagger 2 scope
class FilterButtonPresenter implements Presenter<FilterButtonState, StateView<FilterButtonState>> {
final AccountInteractor accountInteractor;
Subscription subscription;
@Inject // dagger 2 dependency injection
FilterButtonPresenter(AccountInteractor accountInteractor){
this.accountInteractor = accountInteractor;
}