This repository was archived by the owner on Jul 18, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
java/com/yenaly/han1meviewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,6 +132,9 @@ object Preferences {
132132 val videoQuality: String
133133 get() = preferenceSp.getString(HomeSettingsFragment .DEFAULT_VIDEO_QUALITY , " 1080P" ) ? : " 1080P"
134134
135+ val showPlayedIndicator: Boolean
136+ get() = preferenceSp.getBoolean(HomeSettingsFragment .SHOW_PLAYED_INDICATOR ,true )
137+
135138 val fakeLauncherIcon: String
136139 get() = preferenceSp.getString(
137140 HomeSettingsFragment .FAKE_LAUNCHER_ICON ,
Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ object DatabaseRepo {
202202
203203 suspend fun findBy (videoCode : String ) =
204204 watchHistoryDao.findBy(videoCode)
205+
206+ suspend fun getWatched (resultList : List <String >) =
207+ watchHistoryDao.getWatchedCodes(resultList)
205208 }
206209
207210 object HanimeDownload {
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ abstract class WatchHistoryDao {
3030 @Query(" SELECT * FROM WatchHistoryEntity WHERE (`videoCode` = :videoCode) LIMIT 1" )
3131 abstract suspend fun findBy (videoCode : String ): WatchHistoryEntity ?
3232
33+ @Query(" SELECT videoCode FROM WatchHistoryEntity WHERE videoCode IN (:codes)" )
34+ abstract suspend fun getWatchedCodes (codes : List <String >): List <String >
35+
3336 @Query(" UPDATE WatchHistoryEntity SET progress = :progress WHERE videoCode = :videoCode" )
3437 abstract suspend fun updateProgress (videoCode : String , progress : Long )
3538
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ data class HanimeInfo(
2626 override var itemType : Int ,
2727 override val reviews : String? = " " ,
2828 override val currentArtist : String? = " " ,
29+ val watched : Boolean ? = false ,
2930): VideoItemType , HanimeInfoType {
3031 companion object {
3132 const val NORMAL = 0
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import coil.load
1414import com.chad.library.adapter4.BaseQuickAdapter
1515import com.chad.library.adapter4.viewholder.QuickViewHolder
1616import com.itxca.spannablex.spannable
17+ import com.yenaly.han1meviewer.Preferences
1718import com.yenaly.han1meviewer.R
1819import com.yenaly.han1meviewer.VIDEO_LAYOUT_MATCH_PARENT
1920import com.yenaly.han1meviewer.VIDEO_LAYOUT_WRAP_CONTENT
@@ -76,6 +77,8 @@ class HanimeVideoRvAdapter(
7677 crossfade(true )
7778 }
7879 holder.getView<TextView >(R .id.title).text = item.title
80+ if (Preferences .showPlayedIndicator)
81+ holder.getView<ImageView >(R .id.watched_icon).isVisible = item.watched == true
7982 }
8083
8184 HanimeInfo .NORMAL -> {
@@ -121,6 +124,8 @@ class HanimeVideoRvAdapter(
121124 item.artist.text()
122125 }
123126 }
127+ if (Preferences .showPlayedIndicator)
128+ holder.getView<ImageView >(R .id.watched_icon).isVisible = item.watched == true
124129 }
125130 }
126131 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class HomeSettingsFragment : YenalySettingsFragment(R.xml.settings_home) {
8181 companion object {
8282 const val VIDEO_LANGUAGE = " video_language"
8383 const val DEFAULT_VIDEO_QUALITY = " default_video_quality"
84-
84+ const val SHOW_PLAYED_INDICATOR = " show_played_indicator "
8585 const val ALLOW_PIP_MDOE = " allow_pip_mode"
8686 const val PLAYER_SETTINGS = " player_settings"
8787 const val H_KEYFRAME_SETTINGS = " h_keyframe_settings"
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.flowOn
2626import kotlinx.coroutines.flow.getAndUpdate
2727import kotlinx.coroutines.flow.update
2828import kotlinx.coroutines.launch
29+ import kotlinx.coroutines.withContext
2930
3031/* *
3132 * @project Hanime1
@@ -121,7 +122,18 @@ class SearchViewModel(
121122 if (prev is PageLoadingState .Loading ) _searchFlow .value = emptyList()
122123 _searchFlow .update { prevList ->
123124 when (state) {
124- is PageLoadingState .Success -> prevList + state.info
125+ // is PageLoadingState.Success -> prevList + state.info
126+ is PageLoadingState .Success -> {
127+ val list = state.info
128+ val codes = list.map { it.videoCode }
129+ val watchedCodes= withContext(Dispatchers .IO ) {
130+ DatabaseRepo .WatchHistory .getWatched(codes).toSet()
131+ }
132+ val updatedList = list.map { item ->
133+ item.copy(watched = watchedCodes.contains(item.videoCode))
134+ }
135+ prevList + updatedList
136+ }
125137 is PageLoadingState .Loading -> emptyList()
126138 else -> prevList
127139 }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <shape xmlns : android =" http://schemas.android.com/apk/res/android"
3+ android : shape =" oval" >
4+ <solid android : color =" ?attr/colorSurfaceVariant" />
5+ </shape >
Original file line number Diff line number Diff line change 5555 android : gravity =" center"
5656 android : text =" @string/now_playing"
5757 android : textColor =" ?attr/colorSurface" />
58+ <ImageView
59+ android : id =" @+id/watched_icon"
60+ android : layout_width =" 20dp"
61+ android : layout_height =" 20dp"
62+ android : layout_gravity =" top|end"
63+ android : layout_margin =" 6dp"
64+ android : contentDescription =" @null"
65+ android : src =" @drawable/ic_baseline_check_circle_24"
66+ android : background =" @drawable/icon_circle_bg"
67+ android : visibility =" gone"
68+ tools : visibility =" visible" />
5869
5970 <androidx .constraintlayout.widget.ConstraintLayout
6071 android : layout_width =" match_parent"
Original file line number Diff line number Diff line change 4343 android : contentDescription =" @null"
4444 app : shapeAppearanceOverlay =" @style/TopRoundCornerImageView" />
4545
46+ <ImageView
47+ android : id =" @+id/watched_icon"
48+ android : layout_width =" 20dp"
49+ android : layout_height =" 20dp"
50+ android : layout_gravity =" top|end"
51+ android : layout_margin =" 6dp"
52+ android : contentDescription =" @null"
53+ android : src =" @drawable/ic_baseline_check_circle_24"
54+ android : background =" @drawable/icon_circle_bg"
55+ android : visibility =" gone"
56+ tools : visibility =" visible" />
4657 </FrameLayout >
4758
4859 <TextView
You can’t perform that action at this time.
0 commit comments