/** * File generated by Jenny -- https://github.com/LanderlYoung/Jenny * * For bug report, please refer to github issue tracker https://github.com/LanderlYoung/Jenny/issues, * or contact author landerlyoung@gmail.com. */ #include #include "NativeDrawable.h" #include "gen/jenny_GraphicsProxy.h" #include "gen/android_StyleProxy.h" #include "gen/android_RectProxy.h" #include "gen/GenericProxy.h" class State { private: uint _color; public: jobject const paint; State(jobject paint) : _color(0xFF), paint(paint) {} int color() { return _color | 0xFF000000; } void change() { _color *= 97; if (_color == 0) { _color = 0xFF; } } }; /* * Class: io_github_landerlyoung_jennysampleapp_NativeDrawable * Method: private final long nativeInit() * Signature: ()J */ jlong NativeDrawable::nativeInit(JNIEnv *env, jobject thiz) { using jenny::GraphicsProxy; using android::StyleProxy; GenericProxy::initClazz(env); auto fillType = android::StyleProxy::getFILL(env); auto paint = GraphicsProxy::newPaint(env); GraphicsProxy::paintSetStyle(env, paint, fillType); auto paintGlobal = env->NewGlobalRef(paint); return reinterpret_cast(new State(paintGlobal)); } /* * Class: io_github_landerlyoung_jennysampleapp_NativeDrawable * Method: public final void onClick() * Signature: ()V */ void NativeDrawable::onClick(JNIEnv *env, jobject thiz) { State* state = reinterpret_cast(NativeDrawableProxy::getNativeHandle(env, thiz)); state->change(); } /* * Class: io_github_landerlyoung_jennysampleapp_NativeDrawable * Method: public void draw(android.graphics.Canvas canvas) * Signature: (Landroid/graphics/Canvas;)V */ void NativeDrawable::draw(JNIEnv *env, jobject thiz, jobject _canvas) { using namespace android; using jenny::GraphicsProxy; State* state = reinterpret_cast(NativeDrawableProxy::getNativeHandle(env, thiz)); auto bounds = GraphicsProxy::drawableGetBounds(env, thiz); GraphicsProxy::setColor(env, state->paint, state->color()); GraphicsProxy::drawableCircle( env, _canvas, RectProxy::exactCenterX(env, bounds), RectProxy::exactCenterY(env, bounds), std::min(RectProxy::exactCenterX(env, bounds), RectProxy::exactCenterY(env, bounds)) * 0.7f, state->paint ); } /* * Class: io_github_landerlyoung_jennysampleapp_NativeDrawable * Method: public final void release() * Signature: ()V */ void NativeDrawable::release(JNIEnv *env, jobject thiz) { State* state = reinterpret_cast(NativeDrawableProxy::getNativeHandle(env, thiz)); env->DeleteGlobalRef(state->paint); delete state; }