Search in sources :

Example 1 with AlbumsAdapter

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

the class AlbumsFragment 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;
    }
    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);
    }
    mSortOrder = PreferenceHelper.getMPDAlbumSortOrder(sharedPref, getContext());
    mUseArtistSort = sharedPref.getBoolean(getString(R.string.pref_use_artist_sort_key), getResources().getBoolean(R.bool.pref_use_artist_sort_default));
    mAlbumsAdapter = new AlbumsAdapter(getActivity(), mAdapterView, mUseList);
    /* Check if an artistname was given in the extras */
    Bundle args = getArguments();
    if (null != args) {
        mAlbumsPath = args.getString(BUNDLE_STRING_EXTRA_PATH);
        mArtist = args.getParcelable(BUNDLE_STRING_EXTRA_ARTIST);
        mBitmap = args.getParcelable(BUNDLE_STRING_EXTRA_BITMAP);
    } else {
        mAlbumsPath = "";
        // Create dummy album
        mArtist = new MPDArtist("");
    }
    mAdapterView.setAdapter(mAlbumsAdapter);
    mAdapterView.setOnItemClickListener(this);
    mAdapterView.setOnScrollListener(new ScrollSpeedListener(mAlbumsAdapter, mAdapterView));
    // register for context menu
    registerForContextMenu(mAdapterView);
    setHasOptionsMenu(true);
    // 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);
    mBitmapLoader = new CoverBitmapLoader(getContext(), this);
    return rootView;
}
Also used : CoverBitmapLoader(org.gateshipone.malp.application.utils.CoverBitmapLoader) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ScrollSpeedListener(org.gateshipone.malp.application.utils.ScrollSpeedListener) AlbumsAdapter(org.gateshipone.malp.application.adapters.AlbumsAdapter) MPDArtist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist) 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 Bundle (android.os.Bundle)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 AlbumsAdapter (org.gateshipone.malp.application.adapters.AlbumsAdapter)1 CoverBitmapLoader (org.gateshipone.malp.application.utils.CoverBitmapLoader)1 ScrollSpeedListener (org.gateshipone.malp.application.utils.ScrollSpeedListener)1 MPDArtist (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist)1