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


Java KrollFunction类代码示例

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


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

示例1: requestPermission

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
/**
 * Request a permission and optionally register a callback for the current activity
 * 
 * @param requestedPermission permission as defined in Manifest
 * @param permissionCallback function called with result of permission prompt
 * @param requestCode - 8 Bit value to associate callback with request - if none is provided a system generated will used
 * @return true in case of valid request, false if requested permission is not a valid one
 */
@Kroll.method
public boolean requestPermission(String requestedPermission,
		@Kroll.argument(optional = true) KrollFunction permissionCallback,
		@Kroll.argument(optional = true) Integer requestCode) {

	Log.d(LCAT, "Requesting permission: " + requestedPermission);

	if (!isValidPermissionString(requestedPermission)) {
		Log.e(LCAT, "Requested permission is not supported :"
				+ requestedPermission);
		return false;
	}

	return handleRequest(new String[]{requestedPermission}, requestCode, permissionCallback);

}
 
开发者ID:stgrosshh,项目名称:tipermissions,代码行数:25,代码来源:TipermissionsModule.java

示例2: requestPermissions

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
/**
	 * Request a permission and optionally register a callback for the current activity
	 * 
	 * @param requestedPermissions Array of permissions as defined in Manifest
	 * @param permissionCallback function called with result of permission prompt
	 * @param requestCode - 8 Bit value to associate callback with request - if none is provided, a system generated one is used
	 * @return true in case of valid request, false if requested permission is not a valid one
	 */
	@Kroll.method
	public boolean requestPermissions(@Kroll.argument String[] requestedPerms,
			@Kroll.argument(optional = true) KrollFunction permissionCallback,
			@Kroll.argument(optional = true) Integer requestCode)
			 {

//		String[] requestedPermissions = new String[]{requestedPerms};//(String[])requestedPerms;
		for(String permission:requestedPerms) {
			Log.d(LCAT, "Requesting permission: " + permission);

			if (!isValidPermissionString(permission)) {
				Log.e(LCAT, "Requested permission is not supported :"
						+ permission);
				return false;
			}
		}

		return handleRequest(requestedPerms, requestCode, permissionCallback);

	}
 
开发者ID:stgrosshh,项目名称:tipermissions,代码行数:29,代码来源:TipermissionsModule.java

示例3: registerForPushNotifications

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
@Kroll.method
public void registerForPushNotifications(HashMap options) {
	Activity activity = TiApplication.getAppRootOrCurrentActivity();

	if (false == options.containsKey("callback")) {
		Log.e(LCAT, "You have to specify a callback attribute when calling registerForPushNotifications");
		return;
	}

	messageCallback = (KrollFunction)options.get("callback");

	successCallback = options.containsKey("success") ? (KrollFunction)options.get("success") : null;
	errorCallback = options.containsKey("error") ? (KrollFunction)options.get("error") : null;

	parseBootIntent();

	if (checkPlayServices()) {
		activity.startService( new Intent(activity, RegistrationIntentService.class) );
	}
}
 
开发者ID:caffeinalab,项目名称:ti.goosh,代码行数:21,代码来源:TiGooshModule.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: registerForMultiplePushChannelString

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
@Kroll.method
public void registerForMultiplePushChannelString(String deviceToken, String channels, KrollFunction applicationCallback) {
	Log.d(LCAT, "String String Callback");
	Log.d(LCAT, channels);
	
	String[] channelNames = channels.split(",");
	
	for ( String s: channelNames){
		Log.d(LCAT, s);
	}
	
	registerForMultiplePushChannelArray(deviceToken, channelNames, 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.SubscribeToMultiplePushChannel(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,代码行数:23,代码来源:AndroidTitaniumParseModule.java

示例9: 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

示例10: valueListener

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
@Kroll.method
public void valueListener(String ref, KrollFunction change) {
	if (events != null) {
		final KrollFunction changeHandler = change;
		Firebase ch = events.child(ref);
		ch.addValueEventListener(new ValueEventListener() {
			HashMap<String, Object> args = new HashMap<String, Object>();
			String json;
			@Override
			public void onDataChange(DataSnapshot snapshot) {
				json = new Gson().toJson(snapshot.getValue());
	        	args.put("callback", changeHandler);
				args.put("data", json);
				callThisCallbackDirectly(args);
			}
			
			@Override
			public void onCancelled(FirebaseError err) {
				Log.e(TAG, "FirebaseError child.onCancelled: " + err.getMessage());
			}
		});
	}
}
 
开发者ID:Android-Embed,项目名称:ti-firebase,代码行数:24,代码来源:FirebasetiModule.java

示例11: singleValueListener

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
@Kroll.method
public void singleValueListener(String ref, KrollFunction change) {
	if (events != null) {
		final KrollFunction changeHandler = change;
		Firebase ch = events.child(ref);
		ch.addListenerForSingleValueEvent(new ValueEventListener() {
			HashMap<String, Object> args = new HashMap<String, Object>();
			String json;
			@Override
			public void onDataChange(DataSnapshot snapshot) {
				json = new Gson().toJson(snapshot.getValue());
	        	args.put("callback", changeHandler);
				args.put("data", json);
				callThisCallbackDirectly(args);
			}
			
			@Override
			public void onCancelled(FirebaseError err) {
				Log.e(TAG, "FirebaseError child.onCancelled: " + err.getMessage());
			}
		});
	}
}
 
开发者ID:Android-Embed,项目名称:ti-firebase,代码行数:24,代码来源:FirebasetiModule.java

示例12: signin

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
@Kroll.method
public void signin(KrollDict props)
{
	if (props.containsKey("success")) {
		successCallback = (KrollFunction) props.get("success");
	}
	if (props.containsKey("error")) {
		errorCallback = (KrollFunction) props.get("error");
	}
	

	String[] accountTypes = new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE };
	Intent intent = AccountPicker.newChooseAccountIntent(null, null,
			accountTypes, false, null, null, null, null);

	Activity activity = TiApplication.getAppCurrentActivity();
	TiActivitySupport support = (TiActivitySupport) activity;
	requestCode = support.getUniqueResultCode();
	support.launchActivityForResult(intent, requestCode, this);

}
 
开发者ID:Sitata,项目名称:titanium_google_auth_util,代码行数:22,代码来源:TitaniumGoogleAuthUtilModule.java

示例13: handleRequest

import org.appcelerator.kroll.KrollFunction; //导入依赖的package包/类
private boolean handleRequest(String[] permissions, Integer requestCode, KrollFunction permissionCallback) {
	Activity activity = TiApplication.getAppCurrentActivity();

	if (!(activity instanceof TiBaseActivity)) {
		Log.w(LCAT,	"Requesting permission from non-Titanium activity - not supported");
		return false;
	}

	TiBaseActivity currentActivity = (TiBaseActivity) activity;
	// Do we need a callback and request code in any case?
	if (requestCode == null) {
		Log.d(LCAT, "No request code given - Ti Permissions module will generate one");
		requestCode = currentActivity.getUniqueResultCode();
	}

	// register callback in current activity
	// TODO what is the exact purpose of the context? We should provide the Activity's Proxy, not the module object
	KrollObject context = currentActivity.getActivityProxy().getKrollObject();

	Log.d(LCAT, "Registering callback");
	currentActivity.registerPermissionRequestCallback(requestCode, 
			permissionCallback, context,permissions);

	Log.d(LCAT, "Calling permission request");
	ActivityCompat.requestPermissions(activity,	permissions, requestCode);
	return true;
}
 
开发者ID:stgrosshh,项目名称:tipermissions,代码行数:28,代码来源:TipermissionsModule.java

示例14: 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

示例15: 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


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