Search in sources :

Example 26 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project SeriesGuide by UweTrottmann.

the class MovieDetailsFragment method handleLanguageEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void handleLanguageEvent(LanguageChoiceDialogFragment.LanguageChangedEvent event) {
    if (!AndroidUtils.isNetworkConnected(getContext())) {
        Toast.makeText(getContext(), R.string.offline, Toast.LENGTH_LONG).show();
        return;
    }
    String languageCode = getResources().getStringArray(R.array.languageCodesMovies)[event.selectedLanguageIndex];
    PreferenceManager.getDefaultSharedPreferences(getContext()).edit().putString(DisplaySettings.KEY_MOVIES_LANGUAGE, languageCode).apply();
    progressBar.setVisibility(View.VISIBLE);
    // reload movie details and trailers (but not cast/crew info which is not language dependent)
    restartMovieLoader();
    Bundle args = new Bundle();
    args.putInt(InitBundle.TMDB_ID, tmdbId);
    getLoaderManager().restartLoader(MovieDetailsActivity.LOADER_ID_MOVIE_TRAILERS, args, mMovieTrailerLoaderCallbacks);
}
Also used : Bundle(android.os.Bundle) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 27 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project SeriesGuide by UweTrottmann.

the class SeasonsFragment method onEvent.

/**
     * Updates the total remaining episodes counter, updates season counters after episode actions.
     */
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(EpisodeTools.EpisodeTaskCompletedEvent event) {
    if (!event.isSuccessful) {
        // no changes applied
        return;
    }
    if (!isAdded()) {
        // no longer added to activity
        return;
    }
    updateRemainingCounter();
    if (event.flagType instanceof SeasonWatchedType) {
        // If we can narrow it down to just one season...
        SeasonWatchedType seasonWatchedType = (SeasonWatchedType) event.flagType;
        getActivity().startService(UnwatchedUpdaterService.buildIntent(getContext(), getShowId(), seasonWatchedType.getSeasonTvdbId()));
    } else {
        updateUnwatchedCounts();
    }
}
Also used : SeasonWatchedType(com.battlelancer.seriesguide.util.tasks.EpisodeTaskTypes.SeasonWatchedType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 28 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project SeriesGuide by UweTrottmann.

the class GenericCheckInDialogFragment method onEvent.

@SuppressWarnings("unused")
@Subscribe
public void onEvent(TraktTask.TraktCheckInBlockedEvent event) {
    // launch a check-in override dialog
    TraktCancelCheckinDialogFragment newFragment = TraktCancelCheckinDialogFragment.newInstance(event.traktTaskArgs, event.waitMinutes);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    newFragment.show(ft, "cancel-checkin-dialog");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 29 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project Douya by DreaminginCodeZH.

the class UserDiaryListResource method onDiaryDeleted.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onDiaryDeleted(DiaryDeletedEvent event) {
    if (event.isFromMyself(this) || isEmpty()) {
        return;
    }
    List<Diary> diaryList = get();
    for (int i = 0, size = diaryList.size(); i < size; ) {
        Diary diary = diaryList.get(i);
        if (diary.id == event.diaryId) {
            diaryList.remove(i);
            getListener().onDiaryRemoved(getRequestCode(), i);
            --size;
        } else {
            ++i;
        }
    }
}
Also used : Diary(me.zhanghai.android.douya.network.api.info.frodo.Diary) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 30 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project Douya by DreaminginCodeZH.

the class BroadcastListResource method onBroadcastDeleted.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onBroadcastDeleted(BroadcastDeletedEvent event) {
    if (event.isFromMyself(this) || isEmpty()) {
        return;
    }
    List<Broadcast> broadcastList = get();
    for (int i = 0, size = broadcastList.size(); i < size; ) {
        Broadcast broadcast = broadcastList.get(i);
        if (broadcast.id == event.broadcastId || (broadcast.rebroadcastedBroadcast != null && broadcast.rebroadcastedBroadcast.id == event.broadcastId)) {
            broadcastList.remove(i);
            getListener().onBroadcastRemoved(getRequestCode(), i);
            --size;
        } else {
            ++i;
        }
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)43 Intent (android.content.Intent)7 SiteModel (org.wordpress.android.fluxc.model.SiteModel)5 NotificationManager (android.app.NotificationManager)3 NotificationCompat (android.support.v4.app.NotificationCompat)3 Activity (android.app.Activity)2 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 AspectPermission (com.yydcdut.note.aspect.permission.AspectPermission)2 CategoryCreateEvent (com.yydcdut.note.bus.CategoryCreateEvent)2 CategoryDeleteEvent (com.yydcdut.note.bus.CategoryDeleteEvent)2 CategoryEditEvent (com.yydcdut.note.bus.CategoryEditEvent)2 CategoryMoveEvent (com.yydcdut.note.bus.CategoryMoveEvent)2 CategoryUpdateEvent (com.yydcdut.note.bus.CategoryUpdateEvent)2 PhotoNoteCreateEvent (com.yydcdut.note.bus.PhotoNoteCreateEvent)2 PhotoNoteDeleteEvent (com.yydcdut.note.bus.PhotoNoteDeleteEvent)2 UserImageEvent (com.yydcdut.note.bus.UserImageEvent)2 Category (com.yydcdut.note.entity.Category)2 ContextLife (com.yydcdut.note.injector.ContextLife)2