- Creational Patterns
- Abstract Factory
- Builder
- Factory Method
- Object Pool
- Prototype
- Singleton
- Structural Patterns
- Behavioural Patterns
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
CameraManager manager = | |
(CameraManager) view.getContext().getSystemService(CAMERA_SERVICE); | |
try { | |
for (String cameraId : manager.getCameraIdList()) { | |
CameraCharacteristics chars | |
= manager.getCameraCharacteristics(cameraId); | |
App.logException(Log.DEBUG, "PhotoAction", chars.toString()); | |
manager.openCamera(cameraId, new CameraDevice.StateCallback() { | |
@Override |
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 twofer(name: String = "you"): String { | |
return "One for ${name}, one for me." | |
} |
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 org.junit.Ignore | |
import org.junit.Test | |
import kotlin.test.assertEquals | |
class TwoferTest { | |
@Test | |
fun noNameGiven() { | |
assertEquals("One for you, one for me.", twofer()) | |
} |
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 FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService { | |
@Override | |
public void onMessageReceived(RemoteMessage remoteMessage) { | |
super.onMessageReceived(remoteMessage); | |
try { | |
if (remoteMessage.getData().size() > 0) { | |
// do stuff..... | |
} |
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 FirebaseMessagingHelper extends FirebaseInstanceIdService { | |
static public String token; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
token = FirebaseInstanceId.getInstance().getToken(); | |
if(token != null) Timber.d("Token %s", token); |
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 RxImmediateSchedulerRule implements TestRule { | |
private Scheduler immediate = new Scheduler() { | |
@Override | |
public Disposable scheduleDirect(@NonNull Runnable run, long delay, @NonNull TimeUnit unit) { | |
// this prevents StackOverflowErrors when scheduling with a delay | |
return super.scheduleDirect(run, 0, unit); | |
} | |
@Override | |
public Worker createWorker() { |
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
@BeforeClass | |
public static void setUpRxSchedulers() { | |
Scheduler immediate = new Scheduler() { | |
@Override | |
public Disposable scheduleDirect(@NonNull Runnable run, long delay, @NonNull TimeUnit unit) { | |
// this prevents StackOverflowErrors when scheduling with a delay | |
return super.scheduleDirect(run, 0, unit); | |
} | |
@Override |
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 Foundation | |
import PlaygroundSupport | |
import UIKit | |
public enum Device { | |
case phone3_5inch | |
case phone4inch | |
case phone4_7inch | |
case phone5_5inch | |
case pad |
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
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
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="io.github.amadeu01.cameraproportions.MainActivity"> | |
<FrameLayout |