Skip to content

Commit

Permalink
Add method for collecting event generating RPCs.
Browse files Browse the repository at this point in the history
Small cleanups.
  • Loading branch information
damonkohler committed Nov 19, 2010
1 parent d1c6507 commit ad098d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions android/ScriptingLayer/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/SignalStrengthFacade"/>
<classpathentry combineaccessrules="false" kind="src" path="/TextToSpeechFacade"/>
<classpathentry combineaccessrules="false" kind="src" path="/WebCamFacade"/>
<classpathentry kind="lib" path="/Common/libs/guava-r06.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@

package com.googlecode.android_scripting.facade;

import com.google.common.collect.Maps;
import com.googlecode.android_scripting.Log;
import com.googlecode.android_scripting.facade.ui.UiFacade;
import com.googlecode.android_scripting.jsonrpc.RpcReceiver;
import com.googlecode.android_scripting.rpc.MethodDescriptor;
import com.googlecode.android_scripting.rpc.RpcDeprecated;
import com.googlecode.android_scripting.rpc.RpcEvent;
import com.googlecode.android_scripting.rpc.RpcMinSdk;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
Expand Down Expand Up @@ -120,7 +123,7 @@ public static List<MethodDescriptor> collectMethodDescriptors() {
* Returns a list of not deprecated {@link MethodDescriptor} objects for facades supported by the
* current SDK version.
*/
public static List<MethodDescriptor> collectSupportedRpcDescriptors() {
public static List<MethodDescriptor> collectSupportedMethodDescriptors() {
List<MethodDescriptor> list = new ArrayList<MethodDescriptor>();
for (MethodDescriptor descriptor : sRpcs.values()) {
Method method = descriptor.getMethod();
Expand All @@ -137,6 +140,21 @@ public static List<MethodDescriptor> collectSupportedRpcDescriptors() {
return list;
}

public static Map<String, MethodDescriptor> collectEventGeneratingMethodDescriptors() {
Map<String, MethodDescriptor> map = Maps.newHashMap();
for (MethodDescriptor descriptor : sRpcs.values()) {
Method method = descriptor.getMethod();
if (method.isAnnotationPresent(RpcEvent.class)) {
String eventName = method.getAnnotation(RpcEvent.class).value();
if (map.containsKey(eventName)) {
throw new RuntimeException("Duplicate event generating method descriptor found.");
}
map.put(eventName, descriptor);
}
}
return map;
}

/** Returns a method by name. */
public static MethodDescriptor getMethodDescriptor(String name) {
return sRpcs.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public IBinder onBind(Intent intent) {
@Override
protected Notification createNotification() {
Notification notification =
new Notification(R.drawable.sl4a_logo_48, "SL4A Trigger Service is running.", System
new Notification(R.drawable.sl4a_logo_48, "SL4A Trigger Service started.", System
.currentTimeMillis());
notification.contentView = new RemoteViews(getPackageName(), R.layout.notification);
notification.contentView.setTextViewText(R.id.notification_title, "SL4A Trigger Service");
Expand Down

0 comments on commit ad098d2

Please sign in to comment.