1 |
package dk.thoerup.marketstats; |
package dk.thoerup.marketstats; |
2 |
|
|
3 |
|
import java.text.NumberFormat; |
4 |
import java.util.Formatter; |
import java.util.Formatter; |
5 |
|
|
6 |
import com.gc.android.market.api.MarketSession.Callback; |
import com.gc.android.market.api.MarketSession.Callback; |
9 |
import com.gc.android.market.api.model.Market.ResponseContext; |
import com.gc.android.market.api.model.Market.ResponseContext; |
10 |
|
|
11 |
public class AppsCallback implements Callback<AppsResponse>{ |
public class AppsCallback implements Callback<AppsResponse>{ |
12 |
private StringBuilder sb; |
private AppBean result = null; |
13 |
|
|
14 |
public void setStringBuffer(StringBuilder s) { |
public AppBean getResult() { |
15 |
sb = s; |
return result; |
16 |
} |
} |
17 |
|
|
|
|
|
18 |
@Override |
@Override |
19 |
public void onResult(ResponseContext context, AppsResponse response) { |
public void onResult(ResponseContext cntxt, AppsResponse apps) { |
20 |
//System.out.println("Response : " + response); |
if (apps.getAppCount() == 1) { |
21 |
//sb.append("Response: " + response + "\n"); |
NumberFormat form = NumberFormat.getNumberInstance(); |
22 |
|
form.setMinimumFractionDigits(4); |
23 |
Formatter form = new Formatter(sb); |
form.setMaximumFractionDigits(4); |
24 |
App app = response.getApp(0); |
|
25 |
sb.append( "<h2>" + app.getTitle() + "</h2>"); |
|
26 |
sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n" ); |
App app = apps.getApp(0); |
27 |
sb.append("Ratingcount: " + app.getRatingsCount() + "\n"); |
|
28 |
|
|
29 |
sb.append("Rating: " ); |
result = new AppBean(); |
30 |
double rating = Double.parseDouble( app.getRating() ); |
result.id = app.getId(); |
31 |
form.format("%.4f", rating); |
result.title = app.getTitle(); |
32 |
sb.append("\n"); |
result.version = app.getVersion(); |
33 |
|
result.versionCode = app.getVersionCode(); |
34 |
sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" ); |
result.downloadsCount = app.getExtendedInfo().getDownloadsCount(); |
35 |
|
result.downloadsCountText = app.getExtendedInfo().getDownloadsCountText(); |
36 |
sb.append("\n"); |
|
37 |
|
result.ratingsCount = app.getRatingsCount(); |
38 |
|
double rating = Double.parseDouble( app.getRating() ); |
39 |
|
result.rating = form.format(rating); |
40 |
|
} |
41 |
} |
} |
42 |
|
|
43 |
|
|
44 |
} |
} |
45 |
|
|