Skip to content

Instantly share code, notes, and snippets.

View DiegoGSantos's full-sized avatar

Diego Santos DiegoGSantos

  • will bank
  • Ribeirão Preto
View GitHub Profile
@DiegoGSantos
DiegoGSantos / getTranslateXY.js
Last active January 15, 2018 12:32
Get Translate XY with javascript
getTranslateXY(obj) {
const transArr = [];
if (window.getComputedStyle) {
const style = getComputedStyle(obj);
const transform = style.transform || style.webkitTransform || style.mozTransform;
let mat = transform.match(/^matrix3d\((.+)\)$/);
if (mat) return parseFloat(mat[1].split(', ')[13]);
mat = transform.match(/^matrix\((.+)\)$/);
if (mat) {
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.diegosantos.constraintlayoutexample.MainActivity">
<View
android:id="@+id/leftLine"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
@DiegoGSantos
DiegoGSantos / ActivityManager.kt
Last active November 25, 2018 00:08
Manager for storage permission
class Activity {
val permissionManager: PermissionManager
fun selectImage() {
if (permissionManager.isStoragePermissionGranted(this)) {
getImage()
} else {
askPermission()
}
}
@Before
fun setUpTest() {
loadKoinModules(listOf(module {
single { mockRepository }
}))
}
@Mock
lateinit var mockRepository: Repository
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.10.0'
testCompile group: 'org.mockito', name: 'mockito-inline', version: '2.23.3'
@Before
fun setUpTest() {
MockitoAnnotations.initMocks(this)
}
@Test
fun test() {
Mockito.`when`(mockRepository.getList(anyInt(),anyString())).thenReturn(expectedValue)
presenter.loadList()
verify(mockView, times(1)).showLoading()
testImplementation 'com.squareup.okhttp3:mockwebserver:(insert latest version)'