Search in sources :

Example 1 with ArtistsAdapter

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

the class ArtistsFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
    String libraryView = sharedPref.getString(getString(R.string.pref_library_view_key), getString(R.string.pref_library_view_default));
    if (libraryView.equals(getString(R.string.pref_library_view_list_key))) {
        mUseList = true;
    }
    mAlbumSortOrder = PreferenceHelper.getMPDAlbumSortOrder(sharedPref, getContext());
    View rootView;
    // get gridview
    if (mUseList) {
        rootView = inflater.inflate(R.layout.listview_layout_refreshable, container, false);
        mAdapterView = (ListView) rootView.findViewById(R.id.main_listview);
    } else {
        // Inflate the layout for this fragment
        rootView = inflater.inflate(R.layout.fragment_gridview, container, false);
        mAdapterView = (GridView) rootView.findViewById(R.id.grid_refresh_gridview);
    }
    mArtistAdapter = new ArtistsAdapter(getActivity(), mAdapterView, mUseList);
    mAdapterView.setAdapter(mArtistAdapter);
    mAdapterView.setOnItemClickListener(this);
    mAdapterView.setOnScrollListener(new ScrollSpeedListener(mArtistAdapter, mAdapterView));
    // register for context menu
    registerForContextMenu(mAdapterView);
    // 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);
    return rootView;
}
Also used : ArtistsAdapter(org.gateshipone.malp.application.adapters.ArtistsAdapter) SharedPreferences(android.content.SharedPreferences) ScrollSpeedListener(org.gateshipone.malp.application.utils.ScrollSpeedListener) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ListView (android.widget.ListView)1 ArtistsAdapter (org.gateshipone.malp.application.adapters.ArtistsAdapter)1 ScrollSpeedListener (org.gateshipone.malp.application.utils.ScrollSpeedListener)1