Search in sources :

Example 1 with LocalPlaylistManager

use of org.schabi.newpipe.fragments.local.LocalPlaylistManager in project NewPipe by TeamNewPipe.

the class BookmarkFragment method onCreate.

// /////////////////////////////////////////////////////////////////////////
// Fragment LifeCycle - Creation
// /////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final AppDatabase database = NewPipeDatabase.getInstance(getContext());
    localPlaylistManager = new LocalPlaylistManager(database);
    remotePlaylistManager = new RemotePlaylistManager(database);
    disposables = new CompositeDisposable();
}
Also used : AppDatabase(org.schabi.newpipe.database.AppDatabase) LocalPlaylistManager(org.schabi.newpipe.fragments.local.LocalPlaylistManager) RemotePlaylistManager(org.schabi.newpipe.fragments.local.RemotePlaylistManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Example 2 with LocalPlaylistManager

use of org.schabi.newpipe.fragments.local.LocalPlaylistManager in project NewPipe by TeamNewPipe.

the class PlaylistCreationDialog method onCreateDialog.

/*//////////////////////////////////////////////////////////////////////////
    // Dialog
    //////////////////////////////////////////////////////////////////////////*/
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    if (getStreams() == null)
        return super.onCreateDialog(savedInstanceState);
    View dialogView = View.inflate(getContext(), R.layout.dialog_playlist_name, null);
    EditText nameInput = dialogView.findViewById(R.id.playlist_name);
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()).setTitle(R.string.create_playlist).setView(dialogView).setCancelable(true).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.create, (dialogInterface, i) -> {
        final String name = nameInput.getText().toString();
        final LocalPlaylistManager playlistManager = new LocalPlaylistManager(NewPipeDatabase.getInstance(getContext()));
        final Toast successToast = Toast.makeText(getActivity(), R.string.playlist_creation_success, Toast.LENGTH_SHORT);
        playlistManager.createPlaylist(name, getStreams()).observeOn(AndroidSchedulers.mainThread()).subscribe(longs -> successToast.show());
    });
    return dialogBuilder.create();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) Toast(android.widget.Toast) View(android.view.View) LocalPlaylistManager(org.schabi.newpipe.fragments.local.LocalPlaylistManager) NonNull(android.support.annotation.NonNull)

Example 3 with LocalPlaylistManager

use of org.schabi.newpipe.fragments.local.LocalPlaylistManager in project NewPipe by TeamNewPipe.

the class PlaylistAppendDialog method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final LocalPlaylistManager playlistManager = new LocalPlaylistManager(NewPipeDatabase.getInstance(getContext()));
    playlistAdapter = new LocalItemListAdapter(getActivity());
    playlistAdapter.setSelectedListener(new OnClickGesture<LocalItem>() {

        @Override
        public void selected(LocalItem selectedItem) {
            if (!(selectedItem instanceof PlaylistMetadataEntry) || getStreams() == null)
                return;
            onPlaylistSelected(playlistManager, (PlaylistMetadataEntry) selectedItem, getStreams());
        }
    });
    playlistRecyclerView = view.findViewById(R.id.playlist_list);
    playlistRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    playlistRecyclerView.setAdapter(playlistAdapter);
    final View newPlaylistButton = view.findViewById(R.id.newPlaylist);
    newPlaylistButton.setOnClickListener(ignored -> openCreatePlaylistDialog());
    playlistReactor = playlistManager.getPlaylists().observeOn(AndroidSchedulers.mainThread()).subscribe(this::onPlaylistsReceived);
}
Also used : LocalItemListAdapter(org.schabi.newpipe.fragments.local.LocalItemListAdapter) LocalItem(org.schabi.newpipe.database.LocalItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) LocalPlaylistManager(org.schabi.newpipe.fragments.local.LocalPlaylistManager) PlaylistMetadataEntry(org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)

Example 4 with LocalPlaylistManager

use of org.schabi.newpipe.fragments.local.LocalPlaylistManager in project NewPipe by TeamNewPipe.

the class LocalPlaylistFragment method onCreate.

// /////////////////////////////////////////////////////////////////////////
// Fragment LifeCycle - Creation
// /////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    playlistManager = new LocalPlaylistManager(NewPipeDatabase.getInstance(getContext()));
    debouncedSaveSignal = PublishSubject.create();
    disposables = new CompositeDisposable();
    isLoadingComplete = new AtomicBoolean();
    isModified = new AtomicBoolean();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LocalPlaylistManager(org.schabi.newpipe.fragments.local.LocalPlaylistManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Aggregations

LocalPlaylistManager (org.schabi.newpipe.fragments.local.LocalPlaylistManager)4 View (android.view.View)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 AlertDialog (android.app.AlertDialog)1 NonNull (android.support.annotation.NonNull)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 EditText (android.widget.EditText)1 Toast (android.widget.Toast)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AppDatabase (org.schabi.newpipe.database.AppDatabase)1 LocalItem (org.schabi.newpipe.database.LocalItem)1 PlaylistMetadataEntry (org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)1 LocalItemListAdapter (org.schabi.newpipe.fragments.local.LocalItemListAdapter)1 RemotePlaylistManager (org.schabi.newpipe.fragments.local.RemotePlaylistManager)1