Search in sources :

Example 1 with ScrollSpeedListener

use of org.gateshipone.malp.application.utils.ScrollSpeedListener 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)

Example 2 with ScrollSpeedListener

use of org.gateshipone.malp.application.utils.ScrollSpeedListener 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)2 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 GridView (android.widget.GridView)2 ListView (android.widget.ListView)2 ScrollSpeedListener (org.gateshipone.malp.application.utils.ScrollSpeedListener)2 Bundle (android.os.Bundle)1 AlbumsAdapter (org.gateshipone.malp.application.adapters.AlbumsAdapter)1 ArtistsAdapter (org.gateshipone.malp.application.adapters.ArtistsAdapter)1 CoverBitmapLoader (org.gateshipone.malp.application.utils.CoverBitmapLoader)1 MPDArtist (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist)1