Commit 7577d189 authored by sheteng's avatar sheteng

公告点击事件

parent 1bdd68a7
......@@ -6,5 +6,6 @@ data class Notice(
val createdDate: String?,
val gameId: Int?,
val id: Int?,
val title: String?
val title: String?,
val url: String
)
\ No newline at end of file
......@@ -19,8 +19,10 @@ import com.ccwangluo.accelerator.model.Plugin
import com.ccwangluo.accelerator.ui.news.NewsCollectionAdapter
import com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.SysUtils
import com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import com.github.shadowsocks.http.HttpConfig
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
......@@ -48,13 +50,20 @@ class NewsFragment : XPageFragment() {
val titles = arrayOf("全部", "攻略", "视频", "评价", "问答")
var adapter: NewsCollectionAdapter? = null
override fun initViews() {
newsViewModel.notice.observe(this, {
newsViewModel.notice.observe(this) { it1 ->
binding.newsNotice.visibility = View.VISIBLE
it.forEach {
binding.tvMarquee.addDisplayString(it.title)
}
binding.tvMarquee.addDisplayString(it1.title)
binding.tvMarquee.startRoll()
})
binding.newsNotice.setOnClickListener {
DataRePortUtils.report("st_msg_annoucement_clk")
val params = Bundle()
params.putString(
CommonWebViewFragment.WEBVIEW_URL_KEY,
it1.url
)
openPage(CommonWebViewFragment::class.java, params)
}
}
newsViewModel.isRefresh.observe(this, Observer {
binding.refreshNews.isRefreshing = false
......@@ -78,45 +87,49 @@ class NewsFragment : XPageFragment() {
val layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
binding.gameNewsList?.setLayoutManager(layoutManager)
binding.gameNewsList.adapter = KotlinDataAdapter.Builder<Plugin>()
.setData(dataList)
.setLayoutId(R.layout.item_news_game)
.addBindView { itemView, itemData ->
context?.let {
Glide.with(it).load(itemData.icon)
.into(itemView.findViewById<ImageView>(R.id.plugin_img))
.setData(dataList)
.setLayoutId(R.layout.item_news_game)
.addBindView { itemView, itemData ->
context?.let {
Glide.with(it).load(itemData.icon)
.into(itemView.findViewById<ImageView>(R.id.plugin_img))
}
itemView.findViewById<TextView>(R.id.plugin_name).setText(itemData.name)
itemView.setOnClickListener {
if (itemData.type == 3) {
DataRePortUtils.report("st_game_down_clk", mapOf("scene" to "3"))
}
if (!itemData.isOpen) {
ToastUtils.show("暂不支持${itemData.name}")
return@setOnClickListener
}
itemView.findViewById<TextView>(R.id.plugin_name).setText(itemData.name)
itemView.setOnClickListener {
if (!itemData.isOpen) {
ToastUtils.show("暂不支持${itemData.name}")
return@setOnClickListener
}
if (itemData.type == 1) {
itemData.url?.let {
DataRePortUtils.report("st_qq_clk", mapOf("scene" to "3"))
context?.let { it1 -> SysUtils.joinQQGroup(it1) }
}
if (itemData.type == 1) {
itemData.url?.let {
DataRePortUtils.report("st_qq_clk", mapOf("scene" to "3"))
context?.let { it1 -> SysUtils.joinQQGroup(it1) }
}
}
if (itemData.type == 2) {
itemData.url?.let {
DataRePortUtils.report("st_google_clk", mapOf("scene" to "3"))
openToWebview(it)
}
if (itemData.type == 2) {
itemData.url?.let {
DataRePortUtils.report("st_google_clk", mapOf("scene" to "3"))
openToWebview(it)
}
}
if (itemData.type == 3) {
itemData.url?.let {
context?.let { it1 ->
SysUtils.downloadFile(it1, it)
ToastUtils.show("开始下载")
}
if (itemData.type == 3) {
itemData.url?.let {
DataRePortUtils.report("st_game_down_clk", mapOf("scene" to "3"))
context?.let { it1 ->
SysUtils.downloadFile(it1, it)
ToastUtils.show("开始下载")
}
}
}
}
}.create()
}.create()
newsViewModel.pluginList.observe(this, {
dataList.clear()
dataList.addAll(it)
......
......@@ -15,7 +15,7 @@ class NewsViewModel : ViewModel() {
val isRefresh = MutableLiveData<Boolean>()
val notice = MutableLiveData<List<Notice>>()
val notice = MutableLiveData<Notice>()
val pluginList = MutableLiveData<List<Plugin>>()
......@@ -26,7 +26,9 @@ class NewsViewModel : ViewModel() {
res?.let {
if (it.code == 200) {
it.data?.list?.let {
notice.postValue(it)
if(it.size > 0) {
notice.postValue(it.get(0))
}
}
}
}
......
......@@ -4,16 +4,16 @@ object HttpConfig {
//app后端
//val baseUrl = "http://10.16.1.98:9002"
// val baseUrl = "https://test-cc-tt-api.orangenet.org.cn" //测试
val baseUrl = "https://cc-tt-front.srccwl.com" //生产
val baseUrl = "https://test-cc-tt-api.orangenet.org.cn" //测试
// val baseUrl = "https://cc-tt-front.srccwl.com" //生产
/**
* 主页h5
*/
// val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
// val UI_MAIN_URL = "http://10.3.64.200:8080/#"
val UI_MAIN_URL = "https://cc-tt-front.srccwl.com/#" //生产
// val UI_MAIN_URL = "https://cc-tt-front.srccwl.com/#" //生产
//隐私协议地址
val HTML_HOST_PRIVACY="https://sdk-static.srccwl.com/tt_html/"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment