补充缺失的import;一些其它修改。
This commit is contained in:
@@ -2,6 +2,9 @@ package cn.shuto.feishuapi;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.PluginResult;
|
||||
@@ -16,6 +19,7 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class ShutoApi extends CordovaPlugin {
|
||||
private static final String TAG = "ShutoApi";
|
||||
private JSONObject userInfo;
|
||||
|
||||
// 保存事件回调上下文
|
||||
private CallbackContext eventCallbackContext;
|
||||
@@ -54,9 +58,9 @@ public class ShutoApi extends CordovaPlugin {
|
||||
@Override
|
||||
public void run() {
|
||||
cordova.getActivity().moveTaskToBack(true);
|
||||
callbackContext.success();
|
||||
}
|
||||
});
|
||||
callbackContext.success();
|
||||
}
|
||||
|
||||
private void registerEvent(CallbackContext callbackContext) {
|
||||
@@ -70,12 +74,15 @@ public class ShutoApi extends CordovaPlugin {
|
||||
}
|
||||
|
||||
private void getUserInfo(CallbackContext callbackContext) {
|
||||
// TODO: Implement getUserInfo method
|
||||
callbackContext.success();
|
||||
callbackContext.success(this.userInfo);
|
||||
}
|
||||
|
||||
public void setUserInfo(JSONObject userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
// 触发导航到指定路由的事件
|
||||
private void navigateToRoute(String route, JSONObject parameters) {
|
||||
public void navigateToRoute(String route, JSONObject parameters) {
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("route", route);
|
||||
@@ -91,11 +98,11 @@ public class ShutoApi extends CordovaPlugin {
|
||||
}
|
||||
|
||||
// 触发通用事件
|
||||
private void fireEvent(String type, JSONObject parameters) {
|
||||
public void fireEvent(String type, JSONObject parameters) {
|
||||
if (this.eventCallbackContext == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.d(TAG, "type: " + type + ", params: " + parameters);
|
||||
try {
|
||||
// 创建事件数据
|
||||
JSONObject eventData = new JSONObject();
|
||||
@@ -168,7 +175,7 @@ public class ShutoApi extends CordovaPlugin {
|
||||
eventCallbacks.remove(callbackId);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
LOG.e(TAG, "error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user