1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Convert AboutFragment clickListeners to a function extension

This commit is contained in:
TacoTheDank 2021-03-29 19:07:12 -04:00
parent fb1aab2a49
commit 27d0f7f277

View File

@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
@ -59,41 +60,27 @@ class AboutActivity : AppCompatActivity() {
* A placeholder fragment containing a simple view. * A placeholder fragment containing a simple view.
*/ */
class AboutFragment : Fragment() { class AboutFragment : Fragment() {
private fun Button.openLink(url: Int) {
setOnClickListener {
ShareUtils.openUrlInBrowser(
context,
requireContext().getString(url),
false
)
}
}
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
val aboutBinding = FragmentAboutBinding.inflate(inflater, container, false) val aboutBinding = FragmentAboutBinding.inflate(inflater, container, false)
val context = context
aboutBinding.aboutAppVersion.text = BuildConfig.VERSION_NAME aboutBinding.aboutAppVersion.text = BuildConfig.VERSION_NAME
aboutBinding.aboutGithubLink.setOnClickListener { aboutBinding.aboutGithubLink.openLink(R.string.github_url)
ShareUtils.openUrlInBrowser( aboutBinding.aboutDonationLink.openLink(R.string.donation_url)
context, aboutBinding.aboutWebsiteLink.openLink(R.string.website_url)
context!!.getString(R.string.github_url), aboutBinding.aboutPrivacyPolicyLink.openLink(R.string.privacy_policy_url)
false
)
}
aboutBinding.aboutDonationLink.setOnClickListener {
ShareUtils.openUrlInBrowser(
context,
context!!.getString(R.string.donation_url),
false
)
}
aboutBinding.aboutWebsiteLink.setOnClickListener {
ShareUtils.openUrlInBrowser(
context,
context!!.getString(R.string.website_url),
false
)
}
aboutBinding.aboutPrivacyPolicyLink.setOnClickListener {
ShareUtils.openUrlInBrowser(
context, context!!.getString(R.string.privacy_policy_url),
false
)
}
return aboutBinding.root return aboutBinding.root
} }
} }