Skip to content

Commit 4503130

Browse files
author
Robot Media
committed
Style changes to lujop's patch
1 parent 4f2ee5b commit 4503130

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

AndroidBillingLibrary/src/net/robotmedia/billing/BillingRequest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public abstract class BillingRequest {
2626

2727
public static class CheckBillingSupported extends BillingRequest {
2828

29-
public CheckBillingSupported(String packageName,int startId) {
30-
super(packageName,startId);
29+
public CheckBillingSupported(String packageName, int startId) {
30+
super(packageName, startId);
3131
}
3232

3333
@Override
@@ -48,8 +48,8 @@ public static class ConfirmNotifications extends BillingRequest {
4848

4949
private static final String KEY_NOTIFY_IDS = "NOTIFY_IDS";
5050

51-
public ConfirmNotifications(String packageName,int startId, String[] notifyIds) {
52-
super(packageName,startId);
51+
public ConfirmNotifications(String packageName, int startId, String[] notifyIds) {
52+
super(packageName, startId);
5353
this.notifyIds = notifyIds;
5454
}
5555

@@ -70,7 +70,7 @@ public static class GetPurchaseInformation extends BillingRequest {
7070

7171
private static final String KEY_NOTIFY_IDS = "NOTIFY_IDS";
7272

73-
public GetPurchaseInformation(String packageName,int startId, String[] notifyIds) {
73+
public GetPurchaseInformation(String packageName, int startId, String[] notifyIds) {
7474
super(packageName,startId);
7575
this.notifyIds = notifyIds;
7676
}
@@ -97,8 +97,8 @@ public static class RequestPurchase extends BillingRequest {
9797
private static final String KEY_DEVELOPER_PAYLOAD = "DEVELOPER_PAYLOAD";
9898
private static final String KEY_PURCHASE_INTENT = "PURCHASE_INTENT";
9999

100-
public RequestPurchase(String packageName, int startId,String itemId, String developerPayload) {
101-
super(packageName,startId);
100+
public RequestPurchase(String packageName, int startId, String itemId, String developerPayload) {
101+
super(packageName, startId);
102102
this.itemId = itemId;
103103
this.developerPayload = developerPayload;
104104
}
@@ -154,8 +154,8 @@ public static ResponseCode valueOf(int index) {
154154
}
155155
public static class RestoreTransactions extends BillingRequest {
156156

157-
public RestoreTransactions(String packageName,int startId) {
158-
super(packageName,startId);
157+
public RestoreTransactions(String packageName, int startId) {
158+
super(packageName, startId);
159159
}
160160

161161
@Override

AndroidBillingLibrary/src/net/robotmedia/billing/BillingService.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ private void bindMarketBillingService() {
104104

105105
private void checkBillingSupported(int startId) {
106106
final String packageName = getPackageName();
107-
final CheckBillingSupported request = new CheckBillingSupported(packageName,startId);
107+
final CheckBillingSupported request = new CheckBillingSupported(packageName, startId);
108108
runRequestOrQueue(request);
109109
}
110110

111-
private void confirmNotifications(Intent intent,int startId) {
111+
private void confirmNotifications(Intent intent, int startId) {
112112
final String packageName = getPackageName();
113113
final String[] notifyIds = intent.getStringArrayExtra(EXTRA_NOTIFY_IDS);
114-
final ConfirmNotifications request = new ConfirmNotifications(packageName,startId, notifyIds);
114+
final ConfirmNotifications request = new ConfirmNotifications(packageName, startId, notifyIds);
115115
runRequestOrQueue(request);
116116
}
117117

@@ -127,11 +127,11 @@ private Action getActionFromIntent(Intent intent) {
127127
return Action.valueOf(split[split.length - 1]);
128128
}
129129

130-
private void getPurchaseInformation(Intent intent,int startId) {
130+
private void getPurchaseInformation(Intent intent, int startId) {
131131
final String packageName = getPackageName();
132132
final long nonce = intent.getLongExtra(EXTRA_NONCE, 0);
133133
final String[] notifyIds = intent.getStringArrayExtra(EXTRA_NOTIFY_IDS);
134-
final GetPurchaseInformation request = new GetPurchaseInformation(packageName,startId, notifyIds);
134+
final GetPurchaseInformation request = new GetPurchaseInformation(packageName, startId, notifyIds);
135135
request.setNonce(nonce);
136136
runRequestOrQueue(request);
137137
}
@@ -157,16 +157,16 @@ public void onServiceDisconnected(ComponentName name) {
157157
// method will not be called.
158158
@Override
159159
public void onStart(Intent intent, int startId) {
160-
handleCommand(intent,startId);
160+
handleCommand(intent, startId);
161161
}
162162

163163
// @Override // Avoid compile errors on pre-2.0
164164
public int onStartCommand(Intent intent, int flags, int startId) {
165-
handleCommand(intent,startId);
165+
handleCommand(intent, startId);
166166
return Compatibility.START_NOT_STICKY;
167167
}
168168

169-
private void handleCommand(Intent intent,int startId) {
169+
private void handleCommand(Intent intent, int startId) {
170170
final Action action = getActionFromIntent(intent);
171171
if (action == null) {
172172
return;
@@ -176,49 +176,53 @@ private void handleCommand(Intent intent,int startId) {
176176
checkBillingSupported(startId);
177177
break;
178178
case REQUEST_PURCHASE:
179-
requestPurchase(intent,startId);
179+
requestPurchase(intent, startId);
180180
break;
181181
case GET_PURCHASE_INFORMATION:
182-
getPurchaseInformation(intent,startId);
182+
getPurchaseInformation(intent, startId);
183183
break;
184184
case CONFIRM_NOTIFICATIONS:
185-
confirmNotifications(intent,startId);
185+
confirmNotifications(intent, startId);
186186
break;
187187
case RESTORE_TRANSACTIONS:
188-
restoreTransactions(intent,startId);
188+
restoreTransactions(intent, startId);
189189
}
190190
}
191191

192-
private void requestPurchase(Intent intent,int startId) {
192+
private void requestPurchase(Intent intent, int startId) {
193193
final String packageName = getPackageName();
194194
final String itemId = intent.getStringExtra(EXTRA_ITEM_ID);
195195
final String developerPayload = intent.getStringExtra(EXTRA_DEVELOPER_PAYLOAD);
196-
final RequestPurchase request = new RequestPurchase(packageName,startId, itemId, developerPayload);
196+
final RequestPurchase request = new RequestPurchase(packageName, startId, itemId, developerPayload);
197197
runRequestOrQueue(request);
198198
}
199199

200-
private void restoreTransactions(Intent intent,int startId) {
200+
private void restoreTransactions(Intent intent, int startId) {
201201
final String packageName = getPackageName();
202202
final long nonce = intent.getLongExtra(EXTRA_NONCE, 0);
203-
final RestoreTransactions request = new RestoreTransactions(packageName,startId);
203+
final RestoreTransactions request = new RestoreTransactions(packageName, startId);
204204
request.setNonce(nonce);
205205
runRequestOrQueue(request);
206206
}
207207

208208
private void runPendingRequests() {
209209
BillingRequest request;
210-
int maxId=-1;
210+
int maxStartId = -1;
211211
while ((request = mPendingRequests.peek()) != null) {
212212
if (mService != null) {
213213
runRequest(request);
214214
mPendingRequests.remove();
215-
216-
if(maxId<request.getStartId())
217-
maxId=request.getStartId();
215+
if (maxStartId < request.getStartId()) {
216+
maxStartId = request.getStartId();
217+
}
218+
} else {
219+
bindMarketBillingService();
220+
return;
218221
}
219222
}
220-
if(maxId>=0)
221-
stopSelf(maxId);
223+
if (maxStartId >= 0) {
224+
stopSelf(maxStartId);
225+
}
222226
}
223227

224228
private void runRequest(BillingRequest request) {
@@ -243,7 +247,7 @@ private void runRequestOrQueue(BillingRequest request) {
243247
@Override
244248
public void onDestroy() {
245249
super.onDestroy();
246-
//Ensure not leaking android market billing service
250+
// Ensure we're not leaking Android Market billing service
247251
if (mService != null) {
248252
try {
249253
unbindService(this);

0 commit comments

Comments
 (0)