Skip to content

Instantly share code, notes, and snippets.

View jdsingh's full-sized avatar
🎯
Focusing

Jagdeep Singh jdsingh

🎯
Focusing
View GitHub Profile
@jdsingh
jdsingh / build.gradle
Created February 18, 2021 20:40 — forked from tristanlins/build.gradle
Gradle Jacoco Plugin and Gitlab Coverage
plugins {
id 'jacoco'
}
jacocoTestReport {
reports {
xml.enabled true
}
}
@jdsingh
jdsingh / AdbCommands
Created May 22, 2019 10:45 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jdsingh
jdsingh / height.java
Created April 16, 2019 08:56 — forked from hamakn/height.java
Android: Get height of status, action, navigation bar (pixels)
// status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
// action bar height
int actionBarHeight = 0;
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
@jdsingh
jdsingh / SightFragment.java
Created December 6, 2018 14:17 — forked from joinAero/SightFragment.java
Android - Fragment for handling view after it has been created and visible to user for the first time.
package cc.cubone.turbo.core.app;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
/**
* Fragment for handling view after it has been created and visible to user for the first time.
*
* <p>Specially in {@link android.support.v4.view.ViewPager}, the page will be created beforehand
private fun getLocation(lastLocation: Task<Location>) {
lastLocation.addOnCompleteListener { task ->
if (task.isSuccessful) {
val data = workDataOf(
"latitude" to location.latitude,
"longitude" to location.longitude
)
future.set(Payload(Result.SUCCESS, data))
} else {
future.setException(task.exception)
class LocationWorker(
context: Context,
params: WorkerParameters
) : ListenableWorker(context, params) {
private val future: ResolvableFuture<Payload> = ResolvableFuture.create()
override fun startWork(): ListenableFuture<Payload> {
if (hasLocationPermission()) {
getLocation(getFusedLocationProviderClient().lastLocation)
class LocationWorker(
context: Context,
params: WorkerParameters
) : ListenableWorker(context, params) {
override fun startWork(): ListenableFuture<Payload> {
TODO("not implemented")
}
}
"substring" should include("str")
user.email should beLowerCase()
a + b shouldBe result
infix fun String.shouldBeSame(other: String) = this == other
// calling the function using the infix notation
"bello" shouldBeSame "bello"
// is the same as
"hello".shouldBeSame("hello")