Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

Commit ddc5835

Browse files
authored
Merge pull request #94 from misaka10032w/develop
恢复使用外部播放器播放已下载的影片的功能
2 parents 1f778f9 + 73a79d3 commit ddc5835

6 files changed

Lines changed: 46 additions & 6 deletions

File tree

app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HanimeDownloadedRvAdapter.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@ import com.chad.library.adapter4.viewholder.DataBindingHolder
1515
import com.yenaly.han1meviewer.HFileManager
1616
import com.yenaly.han1meviewer.LOCAL_DATE_TIME_FORMAT
1717
import com.yenaly.han1meviewer.R
18-
import com.yenaly.han1meviewer.VIDEO_CODE
1918
import com.yenaly.han1meviewer.databinding.ItemHanimeDownloadedBinding
2019
import com.yenaly.han1meviewer.logic.entity.download.VideoWithCategories
2120
import com.yenaly.han1meviewer.ui.activity.MainActivity
22-
import com.yenaly.han1meviewer.ui.activity.VideoActivity
2321
import com.yenaly.han1meviewer.ui.fragment.home.download.DownloadedFragment
2422
import com.yenaly.han1meviewer.util.HImageMeower.loadUnhappily
2523
import com.yenaly.han1meviewer.util.openDownloadedHanimeVideoInActivity
24+
import com.yenaly.han1meviewer.util.openDownloadedHanimeVideoLocally
2625
import com.yenaly.han1meviewer.util.showAlertDialog
27-
import com.yenaly.yenaly_libs.utils.activity
2826
import com.yenaly.yenaly_libs.utils.dpF
2927
import com.yenaly.yenaly_libs.utils.formatFileSizeV2
3028
import com.yenaly.yenaly_libs.utils.requireActivity
31-
import com.yenaly.yenaly_libs.utils.startActivity
3229
import kotlinx.datetime.Instant
3330
import kotlinx.datetime.TimeZone
3431
import kotlinx.datetime.format
@@ -169,6 +166,23 @@ class HanimeDownloadedRvAdapter(private val fragment: DownloadedFragment) :
169166
// })
170167
context.openDownloadedHanimeVideoInActivity(item.video.videoCode)
171168
}
169+
viewHolder.binding.btnExtPlayer.setOnClickListener {
170+
val position = viewHolder.bindingAdapterPosition
171+
val item = getItem(position) ?: return@setOnClickListener
172+
context.openDownloadedHanimeVideoLocally(item.video.videoUri, onFileNotFound = {
173+
context.showAlertDialog {
174+
setTitle(R.string.video_not_exist)
175+
setMessage(R.string.video_deleted_sure_to_delete_item)
176+
setPositiveButton(R.string.delete) { _, _ ->
177+
fragment.viewModel.deleteDownloadHanimeBy(
178+
item.video.videoCode,
179+
item.video.quality
180+
)
181+
}
182+
setNegativeButton(R.string.cancel, null)
183+
}
184+
})
185+
}
172186
}
173187
}
174188
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="1024"
5+
android:viewportHeight="1024">
6+
<path
7+
android:pathData="M426.7,256v85.3L213.3,341.3v469.3h469.3v-213.3h85.3v256a42.7,42.7 0,0 1,-42.7 42.7L170.7,896a42.7,42.7 0,0 1,-42.7 -42.7L128,298.7a42.7,42.7 0,0 1,42.7 -42.7h256zM896,128v384l-161.9,-161.8 -256,256 -60.3,-60.3 256,-256L512,128h384z"
8+
android:fillColor="#ffffff"/>
9+
</vector>

app/src/main/res/layout/item_hanime_downloaded.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,25 @@
169169
app:icon="@drawable/ic_baseline_delete_24"
170170
app:iconGravity="end"
171171
app:layout_constraintBottom_toBottomOf="parent"
172-
app:layout_constraintEnd_toStartOf="@id/btn_local_playback"
172+
app:layout_constraintEnd_toStartOf="@id/btn_ext_player"
173173
app:layout_constraintHorizontal_chainStyle="spread_inside"
174174
app:layout_constraintStart_toStartOf="parent"
175175
app:layout_constraintTop_toTopOf="parent" />
176176

177+
<com.google.android.material.button.MaterialButton
178+
android:id="@+id/btn_ext_player"
179+
style="@style/Widget.Material3.Button.TextButton"
180+
android:layout_width="wrap_content"
181+
android:layout_height="wrap_content"
182+
android:text="@string/ext_player"
183+
app:icon="@drawable/ic_ext_link"
184+
app:iconGravity="start"
185+
app:layout_constraintBottom_toBottomOf="parent"
186+
app:layout_constraintEnd_toStartOf="@id/btn_local_playback"
187+
app:layout_constraintHorizontal_chainStyle="spread_inside"
188+
app:layout_constraintStart_toEndOf="@id/btn_delete"
189+
app:layout_constraintTop_toTopOf="parent" />
190+
177191
<com.google.android.material.button.MaterialButton
178192
android:id="@+id/btn_local_playback"
179193
style="@style/Widget.Material3.Button.TextButton"
@@ -186,7 +200,7 @@
186200
app:layout_constraintBottom_toBottomOf="parent"
187201
app:layout_constraintEnd_toEndOf="parent"
188202
app:layout_constraintHorizontal_chainStyle="spread_inside"
189-
app:layout_constraintStart_toEndOf="@id/btn_delete"
203+
app:layout_constraintStart_toEndOf="@id/btn_ext_player"
190204
app:layout_constraintTop_toTopOf="parent" />
191205

192206
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values-en/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,5 +397,6 @@ Recommendations are as follows:\n
397397
<string name="request_pip_alert">If the picture-in-picture permission is not authorized, it will be automatically closed.</string>
398398
<string name="approximate_range">Approximate time</string>
399399
<string name="specific_y_m">Specific Y &amp; M</string>
400+
<string name="ext_player">External player</string>
400401

401402
</resources>

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,5 +403,6 @@
403403
<string name="request_pip_alert">未授权画中画权限,将自动关闭</string>
404404
<string name="specific_y_m">具体年月</string>
405405
<string name="approximate_range">大致范围</string>
406+
<string name="ext_player">外部播放器</string>
406407

407408
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@
421421
<string name="request_pip_alert">未授權畫中畫權限,自動關閉</string>
422422
<string name="approximate_range">大致範圍</string>
423423
<string name="specific_y_m">具體年月</string>
424+
<string name="ext_player">外部播放器</string>
424425

425426

426427
</resources>

0 commit comments

Comments
 (0)