1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +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.View
import android.view.ViewGroup
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
@ -59,41 +60,27 @@ class AboutActivity : AppCompatActivity() {
* A placeholder fragment containing a simple view.
*/
class AboutFragment : Fragment() {
private fun Button.openLink(url: Int) {
setOnClickListener {
ShareUtils.openUrlInBrowser(
context,
requireContext().getString(url),
false
)
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val aboutBinding = FragmentAboutBinding.inflate(inflater, container, false)
val context = context
aboutBinding.aboutAppVersion.text = BuildConfig.VERSION_NAME
aboutBinding.aboutGithubLink.setOnClickListener {
ShareUtils.openUrlInBrowser(
context,
context!!.getString(R.string.github_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
)
}
aboutBinding.aboutGithubLink.openLink(R.string.github_url)
aboutBinding.aboutDonationLink.openLink(R.string.donation_url)
aboutBinding.aboutWebsiteLink.openLink(R.string.website_url)
aboutBinding.aboutPrivacyPolicyLink.openLink(R.string.privacy_policy_url)
return aboutBinding.root
}
}