当前位置: 首页>>代码示例>>Java>>正文


Java KrollFunction.callAsync方法代码示例

本文整理汇总了Java中org.appcelerator.kroll.KrollFunction.callAsync方法的典型用法代码示例。如果您正苦于以下问题:Java KrollFunction.callAsync方法的具体用法?Java KrollFunction.callAsync怎么用?Java KrollFunction.callAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.appcelerator.kroll.KrollFunction的用法示例。


在下文中一共展示了KrollFunction.callAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createObject

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void createObject(String className, final HashMap data, final KrollFunction applicationCallback) {

	SaveCallback parseCallback = new SaveCallback() {
		public void done(ParseException e) {
			HashMap result = new HashMap();

			if (e == null) {
				result.put("object", data);
			} else {
				// There was an error
				result.put("error", e.toString());
			}

			if (applicationCallback != null) {
				applicationCallback.callAsync(getKrollObject(), result);
			}
		}
	};

	parseSingleton.CreateDataObject(className, data, parseCallback);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:23,代码来源:AndroidTitaniumParseModule.java

示例2: updateObject

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void updateObject(final HashMap data, final KrollFunction applicationCallback) {
	final ParseObject convertedObject = (ParseObject)ParseDataConversions.ConvertToParseObjectIfNecessary(data);
	SaveCallback parseCallback = new SaveCallback() {
		public void done(ParseException e) {
			HashMap result = new HashMap();
			HashMap returnObject = ParseDataConversions.ObjectToHashMap(convertedObject);
			if (e == null) {
				result.put("object", returnObject);
			} else {
				// There was an error
				result.put("error", e.toString());
			}

			if (applicationCallback != null) {
				applicationCallback.callAsync(getKrollObject(), result);
			}
		}
	};

	parseSingleton.UpdateDataObject(convertedObject, parseCallback);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:23,代码来源:AndroidTitaniumParseModule.java

示例3: deleteObject

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void deleteObject(String className, String objectId, final KrollFunction applicationCallback) {
	DeleteCallback parseCallback = new DeleteCallback() {
		public void done(ParseException e) {
			HashMap result = new HashMap();
			if (e == null) {
				result.put("success", true);
			} else {
				result.put("error", e.toString());
			}

			applicationCallback.callAsync(getKrollObject(), result);
		}
	};

	parseSingleton.DeleteDataObject(className, objectId, parseCallback);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:18,代码来源:AndroidTitaniumParseModule.java

示例4: registerForPush

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void registerForPush(String deviceToken, String channelName, KrollFunction applicationCallback) {

	// NOTE: deviceToken is not used, but in order to maintain call
	// compatibility with the iOS module, I'm leaving it as a parameter
	HashMap results = new HashMap();

	// The channel name can only match letters, numbers, dashes and underscores, and must start with a letter
	if (parseSingleton.ValidChannelName(channelName)) {
		parseSingleton.SubscribeToPushChannel(channelName);
		results.put("success", true);
	}
	else {
		// Invalid channel name
		results.put("success", false);
	}

	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:20,代码来源:AndroidTitaniumParseModule.java

示例5: pushChannelList

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void pushChannelList(KrollFunction applicationCallback) {
	HashMap results = new HashMap();

	List<String> channelList = parseSingleton.ChannelSubscriptionList();
	String[] channels = new String[channelList.size()];

	int count = 0;
	for (String channelName : channelList) {
		channels[count] = channelName;
		++count;
	}

	// Store the resulting string list under the 'channels' field for the Titanium App
	results.put("channels", channels);

	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:19,代码来源:AndroidTitaniumParseModule.java

示例6: unsubscribeFromPush

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void unsubscribeFromPush(String channelName, KrollFunction applicationCallback) {

	HashMap results = new HashMap();

	if (parseSingleton.ValidChannelName(channelName)) {
		parseSingleton.UnsubscribeFromPushChannel(channelName);
		results.put("success", true);
	}
	else {
		results.put("success", false);
	}

	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:16,代码来源:AndroidTitaniumParseModule.java

示例7: registerForSinglePushChannel

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void registerForSinglePushChannel(String deviceToken, String channelName, KrollFunction applicationCallback) {
	// NOTE: deviceToken is not used, but in order to maintain call
	// compatibility with the iOS module, I'm leaving it as a parameter
	parseSingleton.SubscribeToSinglePushChannel(channelName);
	
	// This is just a fake call back function the saveEventually() function will be used and no need for callback
	HashMap results = new HashMap();
	results.put("success", true);
	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:12,代码来源:AndroidTitaniumParseModule.java

示例8: registerForMultiplePushChannelArray

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void registerForMultiplePushChannelArray(String deviceToken, String[] channelNames, KrollFunction applicationCallback) {
	Log.d(LCAT, "String StringArray Callback");
	for ( String s: channelNames){
		Log.d(LCAT, s);
	}
	// NOTE: deviceToken is not used, but in order to maintain call
	// compatibility with the iOS module, I'm leaving it as a parameter
	parseSingleton.SubscribeToMultiplePushChannel(channelNames);
	
	// This is just a fake call back function the saveEventually() function will be used and no need for callback
	HashMap results = new HashMap();
	results.put("success", true);
	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:16,代码来源:AndroidTitaniumParseModule.java

示例9: unsubscribeFromAllChannels

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void unsubscribeFromAllChannels(KrollFunction applicationCallback) {
	// NOTE: deviceToken is not used, but in order to maintain call
	// compatibility with the iOS module, I'm leaving it as a parameter
	parseSingleton.UnsubscribeFromAllChannels();
	
	// This is just a fake call back function the saveEventually() function will be used and no need for callback
	HashMap results = new HashMap();
	results.put("success", true);
	applicationCallback.callAsync(getKrollObject(), results);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:12,代码来源:AndroidTitaniumParseModule.java

示例10: sendError

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
public void sendError(KrollFunction callback, String error) {
    Log.e(LCAT, error);
    if (callback != null) {
        HashMap<String, Object> data = new HashMap<String, Object>();
        data.put("success", false);
        data.put("error", error);

        callback.callAsync(getKrollObject(), data);
    }
}
 
开发者ID:morinel,项目名称:gcmpush,代码行数:11,代码来源:GCMModule.java

示例11: handleCommonStatuses

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
/**
 * Knows about common statuses that the Box.net servers can return, and will log and fire off callbacks are appropriate.
 * @param status
 * @param error
 * @return The English error message interpreted from the status code.
 */
public static String handleCommonStatuses(KrollProxy proxy, String status, KrollFunction error) {
	String message = null;
	if (status.equals("not_logged_in")) {
		message = "You have to be logged in to do that!";
	}
	else if (status.equals("application_restricted")) {
		message = "You provided an invalid apiKey, or the apiKey is restricted from calling this function!";
	}
	else if (status.equals("e_filename_in_use")) {
		message = "The file cannot be copied because a file of the same name already exists in that folder.";
	}
	else if (status.equals("e_no_access")) {
		message = "You do not have the necessary permissions to do that.  Most likely you are trying to act on a collaborated folder, to which you have view-only permission.";
	}
	else {
		message = "Received an unexpected response from the server: " + status + ".";
	}
	
	e(message);
	if (error != null) {
		HashMap event = new HashMap();
		event.put("error", message);
		event.put("status", status);
		error.callAsync(proxy.getKrollObject(), event);
	}
	return message;
}
 
开发者ID:appcelerator-archive,项目名称:ti.box,代码行数:34,代码来源:Util.java

示例12: handleError

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
/**
 * Deals with an error by logging it (and the provided status), and calling the provided error callback.
 * @param message
 * @param status
 * @param error
 * @return
 */
public static String handleError(KrollProxy proxy, String message, String status, KrollFunction error) {
	e(status + ": " + message);
	if (error != null) {
		HashMap event = new HashMap();
		event.put("error", message);
		event.put("status", status);
		error.callAsync(proxy.getKrollObject(), event);
	}
	return message;
}
 
开发者ID:appcelerator-archive,项目名称:ti.box,代码行数:18,代码来源:Util.java

示例13: handleMalformedURLException

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
/**
 * A specific wrapper around the handleError method for the MalformedURLException that is so common in the Box APIs.
 * @param ex
 * @param error
 * @return
 */
public static String handleMalformedURLException(KrollProxy proxy, MalformedURLException ex, KrollFunction error) {
	e("A malformed URL exception was thrown.", ex);
	if (error != null) {
		HashMap event = new HashMap();
		event.put("error", ex.toString());
		event.put("type", "MalformedURLException");
		error.callAsync(proxy.getKrollObject(), event);
	}
	return "A malformed URL exception was thrown.";
}
 
开发者ID:appcelerator-archive,项目名称:ti.box,代码行数:17,代码来源:Util.java

示例14: handleIOException

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
/**
 * A specific wrapper around the handleError method for the IOException that is so common in the Box APIs.
 * @param ex
 * @param error
 * @return
 */
public static String handleIOException(KrollProxy proxy, IOException ex, KrollFunction error) {
	e("A IO exception was thrown.", ex);
	if (error != null) {
		HashMap event = new HashMap();
		event.put("error", ex.toString());
		event.put("type", "IOException");
		error.callAsync(proxy.getKrollObject(), event);
	}
	return "A IO exception was thrown.";
}
 
开发者ID:appcelerator-archive,项目名称:ti.box,代码行数:17,代码来源:Util.java

示例15: findObjects

import org.appcelerator.kroll.KrollFunction; //导入方法依赖的package包/类
@Kroll.method
public void findObjects(String className, HashMap[] conditions, final KrollFunction applicationCallback) {
	FindCallback<ParseObject> parseCallback = new FindCallback<ParseObject>() {
		public void done(List<ParseObject> objects, ParseException e) {

			// General hash map to invoke the Titanium method with
			HashMap returnMap = new HashMap();
			if (objects != null && objects.size() > 0) {
				HashMap[] resultObjects = new HashMap[objects.size()];

				if (e == null) {
					int count = 0;
					for (ParseObject po : objects) {
						// Convert each object to a hash map to retain it's key/value properties
						HashMap objectMap = ParseDataConversions.ObjectToHashMap(po);
						resultObjects[count] = objectMap;
						++count;
					}

					returnMap.put("results", resultObjects);
				}
				else {
					// no objects were returned,
					returnMap.put("results", null);
				}

			}
			else {
				String errorMessage = "No objects found.";
				if (e != null) {
					errorMessage = e.toString();
				}
				returnMap.put("error", errorMessage);
			}

			applicationCallback.callAsync(getKrollObject(), returnMap);
		}
	};

	parseSingleton.FindDataObjects(className, conditions, parseCallback);
}
 
开发者ID:E2010,项目名称:android-parse-module-titanium-3-5,代码行数:42,代码来源:AndroidTitaniumParseModule.java


注:本文中的org.appcelerator.kroll.KrollFunction.callAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。