pref: 优化贴子浏览记录添加时机
This commit is contained in:
parent
8ce4ca4159
commit
7dfd4976d6
|
|
@ -353,6 +353,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
refreshTitle()
|
refreshTitle()
|
||||||
preload()
|
preload()
|
||||||
refreshAdapter()
|
refreshAdapter()
|
||||||
|
updateHistory(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshAdapter() {
|
private fun refreshAdapter() {
|
||||||
|
|
@ -613,7 +614,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
if (!update) Util.miuiFav(this, getString(R.string.title_miui_fav, dataBean!!.thread?.title), url)
|
if (!update) Util.miuiFav(this, getString(R.string.title_miui_fav, dataBean!!.thread?.title), url)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish() {
|
private fun updateHistory(async: Boolean = false) {
|
||||||
if (dataBean != null && dataBean!!.thread != null) {
|
if (dataBean != null && dataBean!!.thread != null) {
|
||||||
val postListItemBean = lastVisibleItem
|
val postListItemBean = lastVisibleItem
|
||||||
var extras = ""
|
var extras = ""
|
||||||
|
|
@ -632,8 +633,12 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
history.avatar = dataBean!!.thread?.author?.portrait
|
history.avatar = dataBean!!.thread?.author?.portrait
|
||||||
history.username = dataBean!!.thread?.author?.nameShow
|
history.username = dataBean!!.thread?.author?.nameShow
|
||||||
}
|
}
|
||||||
HistoryUtil.writeHistory(history)
|
HistoryUtil.writeHistory(history, async)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun finish() {
|
||||||
|
updateHistory()
|
||||||
super.finish()
|
super.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,11 @@ public final class HistoryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeHistory(History history) {
|
public static void writeHistory(History history) {
|
||||||
add(history);
|
writeHistory(history, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeHistory(History history, boolean async) {
|
||||||
|
add(history, async);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<History> getAll() {
|
public static List<History> getAll() {
|
||||||
|
|
@ -49,12 +53,20 @@ public final class HistoryUtil {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void add(History history) {
|
private static void add(History history, boolean async) {
|
||||||
if (update(history)) {
|
if (update(history)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.setCount(1)
|
history.setCount(1)
|
||||||
.setTimestamp(System.currentTimeMillis())
|
.setTimestamp(System.currentTimeMillis());
|
||||||
.save();
|
if (async) {
|
||||||
|
history.saveAsync().listen(null);
|
||||||
|
} else {
|
||||||
|
history.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void add(History history) {
|
||||||
|
add(history, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue