Skip to content

Instantly share code, notes, and snippets.

View miquelbeltran's full-sized avatar

Miguel Beltran miquelbeltran

View GitHub Profile
@miquelbeltran
miquelbeltran / NotificationService.java
Created December 30, 2016 08:30
NotificationService with data payload
public class NotificationService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(remoteMessage.getData().get(“title”))
.setContentText(remoteMessage.getData().get(“body”))
.setSmallIcon(R.mipmap.ic_launcher)
.build();
NotificationManagerCompat manager = NotificationManagerCompat.from(getApplicationContext());
public class NotificationService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setSmallIcon(R.mipmap.ic_launcher)
.build();
NotificationManagerCompat manager = NotificationManagerCompat.from(getApplicationContext());
public class BooksInteractorMock implements BooksInteractor {
@Override
public Observable<BookSearchResult> search(String search) {
return Observable.just(getMockedBookSearchResult());
}
private BookSearchResult getMockedBookSearchResult() {
BookSearchResult bookSearchResult = new BookSearchResult();
// bookSearchResult.setBooks(myListOfBooks);
return bookSearchResult;
public class MainActivity extends AppCompatActivity {
EditText editText;
ImageButton imageButton;
BooksAdapter adapter;
ListView listView;
TextView textNoDataFound;
private CompositeSubscription subscriptions = new CompositeSubscription();
private BooksViewModel booksViewModel;
public class BooksViewModel {
private BooksInteractor interactor;
private Scheduler scheduler;
public BooksViewModel(BooksInteractor interactor, Scheduler scheduler) {
this.interactor = interactor;
this.scheduler = scheduler;
}
public interface BooksInteractor {
Observable<BookSearchResult> search(String search);
}
public class MainActivity extends AppCompatActivity implements BooksView {
EditText editText;
ImageButton imageButton;
BooksAdapter adapter;
ListView listView;
TextView textNoDataFound;
private BooksPresenter presenter;
@Override
public interface BooksView {
void updateUi(List<Book> books);
}
public class BooksPresenter {
BooksView view;
private BooksInteractor interactor;
public BooksPresenter(BooksInteractor interactor) {
this.interactor = interactor;
}
public void bind(BooksView view) {
public interface BooksInteractor {
Call<BookSearchResult> search(String search);
}