Skip to content

Instantly share code, notes, and snippets.

View alz-ahm's full-sized avatar
😎
coding...

A.A. alz-ahm

😎
coding...
View GitHub Profile
library identifier: 'jenkins-shared@master', retriever: modernSCM(
[$class: 'GitSCMSource',
remote: 'https://github.com/MobodidTech/jenkins-shared.git',
])
def sendTelegram(message) {
def encodedMessage = URLEncoder.encode(message, "UTF-8")
withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'),
string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) {
response = httpRequest (consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
httpMode: 'GET',
url: "https://api.telegram.org/bot$TOKEN/sendMessage?text=$encodedMessage&chat_id=$CHAT_ID&disable_web_page_preview=true",
FROM ubuntu:latest
# Install OS prerequisites
RUN apt-get update -qq
RUN apt-get install -y openjdk-8-jdk \
wget \
expect \
zip \
unzip
pipeline {
agent {
docker {
image 'android-agent'
}
}
}
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
*/
fun getContentIfNotHandledOrReturnNull(): T? {
return if (hasBeenHandled) {
class MyViewModel() : ViewModel(){
val networkError = MutableLiveData<String>()
}
//inside activity
viewModel.networkError.observe(this, Observer {
showToast(it)
})
include ':app'
def progressButton = '../../Android-Lib/ProgressButton'
if (file(progressButton).exists()) {
includeBuild(progressButton) {
dependencySubstitution {
substitute module('com.alirezaahmadi:progress-button') with project(':app')
}
}
class LogicHandlingClass {
fun doThis(){
//does something amazing!
}
}
class UserClass {
val logicHandlingClass = LogicHandlingClass()
val myClass = MyClass(logicHandlingClass::doThis)
class MyClass(val doThis: () -> Unit, val doThat: (number: Int) -> Unit = {}) {
fun someFunction(){
doThis()
doThat(12)
}
}
class UserClass {
val myClass = MyClass(::doThis, ::doThat)
class MyClass(val listener: Listener) {
interface Listener {
fun doThis()
fun doThat(number: Int)
}
fun someFunction(){
listener.doThis()
listener.doThat(12)