Skip to content

Commit f5ee076

Browse files
committed
Further refactorings to reduce warnings
1 parent 8628ad9 commit f5ee076

File tree

14 files changed

+205
-164
lines changed

14 files changed

+205
-164
lines changed

.github/workflows/designer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
4040
- name: Build core dependencies
4141
run: |
42+
xvfb-run -a ant -noinput -buildfile Ports/CLDC11/build.xml jar
4243
xvfb-run -a ant -noinput -buildfile Ports/JavaSE/build.xml jar
4344
xvfb-run -a ant -noinput -buildfile Ports/JavaSEWithSVGSupport/build.xml jar
4445
xvfb-run -a ant -noinput -buildfile CodenameOne/build.xml jar

CodenameOne/src/com/codename1/facebook/FaceBookAccess.java

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ public void createNote(String userId, String subject, String message, ActionList
10201020
* @param callback the callback that should be updated when the data arrives
10211021
*/
10221022
public void getUserNotifications(String userId, String startTime, boolean includeRead,
1023-
DefaultListModel notifications, final ActionListener callback) throws IOException {
1023+
DefaultListModel notifications, final ActionListener<NetworkEvent> callback) throws IOException {
10241024
checkAuthentication();
10251025

10261026
final FacebookRESTService con = new FacebookRESTService(token, "https://api.facebook.com/method/notifications.getList", false);
@@ -1030,17 +1030,7 @@ public void getUserNotifications(String userId, String startTime, boolean includ
10301030
con.addArgument("format", "json");
10311031

10321032
con.setResponseDestination(notifications);
1033-
con.addResponseListener(new ActionListener() {
1034-
1035-
public void actionPerformed(ActionEvent evt) {
1036-
if (!con.isAlive()) {
1037-
return;
1038-
}
1039-
if (callback != null) {
1040-
callback.actionPerformed(evt);
1041-
}
1042-
}
1043-
});
1033+
con.addResponseListener(new GetUserNotificationsActionListener(con, callback));
10441034

10451035
if (slider != null) {
10461036
SliderBridge.bindProgress(con, slider);
@@ -1064,7 +1054,7 @@ public void actionPerformed(ActionEvent evt) {
10641054
* Vector users = (Vector) data.elementAt(0);
10651055
* }
10661056
*/
1067-
public void getUsersDetails(String[] usersIds, String[] fields, final ActionListener callback) throws IOException {
1057+
public void getUsersDetails(String[] usersIds, String[] fields, final ActionListener<NetworkEvent> callback) throws IOException {
10681058
checkAuthentication();
10691059

10701060
final FacebookRESTService con = new FacebookRESTService(token, "https://api.facebook.com/method/users.getInfo", false);
@@ -1085,17 +1075,7 @@ public void getUsersDetails(String[] usersIds, String[] fields, final ActionList
10851075
con.addArgumentNoEncoding("fields", fieldsStr.toString());
10861076
con.addArgument("format", "json");
10871077

1088-
con.addResponseListener(new ActionListener() {
1089-
1090-
public void actionPerformed(ActionEvent evt) {
1091-
if (!con.isAlive()) {
1092-
return;
1093-
}
1094-
if (callback != null) {
1095-
callback.actionPerformed(evt);
1096-
}
1097-
}
1098-
});
1078+
con.addResponseListener(new GetUsersDetailsActionListener(con, callback));
10991079
if (slider != null) {
11001080
SliderBridge.bindProgress(con, slider);
11011081
}
@@ -1437,6 +1417,44 @@ public void actionPerformed(NetworkEvent evt) {
14371417
}
14381418
}
14391419

1420+
private static class GetUserNotificationsActionListener implements ActionListener<NetworkEvent> {
1421+
private final FacebookRESTService con;
1422+
private final ActionListener<NetworkEvent> callback;
1423+
1424+
public GetUserNotificationsActionListener(FacebookRESTService con, ActionListener<NetworkEvent> callback) {
1425+
this.con = con;
1426+
this.callback = callback;
1427+
}
1428+
1429+
public void actionPerformed(NetworkEvent evt) {
1430+
if (!con.isAlive()) {
1431+
return;
1432+
}
1433+
if (callback != null) {
1434+
callback.actionPerformed(evt);
1435+
}
1436+
}
1437+
}
1438+
1439+
private static class GetUsersDetailsActionListener implements ActionListener<NetworkEvent> {
1440+
private final FacebookRESTService con;
1441+
private final ActionListener<NetworkEvent> callback;
1442+
1443+
public GetUsersDetailsActionListener(FacebookRESTService con, ActionListener<NetworkEvent> callback) {
1444+
this.con = con;
1445+
this.callback = callback;
1446+
}
1447+
1448+
public void actionPerformed(NetworkEvent evt) {
1449+
if (!con.isAlive()) {
1450+
return;
1451+
}
1452+
if (callback != null) {
1453+
callback.actionPerformed(evt);
1454+
}
1455+
}
1456+
}
1457+
14401458
private class GetUserResponseCodeActionListener implements ActionListener<NetworkEvent> {
14411459

14421460
private final Vector err;

CodenameOne/src/com/codename1/facebook/FacebookRESTService.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class FacebookRESTService extends ConnectionRequest implements JSONParseCallback
5050
public static final String GRAPH_URL = "https://graph.facebook.com/";
5151
public static String PICTURE = "picture";
5252
public static String FRIENDS = "friends";
53-
public static String TAGGED = "tagged";
54-
public static String ACTIVITIES = "activities";
55-
public static String INTERESTS = "interests";
5653
public static String LIKES = "likes";
5754
public static String ALBUMS = "albums";
5855
public static String PHOTOS = "photos";
@@ -61,7 +58,6 @@ class FacebookRESTService extends ConnectionRequest implements JSONParseCallback
6158
public static String FEED = "feed";
6259
public static String POSTS = "posts";
6360
public static String INBOX = "inbox";
64-
public static String MESSAGES = "messages";
6561
public static String EVENTS = "events";
6662
public static String NOTES = "notes";
6763
private final Hashtable entry = new Hashtable();
@@ -73,10 +69,6 @@ class FacebookRESTService extends ConnectionRequest implements JSONParseCallback
7369
private String imageKey;
7470
private String root;
7571

76-
public FacebookRESTService(boolean post, String token) {
77-
setPost(post);
78-
}
79-
8072
public FacebookRESTService(String token, String id, String connectionType, boolean post) {
8173
setPost(post);
8274
String query = id;
@@ -135,14 +127,6 @@ protected void readResponse(InputStream input) throws IOException {
135127
}
136128
}
137129

138-
protected String getConnectionType() {
139-
return connectionType;
140-
}
141-
142-
protected void setConnectionType(String connectionType) {
143-
this.connectionType = connectionType;
144-
}
145-
146130
public void startBlock(String block) {
147131
if (block.equals("paging")) {
148132
return;
@@ -281,34 +265,6 @@ protected int getYield() {
281265
return -1;
282266
}
283267

284-
/**
285-
* @return the responseOffset
286-
*/
287-
public int getResponseOffset() {
288-
return responseOffset;
289-
}
290-
291-
/**
292-
* @param responseOffset the responseOffset to set
293-
*/
294-
public void setResponseOffset(int responseOffset) {
295-
this.responseOffset = responseOffset;
296-
}
297-
298-
/**
299-
* @return the imageKey
300-
*/
301-
public String getImageKey() {
302-
return imageKey;
303-
}
304-
305-
/**
306-
* @param imageKey the imageKey to set
307-
*/
308-
public void setImageKey(String imageKey) {
309-
this.imageKey = imageKey;
310-
}
311-
312268
/**
313269
* {@inheritDoc}
314270
*/

CodenameOne/src/com/codename1/facebook/ui/LikeButton.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public LikeButton(String postId) {
6262
public LikeButton() {
6363
setUIIDFinal("LikeButton");
6464
setText("Like");
65-
addActionListener(this);
65+
super.addActionListener(this);
6666
}
6767

6868
/**
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.codename1.impl;
2+
3+
import com.codename1.components.AudioRecorderComponent;
4+
import com.codename1.io.FileSystemStorage;
5+
import com.codename1.media.MediaRecorderBuilder;
6+
import com.codename1.ui.CN;
7+
import com.codename1.ui.Sheet;
8+
import com.codename1.ui.events.ActionEvent;
9+
import com.codename1.ui.events.ActionListener;
10+
11+
class CaptureAudioActionListener implements ActionListener<ActionEvent> {
12+
private final AudioRecorderComponent cmp;
13+
private final Sheet sheet;
14+
private final ActionListener<ActionEvent> response;
15+
private final MediaRecorderBuilder builder;
16+
17+
public CaptureAudioActionListener(AudioRecorderComponent cmp, Sheet sheet, ActionListener<ActionEvent> response, MediaRecorderBuilder builder) {
18+
this.cmp = cmp;
19+
this.sheet = sheet;
20+
this.response = response;
21+
this.builder = builder;
22+
}
23+
24+
@Override
25+
public void actionPerformed(ActionEvent e) {
26+
switch (cmp.getState()) {
27+
case Accepted:
28+
CN.getCurrentForm().getAnimationManager().flushAnimation(new Runnable() {
29+
public void run() {
30+
sheet.back();
31+
sheet.addCloseListener(new ActionListener<ActionEvent>() {
32+
@Override
33+
public void actionPerformed(ActionEvent evt) {
34+
sheet.removeCloseListener(this);
35+
response.actionPerformed(new ActionEvent(builder.getPath()));
36+
}
37+
38+
});
39+
}
40+
});
41+
42+
43+
break;
44+
case Canceled:
45+
FileSystemStorage fs = FileSystemStorage.getInstance();
46+
if (fs.exists(builder.getPath())) {
47+
FileSystemStorage.getInstance().delete(builder.getPath());
48+
}
49+
CN.getCurrentForm().getAnimationManager().flushAnimation(new Runnable() {
50+
public void run() {
51+
sheet.back();
52+
sheet.addCloseListener(new ActionListener() {
53+
@Override
54+
public void actionPerformed(ActionEvent evt) {
55+
sheet.removeCloseListener(this);
56+
response.actionPerformed(new ActionEvent(null));
57+
}
58+
59+
});
60+
}
61+
});
62+
63+
64+
break;
65+
default:
66+
break;
67+
}
68+
}
69+
70+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.codename1.impl;
2+
3+
import com.codename1.components.AudioRecorderComponent;
4+
import com.codename1.io.FileSystemStorage;
5+
import com.codename1.media.MediaRecorderBuilder;
6+
import com.codename1.ui.CN;
7+
import com.codename1.ui.events.ActionEvent;
8+
import com.codename1.ui.events.ActionListener;
9+
10+
class CaptureAudioCloseActionListener implements ActionListener<ActionEvent> {
11+
private final AudioRecorderComponent cmp;
12+
private final MediaRecorderBuilder builder;
13+
private final ActionListener<ActionEvent> response;
14+
15+
public CaptureAudioCloseActionListener(AudioRecorderComponent cmp, MediaRecorderBuilder builder, ActionListener<ActionEvent> response) {
16+
this.cmp = cmp;
17+
this.builder = builder;
18+
this.response = response;
19+
}
20+
21+
@Override
22+
public void actionPerformed(ActionEvent e) {
23+
if (cmp.getState() != AudioRecorderComponent.RecorderState.Accepted && cmp.getState() != AudioRecorderComponent.RecorderState.Canceled) {
24+
FileSystemStorage fs = FileSystemStorage.getInstance();
25+
if (fs.exists(builder.getPath())) {
26+
FileSystemStorage.getInstance().delete(builder.getPath());
27+
}
28+
CN.getCurrentForm().getAnimationManager().flushAnimation(new Runnable() {
29+
public void run() {
30+
response.actionPerformed(new ActionEvent(null));
31+
}
32+
});
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)