Back to project page RxWatchFace.
The source code is released under:
Apache License
If you think the Android project RxWatchFace listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.colintheshots.rxwatchface.widget; //from w w w.j a v a 2 s. co m import android.content.Context; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.RelativeLayout; import android.widget.TextView; import com.colintheshots.rxwatchface.R; import com.twotoasters.watchface.gears.widget.IWatchface; import com.twotoasters.watchface.gears.widget.Watch; import java.text.SimpleDateFormat; import java.util.Calendar; import butterknife.ButterKnife; import butterknife.InjectView; import hugo.weaving.DebugLog; public class Watchface extends RelativeLayout implements IWatchface { public final static String TIME_FORMAT = "k:mm a"; @InjectView(R.id.timeTextView) TextView timeTextView; private Watch mWatch; private boolean mInflated; private boolean mActive; public Watchface(Context context) { super(context); init(context, null, 0); } public Watchface(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public Watchface(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } @DebugLog private void init(Context context, AttributeSet attrs, int defStyle) { mWatch = new Watch(this); } @DebugLog @Override protected void onFinishInflate() { super.onFinishInflate(); ButterKnife.inject(this, getRootView()); mInflated = true; } @DebugLog @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mWatch.onAttachedToWindow(); } @DebugLog @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); mWatch.onDetachedFromWindow(); } @Override public void onTimeChanged(Calendar time) { // Timber.v("onTimeChanged()"); timeTextView.setText(new SimpleDateFormat(TIME_FORMAT).format(time.getTime())); invalidate(); } @Override @DebugLog public void onActiveStateChanged(boolean active) { this.mActive = active; } @Override public boolean handleSecondsInDimMode() { return false; } private Typeface loadTypeface(int typefaceNameResId) { String typefaceName = getResources().getString(typefaceNameResId); return Typeface.createFromAsset(getContext().getAssets(), typefaceName); } }