Skip to content

Commit

Permalink
update dialog code (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows authored Jan 29, 2024
1 parent 0b19205 commit 307edcb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,20 @@ licenseReport {


```kotlin
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.webkit.WebView

import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction

class OpenSourceLicensesDialog : DialogFragment() {

@SuppressLint("CommitTransaction")
fun showLicenses(activity: AppCompatActivity) {
val fragmentManager = activity.getSupportFragmentManager()
val fragmentManager = activity.supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
val previousFragment = fragmentManager.findFragmentByTag("dialog_licenses")
if (previousFragment != null) {
Expand All @@ -315,11 +314,11 @@ class OpenSourceLicensesDialog : DialogFragment() {
val webView = WebView(requireActivity())
webView.loadUrl("file:///android_asset/open_source_licenses.html")

return Builder(requireActivity())
return AlertDialog.Builder(requireActivity())
.setTitle("Open Source Licenses")
.setView(webView)
.setPositiveButton("OK",
DialogInterface.OnClickListener { dialog: DialogInterface, which: Int -> dialog.dismiss() })
.setPositiveButton("OK"
) { dialog: DialogInterface, _: Int -> dialog.dismiss() }
.create()
}
}
Expand Down

0 comments on commit 307edcb

Please sign in to comment.