From d8cf7bee4da762cf47d4f509ddc2ec7e30b822b0 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Thu, 18 Jul 2019 20:29:44 +0800 Subject: [PATCH] Add HegoPanel --- .../github/pengfeizhou/hego/HegoContext.java | 7 ++- .../github/pengfeizhou/hego/HegoPanel.java | 54 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoPanel.java diff --git a/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoContext.java b/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoContext.java index 7c7e204c..4331c7d2 100644 --- a/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoContext.java +++ b/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoContext.java @@ -1,5 +1,8 @@ package com.github.pengfeizhou.hego; +import com.github.pengfeizhou.hego.utils.HegoSettableFuture; +import com.github.pengfeizhou.jscore.JSDecoder; + import java.util.concurrent.atomic.AtomicInteger; /** @@ -21,8 +24,8 @@ public class HegoContext { return new HegoContext(contextId); } - public void callEntity(String methodName, Object... args) { - HegoDriver.getInstance().invokeContextMethod(mContextId, methodName, args); + public HegoSettableFuture callEntity(String methodName, Object... args) { + return HegoDriver.getInstance().invokeContextMethod(mContextId, methodName, args); } public void teardown() { diff --git a/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoPanel.java b/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoPanel.java new file mode 100644 index 00000000..3490ab17 --- /dev/null +++ b/Android/hego/src/main/java/com/github/pengfeizhou/hego/HegoPanel.java @@ -0,0 +1,54 @@ +package com.github.pengfeizhou.hego; + +import android.content.Context; +import android.os.Build; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.annotation.RequiresApi; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +/** + * @Description: Hego + * @Author: pengfei.zhou + * @CreateDate: 2019-07-18 + */ +public class HegoPanel extends FrameLayout { + + private HegoContext mHegoContext; + + public HegoPanel(@NonNull Context context) { + super(context); + } + + public HegoPanel(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public HegoPanel(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public HegoPanel(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public void config(String script, String alias) { + HegoContext hegoContext = HegoContext.createContext(script, alias); + config(hegoContext); + } + + public void config(HegoContext hegoContext) { + mHegoContext = hegoContext; + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + } + + public HegoContext getHegoContext() { + return mHegoContext; + } +}