Search in sources :

Example 1 with RemotePlaylistManager

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

the class PlaylistFragment method onCreate.

/*//////////////////////////////////////////////////////////////////////////
    // LifeCycle
    //////////////////////////////////////////////////////////////////////////*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    disposables = new CompositeDisposable();
    isBookmarkButtonReady = new AtomicBoolean(false);
    remotePlaylistManager = new RemotePlaylistManager(NewPipeDatabase.getInstance(getContext()));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) RemotePlaylistManager(org.schabi.newpipe.fragments.local.RemotePlaylistManager)

Example 2 with RemotePlaylistManager

use of org.schabi.newpipe.fragments.local.RemotePlaylistManager 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 3 with RemotePlaylistManager

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

the class PlaylistFragment method onBookmarkClicked.

private void onBookmarkClicked() {
    if (isBookmarkButtonReady == null || !isBookmarkButtonReady.get() || remotePlaylistManager == null)
        return;
    final Disposable action;
    if (currentInfo != null && playlistEntity == null) {
        action = remotePlaylistManager.onBookmark(currentInfo).observeOn(AndroidSchedulers.mainThread()).subscribe(ignored -> {
        /* Do nothing */
        }, this::onError);
    } else if (playlistEntity != null) {
        action = remotePlaylistManager.deletePlaylist(playlistEntity.getUid()).observeOn(AndroidSchedulers.mainThread()).doFinally(() -> playlistEntity = null).subscribe(ignored -> {
        /* Do nothing */
        }, this::onError);
    } else {
        action = Disposables.empty();
    }
    disposables.add(action);
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Context(android.content.Context) ImageDisplayConstants(org.schabi.newpipe.util.ImageDisplayConstants) Bundle(android.os.Bundle) ThemeHelper(org.schabi.newpipe.util.ThemeHelper) ImageView(android.widget.ImageView) PlaylistRemoteEntity(org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity) ListExtractor(org.schabi.newpipe.extractor.ListExtractor) NewPipe(org.schabi.newpipe.extractor.NewPipe) NavigationHelper(org.schabi.newpipe.util.NavigationHelper) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue) ArrayList(java.util.ArrayList) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo) InfoItem(org.schabi.newpipe.extractor.InfoItem) Disposables(io.reactivex.disposables.Disposables) MenuInflater(android.view.MenuInflater) ExtractorHelper(org.schabi.newpipe.util.ExtractorHelper) Menu(android.view.Menu) View(android.view.View) BaseListInfoFragment(org.schabi.newpipe.fragments.list.BaseListInfoFragment) AnimationUtils.animateView(org.schabi.newpipe.util.AnimationUtils.animateView) Subscriber(org.reactivestreams.Subscriber) R(org.schabi.newpipe.R) PlaylistInfo(org.schabi.newpipe.extractor.playlist.PlaylistInfo) Log(android.util.Log) ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) DialogInterface(android.content.DialogInterface) RemotePlaylistManager(org.schabi.newpipe.fragments.local.RemotePlaylistManager) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) UserAction(org.schabi.newpipe.report.UserAction) NewPipeDatabase(org.schabi.newpipe.NewPipeDatabase) ViewGroup(android.view.ViewGroup) StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) InfoItemDialog(org.schabi.newpipe.info_list.InfoItemDialog) Subscription(org.reactivestreams.Subscription) PlaylistPlayQueue(org.schabi.newpipe.playlist.PlaylistPlayQueue) PlayQueue(org.schabi.newpipe.playlist.PlayQueue) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity)

Aggregations

CompositeDisposable (io.reactivex.disposables.CompositeDisposable)3 RemotePlaylistManager (org.schabi.newpipe.fragments.local.RemotePlaylistManager)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Activity (android.app.Activity)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Single (io.reactivex.Single)1