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
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' |
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
// STEP 1 - create new file | |
public interface ClickListener { | |
public void onClick(View view, int position); | |
public void onLongClick(View view, int position); | |
} | |
// STEP 2 - create new file | |
import android.content.Context; |
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
import java.util.List; | |
import retrofit2.Call; | |
import retrofit2.Callback; | |
import retrofit2.Response; | |
import retrofit2.Retrofit; | |
import retrofit2.converter.gson.GsonConverterFactory; | |
public class UsersRepository { |
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
// gradients | |
// gradient_1.xml in drawable folder | |
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<gradient | |
android:angle="225" | |
android:endColor="#1a2980" | |
android:startColor="#26d0ce" /> | |
</shape> |
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 imageCapture = ImageCapture.Builder().build() | |
// SETUP CAPTURE MODE | |
// to optimize photo capture for quality | |
val captureMode = ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY | |
// to optimize photo capture for latency (default) | |
val captureMode = ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY | |
imageCapture = ImageCapture.Builder() |
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
fun applyFrameRateOnImageAnalysis(): ImageAnalysis { | |
val imageAnalysisBuilder = ImageAnalysis.Builder() | |
val camera2InterOp = Camera2Interop.Extender(imageAnalysisBuilder) | |
camera2InterOp.setCaptureRequestOption( | |
CaptureRequest.CONTROL_AE_MODE, | |
CaptureRequest.CONTROL_AE_MODE_OFF | |
) | |
camera2InterOp.setCaptureRequestOption( | |
CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, | |
Range(60, 60) |
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
var someNumbers = listOf(1, 4, 5, 6, 7, 8, 2323, 5456, 343, 2) | |
someNumbers | |
.filter { it % 2 == 0 } | |
.map { it * 3 } | |
.sum() | |
someNumbers | |
.asSequence() | |
.filter { it % 2 == 0 } | |
.map { it * 2 } |
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
sealed class Fruit(val name: String) { | |
class Apple : Fruit("Apple") | |
class Mango : Fruit("Mango") | |
} | |
class Pomegranate : Fruit("Pomegranate") | |
fun display(fruit: Fruit) { | |
when (fruit) { | |
is Fruit.Apple -> println("${fruit.name} is good for iron") |
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 displayContentWithTemplate = "Hello $firstName! Please confirm that $email is your email address." |
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
inputStream.use { | |
outputStream.use { | |
// do something with the streams | |
outputStream.write(inputStream.read()) | |
} | |
} | |
// improved option | |
arrayOf(inputStream, outputStream).use { | |
// do something with the streams |
NewerOlder