-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
764f2a1
commit d7a6053
Showing
16 changed files
with
206 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/lizongying/mytv/ConfirmationDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.lizongying.mytv | ||
|
||
import android.app.AlertDialog | ||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.fragment.app.DialogFragment | ||
|
||
class ConfirmationDialogFragment(private val listener: ConfirmationDialogListener) : | ||
DialogFragment() { | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return activity?.let { | ||
val builder = AlertDialog.Builder(it) | ||
builder.setTitle("确认") | ||
.setMessage("确认更新吗?") | ||
.setPositiveButton( | ||
"确定" | ||
) { _, _ -> | ||
listener.onConfirm() | ||
} | ||
.setNegativeButton( | ||
"取消" | ||
) { _, _ -> | ||
listener.onCancel() | ||
} | ||
// 创建并返回 AlertDialog 对象 | ||
builder.create() | ||
} ?: throw IllegalStateException("Activity cannot be null") | ||
} | ||
|
||
interface ConfirmationDialogListener { | ||
fun onConfirm() | ||
fun onCancel() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.