You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
WrapperWidget: create SkArea also for Views with custom draw() method
Previously we only handled custom onDraw() methods
This commit is contained in:
@@ -108,6 +108,7 @@ void set_up_handle_cache(JNIEnv *env)
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
handle_cache.view.onDraw = _METHOD(handle_cache.view.class, "onDraw", "(Landroid/graphics/Canvas;)V");
|
||||
handle_cache.view.draw = _METHOD(handle_cache.view.class, "draw", "(Landroid/graphics/Canvas;)V");
|
||||
handle_cache.view.onMeasure = _METHOD(handle_cache.view.class, "onMeasure", "(II)V");
|
||||
handle_cache.view.onLayout = _METHOD(handle_cache.view.class, "onLayout", "(ZIIII)V");
|
||||
handle_cache.view.getMeasuredWidth = _METHOD(handle_cache.view.class, "getMeasuredWidth", "()I");
|
||||
|
||||
@@ -62,6 +62,7 @@ struct handle_cache {
|
||||
jclass class;
|
||||
jmethodID setLayoutParams;
|
||||
jmethodID onDraw;
|
||||
jmethodID draw;
|
||||
jmethodID onMeasure;
|
||||
jmethodID onLayout;
|
||||
jmethodID getMeasuredWidth;
|
||||
|
||||
@@ -175,8 +175,9 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
|
||||
(*env)->GetJavaVM(env, &jvm);
|
||||
wrapper->jvm = jvm;
|
||||
wrapper->jobj = _REF(jobj);
|
||||
jmethodID draw_method = _METHOD(_CLASS(jobj), "onDraw", "(Landroid/graphics/Canvas;)V");
|
||||
if (draw_method != handle_cache.view.onDraw) {
|
||||
jmethodID on_draw_method = _METHOD(_CLASS(jobj), "onDraw", "(Landroid/graphics/Canvas;)V");
|
||||
jmethodID draw_method = _METHOD(_CLASS(jobj), "draw", "(Landroid/graphics/Canvas;)V");
|
||||
if (on_draw_method != handle_cache.view.onDraw || draw_method != handle_cache.view.draw) {
|
||||
wrapper->draw_method = draw_method;
|
||||
|
||||
GtkWidget *sk_area = sk_area_new();
|
||||
|
||||
@@ -900,6 +900,9 @@ public class View implements Drawable.Callback {
|
||||
}
|
||||
|
||||
public void onDraw(Canvas canvas) {}
|
||||
public void draw(Canvas canvas) {
|
||||
onDraw(canvas);
|
||||
}
|
||||
|
||||
public View(Context context) {
|
||||
this(context, null);
|
||||
|
||||
Reference in New Issue
Block a user