This commit is contained in:
yutou 2020-11-26 18:27:33 +08:00
parent 198d092f94
commit b65001f42a
3 changed files with 65 additions and 0 deletions

View File

@ -45,6 +45,7 @@ android {
} }
dependencies { dependencies {
def room_version = "2.2.5"
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0' 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.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.95'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
} }

View File

@ -18,30 +18,59 @@ import com.yutou.nas_music_player.tools.StringUtil;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.palette.graphics.Palette; 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 { public class MusicData {
@PrimaryKey(autoGenerate = true)
private int id;
@ColumnInfo(name="artist")
private String artist;//艺术家 private String artist;//艺术家
@ColumnInfo(name="album")
private String album;//专辑 private String album;//专辑
@ColumnInfo(name="title")
private String title;//标题 private String title;//标题
@ColumnInfo(name="comment")
private String comment;//评论 private String comment;//评论
@ColumnInfo(name="year")
private String year;//年份 private String year;//年份
@ColumnInfo(name="track")
private String track;//音轨号 private String track;//音轨号
@ColumnInfo(name="disc_no")
private String disc_no;//碟片编号 private String disc_no;//碟片编号
@ColumnInfo(name="composer")
private String composer;//作曲 private String composer;//作曲
@ColumnInfo(name="artist_sort")
private String artist_sort;//分类 private String artist_sort;//分类
@ColumnInfo(name="lastDir")
private String lastDir;//上一个文件夹 private String lastDir;//上一个文件夹
@ColumnInfo(name="file")
private String file; private String file;
@ColumnInfo(name="isDir")
private boolean isDir = false; private boolean isDir = false;
@Ignore
private Bitmap img; private Bitmap img;
@ColumnInfo
private int bitRate;//比特率 private int bitRate;//比特率
@ColumnInfo
private int sampleRate;//采样率 private int sampleRate;//采样率
@ColumnInfo
private long noOfSamples;//采样数 private long noOfSamples;//采样数
@ColumnInfo
private int channelCount;//声道 private int channelCount;//声道
@ColumnInfo
private String encodingType;//解码类型 private String encodingType;//解码类型
@ColumnInfo
private double durationAsDouble;//持续时长 private double durationAsDouble;//持续时长
@ColumnInfo
private boolean lossless;//无损 private boolean lossless;//无损
@ColumnInfo
private boolean variableBitRate;//固定码率 private boolean variableBitRate;//固定码率
@ColumnInfo
private String md5;//确保是同一个文件 private String md5;//确保是同一个文件
public MusicData() { public MusicData() {

View File

@ -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() {
}
}