Search in sources :

Example 1 with FastScrollStateChangeListener

use of com.foobnix.ui2.fast.FastScrollStateChangeListener in project LibreraReader by foobnix.

the class SearchFragment2 method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search2, container, false);
    NO_SERIES = " (" + getString(R.string.without_series) + ")";
    handler = new Handler();
    secondTopPanel = view.findViewById(R.id.secondTopPanel);
    countBooks = (TextView) view.findViewById(R.id.countBooks);
    onRefresh = view.findViewById(R.id.onRefresh);
    onRefresh.setActivated(true);
    cleanFilter = (ImageView) view.findViewById(R.id.cleanFilter);
    sortBy = (TextView) view.findViewById(R.id.sortBy);
    sortOrder = (ImageView) view.findViewById(R.id.sortOrder);
    myAutoCompleteImage = (ImageView) view.findViewById(R.id.myAutoCompleteImage);
    searchEditText = (AutoCompleteTextView) view.findViewById(R.id.filterLine);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    myAutoCompleteImage.setVisibility(View.GONE);
    ((FastScrollRecyclerView) recyclerView).setFastScrollStateChangeListener(new FastScrollStateChangeListener() {

        @Override
        public void onFastScrollStop() {
            ImageLoader.getInstance().resume();
            LOG.d("ImageLoader resume");
        }

        @Override
        public void onFastScrollStart() {
            LOG.d("ImageLoader pause");
            ImageLoader.getInstance().pause();
        }
    });
    searchEditText.addTextChangedListener(filterTextWatcher);
    searchEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    EditTextHelper.enableKeyboardSearch(searchEditText, new Runnable() {

        @Override
        public void run() {
            Keyboards.close(searchEditText);
            Keyboards.hideNavigation(getActivity());
        }
    });
    searchAdapter = new FileMetaAdapter();
    authorsAdapter = new AuthorsAdapter2();
    onGridlList = (ImageView) view.findViewById(R.id.onGridList);
    onGridlList.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            popupMenu(onGridlList);
        }
    });
    onRefresh.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!onRefresh.isActivated()) {
                Toast.makeText(getActivity(), R.string.extracting_information_from_books, Toast.LENGTH_LONG).show();
                return;
            }
            PrefDialogs.chooseFolderDialog(getActivity(), new Runnable() {

                @Override
                public void run() {
                    AppState.get().searchPaths = AppState.get().searchPaths.replace("//", "/");
                }
            }, new Runnable() {

                @Override
                public void run() {
                    recyclerView.scrollToPosition(0);
                    seachAll();
                }
            });
        }
    });
    cleanFilter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            searchEditText.setText("");
            recyclerView.scrollToPosition(0);
            searchAndOrderAsync();
        }
    });
    sortBy.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            sortByPopup(v);
        }
    });
    sortOrder.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppState.get().isSortAsc = !AppState.get().isSortAsc;
            searchAndOrderAsync();
        }
    });
    bindAdapter(searchAdapter);
    searchAdapter.setOnAuthorClickListener(onAuthorClick);
    searchAdapter.setOnSeriesClickListener(onSeriesClick);
    authorsAdapter.setOnItemClickListener(onAuthorSeriesClick);
    onGridList();
    if (AppDB.get().getCount() == 0) {
        seachAll();
    } else {
        checkForDeleteBooks();
        searchAndOrderAsync();
    }
    initAutocomplition();
    onTintChanged();
    recyclerView.addOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
        }
    });
    myAutoCompleteImage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showAutoCompleteDialog();
        }
    });
    return view;
}
Also used : AuthorsAdapter2(com.foobnix.ui2.adapter.AuthorsAdapter2) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) Handler(android.os.Handler) OnClickListener(android.view.View.OnClickListener) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) FastScrollStateChangeListener(com.foobnix.ui2.fast.FastScrollStateChangeListener) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) FileMetaAdapter(com.foobnix.ui2.adapter.FileMetaAdapter)

Aggregations

Handler (android.os.Handler)1 RecyclerView (android.support.v7.widget.RecyclerView)1 OnScrollListener (android.support.v7.widget.RecyclerView.OnScrollListener)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AuthorsAdapter2 (com.foobnix.ui2.adapter.AuthorsAdapter2)1 FileMetaAdapter (com.foobnix.ui2.adapter.FileMetaAdapter)1 FastScrollRecyclerView (com.foobnix.ui2.fast.FastScrollRecyclerView)1 FastScrollStateChangeListener (com.foobnix.ui2.fast.FastScrollStateChangeListener)1