View gist:af7f10f0481bea3681cb
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 Paint mBackgroundAmbientPaint; | |
private Paint mBackgroundPaintFilled; | |
private Paint mBackgroundPaintNotFilled; | |
private Paint mPaintHourText; | |
private Paint mPaintMinuteText; | |
private Typeface mTypefaceRobotoThin; | |
private Typeface mTypefaceRobotoLight; |
View gist:caac0681752b5778c3db
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
mTypefaceRobotoThin = Typeface.createFromAsset(getAssets(), "robotothin.ttf"); | |
mTypefaceRobotoLight = Typeface.createFromAsset(getAssets(), "robotolight.ttf"); | |
mBackgroundPaintFilled = new Paint(); | |
mBackgroundPaintFilled.setColor(getResources().getColor(R.color.color_bg)); | |
mBackgroundPaintNotFilled = new Paint(); | |
mBackgroundPaintNotFilled.setColor(getResources().getColor(R.color.color_gray)); | |
mPaintHourText = new Paint(); |
View gist:f83cefb26647ae30212a
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 int mWidth; | |
private int mHeight; | |
private float mCenterX; | |
private float mCenterY; | |
... | |
@Override | |
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { | |
super.onSurfaceChanged(holder, format, width, height); |
View gist:017c041d271f0401d3dd
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
//Formül -- > ((mTime/60f) * mHeight). | |
//Mavi dikdörtgeni çiziyoruz. | |
canvas.drawRect(0, mHeight - (mTime.minute / 60f) * mHeight, canvas.getWidth(), canvas.getHeight(), mBackgroundPaintFilled); | |
//Gri dikdörtgeni çiziyoruz. | |
canvas.drawRect(0, 0, canvas.getWidth(), mHeight - (mTime.minute / 60f) * mHeight, mBackgroundPaintNotFilled); |
View gist:b0df5b6030b894187f19
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
//Yazacağımız saatin genişliğini ve yüksekliğini alıyoruz ve saate ortalıyoruz. | |
Rect hourBound = new Rect(); | |
mPaintHourText.getTextBounds(mHour, 0, mHour.length(), hourBound); | |
canvas.drawText(mHour, mCenterX - (hourBound.width() / 2f), mCenterY + (hourBound.height() / 2f), mPaintHourText); | |
//Yazacağımız dakikanın genişliğini ve yüksekliğini hesaplayıp saatin yanına yazıyoruz. | |
Rect minuteBound = new Rect(); | |
mPaintMinuteText.getTextBounds(mMinute, 0, mMinute.length(), minuteBound); | |
canvas.drawText(mMinute, mCenterX + (mCenterX / 2f), mCenterY + (minuteBound.height() / 2f), mPaintMinuteText); |
View gist:138e4ace9fcd74321898
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 Engine { | |
public Engine() { | |
} | |
public void turnOn(){ | |
//Engine turned on here. | |
} | |
public void turnOff(){ |
View gist:07eb94c4b1810218d0cf
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 { | |
private Engine engine; | |
public Car() { | |
engine = new Engine(); | |
} | |
public void start(){ | |
engine.turnOn(); |
View gist:51ca8bc0b5303cf0d50c
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 Main { | |
public static void main(String[] args){ | |
Car car = new Car(); | |
car.start(); | |
car.stop(); | |
} | |
} |
View gist:bbdcff2fd27ebaac4966
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 { | |
private Engine engine; | |
public Car(Engine engine) { | |
this.engine = engine; | |
} | |
public void start(){ | |
engine.turnOn(); |
View gist:a3a98ec7d005c1be4b14
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 { | |
private LPGEngine engine; | |
public Car(LPGEngine engine) { | |
this.engine = engine; | |
} | |
public void start(){ | |
engine.turnOn(); |
OlderNewer