use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.
the class PlaylistTracksFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.listview_layout_refreshable, container, false);
// Get the main ListView of this fragment
mListView = rootView.findViewById(R.id.main_listview);
Bundle args = getArguments();
if (null != args) {
mPath = args.getString(EXTRA_PLAYLIST_NAME);
}
// Check if sections should be shown
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean showVisibleSections = sharedPref.getBoolean(getContext().getString(R.string.pref_show_playlist_sections_key), getContext().getResources().getBoolean(R.bool.pref_show_playlist_sections_default));
mClickAction = PreferenceHelper.getClickAction(sharedPref, getContext());
// Create the needed adapter for the ListView
mFileAdapter = new FileAdapter(getActivity(), false, false, showVisibleSections, true);
// Combine the two to a happy couple
mListView.setAdapter(mFileAdapter);
mListView.setOnItemClickListener(this);
registerForContextMenu(mListView);
// 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);
setHasOptionsMenu(true);
// Return the ready inflated and configured fragment view.
return rootView;
}
use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.
the class AlbumTracksFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.listview_layout_refreshable, container, false);
// Get the main ListView of this fragment
mListView = rootView.findViewById(R.id.main_listview);
/* Check if an artistname/albumame was given in the extras */
Bundle args = getArguments();
if (null != args) {
mAlbum = args.getParcelable(BUNDLE_STRING_EXTRA_ALBUM);
mBitmap = args.getParcelable(BUNDLE_STRING_EXTRA_BITMAP);
}
// Create the needed adapter for the ListView
mFileAdapter = new FileAdapter(getActivity(), false, true);
// Combine the two to a happy couple
mListView.setAdapter(mFileAdapter);
registerForContextMenu(mListView);
mListView.setOnItemClickListener(this);
// 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);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
mClickAction = PreferenceHelper.getClickAction(sharedPref, getContext());
mUseArtistSort = sharedPref.getBoolean(getString(R.string.pref_use_artist_sort_key), getResources().getBoolean(R.bool.pref_use_artist_sort_default));
setHasOptionsMenu(true);
mBitmapLoader = new CoverBitmapLoader(getContext(), this);
// Return the ready inflated and configured fragment view.
return rootView;
}
use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.
the class ChoosePlaylistDialog method onCreateDialog.
/**
* Create the dialog to choose to override an existing bookmark or to create a new bookmark.
*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle args = getArguments();
if (null != args) {
mShowNewEntry = args.getBoolean(EXTRA_SHOW_NEW_ENTRY);
}
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
mPlaylistsListViewAdapter = new FileAdapter(getActivity(), false, false);
builder.setTitle(getString(R.string.dialog_choose_playlist)).setAdapter(mPlaylistsListViewAdapter, (dialog, which) -> {
if (null == mSaveCallback) {
return;
}
if (which == 0) {
// open save dialog to create a new playlist
mSaveCallback.onCreateNewObject();
} else {
// override existing playlist
MPDPlaylist playlist = (MPDPlaylist) mPlaylistsListViewAdapter.getItem(which);
String objectTitle = playlist.getPath();
mSaveCallback.onSaveObject(objectTitle);
}
}).setNegativeButton(R.string.dialog_action_cancel, (dialog, id) -> {
// User cancelled the dialog don't save object
getDialog().cancel();
});
// Prepare loader ( start new one or reuse old )
getLoaderManager().initLoader(0, getArguments(), this);
// set divider
AlertDialog dlg = builder.create();
dlg.getListView().setDivider(new ColorDrawable(ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_background_selected)));
dlg.getListView().setDividerHeight(getResources().getDimensionPixelSize(R.dimen.list_divider_size));
return dlg;
}
use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.
the class FilesFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.listview_layout_refreshable, container, false);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean useTags = sharedPref.getBoolean(getString(R.string.pref_use_tags_in_filebrowser_key), getResources().getBoolean(R.bool.pref_use_tags_in_filebrowser_default));
mClickAction = PreferenceHelper.getClickAction(sharedPref, getContext());
// Get the main ListView of this fragment
mListView = rootView.findViewById(R.id.main_listview);
Bundle args = getArguments();
if (null != args) {
mPath = args.getString(EXTRA_FILENAME);
} else {
mPath = "";
}
// Create the needed adapter for the ListView
mAdapter = new FileAdapter(getActivity(), true, true, false, useTags);
// Combine the two to a happy couple
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(this);
registerForContextMenu(mListView);
// 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);
// try to resume the saved search string
if (savedInstanceState != null) {
mSearchString = savedInstanceState.getString(FILESFRAGMENT_SAVED_INSTANCE_SEARCH_STRING);
}
setHasOptionsMenu(true);
// Return the ready inflated and configured fragment view.
return rootView;
}
use of org.gateshipone.malp.application.adapters.FileAdapter in project malp by gateship-one.
the class SavedPlaylistsFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.listview_layout_refreshable, container, false);
// Get the main ListView of this fragment
mListView = rootView.findViewById(R.id.main_listview);
// Create the needed adapter for the ListView
mPlaylistAdapter = new FileAdapter(getActivity(), true, false);
// Combine the two to a happy couple
mListView.setAdapter(mPlaylistAdapter);
mListView.setOnItemClickListener(this);
registerForContextMenu(mListView);
// 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 the ready inflated and configured fragment view.
return rootView;
}
Aggregations