1 |
torben |
663 |
package dk.thoerup.marketstats; |
2 |
|
|
|
3 |
torben |
950 |
import java.text.NumberFormat; |
4 |
torben |
663 |
import java.util.Formatter; |
5 |
|
|
|
6 |
|
|
import com.gc.android.market.api.MarketSession.Callback; |
7 |
|
|
import com.gc.android.market.api.model.Market.App; |
8 |
|
|
import com.gc.android.market.api.model.Market.AppsResponse; |
9 |
|
|
import com.gc.android.market.api.model.Market.ResponseContext; |
10 |
|
|
|
11 |
|
|
public class AppsCallback implements Callback<AppsResponse>{ |
12 |
torben |
950 |
private AppBean result = null; |
13 |
|
|
|
14 |
|
|
public AppBean getResult() { |
15 |
|
|
return result; |
16 |
torben |
663 |
} |
17 |
torben |
705 |
|
18 |
torben |
663 |
@Override |
19 |
torben |
950 |
public void onResult(ResponseContext cntxt, AppsResponse apps) { |
20 |
|
|
if (apps.getAppCount() == 1) { |
21 |
|
|
NumberFormat form = NumberFormat.getNumberInstance(); |
22 |
|
|
form.setMinimumFractionDigits(4); |
23 |
|
|
form.setMaximumFractionDigits(4); |
24 |
torben |
705 |
|
25 |
|
|
|
26 |
torben |
950 |
App app = apps.getApp(0); |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
result = new AppBean(); |
30 |
|
|
result.id = app.getId(); |
31 |
|
|
result.title = app.getTitle(); |
32 |
|
|
result.version = app.getVersion(); |
33 |
|
|
result.versionCode = app.getVersionCode(); |
34 |
|
|
result.downloadsCount = app.getExtendedInfo().getDownloadsCount(); |
35 |
|
|
result.downloadsCountText = app.getExtendedInfo().getDownloadsCountText(); |
36 |
|
|
|
37 |
|
|
result.ratingsCount = app.getRatingsCount(); |
38 |
torben |
705 |
double rating = Double.parseDouble( app.getRating() ); |
39 |
torben |
950 |
result.rating = form.format(rating); |
40 |
torben |
705 |
} |
41 |
torben |
663 |
} |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
} |