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