1 |
torben |
663 |
package dk.thoerup.marketstats; |
2 |
|
|
|
3 |
torben |
950 |
import java.text.NumberFormat; |
4 |
torben |
1014 |
import java.util.ArrayList; |
5 |
|
|
import java.util.List; |
6 |
torben |
663 |
|
7 |
|
|
import com.gc.android.market.api.MarketSession.Callback; |
8 |
|
|
import com.gc.android.market.api.model.Market.App; |
9 |
|
|
import com.gc.android.market.api.model.Market.AppsResponse; |
10 |
|
|
import com.gc.android.market.api.model.Market.ResponseContext; |
11 |
|
|
|
12 |
|
|
public class AppsCallback implements Callback<AppsResponse>{ |
13 |
torben |
1014 |
private List<AppBean> result = new ArrayList<AppBean>(); |
14 |
torben |
950 |
|
15 |
torben |
1014 |
public List<AppBean> getResult() { |
16 |
torben |
950 |
return result; |
17 |
torben |
663 |
} |
18 |
torben |
705 |
|
19 |
torben |
663 |
@Override |
20 |
torben |
950 |
public void onResult(ResponseContext cntxt, AppsResponse apps) { |
21 |
torben |
1014 |
|
22 |
|
|
NumberFormat form = NumberFormat.getNumberInstance(); |
23 |
|
|
form.setMinimumFractionDigits(4); |
24 |
|
|
form.setMaximumFractionDigits(4); |
25 |
torben |
705 |
|
26 |
torben |
1014 |
|
27 |
|
|
for (App app : apps.getAppList()) { |
28 |
|
|
|
29 |
torben |
705 |
|
30 |
torben |
1014 |
AppBean appBean= new AppBean(); |
31 |
|
|
appBean.packageName = app.getPackageName(); |
32 |
torben |
1015 |
appBean.creator = app.getCreator(); |
33 |
|
|
|
34 |
torben |
1014 |
appBean.id = app.getId(); |
35 |
|
|
appBean.title = app.getTitle(); |
36 |
|
|
appBean.version = app.getVersion(); |
37 |
|
|
appBean.versionCode = app.getVersionCode(); |
38 |
torben |
1015 |
|
39 |
torben |
1014 |
appBean.downloadsCount = app.getExtendedInfo().getDownloadsCount(); |
40 |
|
|
appBean.downloadsCountText = app.getExtendedInfo().getDownloadsCountText(); |
41 |
torben |
1015 |
appBean.website = (app.getExtendedInfo().hasContactWebsite() ) ? app.getExtendedInfo().getContactWebsite() : ""; |
42 |
|
|
appBean.description = app.getExtendedInfo().getDescription(); |
43 |
torben |
950 |
|
44 |
torben |
1014 |
appBean.ratingsCount = app.getRatingsCount(); |
45 |
|
|
double rating = Double.parseDouble( app.getRating() ); |
46 |
|
|
appBean.rating = form.format(rating); |
47 |
torben |
950 |
|
48 |
torben |
1014 |
result.add(appBean); |
49 |
torben |
705 |
} |
50 |
torben |
663 |
} |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
} |