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
private void deinitialize() { | |
stopPreview(); | |
releaseCamera(); | |
Log.d(TAG, "Camera Initialization has Been Undone"); | |
} | |
private void initialize() { | |
if (hasCamera(this) && getCameraInstance() != null) { | |
startPreview(); | |
Log.d(TAG, "Camera Initialization has Been Completed"); |
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
<resources> | |
<style name="SampleBase" parent="@android:style/Theme.Light" /> | |
<style name="SampleTheme" parent="SampleBase"> | |
<item name="android:windowBackground">@null</item> | |
<item name="menuDrawerStyle">@style/MenuDrawerStyle</item> | |
</style> | |
<style name="SampleTheme.RightDrawer" parent="SampleBase"> |
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 Car { | |
int year; | |
String make; | |
String model; | |
String carType; | |
public Car(int year) { | |
this.year = year; | |
} |
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 Car { | |
int year; | |
String make; | |
String model; | |
String carType; | |
public static class Builder { | |
int year; | |
String make; | |
String model; |
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
Car carSearchCriteria = new Car(1998, null, "Focus", "Sedan"); |
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
// Using the Telescoping Constructor anti-pattern | |
Car carSearchCriteria = new Car(1998, null, "Focus", "Sedan"); | |
// Using the Builder Pattern | |
Car carSearchCriteria = new Car.Builder().year(1998) | |
.model("Focus") | |
.carType("Sedan") | |
.build(); |
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 LazySingleton { | |
private static LazySingleton instance = null; | |
private LazySingleton() { } | |
public static synchronized LazySingleton getInstance() { | |
if (instance == null) { | |
instance = new LazySingleton(); | |
} | |
return instance; |
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 EagerSingleton { | |
private static final EagerSingleton instance = new EagerSingleton(); | |
private EagerSingleton() { } | |
public static EagerSingleton getInstance() { | |
return instance; | |
} | |
} |
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 EagerStaticSingleton { | |
private static EagerStaticSingleton instance = null; | |
private EagerStaticSingleton() { } | |
static { | |
try { | |
instance = new EagerStaticSingleton(); | |
} catch (Exception e) { | |
// Do something |
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 OnDemandSingleton { | |
private OnDemandSingleton() { } | |
private static class OnDemandSingletonHolder { | |
public static final OnDemandSingleton instance = new OnDemandSingleton(); | |
} | |
public static OnDemandSingleton getInstance() { | |
return OnDemandSingletonHolder.instance; | |
} |