Skip to content

Instantly share code, notes, and snippets.

View pavlospt's full-sized avatar
💻
Refactoring something somewhere

Pavlos-Petros Tournaris pavlospt

💻
Refactoring something somewhere
View GitHub Profile
@pavlospt
pavlospt / SignInActivity.kt
Created December 8, 2016 09:36
SmartLock - Email Hint Request Resolution Success
private fun emailHintRequestSuccess(data: Intent?) {
val credential: Credential? = data?.getParcelableExtra(Credential.EXTRA_KEY)
credential?.let {
proceedOnMainScreen(it.id)
}
}
@pavlospt
pavlospt / SignInActivity.kt
Created December 8, 2016 09:37
SmartLock - Credential Request Result
private fun handleCredentialRequestResult(credentialRequestResult: CredentialRequestResult) {
if (credentialRequestResult.status.isSuccess) {
proceedOnMainScreen(credentialRequestResult.credential.id)
} else {
resolveCredentialRequest(credentialRequestResult.status)
}
}
@pavlospt
pavlospt / SignInActivity.kt
Created December 8, 2016 09:37
SmartLock - Credential Request Resolution Resolve
private fun resolveCredentialRequest(status: Status?) {
if (status?.statusCode == CommonStatusCodes.RESOLUTION_REQUIRED) {
initiateCredentialRequestResolution(status)
} else {
credentialRequestFailure()
}
}
@pavlospt
pavlospt / SignInActivity.kt
Created December 8, 2016 09:38
SmartLock - Initiate Credential Request Resolution
private fun initiateCredentialRequestResolution(status: Status?) {
try {
status?.startResolutionForResult(this, RC_CREDENTIALS_REQUEST)
} catch (sendIntentException: IntentSender.SendIntentException) {
credentialRequestResolutionFailure()
}
}
@pavlospt
pavlospt / ButtonContainerSpec.java
Created April 20, 2017 19:10
ButtonContainerSpec
@LayoutSpec
public class ButtonContainerSpec {
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c) {
return Column.create(c)
.alignItems(YogaAlign.CENTER)
.justifyContent(YogaJustify.CENTER)
.child(Card.create(c)
.cardBackgroundColorRes(R.color.colorPrimary)
@pavlospt
pavlospt / ButtonTextSpec.java
Created April 20, 2017 19:15
ButtonTextSpec
@LayoutSpec
public class ButtonTextSpec {
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop String text) {
return Text.create(c)
.text(text)
.textSizeDip(18)
.textColorRes(android.R.color.white)
.textSizeSp(18)
@pavlospt
pavlospt / ButtonContainerSpec.java
Created April 20, 2017 19:36
ButtonContainerSpec
@LayoutSpec
public class ButtonContainerSpec {
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c) {
return Column.create(c)
.alignItems(YogaAlign.CENTER)
.justifyContent(YogaJustify.CENTER)
.child(Card.create(c)
.cardBackgroundColorRes(R.color.colorPrimary)
@pavlospt
pavlospt / MainActivity.java
Created April 20, 2017 19:44
MainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(
LithoView
.create(this, ButtonContainer
.create(new ComponentContext(this))
@pavlospt
pavlospt / demo.sh
Created January 12, 2018 14:59 — forked from rock3r/README.md
A simple bash script to enable demo mode on a Marshmallow+ device via ADB (based on http://bit.ly/295BHLx)
#!/bin/sh
CMD=$1
if [[ $ADB == "" ]]; then
ADB=adb
fi
if [[ $CMD != "on" && $CMD != "off" ]]; then
echo "Usage: $0 [on|off] [hhmm]" >&2
exit
def postCommitStatus(params = [:]) {
withCredentials([
string([credentialsId: 'your-credentials-id', variable: 'GITHUB_API_TOKEN'])
]) {
def authHeaders = [[name: 'Authorization', value: "token ${GITHUB_API_TOKEN}"]]
def commit = params.commit
def requestBody = params.body
def statusUrl = "https://api.github.com/repos/repo-owner/repo-name/statuses/${commit}"
try {
def response = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: requestBody, url: statusUrl, customHeaders: authHeaders