Search in sources :

Example 1 with DirectionDetectorScrollListener

use of com.frostwire.android.gui.util.DirectionDetectorScrollListener in project frostwire by frostwire.

the class SearchFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    // TODO: refactor this
    if (filterButton == null && isAdded() && getActivity() != null) {
        // best effort
        // this will happen due to the call to onTabReselected on full resume
        // and this is only solving the NPE, the drawback is that it will
        // create a few orphan view objects to be GC'ed soon.
        // it'is a poor solution overall, but the right one requires
        // a big refactor.
        getHeader(getActivity());
    }
    ConfigurationManager CM = ConfigurationManager.instance();
    if (adapter != null && (adapter.getCount() > 0 || adapter.getTotalCount() > 0)) {
        refreshFileTypeCounters(true);
        searchInput.selectTabByMediaType((byte) CM.getLastMediaTypeFilter());
        filterButton.reset(false);
        boolean filtersApplied = !adapter.getKeywordFiltersPipeline().isEmpty();
        if (filtersApplied) {
            updateKeywordDetector(adapter.filter().keywordFiltered);
        } else {
            updateKeywordDetector(adapter.getList());
        }
        searchProgress.setKeywordFiltersApplied(filtersApplied);
        filterButton.updateVisibility();
        keywordFilterDrawerView.updateAppliedKeywordFilters(adapter.getKeywordFiltersPipeline());
    } else {
        setupPromoSlides();
    }
    if (list != null) {
        list.setOnScrollListener(new FastScrollDisabledWhenIdleOnScrollListener());
    }
    if (list != null && CM.getBoolean(Constants.PREF_KEY_GUI_DISTRACTION_FREE_SEARCH)) {
        list.setOnScrollListener(new ComposedOnScrollListener(new FastScrollDisabledWhenIdleOnScrollListener(), new DirectionDetectorScrollListener(new ScrollDirectionListener(this), Engine.instance().getThreadPool())));
    }
    if (searchHeaderBanner != null) {
        searchHeaderBanner.setSearchFragmentReference(this);
        if (getCurrentQuery() == null || Offers.disabledAds()) {
            searchHeaderBanner.setBannerViewVisibility(SearchHeaderBanner.BannerType.ALL, false);
        }
    }
    if (getCurrentQuery() == null) {
        searchInput.setFileTypeCountersVisible(false);
    }
}
Also used : FastScrollDisabledWhenIdleOnScrollListener(com.frostwire.android.gui.util.ScrollListeners.FastScrollDisabledWhenIdleOnScrollListener) DirectionDetectorScrollListener(com.frostwire.android.gui.util.DirectionDetectorScrollListener) ComposedOnScrollListener(com.frostwire.android.gui.util.ScrollListeners.ComposedOnScrollListener) ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Aggregations

ConfigurationManager (com.frostwire.android.core.ConfigurationManager)1 DirectionDetectorScrollListener (com.frostwire.android.gui.util.DirectionDetectorScrollListener)1 ComposedOnScrollListener (com.frostwire.android.gui.util.ScrollListeners.ComposedOnScrollListener)1 FastScrollDisabledWhenIdleOnScrollListener (com.frostwire.android.gui.util.ScrollListeners.FastScrollDisabledWhenIdleOnScrollListener)1