From b65001f42a4a9cd684b8d6de1b52db17ab5d59ac Mon Sep 17 00:00:00 2001 From: yutou Date: Thu, 26 Nov 2020 18:27:33 +0800 Subject: [PATCH] update --- app/build.gradle | 5 +++ .../nas_music_player/Datas/MusicData.java | 29 +++++++++++++++++ .../nas_music_player/tools/SQLiteManager.java | 31 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 app/src/main/java/com/yutou/nas_music_player/tools/SQLiteManager.java diff --git a/app/build.gradle b/app/build.gradle index 3d038b5..ac06344 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,6 +45,7 @@ android { } dependencies { + def room_version = "2.2.5" implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.2.0' @@ -72,4 +73,8 @@ dependencies { implementation 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.95' implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' + + implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$room_version" + } \ No newline at end of file diff --git a/app/src/main/java/com/yutou/nas_music_player/Datas/MusicData.java b/app/src/main/java/com/yutou/nas_music_player/Datas/MusicData.java index 84421a5..75a533b 100644 --- a/app/src/main/java/com/yutou/nas_music_player/Datas/MusicData.java +++ b/app/src/main/java/com/yutou/nas_music_player/Datas/MusicData.java @@ -18,30 +18,59 @@ import com.yutou.nas_music_player.tools.StringUtil; import androidx.annotation.Nullable; import androidx.palette.graphics.Palette; +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.Ignore; +import androidx.room.PrimaryKey; +@Entity public class MusicData { + @PrimaryKey(autoGenerate = true) + private int id; + @ColumnInfo(name="artist") private String artist;//艺术家 + @ColumnInfo(name="album") private String album;//专辑 + @ColumnInfo(name="title") private String title;//标题 + @ColumnInfo(name="comment") private String comment;//评论 + @ColumnInfo(name="year") private String year;//年份 + @ColumnInfo(name="track") private String track;//音轨号 + @ColumnInfo(name="disc_no") private String disc_no;//碟片编号 + @ColumnInfo(name="composer") private String composer;//作曲 + @ColumnInfo(name="artist_sort") private String artist_sort;//分类 + @ColumnInfo(name="lastDir") private String lastDir;//上一个文件夹 + @ColumnInfo(name="file") private String file; + @ColumnInfo(name="isDir") private boolean isDir = false; + @Ignore private Bitmap img; + @ColumnInfo private int bitRate;//比特率 + @ColumnInfo private int sampleRate;//采样率 + @ColumnInfo private long noOfSamples;//采样数 + @ColumnInfo private int channelCount;//声道 + @ColumnInfo private String encodingType;//解码类型 + @ColumnInfo private double durationAsDouble;//持续时长 + @ColumnInfo private boolean lossless;//无损 + @ColumnInfo private boolean variableBitRate;//固定码率 + @ColumnInfo private String md5;//确保是同一个文件 public MusicData() { diff --git a/app/src/main/java/com/yutou/nas_music_player/tools/SQLiteManager.java b/app/src/main/java/com/yutou/nas_music_player/tools/SQLiteManager.java new file mode 100644 index 0000000..886eeb9 --- /dev/null +++ b/app/src/main/java/com/yutou/nas_music_player/tools/SQLiteManager.java @@ -0,0 +1,31 @@ +package com.yutou.nas_music_player.tools; + +import androidx.annotation.NonNull; +import androidx.room.Database; +import androidx.room.DatabaseConfiguration; +import androidx.room.InvalidationTracker; +import androidx.room.RoomDatabase; +import androidx.sqlite.db.SupportSQLiteOpenHelper; + +import com.yutou.nas_music_player.Datas.MusicData; + +@Database(entities = {MusicData.class},version = 1) +public abstract class SQLiteManager extends RoomDatabase { + + @NonNull + @Override + protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) { + return null; + } + + @NonNull + @Override + protected InvalidationTracker createInvalidationTracker() { + return null; + } + + @Override + public void clearAllTables() { + + } +}