2018-01-17 06:12:03 +01:00
|
|
|
package org.schabi.newpipe.database.stream.dao;
|
|
|
|
|
2019-10-04 14:59:08 +02:00
|
|
|
import androidx.room.Dao;
|
|
|
|
import androidx.room.Insert;
|
|
|
|
import androidx.room.OnConflictStrategy;
|
|
|
|
import androidx.room.Query;
|
|
|
|
import androidx.room.Transaction;
|
2018-01-17 06:12:03 +01:00
|
|
|
|
|
|
|
import org.schabi.newpipe.database.BasicDAO;
|
|
|
|
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2020-10-31 21:55:45 +01:00
|
|
|
import io.reactivex.rxjava3.core.Flowable;
|
2018-01-17 06:12:03 +01:00
|
|
|
|
|
|
|
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.JOIN_STREAM_ID;
|
|
|
|
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_STATE_TABLE;
|
|
|
|
|
|
|
|
@Dao
|
|
|
|
public abstract class StreamStateDAO implements BasicDAO<StreamStateEntity> {
|
|
|
|
@Override
|
|
|
|
@Query("SELECT * FROM " + STREAM_STATE_TABLE)
|
|
|
|
public abstract Flowable<List<StreamStateEntity>> getAll();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Query("DELETE FROM " + STREAM_STATE_TABLE)
|
|
|
|
public abstract int deleteAll();
|
|
|
|
|
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
public Flowable<List<StreamStateEntity>> listByService(final int serviceId) {
|
2018-01-17 06:12:03 +01:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2018-01-29 23:08:26 +01:00
|
|
|
@Query("SELECT * FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId")
|
2020-03-31 19:20:15 +02:00
|
|
|
public abstract Flowable<List<StreamStateEntity>> getState(long streamId);
|
2018-01-29 23:08:26 +01:00
|
|
|
|
2018-01-17 06:12:03 +01:00
|
|
|
@Query("DELETE FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId")
|
2020-03-31 19:20:15 +02:00
|
|
|
public abstract int deleteState(long streamId);
|
2018-01-29 23:08:26 +01:00
|
|
|
|
|
|
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
2020-03-31 19:20:15 +02:00
|
|
|
abstract void silentInsertInternal(StreamStateEntity streamState);
|
2018-01-29 23:08:26 +01:00
|
|
|
|
|
|
|
@Transaction
|
2020-03-31 19:20:15 +02:00
|
|
|
public long upsert(final StreamStateEntity stream) {
|
2018-01-29 23:08:26 +01:00
|
|
|
silentInsertInternal(stream);
|
|
|
|
return update(stream);
|
|
|
|
}
|
2018-01-17 06:12:03 +01:00
|
|
|
}
|