2017-08-07 15:02:30 +02:00
|
|
|
package org.schabi.newpipe.database.subscription;
|
|
|
|
|
|
|
|
import android.arch.persistence.room.ColumnInfo;
|
|
|
|
import android.arch.persistence.room.Entity;
|
|
|
|
import android.arch.persistence.room.Ignore;
|
|
|
|
import android.arch.persistence.room.Index;
|
|
|
|
import android.arch.persistence.room.PrimaryKey;
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
|
|
|
|
2017-08-07 15:02:30 +02:00
|
|
|
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_SERVICE_ID;
|
|
|
|
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_TABLE;
|
|
|
|
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_URL;
|
|
|
|
|
|
|
|
@Entity(tableName = SUBSCRIPTION_TABLE,
|
|
|
|
indices = {@Index(value = {SUBSCRIPTION_SERVICE_ID, SUBSCRIPTION_URL}, unique = true)})
|
|
|
|
public class SubscriptionEntity {
|
|
|
|
|
|
|
|
final static String SUBSCRIPTION_TABLE = "subscriptions";
|
|
|
|
final static String SUBSCRIPTION_SERVICE_ID = "service_id";
|
|
|
|
final static String SUBSCRIPTION_URL = "url";
|
2017-09-03 08:04:18 +02:00
|
|
|
final static String SUBSCRIPTION_NAME = "name";
|
|
|
|
final static String SUBSCRIPTION_AVATAR_URL = "avatar_url";
|
2017-08-07 15:02:30 +02:00
|
|
|
final static String SUBSCRIPTION_SUBSCRIBER_COUNT = "subscriber_count";
|
|
|
|
final static String SUBSCRIPTION_DESCRIPTION = "description";
|
|
|
|
|
|
|
|
@PrimaryKey(autoGenerate = true)
|
|
|
|
private long uid = 0;
|
|
|
|
|
|
|
|
@ColumnInfo(name = SUBSCRIPTION_SERVICE_ID)
|
|
|
|
private int serviceId = -1;
|
|
|
|
|
|
|
|
@ColumnInfo(name = SUBSCRIPTION_URL)
|
|
|
|
private String url;
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
@ColumnInfo(name = SUBSCRIPTION_NAME)
|
|
|
|
private String name;
|
2017-08-07 15:02:30 +02:00
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
@ColumnInfo(name = SUBSCRIPTION_AVATAR_URL)
|
|
|
|
private String avatarUrl;
|
2017-08-07 15:02:30 +02:00
|
|
|
|
|
|
|
@ColumnInfo(name = SUBSCRIPTION_SUBSCRIBER_COUNT)
|
|
|
|
private Long subscriberCount;
|
|
|
|
|
|
|
|
@ColumnInfo(name = SUBSCRIPTION_DESCRIPTION)
|
|
|
|
private String description;
|
|
|
|
|
|
|
|
public long getUid() {
|
|
|
|
return uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Keep this package-private since UID should always be auto generated by Room impl */
|
|
|
|
void setUid(long uid) {
|
|
|
|
this.uid = uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getServiceId() {
|
|
|
|
return serviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setServiceId(int serviceId) {
|
|
|
|
this.serviceId = serviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUrl(String url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
2017-08-07 15:02:30 +02:00
|
|
|
}
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
2017-08-07 15:02:30 +02:00
|
|
|
}
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
public String getAvatarUrl() {
|
|
|
|
return avatarUrl;
|
2017-08-07 15:02:30 +02:00
|
|
|
}
|
|
|
|
|
2017-09-03 08:04:18 +02:00
|
|
|
public void setAvatarUrl(String avatarUrl) {
|
|
|
|
this.avatarUrl = avatarUrl;
|
2017-08-07 15:02:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Long getSubscriberCount() {
|
|
|
|
return subscriberCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSubscriberCount(Long subscriberCount) {
|
|
|
|
this.subscriberCount = subscriberCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Ignore
|
2017-09-03 08:04:18 +02:00
|
|
|
public void setData(final String name,
|
|
|
|
final String avatarUrl,
|
2017-08-07 15:02:30 +02:00
|
|
|
final String description,
|
|
|
|
final Long subscriberCount) {
|
2017-09-03 08:04:18 +02:00
|
|
|
this.setName(name);
|
|
|
|
this.setAvatarUrl(avatarUrl);
|
2017-08-07 15:02:30 +02:00
|
|
|
this.setDescription(description);
|
|
|
|
this.setSubscriberCount(subscriberCount);
|
|
|
|
}
|
2017-09-03 08:04:18 +02:00
|
|
|
|
|
|
|
@Ignore
|
|
|
|
public ChannelInfoItem toChannelInfoItem() {
|
|
|
|
ChannelInfoItem item = new ChannelInfoItem();
|
|
|
|
item.url = getUrl();
|
|
|
|
item.service_id = getServiceId();
|
|
|
|
item.name = getName();
|
|
|
|
item.thumbnail_url = getAvatarUrl();
|
|
|
|
item.subscriber_count = getSubscriberCount();
|
|
|
|
item.description = getDescription();
|
|
|
|
return item;
|
|
|
|
}
|
2017-08-07 15:02:30 +02:00
|
|
|
}
|