Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.animation; |
| 18 | |
| 19 | import com.android.layoutlib.bridge.impl.DelegateManager; |
| 20 | import com.android.tools.layoutlib.annotations.LayoutlibDelegate; |
| 21 | |
| 22 | /** |
| 23 | * Delegate implementing the native methods of android.animation.PropertyValuesHolder |
| 24 | * |
| 25 | * Through the layoutlib_create tool, the original native methods of PropertyValuesHolder have been |
| 26 | * replaced by calls to methods of the same name in this delegate class. |
| 27 | * |
| 28 | * Because it's a stateless class to start with, there's no need to keep a {@link DelegateManager} |
| 29 | * around to map int to instance of the delegate. |
| 30 | * |
| 31 | * The main goal of this class' methods are to provide a native way to access setters and getters |
| 32 | * on some object. In this case we want to default to using Java reflection instead so the native |
| 33 | * methods do nothing. |
| 34 | * |
| 35 | */ |
| 36 | /*package*/ class PropertyValuesHolder_Delegate { |
| 37 | |
| 38 | @LayoutlibDelegate |
Ashok Bhat | fbb35fb | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 39 | /*package*/ static long nGetIntMethod(Class<?> targetClass, String methodName) { |
Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 40 | // return 0 to force PropertyValuesHolder to use Java reflection. |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | @LayoutlibDelegate |
Ashok Bhat | fbb35fb | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 45 | /*package*/ static long nGetFloatMethod(Class<?> targetClass, String methodName) { |
Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 46 | // return 0 to force PropertyValuesHolder to use Java reflection. |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | @LayoutlibDelegate |
Deepanshu Gupta | e05bb95 | 2014-01-28 18:55:33 -0800 | [diff] [blame] | 51 | /*package*/ static int nGetMultipleIntMethod(Class<?> targetClass, String methodName, |
| 52 | int numParams) { |
| 53 | // TODO: return the right thing. |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | @LayoutlibDelegate |
| 58 | /*package*/ static int nGetMultipleFloatMethod(Class<?> targetClass, String methodName, |
| 59 | int numParams) { |
| 60 | // TODO: return the right thing. |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | @LayoutlibDelegate |
Ashok Bhat | fbb35fb | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 65 | /*package*/ static void nCallIntMethod(Object target, long methodID, int arg) { |
Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 66 | // do nothing |
| 67 | } |
| 68 | |
| 69 | @LayoutlibDelegate |
Ashok Bhat | fbb35fb | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 70 | /*package*/ static void nCallFloatMethod(Object target, long methodID, float arg) { |
Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 71 | // do nothing |
| 72 | } |
Deepanshu Gupta | e05bb95 | 2014-01-28 18:55:33 -0800 | [diff] [blame] | 73 | |
| 74 | @LayoutlibDelegate |
| 75 | /*package*/ static void nCallTwoIntMethod(Object target, long methodID, int arg1, |
| 76 | int arg2) { |
| 77 | // do nothing |
| 78 | } |
| 79 | |
| 80 | @LayoutlibDelegate |
| 81 | /*package*/ static void nCallFourIntMethod(Object target, long methodID, int arg1, |
| 82 | int arg2, int arg3, int arg4) { |
| 83 | // do nothing |
| 84 | } |
| 85 | |
| 86 | @LayoutlibDelegate |
| 87 | /*package*/ static void nCallMultipleIntMethod(Object target, long methodID, |
| 88 | int[] args) { |
| 89 | // do nothing |
| 90 | } |
| 91 | |
| 92 | @LayoutlibDelegate |
| 93 | /*package*/ static void nCallTwoFloatMethod(Object target, long methodID, float arg1, |
| 94 | float arg2) { |
| 95 | // do nothing |
| 96 | } |
| 97 | |
| 98 | @LayoutlibDelegate |
| 99 | /*package*/ static void nCallFourFloatMethod(Object target, long methodID, float arg1, |
| 100 | float arg2, float arg3, float arg4) { |
| 101 | // do nothing |
| 102 | } |
| 103 | |
| 104 | @LayoutlibDelegate |
| 105 | /*package*/ static void nCallMultipleFloatMethod(Object target, long methodID, |
| 106 | float[] args) { |
| 107 | // do nothing |
| 108 | } |
Adam Lesinski | 282e181 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 109 | } |