diff options
author | Romain Guy <romainguy@android.com> | 2009-07-03 08:18:17 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-07-03 08:18:17 -0700 |
commit | 28dda652a2c776100f3ec94a3352564ac49149de (patch) | |
tree | 7f55c158f17bf9a213b64e59d05a574d85a4c603 /core | |
parent | 10063c10899976c70c64c4dd15f171728e9b3036 (diff) | |
parent | a54755962ca7725d1e2b6cacbbaece6f1cbf5af4 (diff) | |
download | frameworks_base-28dda652a2c776100f3ec94a3352564ac49149de.zip frameworks_base-28dda652a2c776100f3ec94a3352564ac49149de.tar.gz frameworks_base-28dda652a2c776100f3ec94a3352564ac49149de.tar.bz2 |
am a5475596: Cleanup a bunch of warnings in app widgets code.
Merge commit 'a54755962ca7725d1e2b6cacbbaece6f1cbf5af4'
* commit 'a54755962ca7725d1e2b6cacbbaece6f1cbf5af4':
Cleanup a bunch of warnings in app widgets code.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/appwidget/AppWidgetHost.java | 12 | ||||
-rw-r--r-- | core/java/android/appwidget/AppWidgetHostView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/RemoteViews.java | 67 |
3 files changed, 36 insertions, 48 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java index 10c2b02..03e8623 100644 --- a/core/java/android/appwidget/AppWidgetHost.java +++ b/core/java/android/appwidget/AppWidgetHost.java @@ -26,7 +26,6 @@ import android.widget.RemoteViews; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import com.android.internal.appwidget.IAppWidgetHost; import com.android.internal.appwidget.IAppWidgetService; @@ -40,7 +39,7 @@ public class AppWidgetHost { static final int HANDLE_UPDATE = 1; static final int HANDLE_PROVIDER_CHANGED = 2; - static Object sServiceLock = new Object(); + final static Object sServiceLock = new Object(); static IAppWidgetService sService; Context mContext; @@ -85,7 +84,7 @@ public class AppWidgetHost { int mHostId; Callbacks mCallbacks = new Callbacks(); - HashMap<Integer,AppWidgetHostView> mViews = new HashMap(); + final HashMap<Integer,AppWidgetHostView> mViews = new HashMap<Integer, AppWidgetHostView>(); public AppWidgetHost(Context context, int hostId) { mContext = context; @@ -104,8 +103,8 @@ public class AppWidgetHost { * becomes visible, i.e. from onStart() in your Activity. */ public void startListening() { - int[] updatedIds = null; - ArrayList<RemoteViews> updatedViews = new ArrayList(); + int[] updatedIds; + ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); try { if (mPackageName == null) { @@ -209,7 +208,7 @@ public class AppWidgetHost { synchronized (mViews) { mViews.put(appWidgetId, view); } - RemoteViews views = null; + RemoteViews views; try { views = sService.getAppWidgetViews(appWidgetId); } catch (RemoteException e) { @@ -231,6 +230,7 @@ public class AppWidgetHost { /** * Called when the AppWidget provider for a AppWidget has been upgraded to a new apk. */ + @SuppressWarnings({"UnusedDeclaration"}) protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) { } diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index be0f96e..307c4c8 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -22,16 +22,12 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.os.Handler; -import android.os.Message; import android.os.SystemClock; -import android.util.Config; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.animation.Animation; import android.widget.FrameLayout; import android.widget.RemoteViews; import android.widget.TextView; @@ -86,6 +82,7 @@ public class AppWidgetHostView extends FrameLayout { * @param animationIn Resource ID of in animation to use * @param animationOut Resource ID of out animation to use */ + @SuppressWarnings({"UnusedDeclaration"}) public AppWidgetHostView(Context context, int animationIn, int animationOut) { super(context); mContext = context; diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 7936f65..1b5c5bc 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -20,10 +20,8 @@ import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.PorterDuff; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Parcel; @@ -36,15 +34,12 @@ import android.view.View; import android.view.ViewGroup; import android.view.LayoutInflater.Filter; import android.view.View.OnClickListener; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; import java.lang.Class; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -69,13 +64,7 @@ public class RemoteViews implements Parcelable, Filter { * The resource ID of the layout file. (Added to the parcel) */ private int mLayoutId; - - /** - * The Context object used to inflate the layout file. Also may - * be used by actions if they need access to the senders resources. - */ - private Context mContext; - + /** * An array of actions to perform on the view tree once it has been * inflated @@ -85,7 +74,7 @@ public class RemoteViews implements Parcelable, Filter { /** * This annotation indicates that a subclass of View is alllowed to be used - * with the {@link android.widget.RemoteViews} mechanism. + * with the {@link RemoteViews} mechanism. */ @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @@ -116,7 +105,7 @@ public class RemoteViews implements Parcelable, Filter { public int describeContents() { return 0; } - }; + } /** * Equivalent to calling @@ -232,15 +221,17 @@ public class RemoteViews implements Parcelable, Filter { targetDrawable = imageView.getDrawable(); } - // Perform modifications only if values are set correctly - if (alpha != -1) { - targetDrawable.setAlpha(alpha); - } - if (colorFilter != -1 && filterMode != null) { - targetDrawable.setColorFilter(colorFilter, filterMode); - } - if (level != -1) { - targetDrawable.setLevel(level); + if (targetDrawable != null) { + // Perform modifications only if values are set correctly + if (alpha != -1) { + targetDrawable.setAlpha(alpha); + } + if (colorFilter != -1 && filterMode != null) { + targetDrawable.setColorFilter(colorFilter, filterMode); + } + if (level != -1) { + targetDrawable.setLevel(level); + } } } @@ -289,6 +280,7 @@ public class RemoteViews implements Parcelable, Filter { this.viewId = in.readInt(); this.methodName = in.readString(); this.type = in.readInt(); + //noinspection ConstantIfStatement if (false) { Log.d("RemoteViews", "read viewId=0x" + Integer.toHexString(this.viewId) + " methodName=" + this.methodName + " type=" + this.type); @@ -340,31 +332,32 @@ public class RemoteViews implements Parcelable, Filter { out.writeInt(this.viewId); out.writeString(this.methodName); out.writeInt(this.type); + //noinspection ConstantIfStatement if (false) { Log.d("RemoteViews", "write viewId=0x" + Integer.toHexString(this.viewId) + " methodName=" + this.methodName + " type=" + this.type); } switch (this.type) { case BOOLEAN: - out.writeInt(((Boolean)this.value).booleanValue() ? 1 : 0); + out.writeInt((Boolean) this.value ? 1 : 0); break; case BYTE: - out.writeByte(((Byte)this.value).byteValue()); + out.writeByte((Byte) this.value); break; case SHORT: - out.writeInt(((Short)this.value).shortValue()); + out.writeInt((Short) this.value); break; case INT: - out.writeInt(((Integer)this.value).intValue()); + out.writeInt((Integer) this.value); break; case LONG: - out.writeLong(((Long)this.value).longValue()); + out.writeLong((Long) this.value); break; case FLOAT: - out.writeFloat(((Float)this.value).floatValue()); + out.writeFloat((Float) this.value); break; case DOUBLE: - out.writeDouble(((Double)this.value).doubleValue()); + out.writeDouble((Double) this.value); break; case CHAR: out.writeInt((int)((Character)this.value).charValue()); @@ -430,7 +423,7 @@ public class RemoteViews implements Parcelable, Filter { } Class klass = view.getClass(); - Method method = null; + Method method; try { method = klass.getMethod(this.methodName, getParameterType()); } @@ -446,6 +439,7 @@ public class RemoteViews implements Parcelable, Filter { } try { + //noinspection ConstantIfStatement if (false) { Log.d("RemoteViews", "view: " + klass.getName() + " calling method: " + this.methodName + "(" + param.getName() + ") with " @@ -816,13 +810,12 @@ public class RemoteViews implements Parcelable, Filter { * @return The inflated view hierarchy */ public View apply(Context context, ViewGroup parent) { - View result = null; + View result; Context c = prepareContext(context); - Resources r = c.getResources(); - LayoutInflater inflater = (LayoutInflater) c - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater) + c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater = inflater.cloneInContext(c); inflater.setFilter(this); @@ -858,7 +851,7 @@ public class RemoteViews implements Parcelable, Filter { } private Context prepareContext(Context context) { - Context c = null; + Context c; String packageName = mPackage; if (packageName != null) { @@ -872,8 +865,6 @@ public class RemoteViews implements Parcelable, Filter { c = context; } - mContext = c; - return c; } |