|
22 | 22 | import android.content.Context; |
23 | 23 | import android.content.Intent; |
24 | 24 | import android.content.IntentFilter; |
25 | | -import android.content.res.AssetManager; |
26 | | -import android.content.res.Resources; |
27 | 25 | import android.database.ContentObserver; |
28 | 26 | import android.graphics.Typeface; |
29 | 27 | import android.os.Handler; |
@@ -61,6 +59,14 @@ public class DigitalClock extends RelativeLayout { |
61 | 59 | private final Handler mHandler = new Handler(); |
62 | 60 | private BroadcastReceiver mIntentReceiver; |
63 | 61 |
|
| 62 | + private static final Typeface sBackgroundFont; |
| 63 | + private static final Typeface sForegroundFont; |
| 64 | + |
| 65 | + static { |
| 66 | + sBackgroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND); |
| 67 | + sForegroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND); |
| 68 | + } |
| 69 | + |
64 | 70 | private static class TimeChangedReceiver extends BroadcastReceiver { |
65 | 71 | private WeakReference<DigitalClock> mClock; |
66 | 72 | private Context mContext; |
@@ -159,13 +165,11 @@ public DigitalClock(Context context, AttributeSet attrs) { |
159 | 165 | protected void onFinishInflate() { |
160 | 166 | super.onFinishInflate(); |
161 | 167 |
|
162 | | - AssetManager assets = mContext.getAssets(); |
163 | | - |
164 | 168 | /* The time display consists of two tones. That's why we have two overlapping text views. */ |
165 | 169 | mTimeDisplayBackground = (TextView) findViewById(R.id.timeDisplayBackground); |
166 | | - mTimeDisplayBackground.setTypeface(Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND)); |
| 170 | + mTimeDisplayBackground.setTypeface(sBackgroundFont); |
167 | 171 | mTimeDisplayForeground = (TextView) findViewById(R.id.timeDisplayForeground); |
168 | | - mTimeDisplayForeground.setTypeface(Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND)); |
| 172 | + mTimeDisplayForeground.setTypeface(sForegroundFont); |
169 | 173 | mAmPm = new AmPm(this, null); |
170 | 174 | mCalendar = Calendar.getInstance(); |
171 | 175 |
|
|
0 commit comments