android_animation_PropertyValuesHolder.cpp revision 0141e884344a5c267239079d615e1c9d9898a222
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#include <stdio.h> 18#include <assert.h> 19 20#include "jni.h" 21#include <android_runtime/AndroidRuntime.h> 22#include <utils/misc.h> 23 24// ---------------------------------------------------------------------------- 25 26namespace android { 27 28// ---------------------------------------------------------------------------- 29 30const char* const kClassPathName = "android/animation/PropertyValuesHolder"; 31 32static jlong android_animation_PropertyValuesHolder_getIntMethod( 33 JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) 34{ 35 const char *nativeString = env->GetStringUTFChars(methodName, 0); 36 jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V"); 37 env->ReleaseStringUTFChars(methodName, nativeString); 38 return reinterpret_cast<jlong>(mid); 39} 40 41static jlong android_animation_PropertyValuesHolder_getFloatMethod( 42 JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) 43{ 44 const char *nativeString = env->GetStringUTFChars(methodName, 0); 45 jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V"); 46 env->ReleaseStringUTFChars(methodName, nativeString); 47 return reinterpret_cast<jlong>(mid); 48} 49 50static void android_animation_PropertyValuesHolder_callIntMethod( 51 JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg) 52{ 53 env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); 54} 55 56static void android_animation_PropertyValuesHolder_callFloatMethod( 57 JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg) 58{ 59 env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); 60} 61 62static JNINativeMethod gMethods[] = { 63 { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", 64 (void*)android_animation_PropertyValuesHolder_getIntMethod }, 65 { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", 66 (void*)android_animation_PropertyValuesHolder_getFloatMethod }, 67 { "nCallIntMethod", "(Ljava/lang/Object;JI)V", 68 (void*)android_animation_PropertyValuesHolder_callIntMethod }, 69 { "nCallFloatMethod", "(Ljava/lang/Object;JF)V", 70 (void*)android_animation_PropertyValuesHolder_callFloatMethod } 71}; 72 73int register_android_animation_PropertyValuesHolder(JNIEnv* env) 74{ 75 return AndroidRuntime::registerNativeMethods(env, 76 kClassPathName, gMethods, NELEM(gMethods)); 77} 78 79}; 80