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; |
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(); |
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); |
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); |
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); |
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(){ |
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(); |
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(); | |
} | |
} |
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(); |
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