|
|
@ -20,6 +20,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
|
|
|
|
|
|
|
private val textPaint = TextPaint() |
|
|
|
private val textPaint = TextPaint() |
|
|
|
private var name: String? = null |
|
|
|
private var name: String? = null |
|
|
|
|
|
|
|
private var author: String? = null |
|
|
|
|
|
|
|
|
|
|
|
constructor(context: Context) : super(context) |
|
|
|
constructor(context: Context) : super(context) |
|
|
|
|
|
|
|
|
|
|
@ -81,8 +82,9 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setName(name: String?) { |
|
|
|
fun setName(name: String?, author: String?) { |
|
|
|
this.name = name |
|
|
|
this.name = name |
|
|
|
|
|
|
|
this.author = author |
|
|
|
invalidate() |
|
|
|
invalidate() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -91,38 +93,34 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
minimumWidth = width |
|
|
|
minimumWidth = width |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun load(path: String?, name: String?) { |
|
|
|
fun load(path: String?, name: String?, author: String?) { |
|
|
|
if (path.isNullOrEmpty()) { |
|
|
|
ImageLoader.load(context, path)//Glide自动识别http://和file:// |
|
|
|
setName(name) |
|
|
|
.placeholder(R.drawable.image_cover_default) |
|
|
|
} else { |
|
|
|
.error(R.drawable.image_cover_default) |
|
|
|
ImageLoader.load(context, path)//Glide自动识别http://和file:// |
|
|
|
.listener(object : RequestListener<Drawable> { |
|
|
|
.placeholder(R.drawable.image_cover_default) |
|
|
|
override fun onLoadFailed( |
|
|
|
.error(R.drawable.image_cover_default) |
|
|
|
e: GlideException?, |
|
|
|
.listener(object : RequestListener<Drawable> { |
|
|
|
model: Any?, |
|
|
|
override fun onLoadFailed( |
|
|
|
target: Target<Drawable>?, |
|
|
|
e: GlideException?, |
|
|
|
isFirstResource: Boolean |
|
|
|
model: Any?, |
|
|
|
): Boolean { |
|
|
|
target: Target<Drawable>?, |
|
|
|
setName(name, author) |
|
|
|
isFirstResource: Boolean |
|
|
|
return false |
|
|
|
): Boolean { |
|
|
|
} |
|
|
|
setName(name) |
|
|
|
|
|
|
|
return false |
|
|
|
override fun onResourceReady( |
|
|
|
} |
|
|
|
resource: Drawable?, |
|
|
|
|
|
|
|
model: Any?, |
|
|
|
override fun onResourceReady( |
|
|
|
target: Target<Drawable>?, |
|
|
|
resource: Drawable?, |
|
|
|
dataSource: DataSource?, |
|
|
|
model: Any?, |
|
|
|
isFirstResource: Boolean |
|
|
|
target: Target<Drawable>?, |
|
|
|
): Boolean { |
|
|
|
dataSource: DataSource?, |
|
|
|
setName(null, null) |
|
|
|
isFirstResource: Boolean |
|
|
|
return false |
|
|
|
): Boolean { |
|
|
|
} |
|
|
|
setName(null) |
|
|
|
|
|
|
|
return false |
|
|
|
}) |
|
|
|
} |
|
|
|
.centerCrop() |
|
|
|
|
|
|
|
.into(this) |
|
|
|
}) |
|
|
|
|
|
|
|
.centerCrop() |
|
|
|
|
|
|
|
.into(this) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|