This repository has been archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c3cf6b
commit e4da857
Showing
87 changed files
with
969 additions
and
129 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
app/src/main/java/xyz/fycz/myreader/greendao/entity/ReadRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package xyz.fycz.myreader.greendao.entity; | ||
|
||
import org.greenrobot.greendao.annotation.Entity; | ||
import org.greenrobot.greendao.annotation.Generated; | ||
import org.greenrobot.greendao.annotation.Id; | ||
|
||
/** | ||
* @author fengyue | ||
* @date 2021/6/1 18:38 | ||
*/ | ||
@Entity | ||
public class ReadRecord { | ||
@Id | ||
private String id; | ||
private String bookImg; | ||
private String bookName; | ||
private String bookAuthor; | ||
private long readTime; | ||
private long updateTime; | ||
|
||
|
||
@Generated(hash = 1191129215) | ||
public ReadRecord() { | ||
} | ||
|
||
@Generated(hash = 381392552) | ||
public ReadRecord(String id, String bookImg, String bookName, String bookAuthor, | ||
long readTime, long updateTime) { | ||
this.id = id; | ||
this.bookImg = bookImg; | ||
this.bookName = bookName; | ||
this.bookAuthor = bookAuthor; | ||
this.readTime = readTime; | ||
this.updateTime = updateTime; | ||
} | ||
|
||
public String getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getBookName() { | ||
return this.bookName; | ||
} | ||
|
||
public void setBookName(String bookName) { | ||
this.bookName = bookName; | ||
} | ||
|
||
public String getBookAuthor() { | ||
return this.bookAuthor; | ||
} | ||
|
||
public void setBookAuthor(String bookAuthor) { | ||
this.bookAuthor = bookAuthor; | ||
} | ||
|
||
public long getUpdateTime() { | ||
return this.updateTime; | ||
} | ||
|
||
public void setUpdateTime(long updateTime) { | ||
this.updateTime = updateTime; | ||
} | ||
|
||
public String getBookImg() { | ||
return this.bookImg; | ||
} | ||
|
||
public void setBookImg(String bookImg) { | ||
this.bookImg = bookImg; | ||
} | ||
|
||
public long getReadTime() { | ||
return this.readTime; | ||
} | ||
|
||
public void setReadTime(long readTime) { | ||
this.readTime = readTime; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/src/main/java/xyz/fycz/myreader/greendao/service/ReadRecordService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package xyz.fycz.myreader.greendao.service; | ||
|
||
import java.util.List; | ||
|
||
import io.reactivex.Single; | ||
import xyz.fycz.myreader.greendao.DbManager; | ||
import xyz.fycz.myreader.greendao.entity.Book; | ||
import xyz.fycz.myreader.greendao.entity.ReadRecord; | ||
import xyz.fycz.myreader.greendao.gen.BookDao; | ||
import xyz.fycz.myreader.greendao.gen.ReadRecordDao; | ||
|
||
/** | ||
* @author fengyue | ||
* @date 2021/6/1 19:09 | ||
*/ | ||
public class ReadRecordService extends BaseService { | ||
private static volatile ReadRecordService sInstance; | ||
|
||
public static ReadRecordService getInstance() { | ||
if (sInstance == null) { | ||
synchronized (ReadRecordService.class) { | ||
if (sInstance == null) { | ||
sInstance = new ReadRecordService(); | ||
} | ||
} | ||
} | ||
return sInstance; | ||
} | ||
|
||
/** | ||
* 获取所有书籍分组 | ||
* | ||
* @return | ||
*/ | ||
public Single<List<ReadRecord>> getAllRecordsByTime() { | ||
return Single.create(emitter -> emitter.onSuccess(DbManager.getDaoSession().getReadRecordDao() | ||
.queryBuilder() | ||
.orderDesc(ReadRecordDao.Properties.UpdateTime) | ||
.list())); | ||
} | ||
|
||
public Single<Boolean> removeAll() { | ||
return Single.create(emitter -> { | ||
DbManager.getDaoSession().getReadRecordDao().deleteAll(); | ||
emitter.onSuccess(true); | ||
}); | ||
} | ||
|
||
public Single<Boolean> removeAllTime(List<ReadRecord> records) { | ||
return Single.create(emitter -> { | ||
for (ReadRecord record : records) { | ||
record.setReadTime(0); | ||
record.setUpdateTime(0); | ||
} | ||
DbManager.getDaoSession().getReadRecordDao().insertOrReplaceInTx(records); | ||
emitter.onSuccess(true); | ||
}); | ||
} | ||
|
||
public ReadRecord get(String bookName, String bookAuthor) { | ||
try { | ||
return DbManager.getInstance().getSession().getReadRecordDao() | ||
.queryBuilder() | ||
.where(ReadRecordDao.Properties.BookName.eq(bookName), | ||
ReadRecordDao.Properties.BookAuthor.eq(bookAuthor)) | ||
.unique(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return DbManager.getInstance().getSession().getReadRecordDao() | ||
.queryBuilder() | ||
.where(ReadRecordDao.Properties.BookName.eq(bookName), | ||
ReadRecordDao.Properties.BookAuthor.eq(bookAuthor)) | ||
.list().get(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.