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
package net.coding.lucas.screenheight; | |
import android.content.Context; | |
import android.content.res.Configuration; | |
import android.content.res.Resources; | |
import android.graphics.Point; | |
import android.os.Build; | |
import android.util.DisplayMetrics; | |
import android.util.TypedValue; | |
import android.view.Display; |
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
inline fun <A> A.logWith(logger: Logger, block: Logger.(A) -> Unit) : A = | |
this.also { logger.block(it) } | |
// With interface injection | |
interface HasLog { | |
val log: Logger | |
fun <A> A.log(block: Logger.(A) -> Unit) : A = | |
logWith(logger, block) | |
} |
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
//Copy using arraycopy | |
fun catTwoIntArrays1(array1 :IntArray, array2 :IntArray) : IntArray { | |
val newArray = IntArray(array1.size + array2.size) | |
System.arraycopy(array1, 0, newArray, 0 , array1.size) | |
System.arraycopy(array2, 0, newArray, array1.size , array2.size) | |
return newArray | |
} | |
//Copy using for loops | |
fun catTwoIntArrays2(array1 :IntArray, array2 :IntArray) : IntArray { |
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
/** | |
* (C) Copyright 2018 Paulo Vitor Sato 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 |
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
package com.rahul.view; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.util.AttributeSet; | |
import android.view.View; | |
public class GridLineView extends View { |
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
package ${PACKAGE_NAME} | |
#parse("File Header.java") | |
import androidx.room.Dao | |
import androidx.room.Insert | |
import androidx.room.Update | |
import androidx.room.Query | |
@Dao |
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
public class CameraMicPermissionHelper extends Fragment { | |
private static final int REQUEST_CAMERA_MIC_PERMISSIONS = 10; | |
public static final String TAG = "CamMicPerm"; | |
private CameraMicPermissionCallback mCallback; | |
private static boolean sCameraMicPermissionDenied; | |
public static CameraMicPermissionHelper newInstance() { | |
return new CameraMicPermissionHelper(); | |
} |
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
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 21 | |
buildToolsVersion "21.1.2" | |
defaultConfig { | |
applicationId "com.your.application.id" | |
minSdkVersion 15 | |
targetSdkVersion 21 |
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
// Standard device screen widths | |
$iphone-portrait: 320px | |
$iphone-landscape: 480px | |
$ipad-portrait: 767px | |
$ipad-landscape: 980px | |
$desktop: 1224px | |
$desktop-large: 1824px | |
// General device targeting | |
// Use: Only use if you want the style to apply to many devices |
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
val db = Room | |
.databaseBuilder(getApplication(), CitiesDb::class.java, "cities.db") | |
.createFromAsset("databases/cities.db") | |
.fallbackToDestructiveMigration() // On version update - just copy over | |
.build() |