2017-11-17 05:18:11 +11:00
|
|
|
/* Copyright 2017 Andrew Dawson
|
|
|
|
*
|
|
|
|
* This file is a part of Tusky.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
2017-06-29 03:33:20 +10:00
|
|
|
package com.keylesspalace.tusky.db;
|
|
|
|
|
2018-12-18 01:25:35 +11:00
|
|
|
import androidx.room.ColumnInfo;
|
|
|
|
import androidx.room.Entity;
|
|
|
|
import androidx.room.PrimaryKey;
|
|
|
|
import androidx.room.TypeConverter;
|
|
|
|
import androidx.room.TypeConverters;
|
|
|
|
import androidx.annotation.Nullable;
|
2017-11-17 05:18:11 +11:00
|
|
|
|
|
|
|
import com.keylesspalace.tusky.entity.Status;
|
2017-06-29 03:33:20 +10:00
|
|
|
|
|
|
|
/**
|
2017-11-17 05:18:11 +11:00
|
|
|
* Toot model.
|
2017-06-29 03:33:20 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
@Entity
|
2017-11-17 05:18:11 +11:00
|
|
|
@TypeConverters(TootEntity.Converters.class)
|
2017-06-29 03:33:20 +10:00
|
|
|
public class TootEntity {
|
|
|
|
@PrimaryKey(autoGenerate = true)
|
2017-11-17 05:18:11 +11:00
|
|
|
private final int uid;
|
2017-06-29 03:33:20 +10:00
|
|
|
|
|
|
|
@ColumnInfo(name = "text")
|
2017-11-17 05:18:11 +11:00
|
|
|
private final String text;
|
2017-06-29 03:33:20 +10:00
|
|
|
|
2017-07-06 00:36:14 +10:00
|
|
|
@ColumnInfo(name = "urls")
|
2017-11-17 05:18:11 +11:00
|
|
|
private final String urls;
|
2017-07-06 00:36:14 +10:00
|
|
|
|
2018-11-12 05:25:45 +11:00
|
|
|
@ColumnInfo(name = "descriptions")
|
|
|
|
private final String descriptions;
|
|
|
|
|
2017-07-08 12:56:07 +10:00
|
|
|
@ColumnInfo(name = "contentWarning")
|
2017-11-17 05:18:11 +11:00
|
|
|
private final String contentWarning;
|
2017-07-08 12:56:07 +10:00
|
|
|
|
2017-11-17 05:18:11 +11:00
|
|
|
@ColumnInfo(name = "inReplyToId")
|
|
|
|
private final String inReplyToId;
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@ColumnInfo(name = "inReplyToText")
|
|
|
|
private final String inReplyToText;
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@ColumnInfo(name = "inReplyToUsername")
|
|
|
|
private final String inReplyToUsername;
|
|
|
|
|
|
|
|
@ColumnInfo(name = "visibility")
|
|
|
|
private final Status.Visibility visibility;
|
2017-06-29 03:33:20 +10:00
|
|
|
|
2018-11-12 05:25:45 +11:00
|
|
|
public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId,
|
2017-11-17 05:18:11 +11:00
|
|
|
@Nullable String inReplyToText, @Nullable String inReplyToUsername,
|
|
|
|
Status.Visibility visibility) {
|
|
|
|
this.uid = uid;
|
2017-06-29 03:33:20 +10:00
|
|
|
this.text = text;
|
2017-11-17 05:18:11 +11:00
|
|
|
this.urls = urls;
|
2018-11-12 05:25:45 +11:00
|
|
|
this.descriptions = descriptions;
|
2017-11-17 05:18:11 +11:00
|
|
|
this.contentWarning = contentWarning;
|
|
|
|
this.inReplyToId = inReplyToId;
|
|
|
|
this.inReplyToText = inReplyToText;
|
|
|
|
this.inReplyToUsername = inReplyToUsername;
|
|
|
|
this.visibility = visibility;
|
2017-06-29 03:33:20 +10:00
|
|
|
}
|
|
|
|
|
2017-11-17 05:18:11 +11:00
|
|
|
public String getText() {
|
|
|
|
return text;
|
2017-07-08 12:56:07 +10:00
|
|
|
}
|
|
|
|
|
2017-11-17 05:18:11 +11:00
|
|
|
public String getContentWarning() {
|
|
|
|
return contentWarning;
|
2017-07-08 12:56:07 +10:00
|
|
|
}
|
|
|
|
|
2017-06-29 03:33:20 +10:00
|
|
|
public int getUid() {
|
|
|
|
return uid;
|
|
|
|
}
|
|
|
|
|
2017-07-06 00:36:14 +10:00
|
|
|
public String getUrls() {
|
|
|
|
return urls;
|
|
|
|
}
|
|
|
|
|
2018-11-12 05:25:45 +11:00
|
|
|
public String getDescriptions() {
|
|
|
|
return descriptions;
|
|
|
|
}
|
|
|
|
|
2017-11-17 05:18:11 +11:00
|
|
|
public String getInReplyToId() {
|
|
|
|
return inReplyToId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getInReplyToText() {
|
|
|
|
return inReplyToText;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getInReplyToUsername() {
|
|
|
|
return inReplyToUsername;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Status.Visibility getVisibility() {
|
|
|
|
return visibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final class Converters {
|
|
|
|
|
|
|
|
@TypeConverter
|
|
|
|
public Status.Visibility visibilityFromInt(int number) {
|
|
|
|
return Status.Visibility.byNum(number);
|
|
|
|
}
|
|
|
|
|
|
|
|
@TypeConverter
|
|
|
|
public int intToVisibility(Status.Visibility visibility) {
|
|
|
|
return visibility.getNum();
|
|
|
|
}
|
2017-07-06 00:36:14 +10:00
|
|
|
}
|
2017-06-29 03:33:20 +10:00
|
|
|
}
|