Try viewbinding

This commit is contained in:
Blatzar 2022-08-17 23:27:56 +02:00
parent f0e6917368
commit 4726f99f37
2 changed files with 27 additions and 18 deletions

View file

@ -5,7 +5,7 @@ dependencies {
}
// use an integer for version numbers
version = 3
version = 4
cloudstream {
@ -30,3 +30,8 @@ cloudstream {
)
requiresResources = true
}
android {
buildFeatures {
viewBinding = true
}
}

View file

@ -4,9 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
import com.lagradost.cloudstream3.R.drawable.nginx
@ -15,9 +12,13 @@ import com.lagradost.cloudstream3.R.string.*
import com.lagradost.cloudstream3.plugins.Plugin
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.showLoginInfo
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.addAccount
import com.lagradost.databinding.NginxSettingsBinding
class NginxSettingsFragment(private val plugin: Plugin, val nginxApi: NginxApi) :
BottomSheetDialogFragment() {
private lateinit var binding: NginxSettingsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@ -29,31 +30,34 @@ class NginxSettingsFragment(private val plugin: Plugin, val nginxApi: NginxApi)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding = NginxSettingsBinding.inflate(layoutInflater)
super.onViewCreated(view, savedInstanceState)
val infoView = view.findViewById<LinearLayout>(R.id.nginx_info)
val infoTextView = view.findViewById<TextView>(R.id.info_main_text)
val infoSubTextView = view.findViewById<TextView>(R.id.info_sub_text)
val infoImageView = view.findViewById<ImageView>(R.id.nginx_info_imageview)
// val infoView = view.findViewById<LinearLayout>(R.id.nginx_info)
// val infoTextView = view.findViewById<TextView>(R.id.info_main_text)
// val infoSubTextView = view.findViewById<TextView>(R.id.info_sub_text)
// val infoImageView = view.findViewById<ImageView>(R.id.nginx_info_imageview)
infoTextView.text = getString(nginx_info_title)
infoSubTextView.text = getString(nginx_info_summary)
infoImageView.setImageResource(nginx_question)
binding.infoMainText.text = getString(nginx_info_title)
binding.infoSubText.text = getString(nginx_info_summary)
binding.nginxInfoImageview.setImageResource(nginx_question)
val loginView = view.findViewById<LinearLayout>(R.id.nginx_login)
val loginTextView = view.findViewById<TextView>(R.id.main_text)
val loginImageView = view.findViewById<ImageView>(R.id.nginx_login_imageview)
loginImageView.setImageResource(nginx)
// val loginView = view.findViewById<LinearLayout>(R.id.nginx_login)
// val loginTextView = view.findViewById<TextView>(R.id.main_text)
// val loginImageView = view.findViewById<ImageView>(R.id.nginx_login_imageview)
binding.nginxLoginImageview.setImageResource(nginx)
// object : View.OnClickListener is required to make it compile because otherwise it used invoke-customs
infoView.setOnClickListener(object : View.OnClickListener {
binding.nginxInfo.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
openBrowser(nginxApi.createAccountUrl)
}
})
loginTextView.text = getString(login_format).format(nginxApi.name, getString(account))
loginView.setOnClickListener(object : View.OnClickListener {
binding.mainText.text = getString(login_format).format(nginxApi.name, getString(account))
binding.nginxLogin.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
val info = nginxApi.loginInfo()
if (info != null) {