public void setSearchQuery(String query) { if (mPendingJobId != NO_ID) { mJobManager.cancelJobInBackground(mPendingJobId, false); } mQuery = query; mPendingJobId = mJobManager.addJob(new FetchSearchPage(mQuery, 1)); mWatchMeAdapter.clear(); if (!isProgressVisible()) { showProgress(); } }
@Override public void onDestroy() { super.onDestroy(); if (mPendingJobId != NO_ID) { mJobManager.cancelJobInBackground(mPendingJobId, false); } }
@Subscribe @SuppressWarnings("unused") public void onLoadMoreItemsEvent(ScrollManager.LoadMoreItems items) { if (isPageLoading() || !canLoadMorePages()) { return; } mPendingJobId = mJobManager.addJob(new FetchSearchPage(mQuery, mCurrentPageNumber + 1)); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mWatchMeAdapter = getWatchMeAdapter(); WatchMeApplication application = WatchMeApplication.getApplication(); application.inject(this); application.inject(getScrollManager()); application.inject(mWatchMeAdapter); setupToolbar(true, savedInstanceState); setupParent(); if (getArguments() != null) { Bundle args = getArguments(); mQuery = args.getString(SEARCH_QUERY); mCurrentPageNumber = args.getInt(SEARCH_CURRENT_PAGE); SearchView search = getWatchMeActivity().getToolbar().getSearchView(); search.setQuery(mQuery); mPendingJobId = mJobManager.addJob(new FetchSearchPage(mQuery, mCurrentPageNumber)); } }