From 0fc28d13c42a1a050fa7bfb3a320ffd44097027d Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 22 Mar 2014 00:09:15 +0100 Subject: refactoring: do not call getResources() repeatidly --- main/src/cgeo/geocaching/ui/CompassView.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'main/src/cgeo/geocaching/ui/CompassView.java') diff --git a/main/src/cgeo/geocaching/ui/CompassView.java b/main/src/cgeo/geocaching/ui/CompassView.java index e266559..0abfabe 100644 --- a/main/src/cgeo/geocaching/ui/CompassView.java +++ b/main/src/cgeo/geocaching/ui/CompassView.java @@ -3,7 +3,13 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; import cgeo.geocaching.utils.AngleUtils; +import rx.Scheduler; +import rx.Subscription; +import rx.functions.Action1; +import rx.schedulers.Schedulers; + import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -12,10 +18,6 @@ import android.graphics.PaintFlagsDrawFilter; import android.util.AttributeSet; import android.util.FloatMath; import android.view.View; -import rx.Scheduler; -import rx.Subscription; -import rx.functions.Action1; -import rx.schedulers.Schedulers; import java.util.concurrent.TimeUnit; @@ -67,10 +69,11 @@ public class CompassView extends View { @Override public void onAttachedToWindow() { - compassUnderlay = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_underlay); - compassRose = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_rose); - compassArrow = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_arrow); - compassOverlay = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_overlay); + final Resources res = context.getResources(); + compassUnderlay = BitmapFactory.decodeResource(res, R.drawable.compass_underlay); + compassRose = BitmapFactory.decodeResource(res, R.drawable.compass_rose); + compassArrow = BitmapFactory.decodeResource(res, R.drawable.compass_arrow); + compassOverlay = BitmapFactory.decodeResource(res, R.drawable.compass_overlay); compassUnderlayWidth = compassUnderlay.getWidth(); compassUnderlayHeight = compassUnderlay.getWidth(); -- cgit v1.1