Search in sources :

Example 1 with FileAdapter

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;
}
Also used : FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 2 with FileAdapter

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;
}
Also used : FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) CoverBitmapLoader(org.gateshipone.malp.application.utils.CoverBitmapLoader) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 3 with FileAdapter

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;
}
Also used : AlertDialog(android.app.AlertDialog) FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) PlaylistsLoader(org.gateshipone.malp.application.loaders.PlaylistsLoader) Loader(android.support.v4.content.Loader) Bundle(android.os.Bundle) R(org.gateshipone.malp.R) ThemeUtils(org.gateshipone.malp.application.utils.ThemeUtils) MPDFileEntry(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDFileEntry) Dialog(android.app.Dialog) ColorDrawable(android.graphics.drawable.ColorDrawable) NonNull(android.support.annotation.NonNull) FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) AlertDialog(android.app.AlertDialog) OnSaveDialogListener(org.gateshipone.malp.application.callbacks.OnSaveDialogListener) List(java.util.List) MPDPlaylist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDPlaylist) ColorDrawable(android.graphics.drawable.ColorDrawable) Bundle(android.os.Bundle) MPDPlaylist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDPlaylist) NonNull(android.support.annotation.NonNull)

Example 4 with FileAdapter

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;
}
Also used : FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Example 5 with FileAdapter

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;
}
Also used : FileAdapter(org.gateshipone.malp.application.adapters.FileAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Aggregations

FileAdapter (org.gateshipone.malp.application.adapters.FileAdapter)6 View (android.view.View)5 AdapterView (android.widget.AdapterView)5 ListView (android.widget.ListView)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 SearchView (android.support.v7.widget.SearchView)2 AbsListView (android.widget.AbsListView)2 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 NonNull (android.support.annotation.NonNull)1 Loader (android.support.v4.content.Loader)1 SearchView (android.widget.SearchView)1 List (java.util.List)1 R (org.gateshipone.malp.R)1 OnSaveDialogListener (org.gateshipone.malp.application.callbacks.OnSaveDialogListener)1 PlaylistsLoader (org.gateshipone.malp.application.loaders.PlaylistsLoader)1 CoverBitmapLoader (org.gateshipone.malp.application.utils.CoverBitmapLoader)1 ThemeUtils (org.gateshipone.malp.application.utils.ThemeUtils)1