本文整理汇总了Java中com.twofortyfouram.annotation.Slow类的典型用法代码示例。如果您正苦于以下问题:Java Slow类的具体用法?Java Slow怎么用?Java Slow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Slow类属于com.twofortyfouram.annotation包,在下文中一共展示了Slow类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fire
import com.twofortyfouram.annotation.Slow; //导入依赖的package包/类
/**
* Performs a blocking fire of the plug-in's setting action.
*
* @param data The plug-in's instance data previously saved by the Edit Activity.
*/
@Slow(Speed.SECONDS)
public void fire(@NonNull final PluginInstanceData data) {
assertNotNull(data, "data"); //$NON-NLS-1$
final Bundle pluginBundle;
try {
/*
* Referring to the full class name, rather than using an import, works around JavaDoc
* warnings on BundleSerializer which is obfuscated out by the time the JavaDoc task
* runs.
*/
pluginBundle = com.twofortyfouram.locale.sdk.host.internal.BundleSerializer.deserializeFromByteArray(data.getSerializedBundle());
} catch (final Exception e) {
/*
* If the Bundle could be serialized, it should be possible to deserialize. One
* scenario where this could fail is if the Bundle was serialized on a newer version of
* Android and contained a Serializable class not available to the current version of
* Android.
*/
Lumberjack.always("Error deserializing bundle", e); //$NON-NLS-1$
return;
}
fire(pluginBundle);
}
示例2: query
import com.twofortyfouram.annotation.Slow; //导入依赖的package包/类
/**
* Performs a blocking query to the plug-in condition.
*
* @param data The plug-in's instance data previously saved by the Edit Activity.
* @param previousState The previous query result of the plug-in, to be set as the initial
* result code
* when querying the plug-in. This must be one of {@link
* com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_SATISFIED
* RESULT_CONDITION_SATISFIED}
* ,
* {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_UNSATISFIED
* RESULT_CONDITION_UNSATISFIED}
* , or
* {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_UNKNOWN
* RESULT_CONDITION_UNKNOWN}.
* Plug-in implementations might use this
* previous result code for hysteresis. If no previous state is
* available,
* pass {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_UNKNOWN
* RESULT_CONDITION_UNKNOWN}.
* @return One of the Locale plug-in query results:
* {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_SATISFIED
* RESULT_CONDITION_SATISFIED}
* ,
* {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_UNSATISFIED
* RESULT_CONDITION_UNSATISFIED}
* , or
* {@link com.twofortyfouram.locale.api.Intent#RESULT_CONDITION_UNKNOWN
* RESULT_CONDITION_UNKNOWN}
* .
*/
@Slow(Speed.SECONDS)
@ConditionResult
public int query(@NonNull final PluginInstanceData data, @ConditionResult final int
previousState) {
assertNotNull(data, "data"); //$NON-NLS-1$
assertInRangeInclusive(previousState, com.twofortyfouram.locale.api.Intent.
RESULT_CONDITION_SATISFIED, com.twofortyfouram.locale.api.Intent.
RESULT_CONDITION_UNKNOWN, "previousState");
final Bundle pluginBundle;
try {
/*
* Referring to the full class name, rather than using an import, works around JavaDoc
* warnings on BundleSerializer which is obfuscated out by the time the JavaDoc task
* runs.
*/
pluginBundle = com.twofortyfouram.locale.sdk.host.internal.BundleSerializer
.deserializeFromByteArray(data.getSerializedBundle());
} catch (final Exception e) {
/*
* If the Bundle could be serialized, it should be possible to deserialize. One
* scenario where this could fail is if the Bundle was serialized on a newer version of
* Android and contained a Serializable class not available to the current version of
* Android.
*/
Lumberjack.always("Error deserializing bundle", e);
return com.twofortyfouram.locale.api.Intent.RESULT_CONDITION_UNKNOWN;
}
return query(pluginBundle, previousState);
}
示例3: getActivityLabel
import com.twofortyfouram.annotation.Slow; //导入依赖的package包/类
/**
* Retrieves a human-readable version of the Plugin's name that would be
* appropriate to display to a user in a UI.
* <p>
* The results of this method may change after a configuration change (e.g.
* the system's locale is changed).
*
* @param context Application context.
* @return the display name of the plug-in.
*/
@NonNull
@Slow(Speed.MILLISECONDS)
public final String getActivityLabel(@NonNull final Context context) {
assertNotNull(context, "context"); //$NON-NLS-1$
CharSequence name = getActivityClassName();
final PackageManager packageManager = context.getPackageManager();
try {
final ActivityInfo activityInfo = packageManager.getActivityInfo(getComponentName(), 0);
if (0 == activityInfo.labelRes && null != activityInfo.nonLocalizedLabel) {
name = activityInfo.nonLocalizedLabel;
} else if (0 != activityInfo.labelRes) {
name = packageManager.getText(getPackageName(), activityInfo.labelRes,
activityInfo.applicationInfo);
}
if (null == name || 0 == name.length()) {
name = getActivityClassName();
}
} catch (final NameNotFoundException e) {
/*
* This could happen if the plug-in is uninstalled.
*/
}
return name.toString();
}
示例4: Handler
import com.twofortyfouram.annotation.Slow; //导入依赖的package包/类
/**
* Initially loads the registry.
*
* @see #MESSAGE_INIT
*/
@Slow(Speed.SECONDS)
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
/* package */void handleInit() {
mReceiverHandlerThread = ThreadUtil.newHandlerThread(
RegistryReceiver.class.getName(),
ThreadPriority.BACKGROUND);
final Handler receiverHandler = new Handler(mReceiverHandlerThread.getLooper());
{
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addDataScheme("package"); //$NON-NLS-1$
mContext.registerReceiver(mReceiver, filter, null, receiverHandler);
}
{
final IntentFilter externalStorageFilter = new IntentFilter();
externalStorageFilter
.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
externalStorageFilter
.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
mContext.registerReceiver(mReceiver, externalStorageFilter, null,
receiverHandler);
}
mMutableConditionMap = PluginPackageScanner.loadPluginMap(mContext,
PluginType.CONDITION, null);
mMutableSettingMap = PluginPackageScanner.loadPluginMap(mContext,
PluginType.SETTING, null);
setConditions();
setSettings();
sendBroadcast();
}
开发者ID:twofortyfouram,项目名称:android-plugin-host-sdk-for-locale,代码行数:44,代码来源:PluginRegistryHandler.java
示例5: loadPluginMap
import com.twofortyfouram.annotation.Slow; //导入依赖的package包/类
/**
* Loads a map of plug-ins by scanning packages currently installed.
*
* @param context Application context.
* @param type Type of plug-in to load.
* @param onlyForPackage Optional filter to only get a map for the given
* package. {@code null} implies no filter.
* @return Map of registry name to plug-in.
*/
/*
* Note: The performance of this method varies with the number of plug-ins
* installed on the device.
*/
/*
* Deprecation warnings are suppressed because there isn't an alternative to
* PluginCharacteristics yet.
*/
@NonNull
@Slow(Speed.SECONDS)
public static Map<String, Plugin> loadPluginMap(@NonNull final Context context,
@NonNull final PluginType type, @Nullable final String onlyForPackage) {
assertNotNull(context, "context"); //$NON-NLS-1$
assertNotNull(type, "type"); //$NON-NLS-1$
final long start = SystemClock.elapsedRealtime();
final Map<String, Plugin> result = new HashMap<String, Plugin>();
for (final ResolveInfo activityResolveInfo : findActivities(context, type,
onlyForPackage)) {
final String pluginPackageName = activityResolveInfo.activityInfo.packageName;
final int pluginVersionCode = getVersionCode(context.getPackageManager(),
pluginPackageName);
final List<ResolveInfo> pluginReceiverInfos = findReceivers(context, type,
pluginPackageName);
Lumberjack
.always("Found plug-in %s with package: %s, Activity: %s, BroadcastReceiver: %s, versionCode: %d",
type, pluginPackageName, activityResolveInfo, pluginReceiverInfos,
pluginVersionCode); //$NON-NLS-1$
final EnumSet<PluginErrorRegister> errors = checkPluginForErrors(context, type,
activityResolveInfo, pluginReceiverInfos);
// TODO: Some errors are not fatal.
if (errors.isEmpty()) {
// TODO: Plugin characteristics should be downloaded from the cloud.
final String registryName = Plugin.generateRegistryName(pluginPackageName,
activityResolveInfo.activityInfo.name);
final Plugin plugin = new Plugin(type, pluginPackageName,
activityResolveInfo.activityInfo.name,
pluginReceiverInfos.get(0).activityInfo.name,
pluginVersionCode,
new PluginConfiguration(PluginCharacteristics
.isBackwardsCompatibilityEnabled(type, registryName),
PluginCharacteristics.isRequiresConnectivity(type, registryName),
PluginCharacteristics.isDisruptsConnectivity(
type, registryName), PluginCharacteristics.isBuggy(type,
registryName), PluginCharacteristics.isDrainsBattery(type,
registryName),
PluginCharacteristics.isBlacklisted(type, registryName),
PluginCharacteristics.getBuiltInAlternative(type, registryName)
)
);
result.put(plugin.getRegistryName(), plugin);
} else {
for (final PluginErrorRegister error : errors) {
Lumberjack.always(error.getDeveloperExplanation());
}
}
}
Lumberjack
.v("Loaded plug-in map in %d milliseconds",
SystemClock.elapsedRealtime() - start); //$NON-NLS-1$
return result;
}