mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-27 09:11:23 +01:00
添付メディアのサムネイルを表示できない&説明文がない場合は代わりにURLを表示するL
This commit is contained in:
parent
a2fc55a0dd
commit
588e099971
@ -689,8 +689,6 @@ class ColumnViewHolder(
|
||||
|
||||
column.addColumnViewHolder(this)
|
||||
|
||||
showQuickFilter()
|
||||
|
||||
showColumnColor()
|
||||
|
||||
showContent(reason = "onPageCreate", reset = true)
|
||||
@ -775,11 +773,7 @@ class ColumnViewHolder(
|
||||
// カラム内部の背景色
|
||||
c = column.column_bg_color
|
||||
if(c == 0) c = Column.defaultColorContentBg
|
||||
if(c == 0) {
|
||||
ViewCompat.setBackground(flColumnBackground, null)
|
||||
} else {
|
||||
flColumnBackground.setBackgroundColor(c)
|
||||
}
|
||||
flColumnBackground.setBackgroundColor(c)
|
||||
|
||||
// カラム内部の背景画像
|
||||
ivColumnBackgroundImage.alpha = column.column_bg_image_alpha
|
||||
|
@ -1585,74 +1585,82 @@ internal class ItemViewHolder(
|
||||
iv.setScaleTypeForMedia()
|
||||
}
|
||||
|
||||
|
||||
val showUrl : Boolean
|
||||
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_AUDIO -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_music))
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_music))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
TootAttachmentLike.TYPE_UNKNOWN -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_question))
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
val url = ta.urlForThumbnail
|
||||
when {
|
||||
url?.isEmpty() != false -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
}
|
||||
|
||||
else -> {
|
||||
iv.setMediaType(
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_VIDEO -> R.drawable.media_type_video
|
||||
TootAttachmentLike.TYPE_GIFV -> R.drawable.media_type_gifv
|
||||
else -> 0
|
||||
}
|
||||
)
|
||||
iv.setDefaultImage(null)
|
||||
iv.setImageUrl(
|
||||
activity.pref,
|
||||
0f,
|
||||
access_info.supplyBaseUrl(url),
|
||||
access_info.supplyBaseUrl(url)
|
||||
)
|
||||
}
|
||||
else -> when(val urlThumbnail = ta.urlForThumbnail) {
|
||||
null, "" -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
iv.setMediaType(
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_VIDEO -> R.drawable.media_type_video
|
||||
TootAttachmentLike.TYPE_GIFV -> R.drawable.media_type_gifv
|
||||
else -> 0
|
||||
}
|
||||
)
|
||||
iv.setDefaultImage(null)
|
||||
iv.setImageUrl(
|
||||
activity.pref,
|
||||
0f,
|
||||
access_info.supplyBaseUrl(urlThumbnail),
|
||||
access_info.supplyBaseUrl(urlThumbnail)
|
||||
)
|
||||
showUrl = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun appendDescription(s : String) {
|
||||
// val lp = LinearLayout.LayoutParams(
|
||||
// LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
// LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
// )
|
||||
// lp.topMargin = (0.5f + activity.density * 3f).toInt()
|
||||
//
|
||||
// val tv = MyTextView(activity)
|
||||
// tv.layoutParams = lp
|
||||
// //
|
||||
// tv.movementMethod = MyLinkMovementMethod
|
||||
// if(! activity.timeline_font_size_sp.isNaN()) {
|
||||
// tv.textSize = activity.timeline_font_size_sp
|
||||
// }
|
||||
// tv.setTextColor(content_color)
|
||||
|
||||
if(sbDesc.isNotEmpty()) sbDesc.append("\n")
|
||||
val desc = activity.getString(R.string.media_description, idx + 1, s)
|
||||
sbDesc.append(desc)
|
||||
}
|
||||
|
||||
val description = ta.description
|
||||
if(description != null && description.isNotEmpty()) {
|
||||
val lp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
lp.topMargin = (0.5f + activity.density * 3f).toInt()
|
||||
val tv = MyTextView(activity)
|
||||
tv.layoutParams = lp
|
||||
//
|
||||
tv.movementMethod = MyLinkMovementMethod
|
||||
if(! activity.timeline_font_size_sp.isNaN()) {
|
||||
tv.textSize = activity.timeline_font_size_sp
|
||||
}
|
||||
tv.setTextColor(content_color)
|
||||
|
||||
if(ta.description?.isNotEmpty() == true) {
|
||||
if(sbDesc.isNotEmpty()) sbDesc.append("\n")
|
||||
val desc =
|
||||
activity.getString(R.string.media_description, idx + 1, ta.description)
|
||||
sbDesc.append(desc)
|
||||
if(description?.isNotEmpty() == true) {
|
||||
appendDescription(description)
|
||||
} else {
|
||||
val urlString = ta.getUrlString()
|
||||
if(showUrl && urlString?.isNotEmpty() == true) {
|
||||
appendDescription(urlString)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val defaultBoostedAction : () -> Unit = {
|
||||
@ -1681,7 +1689,7 @@ internal class ItemViewHolder(
|
||||
btnShowMedia.visibility = View.VISIBLE
|
||||
llMedia.visibility = View.GONE
|
||||
}
|
||||
if( item is TootScheduled){
|
||||
if(item is TootScheduled) {
|
||||
MediaShown.save(item.uri, false)
|
||||
btnShowMedia.visibility = View.VISIBLE
|
||||
llMedia.visibility = View.GONE
|
||||
@ -1695,7 +1703,7 @@ internal class ItemViewHolder(
|
||||
btnShowMedia.visibility = View.GONE
|
||||
llMedia.visibility = View.VISIBLE
|
||||
}
|
||||
if( item is TootScheduled){
|
||||
if(item is TootScheduled) {
|
||||
MediaShown.save(item.uri, true)
|
||||
btnShowMedia.visibility = View.GONE
|
||||
llMedia.visibility = View.VISIBLE
|
||||
@ -1716,7 +1724,7 @@ internal class ItemViewHolder(
|
||||
list_adapter.notifyChange(reason = "ContentWarning onClick", reset = true)
|
||||
|
||||
}
|
||||
if(item is TootScheduled){
|
||||
if(item is TootScheduled) {
|
||||
val new_shown = llContents.visibility == View.GONE
|
||||
ContentWarning.save(item.uri, new_shown)
|
||||
|
||||
|
@ -88,6 +88,13 @@ class TootAttachment : TootAttachmentLike {
|
||||
else -> false
|
||||
}
|
||||
|
||||
override fun getUrlString() :String? =
|
||||
if( remote_url?.isNotEmpty()==true){
|
||||
remote_url
|
||||
}else{
|
||||
url
|
||||
}
|
||||
|
||||
constructor(serviceType : ServiceType, src : JSONObject) {
|
||||
|
||||
when(serviceType) {
|
||||
|
@ -11,6 +11,8 @@ interface TootAttachmentLike{
|
||||
|
||||
fun hasUrl(url:String):Boolean
|
||||
|
||||
fun getUrlString() :String?
|
||||
|
||||
companion object {
|
||||
const val TYPE_IMAGE = "image"
|
||||
const val TYPE_VIDEO = "video"
|
||||
|
@ -25,6 +25,9 @@ class TootAttachmentMSP(
|
||||
|
||||
override fun hasUrl(url:String):Boolean = (url == this.preview_url)
|
||||
|
||||
override fun getUrlString() :String? = preview_url
|
||||
|
||||
|
||||
companion object {
|
||||
fun parseList(array : JSONArray?) : ArrayList<TootAttachmentLike>? {
|
||||
if(array != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user