Skip to content

Commit 4b9d1ef

Browse files
authored
Formatting changes for checkstyle (#3980)
1 parent 819a47c commit 4b9d1ef

File tree

626 files changed

+101110
-98999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

626 files changed

+101110
-98999
lines changed

CodenameOne/src/com/codename1/ads/AdsService.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
* published by the Free Software Foundation. Codename One designates this
77
* particular file as subject to the "Classpath" exception as provided
88
* by Oracle in the LICENSE file that accompanied this code.
9-
*
9+
*
1010
* This code is distributed in the hope that it will be useful, but WITHOUT
1111
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1212
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1313
* version 2 for more details (a copy is included in the LICENSE file that
1414
* accompanied this code).
15-
*
15+
*
1616
* You should have received a copy of the GNU General Public License version
1717
* 2 along with this work; if not, write to the Free Software Foundation,
1818
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19-
*
20-
* Please contact Codename One through http://www.codenameone.com/ if you
19+
*
20+
* Please contact Codename One through http://www.codenameone.com/ if you
2121
* need additional information or have any questions.
2222
*/
2323
package com.codename1.ads;
@@ -27,44 +27,30 @@
2727
import com.codename1.io.NetworkManager;
2828
import com.codename1.ui.events.ActionEvent;
2929
import com.codename1.ui.html.HTMLComponent;
30+
3031
import java.io.ByteArrayOutputStream;
3132
import java.io.IOException;
3233
import java.io.InputStream;
3334

3435
/**
3536
* This is an abstract Ads Service.
36-
* Each supported Ad network needs to extend this Service and to implement
37+
* Each supported Ad network needs to extend this Service and to implement
3738
* the initService method
38-
*
39+
*
3940
* @author Chen Fishbein
4041
*/
4142
public abstract class AdsService extends ConnectionRequest {
4243

44+
private static Class service = InnerActive.class;
4345
private String currentAd;
4446
private boolean initialized = false;
45-
private static Class service = InnerActive.class;
4647

4748
/**
4849
* Empty constructor
4950
*/
5051
protected AdsService() {
5152
}
5253

53-
/**
54-
* Initialize the ads service.
55-
*/
56-
public void initialize(Ads adsComponent) {
57-
if (!initialized) {
58-
initService(adsComponent);
59-
initialized = true;
60-
}
61-
}
62-
63-
/**
64-
* init the service requests.
65-
*/
66-
public abstract void initService(Ads adsComponent);
67-
6854
/**
6955
* Creates a new AdsService to be used by the Ads Component
7056
*/
@@ -83,12 +69,28 @@ public static AdsService createAdsService() {
8369

8470
/**
8571
* Sets the provider of the ads service.
72+
*
8673
* @param provider this class needs to extend the AdsService class
8774
*/
88-
public static void setAdsProvider(Class provider){
75+
public static void setAdsProvider(Class provider) {
8976
service = provider;
9077
}
91-
78+
79+
/**
80+
* Initialize the ads service.
81+
*/
82+
public void initialize(Ads adsComponent) {
83+
if (!initialized) {
84+
initService(adsComponent);
85+
initialized = true;
86+
}
87+
}
88+
89+
/**
90+
* init the service requests.
91+
*/
92+
public abstract void initService(Ads adsComponent);
93+
9294
/**
9395
* Returns the last requested ad
9496
*/
@@ -118,13 +120,14 @@ protected void readResponse(InputStream input) throws IOException {
118120
if (size > 0) {
119121
String s = new String(out.toByteArray(), 0, size, "UTF-8");
120122
currentAd = s;
121-
fireResponseListener(new ActionEvent(currentAd,ActionEvent.Type.Response));
123+
fireResponseListener(new ActionEvent(currentAd, ActionEvent.Type.Response));
122124
}
123125
}
124126

125127
/**
126128
* This a callback method to inform to the service the Ad is displayed
127-
* @param cmp
129+
*
130+
* @param cmp
128131
*/
129132
public void onAdDisplay(HTMLComponent cmp) {
130133
}

CodenameOne/src/com/codename1/ads/InnerActive.java

Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,47 @@
66
* published by the Free Software Foundation. Codename One designates this
77
* particular file as subject to the "Classpath" exception as provided
88
* by Oracle in the LICENSE file that accompanied this code.
9-
*
9+
*
1010
* This code is distributed in the hope that it will be useful, but WITHOUT
1111
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1212
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1313
* version 2 for more details (a copy is included in the LICENSE file that
1414
* accompanied this code).
15-
*
15+
*
1616
* You should have received a copy of the GNU General Public License version
1717
* 2 along with this work; if not, write to the Free Software Foundation,
1818
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19-
*
20-
* Please contact Codename One through http://www.codenameone.com/ if you
19+
*
20+
* Please contact Codename One through http://www.codenameone.com/ if you
2121
* need additional information or have any questions.
2222
*/
2323
package com.codename1.ads;
2424

2525
import com.codename1.components.Ads;
2626
import com.codename1.io.ConnectionRequest;
27-
import com.codename1.io.Storage;
2827
import com.codename1.ui.Display;
2928
import com.codename1.ui.events.ActionEvent;
30-
import com.codename1.ui.html.HTMLComponent;
29+
3130
import java.io.IOException;
3231
import java.io.InputStream;
3332

3433
/**
3534
* This is an Ad service implementation by InnerActive see:
3635
* http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
37-
*
36+
*
3837
* @author Chen
3938
*/
40-
public class InnerActive extends AdsService{ // PMD Fix: UnusedPrivateField removed obsolete field
41-
42-
private final String REQUEST_URL = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd";
39+
public class InnerActive extends AdsService { // PMD Fix: UnusedPrivateField removed obsolete field
4340

41+
private static final String protocolVersion = "Sm2m-1.5.3";
42+
private static boolean testAds = true;
43+
private final String REQUEST_URL = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd";
4444
//Distribution channel ID
4545
private int po = 559;
46-
4746
private String os;
48-
49-
private static final String protocolVersion = "Sm2m-1.5.3";
50-
5147
//UDID/IMEI
5248
private String hid;
53-
5449
private boolean banner = true;
55-
56-
private static boolean testAds = true;
5750

5851
/**
5952
* Empty constructor of the inner active ads service.
@@ -67,62 +60,63 @@ private static void addParam(ConnectionRequest req, String key, String val) {
6760
}
6861
}
6962

63+
/**
64+
* If true and no ads exists the network will return house holds ads
65+
*
66+
* @param test
67+
*/
68+
public static void setTestAds(boolean test) {
69+
testAds = test;
70+
}
71+
7072
/**
7173
* Sets this ads type, by default this a banner type.
72-
*
74+
*
7375
* @param banner sets the ads to banners or text ads
7476
*/
7577
public void setBanner(boolean banner) {
7678
this.banner = banner;
7779
}
7880

79-
/**
80-
* If true and no ads exists the network will return house holds ads
81-
* @param test
82-
*/
83-
public static void setTestAds(boolean test) {
84-
testAds = test;
85-
}
86-
8781
/**
8882
* initialize the ads service
8983
*/
90-
public void initService(Ads ads){
84+
public void initService(Ads ads) {
9185
this.os = Display.getInstance().getPlatformName();
92-
if(os.equals("and")){
93-
if(banner){
86+
if (os.equals("and")) {
87+
if (banner) {
9488
po = 559;
95-
}else{
96-
po = 600;
89+
} else {
90+
po = 600;
9791
}
98-
}else if(os.equals("rim")){
99-
if(banner){
100-
po = 635;
101-
}else{
102-
po = 634;
92+
} else if (os.equals("rim")) {
93+
if (banner) {
94+
po = 635;
95+
} else {
96+
po = 634;
10397
}
104-
}else if(os.equals("ios")){
105-
if(banner){
106-
if(Display.getInstance().isTablet()){
107-
po = 947;
108-
}else{
109-
po = 642;
98+
} else if (os.equals("ios")) {
99+
if (banner) {
100+
if (Display.getInstance().isTablet()) {
101+
po = 947;
102+
} else {
103+
po = 642;
110104
}
111-
}else{
112-
if(Display.getInstance().isTablet()){
113-
po = 946;
114-
}else{
115-
po = 632;
105+
} else {
106+
if (Display.getInstance().isTablet()) {
107+
po = 946;
108+
} else {
109+
po = 632;
116110
}
117111
}
118-
}else if(os.equals("me")){
119-
if(banner){
120-
po = 551;
121-
}else{
122-
po = 519;
112+
} else if (os.equals("me")) {
113+
if (banner) {
114+
po = 551;
115+
} else {
116+
po = 519;
123117
}
124118
}
125-
119+
126120
String url = REQUEST_URL;
127121
setPost(false);
128122
setUrl(url);
@@ -131,9 +125,9 @@ public void initService(Ads ads){
131125
//protocol version
132126
String version = protocolVersion;
133127
addParam(this, "v", version);
134-
if(os.equals("ios")){
135-
hid = Display.getInstance().getProperty("UDID", null);
136-
}else{
128+
if (os.equals("ios")) {
129+
hid = Display.getInstance().getProperty("UDID", null);
130+
} else {
137131
hid = Display.getInstance().getProperty("IMEI", null);
138132
}
139133
addParam(this, "hid", hid);
@@ -144,19 +138,19 @@ public void initService(Ads ads){
144138
addParam(this, "a", ads.getAge());
145139
addParam(this, "g", ads.getGender());
146140
addParam(this, "c", ads.getCategory());
147-
addParam(this, "l", ads.getLocation());
148-
141+
addParam(this, "l", ads.getLocation());
142+
149143
addParam(this, "mn", Display.getInstance().getProperty("MSISDN", null));
150-
String [] keywords = ads.getKeywords();
151-
if(keywords != null && keywords.length > 0){
144+
String[] keywords = ads.getKeywords();
145+
if (keywords != null && keywords.length > 0) {
152146
int klen = keywords.length;
153147
String k = "";
154148
for (int i = 0; i < klen; i++) {
155149
k += "," + keywords[i];
156150
}
157151
addParam(this, "k", k.substring(1));
158-
}
159-
if(testAds){
152+
}
153+
if (testAds) {
160154
addParam(this, "test", "1");
161155
}
162156
setDuplicateSupported(true);
@@ -172,10 +166,10 @@ protected void readResponse(InputStream input) throws IOException {
172166
while ((len = input.read(buffer)) > 0) {
173167
String temp = new String(buffer, 0, len, "UTF-8");
174168
int endOfFile = temp.indexOf("/html>");
175-
if( endOfFile > 0){
169+
if (endOfFile > 0) {
176170
buf.append(temp.toCharArray(), 0, endOfFile + 6);
177171
break;
178-
}else{
172+
} else {
179173
buf.append(temp);
180174
}
181175
}
@@ -187,7 +181,7 @@ protected void readResponse(InputStream input) throws IOException {
187181
// Storage.getInstance().flushStorageCache();
188182
// addParam(this, "cid", cid);
189183
// }
190-
fireResponseListener(new ActionEvent(s,ActionEvent.Type.Response));
184+
fireResponseListener(new ActionEvent(s, ActionEvent.Type.Response));
191185
}
192186

193187
}

0 commit comments

Comments
 (0)