Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af51e1de authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Removed warnings in LayoutInflater."

parents 10b8c51c 3030193d
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -23,9 +23,9 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint;
import android.os.SystemClock;
import android.os.Parcelable;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseArray;
@@ -58,7 +58,7 @@ public class AppWidgetHostView extends FrameLayout {
    // When we're inflating the initialLayout for a AppWidget, we only allow
    // When we're inflating the initialLayout for a AppWidget, we only allow
    // views that are allowed in RemoteViews.
    // views that are allowed in RemoteViews.
    static final LayoutInflater.Filter sInflaterFilter = new LayoutInflater.Filter() {
    static final LayoutInflater.Filter sInflaterFilter = new LayoutInflater.Filter() {
        public boolean onLoadClass(Class clazz) {
        public boolean onLoadClass(Class<?> clazz) {
            return clazz.isAnnotationPresent(RemoteViews.RemoteView.class);
            return clazz.isAnnotationPresent(RemoteViews.RemoteView.class);
        }
        }
    };
    };
@@ -276,6 +276,7 @@ public class AppWidgetHostView extends FrameLayout {
        }
        }
    }
    }


    @Override
    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
        if (CROSSFADE) {
        if (CROSSFADE) {
            int alpha;
            int alpha;
+21 −14
Original line number Original line Diff line number Diff line
@@ -16,15 +16,15 @@


package android.view;
package android.view;


import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Xml;
import android.util.Xml;


import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.HashMap;
@@ -71,11 +71,11 @@ public abstract class LayoutInflater {


    private final Object[] mConstructorArgs = new Object[2];
    private final Object[] mConstructorArgs = new Object[2];


    private static final Class[] mConstructorSignature = new Class[] {
    private static final Class<?>[] mConstructorSignature = new Class[] {
            Context.class, AttributeSet.class};
            Context.class, AttributeSet.class};


    private static final HashMap<String, Constructor> sConstructorMap =
    private static final HashMap<String, Constructor<? extends View>> sConstructorMap =
            new HashMap<String, Constructor>();
            new HashMap<String, Constructor<? extends View>>();
    
    
    private HashMap<String, Boolean> mFilterMap;
    private HashMap<String, Boolean> mFilterMap;


@@ -97,7 +97,7 @@ public abstract class LayoutInflater {
         * 
         * 
         * @return True if this class is allowed to be inflated, or false otherwise
         * @return True if this class is allowed to be inflated, or false otherwise
         */
         */
        boolean onLoadClass(Class clazz);
        boolean onLoadClass(Class<?> clazz);
    }
    }
    
    
    public interface Factory {
    public interface Factory {
@@ -453,18 +453,18 @@ public abstract class LayoutInflater {
     * @param name The full name of the class to be instantiated.
     * @param name The full name of the class to be instantiated.
     * @param attrs The XML attributes supplied for this instance.
     * @param attrs The XML attributes supplied for this instance.
     * 
     * 
     * @return View The newly instantied view, or null.
     * @return View The newly instantiated view, or null.
     */
     */
    public final View createView(String name, String prefix, AttributeSet attrs)
    public final View createView(String name, String prefix, AttributeSet attrs)
            throws ClassNotFoundException, InflateException {
            throws ClassNotFoundException, InflateException {
        Constructor constructor = sConstructorMap.get(name);
        Constructor<? extends View> constructor = sConstructorMap.get(name);
        Class clazz = null;
        Class<? extends View> clazz = null;


        try {
        try {
            if (constructor == null) {
            if (constructor == null) {
                // Class not found in the cache, see if it's real, and try to add it
                // Class not found in the cache, see if it's real, and try to add it
                clazz = mContext.getClassLoader().loadClass(
                clazz = mContext.getClassLoader().loadClass(
                        prefix != null ? (prefix + name) : name);
                        prefix != null ? (prefix + name) : name).asSubclass(View.class);
                
                
                if (mFilter != null && clazz != null) {
                if (mFilter != null && clazz != null) {
                    boolean allowed = mFilter.onLoadClass(clazz);
                    boolean allowed = mFilter.onLoadClass(clazz);
@@ -482,7 +482,7 @@ public abstract class LayoutInflater {
                    if (allowedState == null) {
                    if (allowedState == null) {
                        // New class -- remember whether it is allowed
                        // New class -- remember whether it is allowed
                        clazz = mContext.getClassLoader().loadClass(
                        clazz = mContext.getClassLoader().loadClass(
                                prefix != null ? (prefix + name) : name);
                                prefix != null ? (prefix + name) : name).asSubclass(View.class);
                        
                        
                        boolean allowed = clazz != null && mFilter.onLoadClass(clazz);
                        boolean allowed = clazz != null && mFilter.onLoadClass(clazz);
                        mFilterMap.put(name, allowed);
                        mFilterMap.put(name, allowed);
@@ -497,7 +497,7 @@ public abstract class LayoutInflater {


            Object[] args = mConstructorArgs;
            Object[] args = mConstructorArgs;
            args[1] = attrs;
            args[1] = attrs;
            return (View) constructor.newInstance(args);
            return constructor.newInstance(args);


        } catch (NoSuchMethodException e) {
        } catch (NoSuchMethodException e) {
            InflateException ie = new InflateException(attrs.getPositionDescription()
            InflateException ie = new InflateException(attrs.getPositionDescription()
@@ -506,6 +506,13 @@ public abstract class LayoutInflater {
            ie.initCause(e);
            ie.initCause(e);
            throw ie;
            throw ie;


        } catch (ClassCastException e) {
            // If loaded class is not a View subclass
            InflateException ie = new InflateException(attrs.getPositionDescription()
                    + ": Class is not a View "
                    + (prefix != null ? (prefix + name) : name));
            ie.initCause(e);
            throw ie;
        } catch (ClassNotFoundException e) {
        } catch (ClassNotFoundException e) {
            // If loadClass fails, we should propagate the exception.
            // If loadClass fails, we should propagate the exception.
            throw e;
            throw e;
@@ -519,7 +526,7 @@ public abstract class LayoutInflater {
    }
    }


    /**
    /**
     * Throw an excpetion because the specified class is not allowed to be inflated.
     * Throw an exception because the specified class is not allowed to be inflated.
     */
     */
    private void failNotAllowed(String name, String prefix, AttributeSet attrs) {
    private void failNotAllowed(String name, String prefix, AttributeSet attrs) {
        InflateException ie = new InflateException(attrs.getPositionDescription()
        InflateException ie = new InflateException(attrs.getPositionDescription()
+4 −3
Original line number Original line Diff line number Diff line
@@ -60,12 +60,12 @@ public class RemoteViews implements Parcelable, Filter {
     * The package name of the package containing the layout 
     * The package name of the package containing the layout 
     * resource. (Added to the parcel)
     * resource. (Added to the parcel)
     */
     */
    private String mPackage;
    private final String mPackage;
    
    
    /**
    /**
     * The resource ID of the layout file. (Added to the parcel)
     * The resource ID of the layout file. (Added to the parcel)
     */
     */
    private int mLayoutId;
    private final int mLayoutId;


    /**
    /**
     * An array of actions to perform on the view tree once it has been
     * An array of actions to perform on the view tree once it has been
@@ -569,6 +569,7 @@ public class RemoteViews implements Parcelable, Filter {
        }
        }
    }
    }


    @Override
    public RemoteViews clone() {
    public RemoteViews clone() {
        final RemoteViews that = new RemoteViews(mPackage, mLayoutId);
        final RemoteViews that = new RemoteViews(mPackage, mLayoutId);
        if (mActions != null) {
        if (mActions != null) {
@@ -989,7 +990,7 @@ public class RemoteViews implements Parcelable, Filter {
     * 
     * 
     * @see android.view.LayoutInflater.Filter#onLoadClass(java.lang.Class)
     * @see android.view.LayoutInflater.Filter#onLoadClass(java.lang.Class)
     */
     */
    public boolean onLoadClass(Class clazz) {
    public boolean onLoadClass(Class<?> clazz) {
        return clazz.isAnnotationPresent(RemoteView.class);
        return clazz.isAnnotationPresent(RemoteView.class);
    }
    }