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
{ | |
"apps": [ | |
{ | |
"serverURL": "http://192.168.17.131:1337/parse", | |
"appId": "test_app_id", | |
"masterKey": "test_master_key", | |
"allowInsecureHTTP": "true", | |
"appName": "MyApp1" | |
} | |
], |
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
{ | |
"appName": "ParseServer", | |
"databaseURI": "mongodb://localhost:27017/parsedb", | |
"appId": "test_app_id", | |
"masterKey": "test_master_key", | |
"serverURL": "https://localhost:1337/parse", | |
"publicServerURL": "https://0.0.0.0:1337/parse", | |
"port": 1337 | |
} |
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
sealed class Failure { | |
/*Network Error*/ | |
class NetworkConnection(var additionalData: Any? = null) : Failure() | |
/*Exception*/ | |
class Exception(var additionalData: Any? = null) : Failure() | |
/** | |
* Although the HTTP standard specifies "unauthorized", | |
* semantically this response means "unauthenticated". |
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 androidx.fragment.app.Fragment | |
import androidx.lifecycle.ViewModel | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn | |
import dagger.hilt.android.components.ViewModelComponent | |
import dagger.hilt.android.lifecycle.HiltViewModel | |
import javax.inject.Inject | |
import javax.inject.Named |
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 IteratorPatternExample { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
val holder = VerifyTickets.getTicketHolder() | |
/*Printing several tickets*/ | |
println("Printing next tickets...") | |
holder.ticketIterator.nextTicket() | |
holder.ticketIterator.nextTicket() |
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
/** | |
* We have a data holder class called [MultithreadedDataHolder] that hold some data | |
* which will be used by different clients from different [Thread]s. Multiple clients | |
* can access the same object simultaneously. | |
* | |
* Any object that is annotated with Annotation [Volatile] make sure that the changes | |
* made in one thread are immediately reflect in other thread. | |
*/ | |
object MultithreadedDataHolder { | |
/*It's guaranteed that all reader threads will see the updated value of the |
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 CommandPatternExample { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
val remoteControl: BaseRemoteControl = RemoteControl() | |
println("-----Testing onButtonPressed on RemoteControl for Car-----") | |
val car = Car() | |
val carMoveCommand: Command = CarMoveCommand(car) | |
remoteControl.onButtonPressed(carMoveCommand) | |
println("-----Testing offButtonPressed on RemoteControl for Car-----") |
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 ChainOfResponsibilityExample { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
SupportCenterClient.handlerChain.apply { | |
println(".....") | |
receiveRequest(AbstractSupportCenter.Constants.GENERAL, "I'm having general issue.") | |
println(".....") | |
receiveRequest(AbstractSupportCenter.Constants.TECHNICAL, "I'm having technical issue.") | |
println(".....") |
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 Worker { | |
/*Async API*/ | |
fun doSomething(listener: Listener, throwError: Boolean) { | |
when (throwError) { | |
true -> { | |
Thread.sleep(3000) | |
listener.onError(Exception("Just a random exception...")) | |
} | |
else -> { | |
Thread.sleep(3000) |
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
/** | |
* Custom Base View to support Kotlin's Coroutine according to View's Lifecycle (On Detach, kill Coroutine). | |
* | |
* @param context [Context] | |
* @param attrs [AttributeSet] | |
*/ | |
open class BaseCustomView(context: Context, attrs: AttributeSet) : | |
ConstraintLayout(context, attrs) { | |
private val tag by lazy { this::class.java.canonicalName ?: "BaseCustomView" } |