Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
优化观看已下载视频的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
grandiloquent authored and grandiloquent committed Nov 15, 2021
1 parent dc501ec commit b54183f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/euphoria/psycho/explorer/VideoListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public boolean onContextItemSelected(@NonNull MenuItem item) {
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("确定要删除 " + videoFile.getName() + " 吗?")
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
actionDelete(videoFile);
mVideoDatabase.remove(videoFile);
dialogInterface.dismiss();
}).setNegativeButton(android.R.string.cancel, (dialogInterface, which) -> {
dialogInterface.dismiss();
Expand All @@ -243,6 +245,7 @@ public boolean onContextItemSelected(@NonNull MenuItem item) {
if (!n.exists()) {
videoFile.renameTo(n);
}
mVideoDatabase.remove(videoFile);
getVideos();
dialogInterface.dismiss();
}).setNegativeButton(android.R.string.cancel, (dialogInterface, which) -> {
Expand Down Expand Up @@ -286,6 +289,12 @@ public List<Video> queryDirectory(String directory, boolean order) {
return videos;
}

public void remove(File video){
getWritableDatabase().delete("video","directory = ? and filename = ?", new String[]{
video.getParentFile().getAbsolutePath(),
video.getName()
});
}
public void scanDirectory(String directory) {
File[] videos = new File(directory)
.listFiles(pathname -> pathname.isFile() && pathname.getName().endsWith(".mp4"));
Expand Down Expand Up @@ -321,6 +330,8 @@ public void scanDirectory(String directory) {
}
}



@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table if not exists video (\n" +
Expand Down

0 comments on commit b54183f

Please sign in to comment.