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;
}
Aggregations