0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-15 23:35:06 +00:00
VancedManager/app/src/main/java/com/vanced/manager/adapter/LinkAdapter.kt

78 lines
2.6 KiB
Kotlin
Raw Normal View History

2020-10-31 19:45:39 +00:00
package com.vanced.manager.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
2020-11-15 09:49:40 +00:00
import androidx.appcompat.content.res.AppCompatResources
2020-10-31 19:45:39 +00:00
import androidx.recyclerview.widget.RecyclerView
import com.vanced.manager.R
import com.vanced.manager.databinding.ViewSocialLinkBinding
import com.vanced.manager.model.LinkModel
import com.vanced.manager.ui.viewmodels.HomeViewModel
class LinkAdapter(context: Context, private val viewModel: HomeViewModel) : RecyclerView.Adapter<LinkAdapter.LinkViewHolder>() {
private val instagram = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_instagram),
2020-10-31 19:45:39 +00:00
"https://instagram.com/vanced.youtube"
)
private val youtube = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_youtube),
2020-10-31 19:45:39 +00:00
"https://youtube.com/c/YouTubeVanced"
)
private val github = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_github),
2020-10-31 19:45:39 +00:00
"https://github.com/YTVanced/VancedManager"
)
private val website = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_website),
2020-10-31 19:45:39 +00:00
"https://vancedapp.com"
)
private val telegram = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_telegram),
2020-10-31 19:45:39 +00:00
"https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w"
)
private val twitter = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_twitter),
2020-10-31 19:45:39 +00:00
"https://twitter.com/YTVanced"
)
private val discord = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_discord),
2020-10-31 19:45:39 +00:00
"https://discord.gg/WCGNdRruzb"
)
private val reddit = LinkModel(
2020-11-15 09:49:40 +00:00
AppCompatResources.getDrawable(context, R.drawable.ic_reddit),
2020-10-31 19:45:39 +00:00
"https://www.reddit.com/r/Vanced/"
)
val links = arrayOf(instagram, youtube, github, website, telegram, twitter, discord, reddit)
inner class LinkViewHolder(private val binding: ViewSocialLinkBinding) : RecyclerView.ViewHolder(binding.root) {
2020-11-15 09:49:40 +00:00
val logo = binding.linkImage
2020-10-31 19:45:39 +00:00
fun bind(position: Int) {
binding.viewModel = viewModel
binding.linkModel = links[position]
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LinkViewHolder {
val view = ViewSocialLinkBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return LinkViewHolder(view)
}
override fun onBindViewHolder(holder: LinkViewHolder, position: Int) {
holder.bind(position)
2020-11-15 09:49:40 +00:00
holder.logo.setImageDrawable(links[position].linkIcon)
2020-10-31 19:45:39 +00:00
}
override fun getItemCount(): Int = links.size
}