Github user riknoll commented on a diff in the pull request:
https://github.com/apache/cordova-android/pull/239#discussion_r44565905
--- Diff: framework/src/org/apache/cordova/ResumeCallback.java ---
@@ -0,0 +1,71 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.apache.cordova;
+
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResumeCallback extends CallbackContext {
+ private final String TAG = "CordovaResumeCallback";
+ private String serviceName;
+ private PluginManager pluginManager;
+
+ public ResumeCallback(String serviceName, PluginManager pluginManager)
{
+ super("resumecallback", null);
+ this.serviceName = serviceName;
+ this.pluginManager = pluginManager;
+ }
+
+ @Override
+ public void sendPluginResult(PluginResult pluginResult) {
+ synchronized (this) {
+ if (finished) {
+ return;
+ } else {
+ finished = true;
+ }
+ }
+
+ JSONObject event = new JSONObject();
+ JSONObject pluginResultObject = new JSONObject();
+
+ try {
+ pluginResultObject.put("pluginServiceName", this.serviceName);
+ pluginResultObject.put("pluginStatus",
PluginResult.StatusMessages[pluginResult.getStatus()]);
+
+ event.put("action", "resume");
+ event.put("pendingResult", pluginResultObject);
+ } catch (JSONException e) {
+ LOG.e(TAG, "Unable to create resume object for Activity
Result");
+ }
+
+ PluginResult eventResult = new
PluginResult(PluginResult.Status.OK, event);
+
+ List<PluginResult> result = new ArrayList<PluginResult>();
--- End diff --
I'll add a comment to the code explaining this. It has to do with how we
encode plugin results. If we were to just send one event object, we would have
to first translate the PluginResult obtained by the ResumeCallback into
something we could place in the event plugin result's JSONObject. Instead of
duplicating our PluginResult decoding code on the Native side of things, I just
send back two results and handle it in platform.js
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]