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
@Parcelize | |
data class PlayerDetails( | |
val id: Int, | |
val name: String | |
) : Parcelable |
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
ivPlayerOneAddScore.setOnClickListener { | |
] gameState.playerOneScore += 1 | |
updateScores() | |
} | |
ivPlayerTwoAddScore.setOnClickListener { | |
gameState.playerTwoScore += 1 | |
updateScores() | |
} |
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
fun newInstance(playersDetails: Pair<PlayerDetails, PlayerDetails>) = | |
GameFragment().apply { | |
arguments = Bundle().apply { | |
putParcelable(ARGS_GAME_STATE, buildNewGame(playersDetails.first, playersDetails.second)) | |
} | |
} |
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
val playerOneName = etPlayer1Name.text.toString() | |
val playerTwoName = etPlayer2Name.text.toString() | |
interactions.onPlayerDetailsEntered( | |
playerOneDetails = PlayerDetails(id = 1, name = playerOneName), | |
playerTwoDetails = PlayerDetails(id = 2, name = playerTwoName) | |
) |
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
data class GameState( | |
val playerOneDetails: PlayerDetails, | |
val playerTwoDetails: PlayerDetails, | |
var playerOneScore: Long, | |
var playerTwoScore: Long | |
) : Parcelable { | |
constructor(parcel: Parcel) : this( | |
playerOneDetails = parcel.readParcelable(PlayerDetails::class.java.classLoader), | |
playerTwoDetails = parcel.readParcelable(PlayerDetails::class.java.classLoader), |
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
import os | |
from shutil import move | |
sourceDirectory = input("Enter Source Directory eg: app/src/main/res: ") | |
destinationDirectory = input("Destination Directory eg: feature/src/main/res: ") | |
drawableFileName = input("Drawable File Name With Extension: ") | |
fileAbsolutePathsToMove = [] | |
directoryPathsToMove = [] |
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
public class WithSync { | |
private static final int NUM_EXECUTIONS = 100000000; | |
// This Object ensures synchronization | |
private static final Object mutexLock = new Object(); | |
private static void someLongOperation() { /* NO-OP */ } | |
public static void main(String[] args) { |
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
public class WithoutSync { | |
private static final int NUM_EXECUTIONS = 100000000; | |
private static void someLongOperation() { /* NO-OP */ } | |
public static void main(String[] args) { | |
final long[] numElements = {0}; |