Search in sources :

Example 1 with LoaderManager

use of androidx.loader.app.LoaderManager in project SeriesGuide by UweTrottmann.

the class MoviesNowFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ViewTools.setSwipeRefreshLayoutColors(requireActivity().getTheme(), swipeRefreshLayout);
    // define dataset
    adapter = new MoviesNowAdapter(getContext(), itemClickListener);
    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            updateEmptyState();
        }

        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            updateEmptyState();
        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            updateEmptyState();
        }
    });
    recyclerView.setAdapter(adapter);
    // if connected to trakt, replace local history with trakt history, show friends history
    if (TraktCredentials.get(getActivity()).hasCredentials()) {
        isLoadingRecentlyWatched = true;
        isLoadingFriends = true;
        showProgressBar(true);
        LoaderManager loaderManager = LoaderManager.getInstance(this);
        loaderManager.initLoader(MoviesActivity.NOW_TRAKT_USER_LOADER_ID, null, recentlyTraktCallbacks);
        loaderManager.initLoader(MoviesActivity.NOW_TRAKT_FRIENDS_LOADER_ID, null, traktFriendsHistoryCallbacks);
    }
    setHasOptionsMenu(true);
}
Also used : LoaderManager(androidx.loader.app.LoaderManager) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with LoaderManager

use of androidx.loader.app.LoaderManager in project SeriesGuide by UweTrottmann.

the class ShowsNowFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ViewTools.setSwipeRefreshLayoutColors(requireActivity().getTheme(), swipeRefreshLayout);
    // define dataset
    adapter = new NowAdapter(getActivity(), itemClickListener);
    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            updateEmptyState();
        }

        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            updateEmptyState();
        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            updateEmptyState();
        }
    });
    recyclerView.setAdapter(adapter);
    // if connected to trakt, replace local history with trakt history, show friends history
    if (TraktCredentials.get(getActivity()).hasCredentials()) {
        isLoadingRecentlyWatched = true;
        isLoadingFriends = true;
        showProgressBar(true);
        LoaderManager loaderManager = LoaderManager.getInstance(this);
        loaderManager.initLoader(ShowsActivity.NOW_TRAKT_USER_LOADER_ID, null, recentlyTraktCallbacks);
        loaderManager.initLoader(ShowsActivity.NOW_TRAKT_FRIENDS_LOADER_ID, null, traktFriendsHistoryCallbacks);
    }
    setHasOptionsMenu(true);
}
Also used : LoaderManager(androidx.loader.app.LoaderManager) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 3 with LoaderManager

use of androidx.loader.app.LoaderManager in project SeriesGuide by UweTrottmann.

the class ShowsNowFragment method refreshStream.

private void refreshStream() {
    showProgressBar(true);
    showError(null);
    // if connected to trakt, replace local history with trakt history, show friends history
    // user might get disconnected during our life-time,
    // so properly clean up old loaders so they won't interfere
    isLoadingRecentlyWatched = true;
    LoaderManager loaderManager = LoaderManager.getInstance(this);
    if (TraktCredentials.get(getActivity()).hasCredentials()) {
        destroyLoaderIfExists(ShowsActivity.NOW_RECENTLY_LOADER_ID);
        loaderManager.restartLoader(ShowsActivity.NOW_TRAKT_USER_LOADER_ID, null, recentlyTraktCallbacks);
        isLoadingFriends = true;
        loaderManager.restartLoader(ShowsActivity.NOW_TRAKT_FRIENDS_LOADER_ID, null, traktFriendsHistoryCallbacks);
    } else {
        // destroy trakt loaders and remove any shown error message
        destroyLoaderIfExists(ShowsActivity.NOW_TRAKT_USER_LOADER_ID);
        destroyLoaderIfExists(ShowsActivity.NOW_TRAKT_FRIENDS_LOADER_ID);
        showError(null);
        loaderManager.restartLoader(ShowsActivity.NOW_RECENTLY_LOADER_ID, null, recentlyLocalCallbacks);
    }
}
Also used : LoaderManager(androidx.loader.app.LoaderManager)

Example 4 with LoaderManager

use of androidx.loader.app.LoaderManager in project devbricks by dailystudio.

the class AbsLoaderFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LoaderManager ldMgr = getLoaderManagerSafe();
    if (ldMgr != null) {
        ldMgr.initLoader(getLoaderId(), createLoaderArguments(), this);
        if (shouldShowLoadingView()) {
            showLoadingView();
        }
    }
}
Also used : LoaderManager(androidx.loader.app.LoaderManager)

Example 5 with LoaderManager

use of androidx.loader.app.LoaderManager in project SeriesGuide by UweTrottmann.

the class MoviesNowFragment method refreshStream.

private void refreshStream() {
    showProgressBar(true);
    showError(null);
    // so properly clean up old loaders so they won't interfere
    if (TraktCredentials.get(getActivity()).hasCredentials()) {
        isLoadingRecentlyWatched = true;
        LoaderManager loaderManager = LoaderManager.getInstance(this);
        loaderManager.restartLoader(MoviesActivity.NOW_TRAKT_USER_LOADER_ID, null, recentlyTraktCallbacks);
        isLoadingFriends = true;
        loaderManager.restartLoader(ShowsActivity.NOW_TRAKT_FRIENDS_LOADER_ID, null, traktFriendsHistoryCallbacks);
    } else {
        // destroy trakt loaders and remove any shown error message
        destroyLoaderIfExists(MoviesActivity.NOW_TRAKT_USER_LOADER_ID);
        destroyLoaderIfExists(MoviesActivity.NOW_TRAKT_FRIENDS_LOADER_ID);
        showError(null);
    }
}
Also used : LoaderManager(androidx.loader.app.LoaderManager)

Aggregations

LoaderManager (androidx.loader.app.LoaderManager)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)2