Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
Focusing

Mert Şimşek iammert

🎧
Focusing
View GitHub Profile
View gist:f83cefb26647ae30212a
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
//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
//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:af7f10f0481bea3681cb
private Paint mBackgroundAmbientPaint;
private Paint mBackgroundPaintFilled;
private Paint mBackgroundPaintNotFilled;
private Paint mPaintHourText;
private Paint mPaintMinuteText;
private Typeface mTypefaceRobotoThin;
private Typeface mTypefaceRobotoLight;
View gist:caac0681752b5778c3db
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:bf7613495cddc2f737c6
public class Main {
public static void main(String[] args){
Engine petrolEngine = new PetrolEngine();
Car car = new Car(petrolEngine);
car.start();
car.stop();
}
View gist:138e4ace9fcd74321898
public class Engine {
public Engine() {
}
public void turnOn(){
//Engine turned on here.
}
public void turnOff(){
View gist:07eb94c4b1810218d0cf
public class Car {
private Engine engine;
public Car() {
engine = new Engine();
}
public void start(){
engine.turnOn();
View gist:a3a98ec7d005c1be4b14
public class Car {
private LPGEngine engine;
public Car(LPGEngine engine) {
this.engine = engine;
}
public void start(){
engine.turnOn();
View gist:51ca8bc0b5303cf0d50c
public class Main {
public static void main(String[] args){
Car car = new Car();
car.start();
car.stop();
}
}