Search in sources :

Example 6 with FileAdapter

use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.

the class SearchFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_server_search, container, false);
    // Get the main ListView of this fragment
    mListView = rootView.findViewById(R.id.main_listview);
    // Create the needed adapter for the ListView
    mFileAdapter = new FileAdapter(getActivity(), false, true);
    // Combine the two to a happy couple
    mListView.setAdapter(mFileAdapter);
    mListView.setOnItemClickListener(this);
    registerForContextMenu(mListView);
    mSelectSpinner = rootView.findViewById(R.id.search_criteria);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.server_search_choices, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    mSelectSpinner.setAdapter(adapter);
    mSelectSpinner.setOnItemSelectedListener(new SpinnerSelectListener());
    mSearchView = rootView.findViewById(R.id.search_text);
    mSearchView.setOnQueryTextListener(new SearchViewQueryListener());
    mSearchView.setOnFocusChangeListener(this);
    // get swipe layout
    mSwipeRefreshLayout = rootView.findViewById(R.id.refresh_layout);
    // set swipe colors
    mSwipeRefreshLayout.setColorSchemeColors(ThemeUtils.getThemeColor(getContext(), R.attr.colorAccent), ThemeUtils.getThemeColor(getContext(), R.attr.colorPrimary));
    // set swipe refresh listener
    mSwipeRefreshLayout.setOnRefreshListener(this::refreshContent);
    setHasOptionsMenu(true);
    // Get album sort order
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
    mAlbumSortOrder = PreferenceHelper.getMPDAlbumSortOrder(sharedPref, getContext());
    mClickAction = PreferenceHelper.getClickAction(sharedPref, getContext());
    // Return the ready inflated and configured fragment view.
    return rootView;
}
Also used : FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) SharedPreferences(android.content.SharedPreferences) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(android.widget.SearchView) ListView(android.widget.ListView)

Aggregations

FileAdapter (org.gateshipone.malp.application.adapters.FileAdapter)6 View (android.view.View)5 AdapterView (android.widget.AdapterView)5 ListView (android.widget.ListView)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 SearchView (android.support.v7.widget.SearchView)2 AbsListView (android.widget.AbsListView)2 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 NonNull (android.support.annotation.NonNull)1 Loader (android.support.v4.content.Loader)1 SearchView (android.widget.SearchView)1 List (java.util.List)1 R (org.gateshipone.malp.R)1 OnSaveDialogListener (org.gateshipone.malp.application.callbacks.OnSaveDialogListener)1 PlaylistsLoader (org.gateshipone.malp.application.loaders.PlaylistsLoader)1 CoverBitmapLoader (org.gateshipone.malp.application.utils.CoverBitmapLoader)1 ThemeUtils (org.gateshipone.malp.application.utils.ThemeUtils)1