feat:【光环助手】工具新增跳转类型配置 https://jira.shanqu.cc/browse/GHZSCY-4618
This commit is contained in:
@ -5,6 +5,7 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity.Companion.getWebByCollectionTools
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
@ -103,19 +104,24 @@ class ToolBoxItemAdapter(
|
||||
viewHolder.binding.root.setOnClickListener {
|
||||
mViewModel.addToHistoryList(toolBoxEntity)
|
||||
|
||||
val url = toolBoxEntity.url
|
||||
if (url != null && url.contains(Config.URL_ARTICLE)) {
|
||||
val newsId = url.substring(url.lastIndexOf("/") + 1, url.length - 5) // 5: ".html"
|
||||
val intent = NewsDetailActivity.getIntentById(mContext, newsId, "工具箱列表")
|
||||
mContext.startActivity(intent)
|
||||
} else {
|
||||
mContext.startActivity(
|
||||
getWebByCollectionTools(
|
||||
mContext,
|
||||
toolBoxEntity,
|
||||
false
|
||||
val linkEntity = toolBoxEntity.toLinkEntity()
|
||||
if (linkEntity.type == "web") {
|
||||
val url = linkEntity.link ?: ""
|
||||
if (url.isNotEmpty() && url.contains(Config.URL_ARTICLE)) {
|
||||
val newsId = url.substring(url.lastIndexOf("/") + 1, url.length - 5) // 5: ".html"
|
||||
val intent = NewsDetailActivity.getIntentById(mContext, newsId, "工具箱列表")
|
||||
mContext.startActivity(intent)
|
||||
} else {
|
||||
mContext.startActivity(
|
||||
getWebByCollectionTools(
|
||||
mContext,
|
||||
toolBoxEntity,
|
||||
false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "工具箱", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,16 +3,16 @@ package com.gh.gamecenter.toolbox
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.baselist.LoadStatus
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.ToolBoxEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils
|
||||
import com.gh.gamecenter.entity.ToolBoxBlockEntity
|
||||
import com.gh.gamecenter.common.entity.ToolBoxEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -77,6 +77,12 @@ class ToolBoxViewModel(application: Application) : AndroidViewModel(application)
|
||||
for (item in historyList) {
|
||||
val offsetDay = TimeUtils.getBeforeDays(item.lastOpenTime / 1000)
|
||||
if (offsetDay <= 30) {
|
||||
if (item.url != null && (item.linkId.isEmpty() || item.linkType.isEmpty() || item.linkText.isEmpty())) {
|
||||
// 给历史数据补充信息
|
||||
item.linkType = "web"
|
||||
item.linkId = item.url!!
|
||||
item.linkText = item.url!!
|
||||
}
|
||||
add(item)
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,14 @@ class ToolBoxEntity : Parcelable {
|
||||
@SerializedName("me")
|
||||
var me: ToolboxMeEntity? = null
|
||||
|
||||
@SerializedName("link_type")
|
||||
var linkType: String = ""
|
||||
@SerializedName("link_id")
|
||||
var linkId: String = ""
|
||||
@SerializedName("link_text")
|
||||
var linkText: String = ""
|
||||
|
||||
fun toLinkEntity() = LinkEntity(link = linkId, type = linkType, text = linkText, linkText = linkText)
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
@ -43,6 +51,9 @@ class ToolBoxEntity : Parcelable {
|
||||
dest.writeString(this.url)
|
||||
dest.writeLong(this.time)
|
||||
dest.writeParcelable(this.me, flags)
|
||||
dest.writeString(this.linkType)
|
||||
dest.writeString(this.linkId)
|
||||
dest.writeString(this.linkText)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@ -58,6 +69,9 @@ class ToolBoxEntity : Parcelable {
|
||||
if (url != other.url) return false
|
||||
if (time != other.time) return false
|
||||
if (me != other.me) return false
|
||||
if (linkType != other.linkType) return false
|
||||
if (linkId != other.linkId) return false
|
||||
if (linkText != other.linkText) return false
|
||||
|
||||
return true
|
||||
}
|
||||
@ -70,9 +84,13 @@ class ToolBoxEntity : Parcelable {
|
||||
result = 31 * result + (url?.hashCode() ?: 0)
|
||||
result = 31 * result + time.hashCode()
|
||||
result = 31 * result + (me?.hashCode() ?: 0)
|
||||
result = 31 * result + linkType.hashCode()
|
||||
result = 31 * result + linkId.hashCode()
|
||||
result = 31 * result + linkText.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
constructor()
|
||||
|
||||
protected constructor(`in`: Parcel) {
|
||||
@ -83,6 +101,9 @@ class ToolBoxEntity : Parcelable {
|
||||
this.url = `in`.readString()
|
||||
this.time = `in`.readLong()
|
||||
this.me = `in`.readParcelable<ToolboxMeEntity>(ToolboxMeEntity::class.java.classLoader)
|
||||
this.linkType = `in`.readString() ?: ""
|
||||
this.linkId = `in`.readString() ?: ""
|
||||
this.linkText = `in`.readString() ?: ""
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
|
||||
Reference in New Issue
Block a user