MCPcopy Create free account
hub / github.com/BombusMod/BombusMod / ActivityList

Class ActivityList

src/main/java/PEP/ActivityList.java:29–89  ·  view source on GitHub ↗

@author evgs

Source from the content-addressed store, hash-verified

27 * @author evgs
28 */
29public class ActivityList extends DefForm implements MIDPTextBox.TextBoxNotify {
30
31 /** Creates a new instance of MoodList */
32
33 String acttext;
34
35 public ActivityList(Display display) {
36 super(SR.MS_USERACTIVITY);
37
38 for (Enumeration e = Activities.getInstance().actValue.elements(); e.hasMoreElements();) {
39 SimpleString item = new SimpleString((String)e.nextElement(), false);
40 item.selectable = true;
41 itemsList.addElement(item);
42 }
43 enableListWrapping(true);
44 }
45
46 public void cmdOk() {
47 eventOk();
48 }
49
50 public void eventOk() {
51 if (cursor==0)
52 OkNotify(null);
53 else
54 new MIDPTextBox(SR.MS_USERACTIVITY, acttext, this);
55 }
56
57 public void OkNotify(String actText) {
58 //String moodName=((MoodItem)getFocusedObject()).getTipString();
59 publish(cursor, actText);
60 parentView = sd.roster;
61 destroyView();
62 }
63
64 public void publish(int activity, String text) {
65 String sid="publish-activity";
66 JabberDataBlock setActivity=new Iq(null, Iq.TYPE_SET, sid);
67 JabberDataBlock action=setActivity.addChildNs("pubsub", "http://jabber.org/protocol/pubsub") .addChild("publish", null);
68 action.setAttribute("node", "http://jabber.org/protocol/activity");
69 JabberDataBlock item=action.addChild("item", null);
70 //item.setAttribute("id", Activities.getInstance().myActId);
71 JabberDataBlock act=item.addChildNs("activity", "http://jabber.org/protocol/activity");
72 if (activity > 0) {
73 String[] actName = Activities.getInstance().getActName(activity);
74 JabberDataBlock gen = act.addChild(actName[0], null);
75 gen.addChild(actName[1], null);
76 act.addChild("text", text);
77 }
78
79 try {
80 //todo: refactor theStream call; send notification to JabberBlockListener if stream was terminated
81 sd.getTheStream().addBlockListener(new PepPublishResult(sid));
82 sd.getTheStream().send(setActivity);
83 } catch (Exception e) {
84 if (StaticData.Debug) {
85 e.printStackTrace();
86 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected