-
-
Save yasukotelin/15bcdb9e809c67cdc448d5fa7da617ac to your computer and use it in GitHub Desktop.
Interfaceの名前被りは気をつけよう
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
class SampleFragment : BookSelectDialogListener, PurchaseDialogListener { | |
override fun onClick() { | |
// Compile error. | |
super.onClick() | |
} | |
} | |
interface BookSelectDialogListener { | |
fun onClick() { | |
println("BookSelectDialogListener on clicked!") | |
} | |
} | |
interface PurchaseDialogListener { | |
fun onClick() { | |
println("PurchaseDialogListener on clicked!") | |
} | |
} |
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
class SampleFragment : BookSelectDialogListener, PurchaseDialogListener { | |
override fun onClick() { | |
super<BookSelectDialogListener>.onClick() | |
super<PurchaseDialogListener>.onClick() | |
} | |
} | |
interface BookSelectDialogListener { | |
fun onClick() { | |
println("BookSelectDialogListener on clicked!") | |
} | |
} | |
interface PurchaseDialogListener { | |
fun onClick() { | |
println("PurchaseDialogListener on clicked!") | |
} | |
} |
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
class SampleFragment : BookSelectDialogListener, PurchaseDialogListener { | |
override fun onClickBook() { | |
} | |
override fun onClickPurchase() { | |
} | |
} | |
interface BookSelectDialogListener { | |
// 書影が選択されたときのコールバック | |
fun onClickBook() | |
} | |
interface PurchaseDialogInterfaceListener { | |
// 購入が選択されたときのコールバック | |
fun onClickPurchase() | |
} |
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
class SampleFragment : BookSelectDialogListener, PurchaseDialogListener { | |
override fun onClick() { | |
// Bookなの?購入なの? | |
} | |
} | |
interface BookSelectDialogListener { | |
// 書影が選択されたときのコールバック | |
fun onClick() | |
} | |
interface PurchaseDialogListener { | |
// 購入が選択されたときのコールバック | |
fun onClick() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment