152 lines
3.7 KiB
Plaintext
152 lines
3.7 KiB
Plaintext
|
package com.novelbook.android.db;
|
||
|
|
||
|
|
||
|
import android.text.TextUtils;
|
||
|
|
||
|
import org.litepal.LitePal;
|
||
|
import org.litepal.crud.LitePalSupport;
|
||
|
|
||
|
import java.io.Serializable;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
import javax.security.auth.callback.CallbackHandler;
|
||
|
|
||
|
|
||
|
public class Chapter extends LitePalSupport implements Serializable {
|
||
|
private int id;
|
||
|
private int novelId;//本地小说id
|
||
|
private String novelPath; //离线导入小说文件地址
|
||
|
private String chapterName;
|
||
|
private long novelChapterStartPos;
|
||
|
private String chapterUrl;
|
||
|
private int length;
|
||
|
private String chapterPath; //缓存地址
|
||
|
private String domain; //目标 site
|
||
|
private int index;//第几章
|
||
|
private int taskId;
|
||
|
|
||
|
|
||
|
|
||
|
public static Chapter getChapter(int id, String domain, int chapId) {
|
||
|
// Chapter chapter =(Chapter)
|
||
|
|
||
|
List<Chapter> lst = LitePal.where("novelId=? and domain = ? and index = ?", id + "", domain, chapId + "").limit(1).find(Chapter.class);
|
||
|
if (lst.size() > 0) {
|
||
|
return lst.get(0);
|
||
|
}
|
||
|
|
||
|
Chapter chapter = new Chapter();
|
||
|
chapter.setDomain(domain);
|
||
|
chapter.setIndex(chapId);
|
||
|
chapter.setNovelId(id);
|
||
|
chapter.setChapterName("");
|
||
|
chapter.setChapterUrl("");
|
||
|
chapter.setChapterPath("");
|
||
|
return chapter;
|
||
|
}
|
||
|
public int getTaskId() {
|
||
|
return taskId;
|
||
|
}
|
||
|
|
||
|
public void setTaskId(int taskId) {
|
||
|
this.taskId = taskId;
|
||
|
}
|
||
|
public int getIndex() {
|
||
|
return index;
|
||
|
}
|
||
|
|
||
|
public void setIndex(int index) {
|
||
|
this.index = index;
|
||
|
}
|
||
|
|
||
|
public String getDomain() {
|
||
|
return domain;
|
||
|
}
|
||
|
|
||
|
public void setDomain(String domain) {
|
||
|
this.domain = domain;
|
||
|
}
|
||
|
|
||
|
public int getId() {
|
||
|
return id;
|
||
|
}
|
||
|
|
||
|
public void setId(int id) {
|
||
|
this.id = id;
|
||
|
}
|
||
|
|
||
|
public int getNovelId() {
|
||
|
return novelId;
|
||
|
}
|
||
|
|
||
|
public void setNovelId(int novelId) {
|
||
|
this.novelId = novelId;
|
||
|
}
|
||
|
|
||
|
public String getNovelPath() {
|
||
|
return novelPath;
|
||
|
}
|
||
|
|
||
|
public void setNovelPath(String novelPath) {
|
||
|
this.novelPath = novelPath;
|
||
|
}
|
||
|
|
||
|
public String getChapterName() {
|
||
|
return chapterName;
|
||
|
}
|
||
|
|
||
|
public void setChapterName(String chapterName) {
|
||
|
this.chapterName = chapterName;
|
||
|
}
|
||
|
|
||
|
public long getNovelChapterStartPos() {
|
||
|
return novelChapterStartPos;
|
||
|
}
|
||
|
|
||
|
public void setNovelChapterStartPos(long novelChapterStartPos) {
|
||
|
this.novelChapterStartPos = novelChapterStartPos;
|
||
|
}
|
||
|
|
||
|
public String getChapterUrl() {
|
||
|
return chapterUrl;
|
||
|
}
|
||
|
|
||
|
public void setChapterUrl(String chapterUrl) {
|
||
|
this.chapterUrl = chapterUrl;
|
||
|
}
|
||
|
|
||
|
public int getLength() {
|
||
|
return length;
|
||
|
}
|
||
|
|
||
|
public void setLength(int length) {
|
||
|
this.length = length;
|
||
|
}
|
||
|
|
||
|
public String getChapterPath() {
|
||
|
return chapterPath;
|
||
|
}
|
||
|
|
||
|
public void setChapterPath(String chapterPath) {
|
||
|
this.chapterPath = chapterPath;
|
||
|
}
|
||
|
|
||
|
public static List<Chapter> getUnCachedChapters(int taskId){
|
||
|
// return LitePal.where("novelId = ? and domain = ? and chapterPath = null" ,noveId+"",domain ) .find(Chapter.class);
|
||
|
//ist<Chapter> lst = LitePal.where("novelId = ? and domain = ? " ,noveId+"",domain).find(Chapter.class);
|
||
|
List<Chapter> lst = LitePal.where("taskId= ? " ,taskId+"").find(Chapter.class);
|
||
|
List<Chapter> lstrt = new ArrayList<Chapter>();
|
||
|
for(Chapter chapter : lst){
|
||
|
if(TextUtils.isEmpty(chapter.getChapterPath())){
|
||
|
lstrt.add(chapter);
|
||
|
}
|
||
|
}
|
||
|
return lstrt;
|
||
|
// return LitePal.where("novelId = ? and domain = ? " ,noveId+"",domain).find(Chapter.class);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|