Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dialog code #411

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading