Search in sources :

Example 1 with RadioViewModel

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();
}
Also used : RadioViewModel(me.echeung.moemoekyun.viewmodels.RadioViewModel) PreferenceUtil(me.echeung.moemoekyun.utils.PreferenceUtil) UserViewModel(me.echeung.moemoekyun.viewmodels.UserViewModel) AuthViewModel(me.echeung.moemoekyun.viewmodels.AuthViewModel) APIClient(me.echeung.listenmoeapi.APIClient)

Example 2 with RadioViewModel

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);
}
Also used : RadioViewModel(me.echeung.moemoekyun.viewmodels.RadioViewModel) Song(me.echeung.listenmoeapi.models.Song) ParseException(java.text.ParseException)

Aggregations

RadioViewModel (me.echeung.moemoekyun.viewmodels.RadioViewModel)2 ParseException (java.text.ParseException)1 APIClient (me.echeung.listenmoeapi.APIClient)1 Song (me.echeung.listenmoeapi.models.Song)1 PreferenceUtil (me.echeung.moemoekyun.utils.PreferenceUtil)1 AuthViewModel (me.echeung.moemoekyun.viewmodels.AuthViewModel)1 UserViewModel (me.echeung.moemoekyun.viewmodels.UserViewModel)1