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
|
|
|
|
|
2020-11-23 20:33:24 +00:00
|
|
|
class LinkAdapter(
|
|
|
|
private val context: Context,
|
|
|
|
private val viewModel: HomeViewModel
|
|
|
|
) : RecyclerView.Adapter<LinkAdapter.LinkViewHolder>() {
|
2020-10-31 19:45:39 +00:00
|
|
|
|
|
|
|
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-23 20:33:24 +00:00
|
|
|
|
2020-11-15 09:49:40 +00:00
|
|
|
val logo = binding.linkImage
|
2020-11-23 20:33:24 +00:00
|
|
|
|
2020-10-31 19:45:39 +00:00
|
|
|
fun bind(position: Int) {
|
2020-11-23 20:33:24 +00:00
|
|
|
binding.linkBg.setOnClickListener {
|
|
|
|
viewModel.openUrl(links[position].linkUrl)
|
|
|
|
}
|
2020-10-31 19:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LinkViewHolder {
|
2020-11-23 20:33:24 +00:00
|
|
|
val view = ViewSocialLinkBinding.inflate(LayoutInflater.from(context), parent, false)
|
2020-10-31 19:45:39 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
}
|