PropertyValuesHolder_Delegate.java revision 282e181b58cf72b6ca770dc7ca5f91f135444502
1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/* 2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2010 The Android Open Source Project 3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License"); 5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License. 6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at 7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * http://www.apache.org/licenses/LICENSE-2.0 9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software 11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS, 12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and 14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License. 15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage android.animation; 18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.layoutlib.bridge.impl.DelegateManager; 20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/** 23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Delegate implementing the native methods of android.animation.PropertyValuesHolder 24282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Through the layoutlib_create tool, the original native methods of PropertyValuesHolder have been 26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * replaced by calls to methods of the same name in this delegate class. 27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 28282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Because it's a stateless class to start with, there's no need to keep a {@link DelegateManager} 29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * around to map int to instance of the delegate. 30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * The main goal of this class' methods are to provide a native way to access setters and getters 32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * on some object. In this case we want to default to using Java reflection instead so the native 33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * methods do nothing. 34282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 35282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 36282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/*package*/ class PropertyValuesHolder_Delegate { 37282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 38282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski @LayoutlibDelegate 39282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) { 40282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // return 0 to force PropertyValuesHolder to use Java reflection. 41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski return 0; 42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 43282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 44282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski @LayoutlibDelegate 45282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) { 46282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // return 0 to force PropertyValuesHolder to use Java reflection. 47282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski return 0; 48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 50282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski @LayoutlibDelegate 51282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) { 52282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // do nothing 53282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 54282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 55282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski @LayoutlibDelegate 56282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) { 57282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // do nothing 58282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 59282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski} 60