Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
新增阅读记录
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuecanzhu committed Jun 1, 2021
1 parent 0c3cf6b commit e4da857
Show file tree
Hide file tree
Showing 87 changed files with 969 additions and 129 deletions.
4 changes: 2 additions & 2 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dependencies {
}

greendao {
schemaVersion 28
schemaVersion 29
daoPackage 'xyz.fycz.myreader.greendao.gen'
// targetGenDir 'src/main/java'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<activity android:name=".ui.activity.DonateActivity" />
<activity android:name=".ui.activity.BookInfoEditActivity" />
<activity android:name=".ui.activity.SourceLoginActivity" />
<activity android:name=".ui.activity.ReadRecordActivity" />

<receiver android:name=".util.notification.NotificationClickReceiver" />
<receiver android:name=".ui.presenter.BookcasePresenter$cancelDownloadReceiver" />
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/assets/updatelog.fy
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
2021.06.01
风月读书v2.0.2
风月读书v2.0.5
更新内容:
1、优化对话框
2、新增阅读记录(记录上次阅读时间和时长)
3、新增友链

风月读书v2.0.4
更新内容:
1、修复部分机型概率性启动闪退的问题

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/xyz/fycz/myreader/application/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import xyz.fycz.myreader.ui.fragment.BookcaseFragment;
import xyz.fycz.myreader.util.help.SSLSocketClient;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.NetworkUtils;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/xyz/fycz/myreader/entity/Date.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xyz.fycz.myreader.entity;


import xyz.fycz.myreader.util.CalendarHelper;
import xyz.fycz.myreader.util.help.CalendarHelper;

import java.io.Serializable;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/xyz/fycz/myreader/entity/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import xyz.fycz.myreader.enums.BookcaseStyle;
import xyz.fycz.myreader.enums.Font;
import xyz.fycz.myreader.enums.Language;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.ZipUtils;
import xyz.fycz.myreader.util.utils.BitmapUtil;
import xyz.fycz.myreader.util.utils.FileUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;

import java.io.Serializable;
import java.util.HashMap;
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xyz.fycz.myreader.greendao.entity.BookGroup;
import xyz.fycz.myreader.greendao.gen.BookGroupDao;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import xyz.fycz.myreader.greendao.DbManager;
import xyz.fycz.myreader.greendao.entity.BookMark;
import xyz.fycz.myreader.greendao.gen.BookMarkDao;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import xyz.fycz.myreader.util.*;
import xyz.fycz.myreader.greendao.DbManager;
import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xyz.fycz.myreader.greendao.entity.Chapter;
import xyz.fycz.myreader.greendao.gen.ChapterDao;
import xyz.fycz.myreader.util.IOUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.greendao.DbManager;
import xyz.fycz.myreader.util.utils.FileUtils;

Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import xyz.fycz.myreader.greendao.entity.SearchHistory;
import xyz.fycz.myreader.greendao.gen.SearchHistoryDao;
import xyz.fycz.myreader.util.DateHelper;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.DateHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.greendao.DbManager;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onDropAllTables(Database db, boolean ifExists) {
},
BookDao.class, ChapterDao.class, SearchHistoryDao.class,
BookMarkDao.class, BookGroupDao.class, ReplaceRuleBeanDao.class,
BookSourceDao.class, CookieBeanDao.class
BookSourceDao.class, CookieBeanDao.class, ReadRecordDao.class
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Collections;
import java.util.List;

import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.StringUtils;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -24,7 +22,7 @@
import xyz.fycz.myreader.greendao.entity.rule.BookSource;
import xyz.fycz.myreader.greendao.gen.BookSourceDao;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import xyz.fycz.myreader.util.utils.GsonUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.ArrayList;
import java.util.List;

import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;

/**
* @author fengyue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import xyz.fycz.myreader.greendao.entity.rule.InfoRule;
import xyz.fycz.myreader.greendao.entity.rule.SearchRule;
import xyz.fycz.myreader.greendao.entity.rule.TocRule;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.ArrayList;
import java.util.List;

import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;

/**
* @author fengyue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object WebDavHelp {
}*/
BottomMenu.build().setTitle("选择恢复文件")
.setMenuStringList(names)
.setOnMenuItemClickListener { dialog, text, which ->
.setOnMenuItemClickListener { _, _, which ->
if (which in 0 until 30.coerceAtLeast(names.size)) {
restoreWebDav(names[which], callBack)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.service.CookieStore;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.help.JsExtensions;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StringUtils;
Expand All @@ -28,7 +28,7 @@
import static xyz.fycz.myreader.common.APPCONST.JS_PATTERN;
import static xyz.fycz.myreader.common.APPCONST.MAP_STRING;
import static xyz.fycz.myreader.common.APPCONST.SCRIPT_ENGINE;
import static xyz.fycz.myreader.util.StringHelper.isEmpty;
import static xyz.fycz.myreader.util.help.StringHelper.isEmpty;
import static xyz.fycz.myreader.util.utils.NetworkUtils.headerPattern;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import javax.script.SimpleBindings;

import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.help.JsExtensions;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.databinding.ActivityAdSettingBinding;
import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.util.DateHelper;
import xyz.fycz.myreader.util.help.DateHelper;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
Expand Down
Loading

0 comments on commit e4da857

Please sign in to comment.