|
|
|
@ -20,6 +20,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
|
|
|
|
|
private val textPaint = TextPaint() |
|
|
|
|
private var name: String? = null |
|
|
|
|
private var author: String? = null |
|
|
|
|
|
|
|
|
|
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.author = author |
|
|
|
|
invalidate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -91,10 +93,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
minimumWidth = width |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun load(path: String?, name: String?) { |
|
|
|
|
if (path.isNullOrEmpty()) { |
|
|
|
|
setName(name) |
|
|
|
|
} else { |
|
|
|
|
fun load(path: String?, name: String?, author: String?) { |
|
|
|
|
ImageLoader.load(context, path)//Glide自动识别http://和file:// |
|
|
|
|
.placeholder(R.drawable.image_cover_default) |
|
|
|
|
.error(R.drawable.image_cover_default) |
|
|
|
@ -105,7 +104,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
target: Target<Drawable>?, |
|
|
|
|
isFirstResource: Boolean |
|
|
|
|
): Boolean { |
|
|
|
|
setName(name) |
|
|
|
|
setName(name, author) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -116,7 +115,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
dataSource: DataSource?, |
|
|
|
|
isFirstResource: Boolean |
|
|
|
|
): Boolean { |
|
|
|
|
setName(null) |
|
|
|
|
setName(null, null) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -124,5 +123,4 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { |
|
|
|
|
.centerCrop() |
|
|
|
|
.into(this) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|