use of me.echeung.moemoekyun.viewmodels.RadioViewModel in project android-app by LISTEN-moe.
the class App method onCreate.
@Override
public void onCreate() {
super.onCreate();
// Preferences
preferenceUtil = new PreferenceUtil(this);
// API client
apiClient = new APIClient(this, getUserAgent(), preferenceUtil.getLibraryMode());
// UI view models
authViewModel = new AuthViewModel(this);
radioViewModel = new RadioViewModel(this);
userViewModel = new UserViewModel(this);
// Music player service
initNotificationChannel();
initService();
}
use of me.echeung.moemoekyun.viewmodels.RadioViewModel in project android-app by LISTEN-moe.
the class RadioService method onSocketReceive.
@Override
public void onSocketReceive(SocketUpdateResponse.Details info) {
final RadioViewModel viewModel = App.getRadioViewModel();
final Song song = info.getSong();
viewModel.setCurrentSong(song);
try {
this.trackStartTime = ISO8601.toCalendar(info.getStartTime());
} catch (ParseException e) {
e.printStackTrace();
}
viewModel.setLastSong(info.getLastPlayed().get(0));
viewModel.setSecondLastSong(info.getLastPlayed().get(1));
viewModel.setListeners(info.getListeners());
viewModel.setRequester(info.getRequester());
viewModel.setEvent(info.getEvent());
if (info.getQueue() != null) {
viewModel.setQueueSize(info.getQueue().getInQueue());
viewModel.setInQueueByUser(info.getQueue().getInQueueByUser());
viewModel.setQueuePosition(info.getQueue().getInQueueBeforeUser());
}
updateMediaSession();
updateNotification();
sendPublicIntent(RadioService.META_CHANGED);
}
Aggregations