use of com.squareup.otto.Subscribe in project zype-android by zype.
the class VideoDetailViewModel method handleVideo.
/**
* Handles API request for video
*
* @param event Response event
*/
@Subscribe
public void handleVideo(VideoEvent event) {
Logger.d("handleVideo()");
VideoData data = event.getEventData().getModelData().getVideoData();
Video video = DbHelper.videoDataToVideoEntity(data);
Video dbVideo = repo.getVideoSync(videoId);
if (dbVideo == null) {
dbVideo = video;
onAir.setValue(video.onAir == 1);
} else {
if (dbVideo.onAir != video.onAir) {
dbVideo.onAir = video.onAir;
onAir.setValue(video.onAir == 1);
}
}
repo.updateVideo(dbVideo);
if (dbVideo != null)
videoLiveData.setValue(dbVideo);
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class VideoDetailViewModel method handleDownloadVideo.
/**
* Handles API request for player video download url
*
* @param event Response event
*/
@Subscribe
public void handleDownloadVideo(DownloadVideoEvent event) {
Logger.d("handleDownloadVideo()");
File file = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "mp4");
String url;
if (file != null) {
url = file.getUrl();
String videoId = event.mFileId;
// Save download url in the local database if it was changed
Video video = repo.getVideoSync(videoId);
video.downloadVideoUrl = url;
repo.updateVideo(video);
if (!TextUtils.isEmpty(url)) {
downloadsAvailableLiveData.setValue(true);
}
} else {
Logger.e("handleDownloadVideo(): mp4 source not found");
}
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class ZypeApp method handleConsumer.
@Subscribe
public void handleConsumer(ConsumerEvent event) {
Logger.d("handleConsumer()");
if (event.getRequest() == WebApiManager.Request.CONSUMER_FORGOT_PASSWORD) {
return;
}
Consumer data = event.getEventData().getModelData();
int subscriptionCount = data.getConsumerData().getSubscriptionCount();
SettingsProvider.getInstance().saveSubscriptionCount(subscriptionCount);
String consumerId = data.getConsumerData().getId();
SettingsProvider.getInstance().saveConsumerId(consumerId);
SettingsProvider.getInstance().setString(SettingsProvider.CONSUMER_EMAIL, data.getConsumerData().getEmail());
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class ActionCreatorTest method createTodoActionTest.
@Test
public void createTodoActionTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
actionBus.register(new Object() {
@Subscribe
public void addTodo(TodoAction action) {
assertThat(action.getData().get(TodoAction.DataKeys.DESCRIPTION, "")).isEqualTo("Test");
testDone.set(true);
}
});
actionCreator.createNewTodoAction("Test");
while (!testDone.get()) ;
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class ActionCreatorTest method createViewActiveTodosActionTest.
@Test
public void createViewActiveTodosActionTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
actionBus.register(new Object() {
@Subscribe
public void addTodo(ViewAction action) {
assertThat(action.getType()).isEqualTo(ViewAction.ActionTypes.VIEW_ACTIVE);
testDone.set(true);
}
});
actionCreator.createViewActiveTodosAction();
while (!testDone.get()) ;
}
Aggregations