1 |
package dk.thoerup.marketstats; |
2 |
|
3 |
import java.util.Formatter; |
4 |
|
5 |
import com.gc.android.market.api.MarketSession.Callback; |
6 |
import com.gc.android.market.api.model.Market.App; |
7 |
import com.gc.android.market.api.model.Market.AppsResponse; |
8 |
import com.gc.android.market.api.model.Market.ResponseContext; |
9 |
|
10 |
public class AppsCallback implements Callback<AppsResponse>{ |
11 |
private StringBuilder sb; |
12 |
private String appId = null; |
13 |
|
14 |
public void setStringBuffer(StringBuilder s) { |
15 |
sb = s; |
16 |
} |
17 |
|
18 |
public String getAppId() { |
19 |
return appId; |
20 |
} |
21 |
|
22 |
|
23 |
@Override |
24 |
public void onResult(ResponseContext context, AppsResponse response) { |
25 |
//System.out.println("Response : " + response); |
26 |
//sb.append("Response: " + response + "\n"); |
27 |
|
28 |
if (response.getAppCount() == 1 ) { |
29 |
|
30 |
App app = response.getApp(0); |
31 |
appId = app.getId(); |
32 |
|
33 |
Formatter form = new Formatter(sb); |
34 |
|
35 |
|
36 |
sb.append( "<h2>" + app.getTitle() + "</h2>"); |
37 |
sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n" ); |
38 |
sb.append("Ratingcount: " + app.getRatingsCount() + "\n"); |
39 |
|
40 |
sb.append("Rating: " ); |
41 |
double rating = Double.parseDouble( app.getRating() ); |
42 |
form.format("%.4f", rating); |
43 |
sb.append("\n"); |
44 |
|
45 |
sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" ); |
46 |
|
47 |
sb.append("\n"); |
48 |
} else { |
49 |
sb.append("<h2>Application not found</h2>"); |
50 |
} |
51 |
|
52 |
} |
53 |
|
54 |
|
55 |
} |